SpECTRE Documentation Coverage Report
Current view: top level - Evolution/DgSubcell - GhostZoneInverseJacobian.hpp Hit Total Coverage
Commit: c3e43f8d41800b0ecefb9d1393f1de1d5a280c8f Lines: 10 11 90.9 %
Date: 2026-07-24 22:09:25
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14