SpECTRE Documentation Coverage Report
Current view: top level - Evolution/DiscontinuousGalerkin/Initialization - Mortars.hpp Hit Total Coverage
Commit: 3f09028930c0450a2fb61ee918b22882f5d03d2b Lines: 2 9 22.2 %
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 <boost/functional/hash.hpp>
       8             : #include <cstddef>
       9             : #include <optional>
      10             : #include <tuple>
      11             : #include <unordered_map>
      12             : #include <utility>
      13             : #include <vector>
      14             : 
      15             : #include "DataStructures/DataBox/DataBox.hpp"
      16             : #include "DataStructures/DataBox/DataBoxTag.hpp"
      17             : #include "DataStructures/DataBox/Prefixes.hpp"
      18             : #include "DataStructures/Variables.hpp"
      19             : #include "Domain/Structure/Direction.hpp"
      20             : #include "Domain/Structure/Element.hpp"
      21             : #include "Domain/Structure/Neighbors.hpp"
      22             : #include "Domain/Structure/OrientationMap.hpp"
      23             : #include "Domain/Tags.hpp"
      24             : #include "Evolution/DiscontinuousGalerkin/Initialization/QuadratureTag.hpp"
      25             : #include "Evolution/DiscontinuousGalerkin/MortarData.hpp"
      26             : #include "Evolution/DiscontinuousGalerkin/MortarTags.hpp"
      27             : #include "Evolution/DiscontinuousGalerkin/NormalVectorTags.hpp"
      28             : #include "NumericalAlgorithms/Spectral/Mesh.hpp"
      29             : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
      30             : #include "Time/BoundaryHistory.hpp"
      31             : #include "Time/Tags.hpp"
      32             : #include "Time/TimeStepId.hpp"
      33             : #include "Utilities/TMPL.hpp"
      34             : 
      35             : /// \cond
      36             : namespace Parallel {
      37             : template <typename Metavariables>
      38             : class GlobalCache;
      39             : }  // namespace Parallel
      40             : namespace tuples {
      41             : template <class... Tags>
      42             : class TaggedTuple;
      43             : }  // namespace tuples
      44             : /// \endcond
      45             : 
      46           1 : namespace evolution::dg::Initialization {
      47             : namespace detail {
      48             : template <size_t Dim>
      49             : std::tuple<
      50             :     std::unordered_map<std::pair<Direction<Dim>, ElementId<Dim>>,
      51             :                        evolution::dg::MortarData<Dim>,
      52             :                        boost::hash<std::pair<Direction<Dim>, ElementId<Dim>>>>,
      53             :     std::unordered_map<std::pair<Direction<Dim>, ElementId<Dim>>, Mesh<Dim - 1>,
      54             :                        boost::hash<std::pair<Direction<Dim>, ElementId<Dim>>>>,
      55             :     std::unordered_map<std::pair<Direction<Dim>, ElementId<Dim>>,
      56             :                        std::array<Spectral::MortarSize, Dim - 1>,
      57             :                        boost::hash<std::pair<Direction<Dim>, ElementId<Dim>>>>,
      58             :     std::unordered_map<std::pair<Direction<Dim>, ElementId<Dim>>, TimeStepId,
      59             :                        boost::hash<std::pair<Direction<Dim>, ElementId<Dim>>>>,
      60             :     DirectionMap<Dim, std::optional<Variables<tmpl::list<
      61             :                           evolution::dg::Tags::MagnitudeOfNormal,
      62             :                           evolution::dg::Tags::NormalCovector<Dim>>>>>>
      63             : mortars_apply_impl(const std::vector<std::array<size_t, Dim>>& initial_extents,
      64             :                    Spectral::Quadrature quadrature, const Element<Dim>& element,
      65             :                    const TimeStepId& next_temporal_id,
      66             :                    const Mesh<Dim>& volume_mesh);
      67             : }  // namespace detail
      68             : 
      69             : /*!
      70             :  * \brief Initialize mortars between elements for exchanging boundary correction
      71             :  * terms.
      72             :  *
      73             :  * Uses:
      74             :  * - DataBox:
      75             :  *   - `Tags::Element<Dim>`
      76             :  *   - `Tags::Mesh<Dim>`
      77             :  *   - `BoundaryScheme::receive_temporal_id`
      78             :  *
      79             :  * DataBox changes:
      80             :  * - Adds:
      81             :  *   - `Tags::MortarData<Dim>`
      82             :  *   - `Tags::MortarMesh<Dim>`
      83             :  *   - `Tags::MortarSize<Dim>`
      84             :  *   - `Tags::MortarNextTemporalId<Dim>`
      85             :  *   - `evolution::dg::Tags::NormalCovectorAndMagnitude<Dim>`
      86             :  * - Removes: nothing
      87             :  * - Modifies: nothing
      88             :  */
      89             : template <size_t Dim, typename System>
      90           1 : struct Mortars {
      91           0 :   using Key = std::pair<Direction<Dim>, ElementId<Dim>>;
      92             : 
      93             :   template <typename MappedType>
      94           0 :   using MortarMap = std::unordered_map<Key, MappedType, boost::hash<Key>>;
      95             : 
      96             :  public:
      97           0 :   using initialization_tags = tmpl::list<::domain::Tags::InitialExtents<Dim>,
      98             :                                          evolution::dg::Tags::Quadrature>;
      99             : 
     100           0 :   using simple_tags = tmpl::list<
     101             :       Tags::MortarData<Dim>, Tags::MortarMesh<Dim>, Tags::MortarSize<Dim>,
     102             :       Tags::MortarNextTemporalId<Dim>,
     103             :       evolution::dg::Tags::NormalCovectorAndMagnitude<Dim>,
     104             :       Tags::MortarDataHistory<
     105             :           Dim, typename db::add_tag_prefix<
     106             :                    ::Tags::dt, typename System::variables_tag>::type>>;
     107           0 :   using compute_tags = tmpl::list<>;
     108             : 
     109             :   template <typename DbTagsList, typename... InboxTags, typename Metavariables,
     110             :             typename ArrayIndex, typename ActionList,
     111             :             typename ParallelComponent>
     112           0 :   static auto apply(db::DataBox<DbTagsList>& box,
     113             :                     const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
     114             :                     const Parallel::GlobalCache<Metavariables>& /*cache*/,
     115             :                     const ArrayIndex& /*array_index*/, ActionList /*meta*/,
     116             :                     const ParallelComponent* const /*meta*/) {
     117             :     if constexpr (db::tag_is_retrievable_v<::domain::Tags::InitialExtents<Dim>,
     118             :                                            db::DataBox<DbTagsList>>) {
     119             :       auto [mortar_data, mortar_meshes, mortar_sizes, mortar_next_temporal_ids,
     120             :             normal_covector_quantities] =
     121             :           detail::mortars_apply_impl(
     122             :               db::get<::domain::Tags::InitialExtents<Dim>>(box),
     123             :               db::get<evolution::dg::Tags::Quadrature>(box),
     124             :               db::get<::domain::Tags::Element<Dim>>(box),
     125             :               db::get<::Tags::Next<::Tags::TimeStepId>>(box),
     126             :               db::get<::domain::Tags::Mesh<Dim>>(box));
     127             :       typename Tags::MortarDataHistory<
     128             :           Dim, typename db::add_tag_prefix<
     129             :                    ::Tags::dt, typename System::variables_tag>::type>::type
     130             :           boundary_data_history{};
     131             :       if (Metavariables::local_time_stepping) {
     132             :         for (const auto& mortar_id_and_data : mortar_data) {
     133             :           // default initialize data
     134             :           boundary_data_history[mortar_id_and_data.first];
     135             :         }
     136             :       }
     137             :       ::Initialization::mutate_assign<simple_tags>(
     138             :           make_not_null(&box), std::move(mortar_data), std::move(mortar_meshes),
     139             :           std::move(mortar_sizes), std::move(mortar_next_temporal_ids),
     140             :           std::move(normal_covector_quantities),
     141             :           std::move(boundary_data_history));
     142             :       return std::make_tuple(std::move(box));
     143             :     } else {
     144             :       ERROR(
     145             :           "Missing a tag in the DataBox. Did you forget to terminate the "
     146             :           "phase after removing options? The missing tag is "
     147             :           "'domain::Tags::InitialExtents<Dim>'.");
     148             :       return std::forward_as_tuple(std::move(box));
     149             :     }
     150             :   }
     151             : };
     152             : }  // namespace evolution::dg::Initialization

Generated by: LCOV version 1.14