SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/DiscontinuousGalerkin - InitializeInterfaces.hpp Hit Total Coverage
Commit: ebec864322c50bab8dca0a90baf8d01875114261 Lines: 5 18 27.8 %
Date: 2020-11-25 20:28:50
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 <tuple>
       8             : #include <utility>
       9             : 
      10             : #include "DataStructures/DataBox/DataBox.hpp"
      11             : #include "DataStructures/Tensor/EagerMath/Magnitude.hpp"
      12             : #include "Domain/FaceNormal.hpp"
      13             : #include "Domain/InterfaceComputeTags.hpp"
      14             : #include "Domain/Tags.hpp"
      15             : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
      16             : #include "Utilities/TMPL.hpp"
      17             : #include "Utilities/TaggedTuple.hpp"
      18             : 
      19             : /// \cond
      20             : namespace Parallel {
      21             : template <typename Metavariables>
      22             : class GlobalCache;
      23             : }  // namespace Parallel
      24             : /// \endcond
      25             : 
      26             : namespace dg {
      27           0 : namespace Initialization {
      28             : /// \ingroup InitializationGroup
      29             : /// %Tags that are to be sliced to the faces of the element
      30             : template <typename... Tags>
      31           1 : using slice_tags_to_face = tmpl::list<Tags...>;
      32             : 
      33             : /// \ingroup InitializationGroup
      34             : /// %Tags that are to be sliced to the exterior side of the faces of the element
      35             : template <typename... Tags>
      36           1 : using slice_tags_to_exterior = tmpl::list<Tags...>;
      37             : 
      38             : /// \ingroup InitializationGroup
      39             : /// Compute tags on the faces of the element
      40             : template <typename... Tags>
      41           1 : using face_compute_tags = tmpl::list<Tags...>;
      42             : 
      43             : /// \ingroup InitializationGroup
      44             : /// Compute tags on the exterior side of the faces of the element
      45             : template <typename... Tags>
      46           1 : using exterior_compute_tags = tmpl::list<Tags...>;
      47             : }  // namespace Initialization
      48             : 
      49             : namespace Actions {
      50             : 
      51             : namespace detail {
      52             : template <typename System, typename = std::void_t<>>
      53             : struct vars_tag {
      54             :   using type = NoSuchType;
      55             : };
      56             : template <typename System>
      57             : struct vars_tag<System, std::void_t<typename System::variables_tag>> {
      58             :   using type = typename System::variables_tag;
      59             : };
      60             : }  // namespace detail
      61             : 
      62             : /// \ingroup InitializationGroup
      63             : /// \brief Initialize items related to the interfaces between Elements and on
      64             : /// external boundaries
      65             : ///
      66             : /// The `dg::Initialization::slice_tags_to_face` and
      67             : /// `dg::Initialization::slice_tags_to_exterior` types should be used for the
      68             : /// `SliceTagsToFace` and `SliceTagsToExterior` template parameters,
      69             : /// respectively. These are used to set additional volume quantities that are to
      70             : /// be sliced to the interfaces. Compute tags on the interfaces are controlled
      71             : /// using the `FaceComputeTags` and `ExteriorComputeTags` template parameters,
      72             : /// which should be passed the `dg::Initialization::face_compute_tags` and
      73             : /// `dg::Initialization::exterior_compute_tags` types, respectively.
      74             : ///
      75             : /// By default, this initializer also adds the system's `variables_tag` on
      76             : /// exterior (ghost) boundary faces. These are stored in a simple tag and
      77             : /// updated manually to impose boundary conditions. Set the
      78             : /// `AddExteriorVariables` template parameter to `false` to disable this
      79             : /// behavior.
      80             : ///
      81             : /// Uses:
      82             : /// - System:
      83             : ///   * `volume_dim`
      84             : ///   * `variables_tag`
      85             : ///   * `magnitude_tag`
      86             : ///
      87             : /// DataBox changes:
      88             : /// - Adds:
      89             : ///   * `Tags::Interface<Tags::BoundaryDirectionsExterior<volume_dim>,
      90             : ///   variables_tag>` (as a simple tag)
      91             : ///   * `face_tags<Tags::InternalDirections<Dim>>`
      92             : ///   * `face_tags<Tags::BoundaryDirectionsInterior<Dim>>`
      93             : ///   * `face_tags<Tags::BoundaryDirectionsExterior<Dim>>`
      94             : ///
      95             : /// - For `face_tags<Directions>`:
      96             : ///   * `Directions`
      97             : ///   * `Tags::Interface<Directions, Tags::Directions<Dim>>`
      98             : ///   * `Tags::Interface<Directions, Tags::Mesh<Dim - 1>>`
      99             : ///   * `Tags::Interface<Directions, Tags::Coordinates<Dim, Frame::Inertial>>`
     100             : ///   (only on exterior faces)
     101             : ///   * `Tags::Interface<Directions, Tags::UnnormalizedFaceNormal<Dim>>`
     102             : ///   * `Tags::Interface<Directions, Tags::Magnitude<
     103             : ///   Tags::UnnormalizedFaceNormal<Dim>>>`
     104             : ///   * `Tags::Interface<Directions, Tags::Normalized<
     105             : ///   Tags::UnnormalizedFaceNormal<Dim>>>`
     106             : ///
     107             : /// - Removes: nothing
     108             : /// - Modifies: nothing
     109             : ///
     110             : /// \note This action relies on the `SetupDataBox` aggregated initialization
     111             : /// mechanism, so `Actions::SetupDataBox` must be present in the
     112             : /// `Initialization` phase action list prior to this action.
     113             : template <
     114             :     typename System,
     115             :     typename SliceTagsToFace = Initialization::slice_tags_to_face<>,
     116             :     typename SliceTagsToExterior = Initialization::slice_tags_to_exterior<>,
     117             :     typename FaceComputeTags = Initialization::face_compute_tags<>,
     118             :     typename ExteriorComputeTags = Initialization::exterior_compute_tags<>,
     119             :     bool AddExteriorVariables = true, bool UseMovingMesh = false>
     120           1 : struct InitializeInterfaces {
     121             :  private:
     122           0 :   static constexpr size_t dim = System::volume_dim;
     123             : 
     124           0 :   using exterior_vars_tag =
     125             :       domain::Tags::Interface<domain::Tags::BoundaryDirectionsExterior<dim>,
     126             :                               typename detail::vars_tag<System>::type>;
     127             : 
     128             :   template <typename TagToSlice, typename Directions>
     129           0 :   struct make_slice_tag {
     130           0 :     using type = domain::Tags::Slice<Directions, TagToSlice>;
     131             :   };
     132             : 
     133             :   template <typename ComputeTag, typename Directions>
     134           0 :   struct make_compute_tag {
     135           0 :     using type = domain::Tags::InterfaceCompute<Directions, ComputeTag>;
     136             :   };
     137             : 
     138             :   template <typename Directions>
     139           0 :   using face_tags = tmpl::flatten<tmpl::list<
     140             :       domain::Tags::InterfaceCompute<Directions, domain::Tags::Direction<dim>>,
     141             :       domain::Tags::InterfaceCompute<Directions,
     142             :                                      domain::Tags::InterfaceMesh<dim>>,
     143             :       tmpl::transform<SliceTagsToFace,
     144             :                       make_slice_tag<tmpl::_1, tmpl::pin<Directions>>>,
     145             :       domain::Tags::InterfaceCompute<
     146             :           Directions,
     147             :           tmpl::conditional_t<
     148             :               UseMovingMesh,
     149             :               domain::Tags::UnnormalizedFaceNormalMovingMeshCompute<dim>,
     150             :               domain::Tags::UnnormalizedFaceNormalCompute<dim>>>,
     151             :       domain::Tags::InterfaceCompute<
     152             :           Directions, typename System::template magnitude_tag<
     153             :                           domain::Tags::UnnormalizedFaceNormal<dim>>>,
     154             :       domain::Tags::InterfaceCompute<
     155             :           Directions,
     156             :           ::Tags::NormalizedCompute<domain::Tags::UnnormalizedFaceNormal<dim>>>,
     157             :       tmpl::transform<FaceComputeTags,
     158             :                       make_compute_tag<tmpl::_1, tmpl::pin<Directions>>>>>;
     159             : 
     160           0 :   using exterior_face_tags = tmpl::flatten<tmpl::list<
     161             :       domain::Tags::BoundaryDirectionsExteriorCompute<dim>,
     162             :       domain::Tags::InterfaceCompute<
     163             :           domain::Tags::BoundaryDirectionsExterior<dim>,
     164             :           domain::Tags::Direction<dim>>,
     165             :       domain::Tags::InterfaceCompute<
     166             :           domain::Tags::BoundaryDirectionsExterior<dim>,
     167             :           domain::Tags::InterfaceMesh<dim>>,
     168             :       tmpl::transform<
     169             :           SliceTagsToExterior,
     170             :           make_slice_tag<
     171             :               tmpl::_1,
     172             :               tmpl::pin<domain::Tags::BoundaryDirectionsExterior<dim>>>>,
     173             :       domain::Tags::InterfaceCompute<
     174             :           domain::Tags::BoundaryDirectionsExterior<dim>,
     175             :           domain::Tags::BoundaryCoordinates<dim, UseMovingMesh>>,
     176             :       domain::Tags::InterfaceCompute<
     177             :           domain::Tags::BoundaryDirectionsExterior<dim>,
     178             :           tmpl::conditional_t<
     179             :               UseMovingMesh,
     180             :               domain::Tags::UnnormalizedFaceNormalMovingMeshCompute<dim>,
     181             :               domain::Tags::UnnormalizedFaceNormalCompute<dim>>>,
     182             :       domain::Tags::InterfaceCompute<
     183             :           domain::Tags::BoundaryDirectionsExterior<dim>,
     184             :           typename System::template magnitude_tag<
     185             :               domain::Tags::UnnormalizedFaceNormal<dim>>>,
     186             :       domain::Tags::InterfaceCompute<
     187             :           domain::Tags::BoundaryDirectionsExterior<dim>,
     188             :           ::Tags::NormalizedCompute<domain::Tags::UnnormalizedFaceNormal<dim>>>,
     189             :       tmpl::transform<
     190             :           ExteriorComputeTags,
     191             :           make_compute_tag<
     192             :               tmpl::_1,
     193             :               tmpl::pin<domain::Tags::BoundaryDirectionsExterior<dim>>>>>>;
     194             : 
     195             :  public:
     196           0 :   using simple_tags =
     197             :       tmpl::conditional_t<AddExteriorVariables, tmpl::list<exterior_vars_tag>,
     198             :                           tmpl::list<>>;
     199             : 
     200           0 :   using compute_tags = tmpl::push_front<
     201             :    tmpl::append<face_tags<domain::Tags::InternalDirections<dim>>,
     202             :                 face_tags<domain::Tags::BoundaryDirectionsInterior<dim>>,
     203             :                 exterior_face_tags>,
     204             :    domain::Tags::InternalDirectionsCompute<dim>,
     205             :    domain::Tags::BoundaryDirectionsInteriorCompute<dim>>;
     206             : 
     207             :   template <typename DbTagsList, typename... InboxTags, typename Metavariables,
     208             :             typename ArrayIndex, typename ActionList,
     209             :             typename ParallelComponent>
     210           0 :   static auto apply(db::DataBox<DbTagsList>& box,
     211             :                     const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
     212             :                     const Parallel::GlobalCache<Metavariables>& /*cache*/,
     213             :                     const ArrayIndex& /*array_index*/, ActionList /*meta*/,
     214             :                     const ParallelComponent* const /*meta*/) noexcept {
     215             :     if constexpr (AddExteriorVariables) {
     216             :       typename exterior_vars_tag::type exterior_boundary_vars{};
     217             :       const auto& mesh = db::get<domain::Tags::Mesh<dim>>(box);
     218             :       for (const auto& direction :
     219             :            db::get<domain::Tags::Element<dim>>(box).external_boundaries()) {
     220             :         exterior_boundary_vars[direction] =
     221             :             typename detail::vars_tag<System>::type::type{
     222             :                 mesh.slice_away(direction.dimension()).number_of_grid_points()};
     223             :       }
     224             :       ::Initialization::mutate_assign<simple_tags>(
     225             :           make_not_null(&box), std::move(exterior_boundary_vars));
     226             :       return std::make_tuple(std::move(box));
     227             :     } else {
     228             :       return std::make_tuple(std::move(box));
     229             :     }
     230             :   }
     231             : };
     232             : }  // namespace Actions
     233             : }  // namespace dg

Generated by: LCOV version 1.14