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 // ---------------------------------------------------------------------------- 113eb59678SJeremy L Thompson pub(crate) fn transform_mesh_coordinates( 123eb59678SJeremy L Thompson dim: usize, 133eb59678SJeremy L Thompson mesh_size: usize, 143eb59678SJeremy L Thompson mesh_coords: &mut libceed::Vector, 153eb59678SJeremy L Thompson ) -> libceed::Result<libceed::Scalar> { 163eb59678SJeremy L Thompson // Transform coordinates 173eb59678SJeremy L Thompson match dim { 183eb59678SJeremy L Thompson 1 => { 193eb59678SJeremy L Thompson for coord in mesh_coords.view_mut()?.iter_mut() { 203eb59678SJeremy L Thompson // map [0,1] to [0,1] varying the mesh density 213eb59678SJeremy L Thompson *coord = 0.5 223eb59678SJeremy L Thompson + 1.0 / (3.0 as libceed::Scalar).sqrt() 233eb59678SJeremy L Thompson * ((2.0 / 3.0) * std::f64::consts::PI as libceed::Scalar * (*coord - 0.5)) 243eb59678SJeremy L Thompson .sin() 253eb59678SJeremy L Thompson } 263eb59678SJeremy L Thompson } 273eb59678SJeremy L Thompson _ => { 283eb59678SJeremy L Thompson let num_nodes = mesh_size / dim; 293eb59678SJeremy L Thompson let mut coords = mesh_coords.view_mut()?; 303eb59678SJeremy L Thompson for i in 0..num_nodes { 313eb59678SJeremy L Thompson // map (x,y) from [0,1]x[0,1] to the quarter annulus with polar 323eb59678SJeremy L Thompson // coordinates, (r,phi) in [1,2]x[0,pi/2] with area = 3/4*pi 333eb59678SJeremy L Thompson let u = coords[i] + 1.; 343eb59678SJeremy L Thompson let v = coords[i + num_nodes] * std::f64::consts::PI / 2.; 353eb59678SJeremy L Thompson coords[i] = u * v.cos(); 363eb59678SJeremy L Thompson coords[i + num_nodes] = u * v.sin(); 373eb59678SJeremy L Thompson } 383eb59678SJeremy L Thompson } 393eb59678SJeremy L Thompson } 403eb59678SJeremy L Thompson 413eb59678SJeremy L Thompson // Exact volume of transformed region 423eb59678SJeremy L Thompson let exact_volume = match dim { 433eb59678SJeremy L Thompson 1 => 1., 443eb59678SJeremy L Thompson 2 | 3 => 3. / 4. * std::f64::consts::PI, 453eb59678SJeremy L Thompson _ => unreachable!(), 463eb59678SJeremy L Thompson }; 473eb59678SJeremy L Thompson Ok(exact_volume) 483eb59678SJeremy L Thompson } 493eb59678SJeremy L Thompson 503eb59678SJeremy L Thompson // ---------------------------------------------------------------------------- 51