DgDomain.hpp
1 // 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 <tuple>
10 #include <utility>
11 #include <vector>
12 
16 #include "Domain/CoordinateMaps/Tags.hpp"
17 #include "Domain/CreateInitialElement.hpp"
18 #include "Domain/Domain.hpp"
19 #include "Domain/ElementMap.hpp"
21 #include "Domain/MinimumGridSpacing.hpp"
22 #include "Domain/Structure/CreateInitialMesh.hpp"
25 #include "Domain/Tags.hpp"
26 #include "Domain/TagsTimeDependent.hpp"
27 #include "Evolution/DiscontinuousGalerkin/Initialization/QuadratureTag.hpp"
28 #include "Evolution/TagsDomain.hpp"
30 #include "Parallel/GlobalCache.hpp"
31 #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
32 #include "Utilities/Requires.hpp"
33 #include "Utilities/TMPL.hpp"
34 #include "Utilities/TaggedTuple.hpp"
35 
36 /// \cond
37 template <size_t VolumeDim>
38 class ElementId;
39 namespace Frame {
40 struct Inertial;
41 } // namespace Frame
42 /// \endcond
43 
44 namespace evolution {
45 namespace dg {
46 namespace Initialization {
47 /*!
48  * \ingroup InitializationGroup
49  * \brief Initialize items related to the basic structure of the element
50  *
51  * GlobalCache:
52  * - Uses:
53  * - `domain::Tags::Domain<Dim, Frame::Inertial>`
54  * DataBox:
55  * - Uses:
56  * - `domain::Tags::InitialExtents<Dim>`
57  * - `domain::Tags::FunctionsOfTime`
58  * - Adds:
59  * - `domain::Tags::Mesh<Dim>`
60  * - `domain::Tags::Element<Dim>`
61  * - `domain::Tags::ElementMap<Dim, Frame::Inertial>`
62  * - `domain::CoordinateMaps::Tags::CoordinateMap<Dim, Frame::Grid,
63  * Frame::Inertial>`
64  * - `domain::Tags::CoordinatesMeshVelocityAndJacobiansCompute<
65  * CoordinateMap<Dim, Frame::Grid, Frame::Inertial>>`
66  * - `domain::Tags::Coordinates<Dim, Frame::Logical>`
67  * - `domain::Tags::Coordinates<Dim, Frame::Grid>`
68  * - `domain::Tags::Coordinates<Dim, Frame::Inertial>`
69  * - `domain::Tags::InverseJacobian<Dim, Frame::Logical, Frame::Grid>`
70  * - `domain::Tags::InverseJacobian<Dim, Frame::Logical, Frame::Inertial>`
71  * - `domain::Tags::DetInvJacobian<Frame::Logical, Frame::Inertial>`
72  * - `domain::Tags::MeshVelocity<Dim, Frame::Inertial>`
73  * - `domain::Tags::DivMeshVelocity`
74  * - `domain::Tags::MinimumGridSpacingCompute<Dim, Frame::Inertial>>`
75  * - Removes: nothing
76  * - Modifies: nothing
77  *
78  * \note This action relies on the `SetupDataBox` aggregated initialization
79  * mechanism, so `Actions::SetupDataBox` must be present in the `Initialization`
80  * phase action list prior to this action.
81  * \note If OverrideCubicFunctionsOfTime == true, then cubic functions
82  * of time are overriden via `read_spec_piecewise_polynomial()`
83  */
84 template <size_t Dim, bool OverrideCubicFunctionsOfTime = false>
85 struct Domain {
86  using initialization_tags =
87  tmpl::list<::domain::Tags::InitialExtents<Dim>,
90  using const_global_cache_tags = tmpl::list<::domain::Tags::Domain<Dim>>;
91 
92  using mutable_global_cache_tags = tmpl::list<::domain::Tags::FunctionsOfTime>;
93 
94  using simple_tags =
95  tmpl::list<::domain::Tags::Mesh<Dim>, ::domain::Tags::Element<Dim>,
99 
100  using compute_tags = tmpl::list<
102  // Compute tags for Frame::Grid quantities
109  // Compute tag to retrieve functions of time from global cache.
111  // Compute tags for Frame::Inertial quantities
114  Frame::Inertial>>,
115 
122  // Compute tags for other mesh quantities
124 
125  template <
126  typename DataBox, typename... InboxTags, typename Metavariables,
127  typename ActionList, typename ParallelComponent,
128  Requires<tmpl::all<initialization_tags,
129  tmpl::bind<db::tag_is_retrievable, tmpl::_1,
130  tmpl::pin<DataBox>>>::value> = nullptr>
131  static auto apply(DataBox& box,
132  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
133  const Parallel::GlobalCache<Metavariables>& /*cache*/,
134  const ElementId<Dim>& array_index,
135  const ActionList /*meta*/,
136  const ParallelComponent* const /*meta*/) noexcept {
137  const auto& initial_extents =
138  db::get<::domain::Tags::InitialExtents<Dim>>(box);
139  const auto& initial_refinement =
140  db::get<::domain::Tags::InitialRefinementLevels<Dim>>(box);
141  const auto& domain = db::get<::domain::Tags::Domain<Dim>>(box);
142 
143  const ElementId<Dim> element_id{array_index};
144  const auto& my_block = domain.blocks()[element_id.block_id()];
146  initial_extents, element_id,
147  db::get<evolution::dg::Tags::Quadrature>(box));
149  element_id, my_block, initial_refinement);
150  ElementMap<Dim, Frame::Grid> element_map{
151  element_id, my_block.is_time_dependent()
152  ? my_block.moving_mesh_logical_to_grid_map().get_clone()
153  : my_block.stationary_map().get_to_grid_frame()};
154 
157  grid_to_inertial_map;
158  if (my_block.is_time_dependent()) {
159  grid_to_inertial_map =
160  my_block.moving_mesh_grid_to_inertial_map().get_clone();
161  } else {
162  grid_to_inertial_map =
163  ::domain::make_coordinate_map_base<Frame::Grid, Frame::Inertial>(
165  }
166  ::Initialization::mutate_assign<simple_tags>(
167  make_not_null(&box), std::move(mesh), std::move(element),
168  std::move(element_map), std::move(grid_to_inertial_map));
169 
170  return std::make_tuple(std::move(box));
171  }
172 
173  template <
174  typename DataBox, typename... InboxTags, typename Metavariables,
175  typename ArrayIndex, typename ActionList, typename ParallelComponent,
176  Requires<not tmpl::all<initialization_tags,
177  tmpl::bind<db::tag_is_retrievable, tmpl::_1,
178  tmpl::pin<DataBox>>>::value> = nullptr>
179  static std::tuple<DataBox&&> apply(
180  DataBox& /*box*/, const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
181  const Parallel::GlobalCache<Metavariables>& /*cache*/,
182  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
183  const ParallelComponent* const /*meta*/) noexcept {
184  ERROR(
185  "Dependencies not fulfilled. Did you forget to terminate the phase "
186  "after removing options?");
187  }
188 };
189 } // namespace Initialization
190 } // namespace dg
191 } // namespace evolution
Identity.hpp
domain::Initialization::create_initial_element
Element< VolumeDim > create_initial_element(const ElementId< VolumeDim > &element_id, const Block< VolumeDim > &block, const std::vector< std::array< size_t, VolumeDim >> &initial_refinement_levels) noexcept
Creates an initial element of a Block.
utility
Frame::Inertial
Definition: IndexType.hpp:44
evolution::dg::Tags::Quadrature
The quadrature points to use initially.
Definition: QuadratureTag.hpp:29
domain::CoordinateMapBase
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:45
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
evolution
Functionality for evolving hyperbolic partial differential equations.
Definition: RunEventsAndDenseTriggers.hpp:30
domain::Tags::DetInvJacobianCompute
Definition: Tags.hpp:247
domain::Tags::Coordinates
Definition: Tags.hpp:130
Frame::Grid
Definition: IndexType.hpp:43
GlobalCache.hpp
domain::Tags::MinimumGridSpacingCompute
Definition: MinimumGridSpacing.hpp:42
Tags.hpp
vector
domain::Tags::Element
Definition: Tags.hpp:97
Domain.hpp
Parallel::Tags::FromGlobalCache
Definition: GlobalCache.hpp:694
domain::Tags::CoordinatesMeshVelocityAndJacobiansCompute
Computes the Inertial coordinates, the inverse Jacobian from the Grid to the Inertial frame,...
Definition: TagsTimeDependent.hpp:51
domain::Tags::ElementToInertialInverseJacobian
Computes the Logical to Inertial inverse Jacobian from CoordinatesVelocityAndJacobians
Definition: TagsTimeDependent.hpp:109
tuple
CoordinateMap.hpp
dg
Functionality related to discontinuous Galerkin schemes.
Definition: ApplyMassMatrix.hpp:13
Element
Definition: Element.hpp:29
domain::Tags::InverseJacobianCompute
Definition: Tags.hpp:179
ElementId
An ElementId uniquely labels an Element.
Definition: ElementId.hpp:51
ElementId.hpp
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:37
evolution::domain::Tags::DivMeshVelocityCompute
The divergence of the frame velocity.
Definition: TagsDomain.hpp:26
DataBox.hpp
cstddef
db::tag_is_retrievable
tmpl::any< typename DataBoxType::tags_list, std::is_base_of< tmpl::pin< Tag >, tmpl::_1 > > tag_is_retrievable
Definition: DataBox.hpp:58
evolution::dg::Initialization::Domain
Initialize items related to the basic structure of the element.
Definition: DgDomain.hpp:85
array
LogicalCoordinates.hpp
domain::Tags::LogicalCoordinates
Definition: LogicalCoordinates.hpp:78
ElementMap
The CoordinateMap for the Element from the Logical frame to the TargetFrame
Definition: ElementMap.hpp:33
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
domain::Tags::InertialFromGridCoordinatesCompute
Computes the Inertial coordinates from CoordinatesVelocityAndJacobians
Definition: TagsTimeDependent.hpp:86
domain::Tags::MappedCoordinates
Definition: Tags.hpp:143
memory
domain::Tags::InertialMeshVelocityCompute
Computes the Inertial mesh velocity from CoordinatesVelocityAndJacobians
Definition: TagsTimeDependent.hpp:147
domain::CoordinateMaps::Tags::CoordinateMap
Definition: Tags.hpp:30
Element.hpp
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:49
domain::CoordinateMaps::Identity
Definition: Identity.hpp:28
domain::Initialization::create_initial_mesh
Mesh< Dim > create_initial_mesh(const std::vector< std::array< size_t, Dim >> &initial_extents, const ElementId< Dim > &element_id, Spectral::Quadrature quadrature, const OrientationMap< Dim > &orientation={}) noexcept
Construct the initial Mesh of an Element.
domain::Tags::InitialRefinementLevels
Definition: Tags.hpp:84
Frame
Definition: IndexType.hpp:36
Requires.hpp
Frame::Logical
Definition: IndexType.hpp:42
make_not_null
gsl::not_null< T * > make_not_null(T *ptr) noexcept
Construct a not_null from a pointer. Often this will be done as an implicit conversion,...
Definition: Gsl.hpp:880
Requires
typename Requires_detail::requires_impl< B >::template_error_type_failed_to_meet_requirements_on_template_parameters Requires
Express requirements on the template parameters of a function or class, replaces std::enable_if_t
Definition: Requires.hpp:67
std::unique_ptr
TMPL.hpp
Mesh.hpp
domain::Tags::ElementMap
Definition: Tags.hpp:115