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 <cstddef> 8 : #include <memory> 9 : #include <random> 10 : #include <string> 11 : #include <unordered_map> 12 : 13 : #include "DataStructures/DataBox/DataBox.hpp" 14 : #include "DataStructures/DataVector.hpp" 15 : #include "DataStructures/Tensor/Tensor.hpp" 16 : #include "Domain/ElementMap.hpp" 17 : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp" 18 : #include "Domain/FunctionsOfTime/Tags.hpp" 19 : #include "Domain/Tags.hpp" 20 : #include "Domain/TagsTimeDependent.hpp" 21 : #include "Evolution/Initialization/Tags.hpp" 22 : #include "Evolution/Systems/GeneralizedHarmonic/GaugeSourceFunctions/Tags/GaugeCondition.hpp" 23 : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp" 24 : #include "Parallel/GlobalCache.hpp" 25 : #include "Utilities/TMPL.hpp" 26 : 27 : /// \cond 28 : namespace Tags { 29 : struct Time; 30 : } // namespace Tags 31 : /// \endcond 32 : 33 : namespace gh { 34 : namespace Tags { 35 : /// DataBox tag for holding whether or not to set GH variables $\Pi$ and $\Phi$ 36 : /// from constraints. 37 1 : struct SetPiAndPhiFromConstraints : db::SimpleTag { 38 0 : using type = bool; 39 : 40 0 : using option_tags = tmpl::list<>; 41 0 : static constexpr bool pass_metavariables = false; 42 : 43 0 : static bool create_from_options() { return true; } 44 : }; 45 : } // namespace Tags 46 : 47 : namespace gauges { 48 : /*! 49 : * \brief GlobalCache mutator to set the value of the 50 : * `gh::Tags::SetPiAndPhiFromConstraints` tag. 51 : */ 52 1 : struct SetPiAndPhiFromConstraintsCacheMutator { 53 0 : static void apply(gsl::not_null<bool*> value, bool new_value); 54 : }; 55 : 56 : /*! 57 : * \brief Set \f$\Pi_{ab}\f$ from the gauge source function (or 1-index 58 : * constraint) and \f$\Phi_{iab}\f$ from the 3-index constraint. 59 : * 60 : * This is necessary to ensure the initial data is in the desired evolution 61 : * gauge and that the 1- and 3-index constraints are satisfied. 62 : */ 63 : template <class AllSolutionsForChristoffelAnalytic, size_t Dim> 64 1 : struct SetPiAndPhiFromConstraints { 65 : public: 66 0 : using return_tags = 67 : tmpl::list<gh::Tags::Pi<DataVector, Dim>, gh::Tags::Phi<DataVector, Dim>>; 68 0 : using argument_tags = 69 : tmpl::list<::Tags::Time, domain::Tags::Mesh<Dim>, 70 : domain::Tags::ElementMap<Dim, Frame::Grid>, 71 : domain::CoordinateMaps::Tags::CoordinateMap<Dim, Frame::Grid, 72 : Frame::Inertial>, 73 : domain::Tags::FunctionsOfTime, 74 : domain::Tags::Coordinates<Dim, Frame::ElementLogical>, 75 : gr::Tags::SpacetimeMetric<DataVector, Dim>, 76 : gh::gauges::Tags::GaugeCondition, 77 : gh::Tags::SetPiAndPhiFromConstraints>; 78 : 79 0 : using compute_tags = tmpl::list< 80 : Parallel::Tags::FromGlobalCache<gh::Tags::SetPiAndPhiFromConstraints>>; 81 0 : using const_global_cache_tags = tmpl::list<gh::gauges::Tags::GaugeCondition>; 82 0 : using mutable_global_cache_tags = 83 : tmpl::list<gh::Tags::SetPiAndPhiFromConstraints>; 84 : 85 0 : static void apply( 86 : gsl::not_null<tnsr::aa<DataVector, Dim, Frame::Inertial>*> pi, 87 : gsl::not_null<tnsr::iaa<DataVector, Dim, Frame::Inertial>*> phi, 88 : double time, const Mesh<Dim>& mesh, 89 : const ElementMap<Dim, Frame::Grid>& logical_to_grid_map, 90 : const domain::CoordinateMapBase<Frame::Grid, Frame::Inertial, Dim>& 91 : grid_to_inertial_map, 92 : const std::unordered_map< 93 : std::string, 94 : std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>>& 95 : functions_of_time, 96 : const tnsr::I<DataVector, Dim, Frame::ElementLogical>& 97 : logical_coordinates, 98 : const tnsr::aa<DataVector, Dim, Frame::Inertial>& spacetime_metric, 99 : const gauges::GaugeCondition& gauge_condition, 100 : bool set_pi_and_phi_from_constraints = true); 101 : }; 102 : } // namespace gauges 103 : } // namespace gh