SpECTRE Documentation Coverage Report
Current view: top level - Evolution/DgSubcell - GhostZoneInverseJacobian.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 90.9 % 11 10
Test Date: 2026-10-22 17:29:42
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              :     // Skip for elements whose topology does not support subcell.
      73              :     // For non-hypercube elements, fd::mesh() returns the DG mesh unchanged,
      74              :     // so the subcell mesh won't have FiniteDifference basis.
      75              :     if (subcell_mesh.basis(0) != Spectral::Basis::FiniteDifference) {
      76              :       return;
      77              :     }
      78              : 
      79              :     using neighbor_tags = tmpl::list<
      80              :         evolution::dg::subcell::Tags::Coordinates<Dim, Frame::Grid>,
      81              :         evolution::dg::subcell::fd::Tags::InverseJacobianLogicalToGrid<Dim>>;
      82              : 
      83              :     const size_t comp_dim = fd::get_computational_dim(subcell_mesh);
      84              :     for (const auto& direction : Direction<Dim>::all_directions()) {
      85              :       if (direction.dimension() >= comp_dim) {
      86              :         continue;
      87              :       }
      88              :       const auto logical_coords = fd::ghost_zone_logical_coordinates(
      89              :           subcell_mesh, reconstructor.ghost_zone_size(), direction);
      90              :       const auto inv_jacobian = element_map.inv_jacobian(logical_coords);
      91              :       const auto grid_coords = element_map(logical_coords);
      92              : 
      93              :       Variables<neighbor_tags> ghost_coords_and_inv_jacobian{
      94              :           logical_coords.get(0).size()};
      95              :       get<evolution::dg::subcell::Tags::Coordinates<Dim, Frame::Grid>>(
      96              :           ghost_coords_and_inv_jacobian) = grid_coords;
      97              :       get<evolution::dg::subcell::fd::Tags::InverseJacobianLogicalToGrid<Dim>>(
      98              :           ghost_coords_and_inv_jacobian) = inv_jacobian;
      99              : 
     100              :       ghost_zone_inverse_jacobian->insert_or_assign(
     101              :           direction, ghost_coords_and_inv_jacobian);
     102              :     }
     103              :   }
     104              : };
     105              : }  // namespace evolution::dg::subcell
        

Generated by: LCOV version 2.0-1