1 // Copyright (c) 2017-2025, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 8 use libceed::prelude::*; 9 10 // ---------------------------------------------------------------------------- 11 // Transform mesh coordinates 12 // ---------------------------------------------------------------------------- 13 pub(crate) fn transform_mesh_coordinates( 14 dim: usize, 15 mesh_coords: &mut Vector, 16 ) -> libceed::Result<Scalar> { 17 // Transform coordinates 18 for coord in mesh_coords.view_mut()?.iter_mut() { 19 // map [0,1] to [0,1] varying the mesh density 20 *coord = 0.5 21 + 1.0 / (3.0 as Scalar).sqrt() 22 * ((2.0 / 3.0) * std::f64::consts::PI as Scalar * (*coord - 0.5)).sin() 23 } 24 25 // Exact surface area of transformed region 26 let exact_area = match dim { 27 1 => 2.0, 28 2 => 4.0, 29 _ => 6.0, 30 }; 31 Ok(exact_area) 32 } 33 34 // ---------------------------------------------------------------------------- 35