InitializeDampedHarmonic.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 #include <utility>
9 
12 #include "Domain/CoordinateMaps/Tags.hpp"
13 #include "Domain/Mesh.hpp"
14 #include "Domain/Tags.hpp"
15 #include "ErrorHandling/Error.hpp"
16 #include "Evolution/Initialization/Tags.hpp"
17 #include "Evolution/Systems/GeneralizedHarmonic/GaugeSourceFunctions/DampedHarmonic.hpp"
18 #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
19 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
20 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
22 #include "Utilities/TMPL.hpp"
23 
24 namespace GeneralizedHarmonic::gauges::Actions {
25 template <size_t Dim>
27  using frame = Frame::Inertial;
28 
29  using const_global_cache_tags = tmpl::list<
33 
34  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
35  typename ArrayIndex, typename ActionList,
36  typename ParallelComponent>
37  static auto apply(db::DataBox<DbTagsList>& box,
38  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
40  const ArrayIndex& /*array_index*/,
41  const ActionList /*meta*/,
42  const ParallelComponent* const /*meta*/) noexcept {
44  Metavariables::volume_dim, Frame::Grid, Frame::Inertial>>(box)
45  .is_identity()) {
46  ERROR(
47  "Cannot use the damped harmonic rollon gauge with a moving mesh "
48  "because the rollon is not implemented for a moving mesh. The issue "
49  "is that the initial H_a needs to be in the grid frame, and then "
50  "transformed to the inertial frame at each time step. Transforming "
51  "the spacetime derivative requires spacetime Hessians, which are not "
52  "implemented for the maps and there is currently no plan to add them "
53  "because we do not need them for anything else.");
54  }
55  const auto& inverse_jacobian =
56  db::get<domain::Tags::InverseJacobian<Dim, Frame::Logical, frame>>(box);
57 
58  auto [initial_gauge_h, initial_d4_gauge_h] = impl(
60  box),
63  db::get<domain::Tags::Mesh<Dim>>(box), inverse_jacobian);
64 
65  // Add gauge tags
66  using compute_tags = db::AddComputeTags<
68 
69  // Finally, insert gauge related quantities to the box
70  return std::make_tuple(
76  frame>>,
77  compute_tags>(std::move(box), std::move(initial_gauge_h),
78  std::move(initial_d4_gauge_h)));
79  }
80 
81  private:
83  tnsr::ab<DataVector, Dim, Frame::Inertial>>
84  impl(const tnsr::aa<DataVector, Dim, Frame::Inertial>& spacetime_metric,
85  const tnsr::aa<DataVector, Dim, Frame::Inertial>& pi,
86  const tnsr::iaa<DataVector, Dim, Frame::Inertial>& phi,
87  const Mesh<Dim>& mesh,
88  const InverseJacobian<DataVector, Dim, Frame::Logical, Frame::Inertial>&
89  inverse_jacobian) noexcept;
90 };
91 } // namespace GeneralizedHarmonic::gauges::Actions
Parallel::ConstGlobalCache
Definition: ElementReceiveInterpPoints.hpp:16
GeneralizedHarmonic::pi
void pi(gsl::not_null< tnsr::aa< DataType, SpatialDim, Frame > * > pi, const Scalar< DataType > &lapse, const Scalar< DataType > &dt_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::I< DataType, SpatialDim, Frame > &dt_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ii< DataType, SpatialDim, Frame > &dt_spatial_metric, const tnsr::iaa< DataType, SpatialDim, Frame > &phi) noexcept
Computes the conjugate momentum of the spacetime metric .
utility
Frame::Inertial
Definition: IndexType.hpp:44
Frame::Grid
Definition: IndexType.hpp:43
Tags.hpp
Error.hpp
db::AddComputeTags
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1171
domain::Tags::Mesh
The computational grid of the Element in the DataBox.
Definition: Tags.hpp:106
tuple
db::get
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:1134
GeneralizedHarmonic::gauges::DampedHarmonicRollonCompute
Compute tag for the damped harmonic gauge source function and its spacetime derivative.
Definition: DampedHarmonic.hpp:194
GeneralizedHarmonic::gauges::Actions::InitializeDampedHarmonic
Definition: InitializeDampedHarmonic.hpp:26
GeneralizedHarmonic::Tags::GaugeHRollOnTimeWindow
Gauge control parameter determining how long the transition to the evolution gauge should take at the...
Definition: Tags.hpp:81
GeneralizedHarmonic::Tags::GaugeHRollOnStartTime
Gauge control parameter determining when to start rolling-on the evolution gauge.
Definition: Tags.hpp:62
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
DataBox.hpp
cstddef
MakeWithValue.hpp
GeneralizedHarmonic::Tags::Pi
Conjugate momentum to the spacetime metric.
Definition: Tags.hpp:29
gr::Tags::SpacetimeMetric
Definition: Tags.hpp:17
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
GeneralizedHarmonic::phi
void phi(gsl::not_null< tnsr::iaa< DataType, SpatialDim, Frame > * > phi, const Scalar< DataType > &lapse, const tnsr::i< DataType, SpatialDim, Frame > &deriv_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::iJ< DataType, SpatialDim, Frame > &deriv_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ijj< DataType, SpatialDim, Frame > &deriv_spatial_metric) noexcept
Computes the auxiliary variable used by the generalized harmonic formulation of Einstein's equations...
domain::CoordinateMaps::Tags::CoordinateMap
Definition: Tags.hpp:30
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:50
db::AddSimpleTags
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1150
GeneralizedHarmonic::Tags::Phi
Auxiliary variable which is analytically the spatial derivative of the spacetime metric.
Definition: Tags.hpp:40
gr::spacetime_metric
void spacetime_metric(gsl::not_null< tnsr::aa< DataType, Dim, Frame > * > spacetime_metric, const Scalar< DataType > &lapse, const tnsr::I< DataType, Dim, Frame > &shift, const tnsr::ii< DataType, Dim, Frame > &spatial_metric) noexcept
Computes the spacetime metric from the spatial metric, lapse, and shift.
Tensor.hpp
GeneralizedHarmonic::Tags::InitialGaugeH
Initial value of the gauge source function for the generalized harmonic system.
Definition: Tags.hpp:154
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
db::DataBox
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
TMPL.hpp
GeneralizedHarmonic::Tags::GaugeHSpatialWeightDecayWidth
Gauge control parameter to specify the spatial weighting function that enters damped harmonic gauge s...
Definition: Tags.hpp:105
GeneralizedHarmonic::Tags::SpacetimeDerivInitialGaugeH
Initial spacetime derivatives of the gauge source function for the generalized harmonic system.
Definition: Tags.hpp:169