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