1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
23eb59678SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
33eb59678SJeremy L Thompson //
43eb59678SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
53eb59678SJeremy L Thompson //
63eb59678SJeremy L Thompson // This file is part of CEED: http://github.com/ceed
73eb59678SJeremy L Thompson
83eb59678SJeremy L Thompson // ----------------------------------------------------------------------------
93eb59678SJeremy L Thompson // Transform mesh coordinates
103eb59678SJeremy L Thompson // ----------------------------------------------------------------------------
transform_mesh_coordinates( dim: usize, mesh_coords: &mut libceed::Vector, ) -> libceed::Result<libceed::Scalar>113eb59678SJeremy L Thompson pub(crate) fn transform_mesh_coordinates(
123eb59678SJeremy L Thompson dim: usize,
133eb59678SJeremy L Thompson mesh_coords: &mut libceed::Vector,
143eb59678SJeremy L Thompson ) -> libceed::Result<libceed::Scalar> {
153eb59678SJeremy L Thompson // Transform coordinates
163eb59678SJeremy L Thompson for coord in mesh_coords.view_mut()?.iter_mut() {
173eb59678SJeremy L Thompson // map [0,1] to [0,1] varying the mesh density
183eb59678SJeremy L Thompson *coord = 0.5
193eb59678SJeremy L Thompson + 1.0 / (3.0 as libceed::Scalar).sqrt()
203eb59678SJeremy L Thompson * ((2.0 / 3.0) * std::f64::consts::PI as libceed::Scalar * (*coord - 0.5)).sin()
213eb59678SJeremy L Thompson }
223eb59678SJeremy L Thompson
233eb59678SJeremy L Thompson // Exact surface area of transformed region
243eb59678SJeremy L Thompson let exact_area = match dim {
253eb59678SJeremy L Thompson 1 => 2.0,
263eb59678SJeremy L Thompson 2 => 4.0,
273eb59678SJeremy L Thompson 3 => 6.0,
283eb59678SJeremy L Thompson _ => unreachable!(),
293eb59678SJeremy L Thompson };
303eb59678SJeremy L Thompson Ok(exact_area)
313eb59678SJeremy L Thompson }
323eb59678SJeremy L Thompson
333eb59678SJeremy L Thompson // ----------------------------------------------------------------------------
34