Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <cstddef> 7 : 8 : #include "Domain/ElementMap.hpp" 9 : #include "Domain/Structure/Direction.hpp" 10 : #include "Domain/Structure/DirectionMap.hpp" 11 : #include "Domain/Tags.hpp" 12 : #include "Evolution/DgSubcell/GhostZoneLogicalCoordinates.hpp" 13 : #include "Evolution/DgSubcell/Tags/GhostZoneInverseJacobian.hpp" 14 : #include "Utilities/Gsl.hpp" 15 : 16 : namespace evolution::dg::subcell { 17 : 18 : /// \brief Mutator that stores the grid coordinates and inverse Jacobians of the 19 : /// ghost zone. 20 : /// 21 : /// \details Mutator that stores the grid coordinates and inverse Jacobians of 22 : /// the ghost zone. This is run in the initialization phase since this 23 : /// information is time-independent. The full Jacobian to inertial coordinates 24 : /// may be applied at each time step. 25 : 26 : template <size_t Dim, typename ReconstructorTag> 27 1 : struct GhostZoneInverseJacobian { 28 : /// Tags for constant items added to the GlobalCache. These items are 29 : /// initialized from input file options. 30 1 : using const_global_cache_tags = tmpl::list<>; 31 : 32 : /// Tags for mutable items added to the GlobalCache. These items are 33 : /// initialized from input file options. 34 1 : using mutable_global_cache_tags = tmpl::list<>; 35 : 36 : /// Tags for simple DataBox items that are initialized from input file options 37 1 : using simple_tags_from_options = tmpl::list<>; 38 : 39 : /// Tags for simple DataBox items that are default initialized. 40 1 : using default_initialized_simple_tags = tmpl::list<>; 41 : 42 : /// Tags for items fetched by the DataBox and passed to the apply function 43 1 : using argument_tags = 44 : tmpl::list<Tags::Mesh<Dim>, ::domain::Tags::ElementMap<Dim, Frame::Grid>, 45 : ReconstructorTag>; 46 : 47 : /// Tags for items in the DataBox that are mutated by the apply function 48 1 : using return_tags = tmpl::list<Tags::GhostZoneInverseJacobian<Dim>>; 49 : 50 : /// Tags for mutable DataBox items that are either default initialized or 51 : /// initialized by the apply function 52 1 : using simple_tags = return_tags; 53 : 54 : /// Tags for immutable DataBox items (compute items or reference items) added 55 : /// to the DataBox. 56 1 : using compute_tags = tmpl::list<>; 57 : 58 : /// Given the items fetched from a DataBox by the argument_tags, mutate 59 : /// the items in the DataBox corresponding to return_tags 60 : template <typename ReconstructorType> 61 1 : static void apply( 62 : const gsl::not_null<DirectionMap< 63 : Dim, Variables<tmpl::list< 64 : evolution::dg::subcell::Tags::Coordinates<Dim, Frame::Grid>, 65 : evolution::dg::subcell::fd::Tags:: 66 : InverseJacobianLogicalToGrid<Dim>>>>*> 67 : ghost_zone_inverse_jacobian, 68 : const Mesh<Dim>& subcell_mesh, 69 : const ElementMap<Dim, Frame::Grid>& element_map, 70 : const ReconstructorType& reconstructor) { 71 : using neighbor_tags = tmpl::list< 72 : evolution::dg::subcell::Tags::Coordinates<Dim, Frame::Grid>, 73 : evolution::dg::subcell::fd::Tags::InverseJacobianLogicalToGrid<Dim>>; 74 : 75 : for (const auto& direction : Direction<Dim>::all_directions()) { 76 : const auto logical_coords = fd::ghost_zone_logical_coordinates( 77 : subcell_mesh, reconstructor.ghost_zone_size(), direction); 78 : const auto inv_jacobian = element_map.inv_jacobian(logical_coords); 79 : const auto grid_coords = element_map(logical_coords); 80 : 81 : Variables<neighbor_tags> ghost_coords_and_inv_jacobian{ 82 : logical_coords.get(0).size()}; 83 : get<evolution::dg::subcell::Tags::Coordinates<Dim, Frame::Grid>>( 84 : ghost_coords_and_inv_jacobian) = grid_coords; 85 : get<evolution::dg::subcell::fd::Tags::InverseJacobianLogicalToGrid<Dim>>( 86 : ghost_coords_and_inv_jacobian) = inv_jacobian; 87 : 88 : ghost_zone_inverse_jacobian->insert_or_assign( 89 : direction, ghost_coords_and_inv_jacobian); 90 : } 91 : } 92 : }; 93 : } // namespace evolution::dg::subcell