Initialize.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 <tuple>
9 #include <utility> // IWYU pragma: keep
10 #include <vector>
11 
16 #include "DataStructures/Tensor/EagerMath/Norms.hpp"
18 #include "Domain/Mesh.hpp"
19 #include "Domain/Tags.hpp"
20 #include "ErrorHandling/Assert.hpp"
21 #include "Evolution/Initialization/DiscontinuousGalerkin.hpp"
22 #include "Evolution/Initialization/Evolution.hpp"
23 #include "Evolution/Systems/GeneralizedHarmonic/Characteristics.hpp"
25 #include "Evolution/Systems/GeneralizedHarmonic/System.hpp"
26 #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
29 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
30 #include "PointwiseFunctions/AnalyticData/Tags.hpp"
31 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
35 #include "PointwiseFunctions/GeneralRelativity/IndexManipulation.hpp"
36 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
37 #include "Utilities/Gsl.hpp"
39 #include "Utilities/TMPL.hpp"
40 #include "Utilities/TypeTraits.hpp"
41 
42 namespace GeneralizedHarmonic {
43 namespace Actions {
44 template <size_t Dim>
46  using frame = Frame::Inertial;
47 
48  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
49  typename ArrayIndex, typename ActionList,
50  typename ParallelComponent>
51  static auto apply(db::DataBox<DbTagsList>& box,
52  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
54  const ArrayIndex& /*array_index*/,
55  const ActionList /*meta*/,
56  const ParallelComponent* const /*meta*/) noexcept {
57  using compute_tags = db::AddComputeTags<
60  // following tags added to observe constraints
67 
68  return std::make_tuple(
70  db::AddSimpleTags<>, compute_tags>(
71  std::move(box)));
72  }
73 };
74 
75 template <size_t Dim>
77  using frame = Frame::Inertial;
78 
79  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
80  typename ArrayIndex, typename ActionList,
81  typename ParallelComponent>
82  static auto apply(db::DataBox<DbTagsList>& box,
83  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
85  const ArrayIndex& /*array_index*/,
86  const ActionList /*meta*/,
87  const ParallelComponent* const /*meta*/) noexcept {
88  using compute_tags = db::AddComputeTags<
109  DataVector>,
113  DataVector>,
119 
120  return std::make_tuple(
122  db::AddSimpleTags<>, compute_tags>(
123  std::move(box)));
124  }
125 };
126 
127 template <size_t Dim>
129  using frame = Frame::Inertial;
130 
131  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
132  typename ArrayIndex, typename ActionList,
133  typename ParallelComponent>
134  static auto apply(db::DataBox<DbTagsList>& box,
135  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
137  const ArrayIndex& /*array_index*/,
138  const ActionList /*meta*/,
139  const ParallelComponent* const /*meta*/) noexcept {
140  // compute initial-gauge related quantities
141  const auto& mesh = db::get<::Tags::Mesh<Dim>>(box);
142  const size_t num_grid_points = mesh.number_of_grid_points();
143  const auto& lapse = get<gr::Tags::Lapse<DataVector>>(box);
144  const auto& dt_lapse = get<::Tags::dt<gr::Tags::Lapse<DataVector>>>(box);
145  const auto& deriv_lapse = get<
146  ::Tags::deriv<gr::Tags::Lapse<DataVector>, tmpl::size_t<Dim>, frame>>(
147  box);
148  const auto& shift = get<gr::Tags::Shift<Dim, frame, DataVector>>(box);
149  const auto& dt_shift =
150  get<::Tags::dt<gr::Tags::Shift<Dim, frame, DataVector>>>(box);
151  const auto& deriv_shift =
152  get<::Tags::deriv<gr::Tags::Shift<Dim, frame, DataVector>,
153  tmpl::size_t<Dim>, frame>>(box);
154  const auto& spatial_metric =
155  get<gr::Tags::SpatialMetric<Dim, frame, DataVector>>(box);
156  const auto& trace_extrinsic_curvature =
157  get<gr::Tags::TraceExtrinsicCurvature<DataVector>>(box);
158  const auto& trace_christoffel_last_indices =
159  get<gr::Tags::TraceSpatialChristoffelFirstKind<Dim, frame, DataVector>>(
160  box);
161 
162  // compute the initial gauge source function
163  auto initial_gauge_h = GeneralizedHarmonic::gauge_source<Dim, frame>(
164  lapse, dt_lapse, deriv_lapse, shift, dt_shift, deriv_shift,
165  spatial_metric, trace_extrinsic_curvature,
166  trace_christoffel_last_indices);
167  // set time derivatives of InitialGaugeH = 0
168  // NOTE: this will need to be generalized to handle numerical initial data
169  // and analytic initial data whose gauge is not initially stationary.
170  auto dt_initial_gauge_source =
171  make_with_value<tnsr::a<DataVector, Dim, frame>>(lapse, 0.);
172 
173  // compute spatial derivatives of InitialGaugeH
174  // The `partial_derivatives` function does not support single Tensor input,
175  // and so we must store the tensor in a Variables first.
176  using InitialGaugeHVars = ::Variables<
177  tmpl::list<GeneralizedHarmonic::Tags::InitialGaugeH<Dim, frame>>>;
178  InitialGaugeHVars initial_gauge_h_vars{num_grid_points};
179 
180  get<GeneralizedHarmonic::Tags::InitialGaugeH<Dim, frame>>(
181  initial_gauge_h_vars) = initial_gauge_h;
182  const auto& inverse_jacobian = db::get<
185  auto d_initial_gauge_source =
186  get<::Tags::deriv<GeneralizedHarmonic::Tags::InitialGaugeH<Dim, frame>,
187  tmpl::size_t<Dim>, frame>>(
188  partial_derivatives<typename InitialGaugeHVars::tags_list>(
189  initial_gauge_h_vars, mesh, inverse_jacobian));
190 
191  // compute spacetime derivatives of InitialGaugeH
192  auto initial_d4_gauge_h =
194  Dim, frame>::function(std::move(dt_initial_gauge_source),
195  std::move(d_initial_gauge_source));
196  // Add gauge tags
197  using compute_tags = db::AddComputeTags<
200 
201  // Finally, insert gauge related quantities to the box
202  return std::make_tuple(
208  frame>>,
209  compute_tags>(std::move(box), std::move(initial_gauge_h),
210  std::move(initial_d4_gauge_h)));
211  }
212 };
213 
214 } // namespace Actions
215 } // namespace GeneralizedHarmonic
Compute item for spatial metric determinant and inverse in terms of the spatial metric ...
Definition: ComputeSpacetimeQuantities.hpp:299
Compute item to get time derivative of the spatial metric from generalized harmonic and geometric var...
Definition: ComputeGhQuantities.hpp:490
Compute item for spatial Christoffel symbols of the second kind computed from the Christoffel symbol...
Definition: Christoffel.hpp:74
Compute item to get spatial derivative of spacetime metric from spatial metric, lapse, shift, and their space and time derivatives.
Definition: ComputeSpacetimeQuantities.hpp:354
Initial spacetime derivatives of the gauge source function for the generalized harmonic system...
Definition: Tags.hpp:174
Tags corresponding to various constraints of the generalized harmonic system, and their diagnosticall...
Definition: Tags.hpp:257
Compute item to get the gauge constraint for the generalized harmonic evolution system.
Definition: ComputeGhQuantities.hpp:838
Compute item to get time derivative of lapse (N) from the generalized harmonic variables, lapse, shift and the spacetime unit normal 1-form.
Definition: ComputeGhQuantities.hpp:514
Compute item for shift from the spacetime metric and the inverse spatial metric ...
Definition: ComputeSpacetimeQuantities.hpp:401
Compute items to compute constraint-damping parameters for a single-BH evolution. ...
Definition: ComputeGhQuantities.hpp:736
Define prefixes for DataBox tags.
Defines functions euclidean dot_product and dot_product with a metric.
Compute item to get the three-index constraint for the generalized harmonic evolution system...
Definition: ComputeGhQuantities.hpp:940
Compute item for the trace of the spacetime Christoffel symbols of the first kind computed from the ...
Definition: Christoffel.hpp:157
Compute item to get the square root of the determinant of the spatial metric via gr::Tags::DetAndInv...
Definition: ComputeSpacetimeQuantities.hpp:385
Defines Functions for calculating spacetime tensors from 3+1 quantities.
tnsr::ii< DataType, SpatialDim, Frame > spatial_metric(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute spatial metric from spacetime metric.
Definition: ComputeSpacetimeQuantities.cpp:62
Compute item to get the trace of extrinsic curvature from generalized harmonic variables and the spac...
Definition: ComputeGhQuantities.hpp:714
Compute item for the trace of the spatial Christoffel symbols of the first kind computed from the Ch...
Definition: Christoffel.hpp:96
auto merge_into_databox(db::DataBox< DbTagsList > &&box, Args &&... args) noexcept
Add tags that are not yet in the DataBox.
Definition: MergeIntoDataBox.hpp:132
Compute item for spatial metric from the spacetime metric .
Definition: ComputeSpacetimeQuantities.hpp:283
Compute item for inverse spacetime metric in terms of the lapse , shift , and inverse spatial metric...
Definition: ComputeSpacetimeQuantities.hpp:265
Compute item for lapse from the spacetime metric and the shift .
Definition: ComputeSpacetimeQuantities.hpp:416
Compute item for spacetime Christoffel symbols of the second kind computed from the Christoffel symb...
Definition: Christoffel.hpp:135
Definition: Initialize.hpp:128
Compute items to compute constraint-damping parameters for a single-BH evolution. ...
Definition: ComputeGhQuantities.hpp:759
Compute item for spacetime Christoffel symbols of the first kind computed from the first derivative ...
Definition: Christoffel.hpp:116
Computes the inverse Jacobian of the map held by MapTag at the coordinates held by SourceCoordsTag...
Definition: Tags.hpp:169
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:273
Defines classes and functions used for manipulating DataBox&#39;s.
Compute item to get spatial derivatives of the spatial metric from the generalized harmonic spatial d...
Definition: ComputeGhQuantities.hpp:565
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1222
Items related to evolving the first-order generalized harmonic system.
Definition: Characteristics.cpp:20
Compute item to get spatial derivatives of lapse from the generalized harmonic variables and spacetim...
Definition: ComputeGhQuantities.hpp:586
Compute item for spatial Christoffel symbols of the first kind computed from the first derivative of...
Definition: Christoffel.hpp:56
Defines functions computing partial derivatives.
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Defines class Variables.
Scalar< DataType > lapse(const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute lapse from shift and spacetime metric.
Definition: ComputeSpacetimeQuantities.cpp:117
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:135
Defines Functions for calculating damped harmonic gauge quantities from 3+1 quantities.
Defines the class template Mesh.
The coordinates in a given frame.
Definition: Tags.hpp:139
Tags corresponding to various constraints of the generalized harmonic system, and their diagnosticall...
Definition: Tags.hpp:263
tnsr::I< DataType, SpatialDim, Frame > shift(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric, const tnsr::II< DataType, SpatialDim, Frame > &inverse_spatial_metric) noexcept
Compute shift from spacetime metric and inverse spatial metric.
Definition: ComputeSpacetimeQuantities.cpp:101
Defines macro ASSERT.
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:1206
Tags corresponding to various constraints of the generalized harmonic system, and their diagnosticall...
Definition: Tags.hpp:239
Stores a collection of function values.
Definition: DataVector.hpp:42
Wraps the template metaprogramming library used (brigand)
Compute item to get time derivative of the shift vector from the generalized harmonic and geometric v...
Definition: ComputeGhQuantities.hpp:538
Definition: Norms.hpp:114
Defines functions and classes from the GSL.
Compute item to get spacetime derivative of spacetime metric from spatial metric, lapse...
Definition: ComputeSpacetimeQuantities.hpp:324
Defines tags related to domain quantities.
Compute item to get the four-index constraint for the generalized harmonic evolution system...
Definition: ComputeGhQuantities.hpp:960
Definition: IndexType.hpp:44
Compute items to compute constraint-damping parameters for a single-BH evolution. ...
Definition: ComputeGhQuantities.hpp:749
Compute item to get spatial derivatives of the shift vector from generalized harmonic and geometric v...
Definition: ComputeGhQuantities.hpp:609
Spacetime derivatives of the damped harmonic gauge source function.
Definition: DampedHarmonic.hpp:267
Initial value of the gauge source function for the generalized harmonic system.
Definition: Tags.hpp:158
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines Functions for calculating spacetime tensors from 3+1 quantities.
Defines class template ConstGlobalCache.
Defines type traits, some of which are future STL type_traits header.
Compute item to get spacetime derivative of the gauge source function from its spatial and time deriv...
Definition: ComputeGhQuantities.hpp:806
Compute item to get extrinsic curvature from generalized harmonic variables and the spacetime normal ...
Definition: ComputeGhQuantities.hpp:690
Compute item for spacetime normal vector from the lapse and the shift .
Definition: ComputeSpacetimeQuantities.hpp:228
Damped harmonic gauge source function.
Definition: DampedHarmonic.hpp:126
Defines functions to calculate Christoffel symbols.
Definition: ComputeTimeDerivative.hpp:28
Compute item for spacetime normal oneform from the lapse .
Definition: ComputeSpacetimeQuantities.hpp:212
Defines make_with_value.
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1243