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 // ---------------------------------------------------------------------------- 9 // Transform mesh coordinates 10 // ---------------------------------------------------------------------------- 11 pub(crate) fn transform_mesh_coordinates( 12 dim: usize, 13 mesh_coords: &mut libceed::Vector, 14 ) -> libceed::Result<libceed::Scalar> { 15 // Transform coordinates 16 for coord in mesh_coords.view_mut()?.iter_mut() { 17 // map [0,1] to [0,1] varying the mesh density 18 *coord = 0.5 19 + 1.0 / (3.0 as libceed::Scalar).sqrt() 20 * ((2.0 / 3.0) * std::f64::consts::PI as libceed::Scalar * (*coord - 0.5)).sin() 21 } 22 23 // Exact surface area of transformed region 24 let exact_area = match dim { 25 1 => 2.0, 26 2 => 4.0, 27 _ => 6.0, 28 }; 29 Ok(exact_area) 30 } 31 32 // ---------------------------------------------------------------------------- 33