SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/GrMhd/ValenciaDivClean/Subcell - GrTagsForHydro.hpp Hit Total Coverage
Commit: 3f09028930c0450a2fb61ee918b22882f5d03d2b Lines: 2 13 15.4 %
Date: 2021-10-22 20:52:16
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 <array>
       7             : #include <cstddef>
       8             : #include <memory>
       9             : #include <string>
      10             : #include <unordered_map>
      11             : #include <utility>
      12             : 
      13             : #include "DataStructures/Tensor/Tensor.hpp"
      14             : #include "DataStructures/Variables.hpp"
      15             : #include "Domain/CoordinateMaps/CoordinateMap.hpp"
      16             : #include "Domain/CoordinateMaps/Tags.hpp"
      17             : #include "Domain/ElementMap.hpp"
      18             : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
      19             : #include "Domain/FunctionsOfTime/Tags.hpp"
      20             : #include "Domain/Tags.hpp"
      21             : #include "Evolution/DgSubcell/Tags/Coordinates.hpp"
      22             : #include "Evolution/DgSubcell/Tags/Inactive.hpp"
      23             : #include "Evolution/DgSubcell/Tags/Mesh.hpp"
      24             : #include "Evolution/DgSubcell/Tags/OnSubcellFaces.hpp"
      25             : #include "Evolution/Initialization/InitialData.hpp"
      26             : #include "NumericalAlgorithms/Spectral/Mesh.hpp"
      27             : #include "NumericalAlgorithms/Spectral/Spectral.hpp"
      28             : #include "Utilities/ErrorHandling/Assert.hpp"
      29             : #include "Utilities/Gsl.hpp"
      30             : #include "Utilities/TMPL.hpp"
      31             : 
      32             : /// \cond
      33             : namespace Initialization {
      34             : namespace Tags {
      35             : struct InitialTime;
      36             : }  // namespace Tags
      37             : }  // namespace Initialization
      38             : namespace Tags {
      39             : struct AnalyticSolutionOrData;
      40             : }  // namespace Tags
      41             : namespace domain {
      42             : namespace Tags {
      43             : template <size_t Dim, typename Frame>
      44             : struct Coordinates;
      45             : template <size_t VolumeDim>
      46             : struct Mesh;
      47             : }  // namespace Tags
      48             : }  // namespace domain
      49             : // IWYU pragma: no_forward_declare db::DataBox
      50             : /// \endcond
      51             : 
      52             : namespace Initialization {
      53             : /// Generic initialization actions and mutators for the subcell solver.
      54           1 : namespace subcell {
      55             : /*!
      56             :  * \ingroup InitializationGroup
      57             :  * \brief Allocate and set general relativity quantities needed for evolution
      58             :  * of hydro systems when using a DG-subcell hybrid scheme.
      59             :  *
      60             :  * Uses:
      61             :  * - DataBox:
      62             :  *   * `evolution::dg::subcell::Tags::Mesh<Dim>`
      63             :  *   * `domain::Tags::ElementMap<Dim, Frame::Grid>`
      64             :  *   * `Tags::CoordinateMap<Dim, Frame::Grid, Frame::Inertial>`
      65             :  *   * `domain::Tags::FunctionsOfTime`
      66             :  *   * `evolution::dg::subcell::Tags::Coordinates<Dim, Frame::ElementLogical>`
      67             :  *   * `::Tags::AnalyticSolutionOrData`
      68             :  *
      69             :  * DataBox changes:
      70             :  * - Adds:
      71             :  *   * `dg::subcell::Tags::Inactive<System::spacetime_variables_tag>`
      72             :  *   * `Tags::OnSubcellFaces<System::flux_spacetime_variables_tag, Dim>`
      73             :  *
      74             :  * - Removes: nothing
      75             :  * - Modifies: nothing
      76             :  *
      77             :  * \note This action relies on the `SetupDataBox` aggregated initialization
      78             :  * mechanism, so `Actions::SetupDataBox` must be present in the
      79             :  * `Initialization` phase action list prior to this action.
      80             :  */
      81             : template <typename System, size_t Dim>
      82           1 : struct GrTagsForHydro {
      83           0 :   using initialization_tags = tmpl::list<Initialization::Tags::InitialTime>;
      84             : 
      85           0 :   using gr_tag = typename System::spacetime_variables_tag;
      86           0 :   using subcell_gr_tag = evolution::dg::subcell::Tags::Inactive<gr_tag>;
      87           0 :   using subcell_faces_gr_tag = evolution::dg::subcell::Tags::OnSubcellFaces<
      88             :       typename System::flux_spacetime_variables_tag, Dim>;
      89           0 :   using GrVars = typename gr_tag::type;
      90           0 :   using SubcellGrVars = typename subcell_gr_tag::type;
      91           0 :   using FaceGrVars = typename subcell_faces_gr_tag::type::value_type;
      92             : 
      93           0 :   using return_tags = tmpl::list<subcell_gr_tag, subcell_faces_gr_tag>;
      94           0 :   using argument_tags = tmpl::list<
      95             :       Initialization::Tags::InitialTime,
      96             :       evolution::dg::subcell::Tags::Mesh<Dim>,
      97             :       domain::Tags::ElementMap<Dim, Frame::Grid>,
      98             :       domain::CoordinateMaps::Tags::CoordinateMap<Dim, Frame::Grid,
      99             :                                                   Frame::Inertial>,
     100             :       domain::Tags::FunctionsOfTime,
     101             :       evolution::dg::subcell::Tags::Coordinates<Dim, Frame::ElementLogical>,
     102             :       ::Tags::AnalyticSolutionOrData>;
     103             : 
     104             :   template <typename AnalyticDataOrSolution>
     105           0 :   static void apply(
     106             :       const gsl::not_null<SubcellGrVars*> cell_centered_gr_vars,
     107             :       const gsl::not_null<std::array<FaceGrVars, Dim>*> face_centered_gr_vars,
     108             :       const double initial_time, const Mesh<Dim>& subcell_mesh,
     109             :       const ElementMap<Dim, Frame::Grid>& logical_to_grid_map,
     110             :       const domain::CoordinateMapBase<Frame::Grid, Frame::Inertial, Dim>&
     111             :           grid_to_inertial_map,
     112             :       const std::unordered_map<
     113             :           std::string,
     114             :           std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>>&
     115             :           functions_of_time,
     116             :       const tnsr::I<DataVector, Dim, Frame::ElementLogical>&
     117             :           subcell_logical_coordinates,
     118             :       const AnalyticDataOrSolution& analytic_data_or_solution) {
     119             :     const size_t num_grid_points = subcell_mesh.number_of_grid_points();
     120             :     const auto cell_centered_inertial_coords =
     121             :         grid_to_inertial_map(logical_to_grid_map(subcell_logical_coordinates),
     122             :                              initial_time, functions_of_time);
     123             : 
     124             :     // Set cell-centered vars. Need to first do without prefix then move into
     125             :     // prefixed Variables.
     126             :     GrVars no_prefix_cell_centered_gr_vars{num_grid_points};
     127             :     no_prefix_cell_centered_gr_vars.assign_subset(evolution::initial_data(
     128             :         analytic_data_or_solution, cell_centered_inertial_coords, initial_time,
     129             :         typename GrVars::tags_list{}));
     130             :     *cell_centered_gr_vars = std::move(no_prefix_cell_centered_gr_vars);
     131             : 
     132             :     // Set GR variables needed for computing the fluxes on the faces.
     133             :     ASSERT(Mesh<Dim>(subcell_mesh.extents(0), subcell_mesh.basis(0),
     134             :                      subcell_mesh.quadrature(0)) == subcell_mesh,
     135             :            "The subcell mesh must have isotropic basis, quadrature. and "
     136             :            "extents but got "
     137             :                << subcell_mesh);
     138             :     for (size_t d = 0; d < Dim; ++d) {
     139             :       const auto basis = make_array<Dim>(subcell_mesh.basis(0));
     140             :       auto quadrature = make_array<Dim>(subcell_mesh.quadrature(0));
     141             :       auto extents = make_array<Dim>(subcell_mesh.extents(0));
     142             :       gsl::at(extents, d) = subcell_mesh.extents(0) + 1;
     143             :       gsl::at(quadrature, d) = Spectral::Quadrature::FaceCentered;
     144             :       const Mesh<Dim> face_centered_mesh{extents, basis, quadrature};
     145             :       const auto face_centered_logical_coords =
     146             :           logical_coordinates(face_centered_mesh);
     147             :       const auto face_centered_inertial_coords = grid_to_inertial_map(
     148             :           logical_to_grid_map(face_centered_logical_coords), initial_time,
     149             :           functions_of_time);
     150             : 
     151             :       gsl::at(*face_centered_gr_vars, d)
     152             :           .initialize(face_centered_mesh.number_of_grid_points());
     153             :       gsl::at(*face_centered_gr_vars, d)
     154             :           .assign_subset(evolution::initial_data(
     155             :               analytic_data_or_solution, face_centered_inertial_coords,
     156             :               initial_time, typename FaceGrVars::tags_list{}));
     157             :     }
     158             :   }
     159             : };
     160             : }  // namespace subcell
     161             : }  // namespace Initialization

Generated by: LCOV version 1.14