InitializeFirstOrderOperator.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <tuple>
8 
10 #include "DataStructures/DataBox/PrefixHelpers.hpp"
14 #include "Domain/Tags.hpp"
15 #include "Elliptic/FirstOrderComputeTags.hpp"
16 #include "Elliptic/Tags.hpp"
17 #include "NumericalAlgorithms/DiscontinuousGalerkin/NormalDotFlux.hpp"
18 #include "NumericalAlgorithms/LinearOperators/Divergence.tpp"
20 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
21 #include "Utilities/TMPL.hpp"
22 
23 /// \cond
24 namespace Parallel {
25 template <typename Metavariables>
26 struct GlobalCache;
27 } // namespace Parallel
28 namespace tuples {
29 template <typename... Tags>
30 struct TaggedTuple;
31 } // namespace tuples
32 /// \endcond
33 
34 namespace elliptic {
35 namespace dg {
36 namespace Actions {
37 
38 /*!
39  * \brief Initialize DataBox tags for building the first-order elliptic DG
40  * operator
41  */
42 template <size_t Dim, typename FluxesComputer, typename SourcesComputer,
43  typename VariablesTag, typename PrimalVariables,
44  typename AuxiliaryVariables>
46  private:
47  static constexpr size_t volume_dim = Dim;
48  using vars_tag = VariablesTag;
51  using fluxes_tag =
54  using div_fluxes_tag = db::add_tag_prefix<::Tags::div, fluxes_tag>;
55  using inv_jacobian_tag =
57 
58  template <typename Directions>
59  using face_tags =
60  tmpl::list<domain::Tags::Slice<Directions, vars_tag>,
63  // For the strong first-order DG scheme we also need the
64  // interface normal dotted into the fluxes
66  Directions, ::Tags::NormalDotFluxCompute<
67  vars_tag, volume_dim, Frame::Inertial>>>;
68 
69  using fluxes_compute_tag =
70  elliptic::Tags::FirstOrderFluxesCompute<volume_dim, FluxesComputer,
71  vars_tag, PrimalVariables,
72  AuxiliaryVariables>;
74  SourcesComputer, vars_tag, PrimalVariables, AuxiliaryVariables>;
75 
76  using exterior_tags = tmpl::list<
77  // On exterior (ghost) boundary faces we compute the fluxes from the
78  // data that is being set there to impose boundary conditions. Then, we
79  // compute their normal-dot-fluxes. The flux divergences are sliced from
80  // the volume.
88  div_fluxes_tag>>;
89 
90  public:
91  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
92  typename ArrayIndex, typename ActionList,
93  typename ParallelComponent>
94  static auto apply(db::DataBox<DbTagsList>& box,
95  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
96  const Parallel::GlobalCache<Metavariables>& /*cache*/,
97  const ArrayIndex& /*array_index*/,
98  const ActionList /*meta*/,
99  const ParallelComponent* const /*meta*/) noexcept {
100  // Initialize the variables on exterior (ghost) boundary faces. They are
101  // updated throughout the algorithm to impose boundary conditions.
102  typename exterior_vars_tag::type exterior_boundary_vars{};
103  const auto& mesh = db::get<domain::Tags::Mesh<volume_dim>>(box);
104  for (const auto& direction : db::get<domain::Tags::Element<volume_dim>>(box)
105  .external_boundaries()) {
106  exterior_boundary_vars[direction] = typename vars_tag::type{
107  mesh.slice_away(direction.dimension()).number_of_grid_points()};
108  }
109  using compute_tags = tmpl::flatten<tmpl::list<
112  face_tags<domain::Tags::InternalDirections<volume_dim>>,
113  face_tags<domain::Tags::BoundaryDirectionsInterior<volume_dim>>,
114  exterior_tags>>;
115  return std::make_tuple(
118  compute_tags>(std::move(box), std::move(exterior_boundary_vars)));
119  }
120 };
121 } // namespace Actions
122 } // namespace dg
123 } // namespace elliptic
Tags::NormalDotFluxCompute
Prefix computing a boundary unit normal vector dotted into the flux from a flux on the boundary.
Definition: NormalDotFlux.hpp:79
elliptic::Tags::FirstOrderFluxesCompute
Definition: FirstOrderComputeTags.hpp:23
Frame::Inertial
Definition: IndexType.hpp:44
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:16
Tags.hpp
domain::Tags::Element
Definition: Tags.hpp:98
Tags::DivVariablesCompute
Compute the divergence of a Variables.
Definition: Divergence.hpp:120
db::add_tag_prefix
typename detail::add_tag_prefix_impl< Prefix, Tag, Args... >::type add_tag_prefix
Definition: PrefixHelpers.hpp:52
domain::Tags::BoundaryDirectionsExterior
Definition: Tags.hpp:324
tuple
db::get
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:1116
elliptic::Tags::FirstOrderSourcesCompute
Definition: FirstOrderComputeTags.hpp:51
dg
Functionality related to discontinuous Galerkin schemes.
Definition: ComputeNonconservativeBoundaryFluxes.hpp:23
domain::Tags::Slice
Compute tag for representing a compute item that slices data from the volume to a set of interfaces.
Definition: InterfaceComputeTags.hpp:115
DataBox.hpp
cstddef
domain::Tags::InverseJacobian< Dim, Frame::Logical, Frame::Inertial >
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Variables.hpp
Element.hpp
db::AddSimpleTags
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1132
domain::Tags::Interface
Tag which is either a SimpleTag for quantities on an interface, base tag to a compute item which acts...
Definition: Tags.hpp:366
domain::Tags::InterfaceCompute
Compute tag for representing items computed on a set of interfaces. Can be retrieved using Tags::Inte...
Definition: InterfaceComputeTags.hpp:67
elliptic
Functionality related to solving elliptic partial differential equations.
Definition: InitializeAnalyticSolution.hpp:30
Initialization::merge_into_databox
auto merge_into_databox(db::DataBox< DbTagsList > &&box, Args &&... args) noexcept
Add tags that are not yet in the DataBox.
Definition: MergeIntoDataBox.hpp:133
Mesh.hpp
elliptic::dg::Actions::InitializeFirstOrderOperator
Initialize DataBox tags for building the first-order elliptic DG operator.
Definition: InitializeFirstOrderOperator.hpp:45
Prefixes.hpp
std::unordered_map
db::DataBox
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Parallel
Contains functions that forward to Charm++ parallel functions.
Definition: ElementReceiveInterpPoints.hpp:14
TMPL.hpp