1 // Copyright (c) 2017-2021, Lawrence Livermore National Security, LLC. 2 // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. 3 // All Rights reserved. See files LICENSE and NOTICE for details. 4 // 5 // This file is part of CEED, a collection of benchmarks, miniapps, software 6 // libraries and APIs for efficient high-order finite element and spectral 7 // element discretizations for exascale applications. For more information and 8 // source code availability see http://github.com/ceed. 9 // 10 // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11 // a collaborative effort of two U.S. Department of Energy organizations (Office 12 // of Science and the National Nuclear Security Administration) responsible for 13 // the planning and preparation of a capable exascale ecosystem, including 14 // software, applications, hardware, advanced system engineering and early 15 // testbed platforms, in support of the nation's exascale computing imperative. 16 17 use libceed::prelude::*; 18 19 // ---------------------------------------------------------------------------- 20 // Transform mesh coordinates 21 // ---------------------------------------------------------------------------- 22 pub(crate) fn transform_mesh_coordinates( 23 dim: usize, 24 mesh_size: usize, 25 mesh_coords: &mut Vector, 26 ) -> Scalar { 27 // Transform coordinates 28 if dim == 1 { 29 mesh_coords.view_mut().iter_mut().for_each(|coord| { 30 // map [0,1] to [0,1] varying the mesh density 31 *coord = 0.5 32 + 1.0 / (3.0 as Scalar).sqrt() 33 * ((2.0 / 3.0) * std::f64::consts::PI as Scalar * (*coord - 0.5)).sin() 34 }); 35 } else { 36 let mut coords = mesh_coords.view_mut(); 37 let num_nodes = mesh_size / dim; 38 for i in 0..num_nodes { 39 // map (x,y) from [0,1]x[0,1] to the quarter annulus with polar 40 // coordinates, (r,phi) in [1,2]x[0,pi/2] with area = 3/4*pi 41 let u = 1.0 + coords[i]; 42 let v = std::f64::consts::PI as Scalar / 2.0 * coords[i + num_nodes]; 43 coords[i] = u * v.cos(); 44 coords[i + num_nodes] = u * v.sin(); 45 } 46 } 47 48 // Exact volume of transformed region 49 let exact_volume = match dim { 50 1 => 1.0, 51 _ => 3.0 / 4.0 * std::f64::consts::PI as Scalar, 52 }; 53 exact_volume 54 } 55 56 // ---------------------------------------------------------------------------- 57