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