SpECTRE Documentation Coverage Report
Current view: top level - Evolution/DgSubcell - Mesh.hpp Hit Total Coverage
Commit: a18e59fda1a195609825c55450f7d61ad20a91a4 Lines: 6 7 85.7 %
Date: 2026-06-11 22:10:41
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             : #include <string>
       8             : 
       9             : #include "DataStructures/Index.hpp"
      10             : #include "NumericalAlgorithms/Spectral/Basis.hpp"
      11             : #include "NumericalAlgorithms/Spectral/Mesh.hpp"
      12             : #include "NumericalAlgorithms/Spectral/Quadrature.hpp"
      13             : #include "Utilities/ErrorHandling/Assert.hpp"
      14             : 
      15             : /// \cond
      16             : template <size_t Dim>
      17             : class Mesh;
      18             : template <size_t Dim>
      19             : class Index;
      20             : /// \endcond
      21             : 
      22             : namespace evolution::dg::subcell::fd {
      23             : /*!
      24             :  * \brief Computes the cell-centered finite-difference mesh from the DG mesh,
      25             :  * using \f$2N-1\f$ grid points per dimension, where \f$N\f$ is the degree of
      26             :  * the DG basis.
      27             :  */
      28             : template <size_t Dim>
      29           1 : Mesh<Dim> mesh(const Mesh<Dim>& dg_mesh);
      30             : 
      31             : /*!
      32             :  * \brief Computes the DG mesh from the cell-centered finite-difference mesh.
      33             :  */
      34             : template <size_t Dim>
      35           1 : Mesh<Dim> dg_mesh(const Mesh<Dim>& subcell_mesh, Spectral::Basis basis,
      36             :                   Spectral::Quadrature quadrature);
      37             : 
      38             : /*!
      39             :  * \brief Computes the computational dimension from the subcell mesh, which
      40             :  * can be less than `Dim` when Cartoon bases are used.
      41             :  */
      42             : template <size_t Dim>
      43           1 : size_t get_computational_dim(const Mesh<Dim>& subcell_mesh) {
      44             :   if constexpr (Dim == 3) {
      45             :     if (subcell_mesh.quadrature(2) == Spectral::Quadrature::SphericalSymmetry) {
      46             :       return 1;
      47             :     } else if (subcell_mesh.quadrature(2) ==
      48             :                Spectral::Quadrature::AxialSymmetry) {
      49             :       return 2;
      50             :     } else {
      51             :       return 3;
      52             :     }
      53             :   } else {
      54             :     return Dim;
      55             :   }
      56             : }
      57             : 
      58             : /*!
      59             :  * \brief Computes the computational dimension from the subcell extents, which
      60             :  * can be less than `Dim` when Cartoon bases are used.
      61             :  */
      62             : template <size_t Dim>
      63           1 : size_t get_computational_dim(const Index<Dim>& subcell_extents) {
      64             :   if constexpr (Dim == 3) {
      65             :     if (subcell_extents[1] == 1) {
      66             :       return 1;
      67             :     } else if (subcell_extents[2] == 1) {
      68             :       return 2;
      69             :     } else {
      70             :       return 3;
      71             :     }
      72             :   } else {
      73             :     return Dim;
      74             :   }
      75             : }
      76             : 
      77             : /*!
      78             :  * \brief Verifies the passed subcell mesh is valid, i.e. properly using
      79             :  * Cartoon bases and isotropic in non-Cartoon extents.
      80             :  *
      81             :  * The \p neighbor argument should be set to `true` when checking a neighbor's
      82             :  * mesh (only the output of the assert is modified).
      83             :  */
      84             : template <size_t Dim>
      85           1 : void verify_subcell_mesh(const Mesh<Dim>& subcell_mesh, bool neighbor = false);
      86             : 
      87             : /*!
      88             :  * \brief Verifies the passed subcell extents are valid, i.e. fully isotropic
      89             :  * or deviating in a Cartoon-specific manner.
      90             :  *
      91             :  * The \p neighbor argument should be set to `true` when checking a neighbor's
      92             :  * mesh (only the output of the assert is modified).
      93             :  */
      94             : template <size_t Dim>
      95           1 : void verify_subcell_extents(const Index<Dim>& subcell_extents,
      96             :                             bool neighbor = false) {
      97             :   const std::string neighbor_str = neighbor ? " neighbor" : "";
      98             :   if constexpr (Dim == 3) {
      99             :     if (subcell_extents[1] == 1) {
     100             :       // Checking for spherical symmetry
     101             :       ASSERT(
     102             :           subcell_extents[0] != 1 and subcell_extents[2] == 1,
     103             :           "The" << neighbor_str
     104             :                 << " subcell extents are neither isotropic nor a valid cartoon "
     105             :                    "pattern, got "
     106             :                 << subcell_extents);
     107             :     } else if (subcell_extents[2] == 1) {
     108             :       // Checking for axial symmetry
     109             :       ASSERT(
     110             :           subcell_extents.slice_away(2) == Index<2>(subcell_extents[0]),
     111             :           "The" << neighbor_str
     112             :                 << " subcell extents are neither isotropic nor a valid cartoon "
     113             :                    "pattern, got "
     114             :                 << subcell_extents);
     115             :     } else {
     116             :       // No cartoon, normal extents
     117             :       ASSERT(subcell_extents == Index<Dim>(subcell_extents[0]),
     118             :              "The" << neighbor_str << " subcell mesh must be uniform but is "
     119             :                    << subcell_extents);
     120             :     }
     121             :   } else {
     122             :     ASSERT(subcell_extents == Index<Dim>(subcell_extents[0]),
     123             :            "The" << neighbor_str << " subcell mesh must be uniform but is "
     124             :                  << subcell_extents);
     125             :   }
     126             : }
     127             : }  // namespace evolution::dg::subcell::fd

Generated by: LCOV version 1.14