Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <cstddef> 7 : 8 : #include "DataStructures/DataBox/DataBoxTag.hpp" 9 : #include "DataStructures/DataBox/Tag.hpp" 10 : #include "DataStructures/DataVector.hpp" 11 : #include "DataStructures/Tensor/Tensor.hpp" 12 : #include "Evolution/Systems/CurvedScalarWave/Constraints.hpp" 13 : #include "Evolution/Systems/CurvedScalarWave/Tags.hpp" 14 : #include "Evolution/Tags.hpp" 15 : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp" 16 : #include "Options/String.hpp" 17 : #include "Utilities/TMPL.hpp" 18 : 19 : /// \cond 20 : namespace ScalarTensor::OptionTags { 21 : struct Group; 22 : } // namespace ScalarTensor::OptionTags 23 : /// \endcond 24 : 25 : /*! 26 : * \brief Tags for the scalar tensor system. 27 : */ 28 : namespace ScalarTensor { 29 : namespace Tags { 30 : /*! 31 : * \brief Represents the trace-reversed stress-energy tensor of the scalar 32 : * field. 33 : */ 34 : template <typename DataType, size_t Dim, typename Fr = Frame::Inertial> 35 1 : struct TraceReversedStressEnergy : db::SimpleTag { 36 0 : using type = tnsr::aa<DataType, Dim, Fr>; 37 : }; 38 : 39 : /*! 40 : * \brief Tag holding the source term of the scalar equation. 41 : * 42 : * \details This tag hold the source term \f$ \mathcal{S} \f$, 43 : * entering a wave equation of the form 44 : * \f[ 45 : * \Box \Psi = \mathcal{S} ~. 46 : * \f] 47 : */ 48 1 : struct ScalarSource : db::SimpleTag { 49 0 : using type = Scalar<DataVector>; 50 : }; 51 : 52 : } // namespace Tags 53 : 54 0 : namespace OptionTags { 55 : /*! 56 : * \brief Scalar mass parameter. 57 : */ 58 1 : struct ScalarMass { 59 0 : static std::string name() { return "ScalarMass"; } 60 0 : using type = double; 61 0 : static constexpr Options::String help{ 62 : "Mass of the scalar field in code units"}; 63 0 : using group = ::ScalarTensor::OptionTags::Group; 64 : }; 65 : 66 : /*! 67 : * \ingroup OptionGroupsGroup 68 : * Groups option tags related to the ScalarTensor evolution system. 69 : */ 70 1 : struct Group { 71 0 : static std::string name() { return "ScalarTensor"; } 72 0 : static constexpr Options::String help{ 73 : "Options for the ScalarTensor evolution system"}; 74 0 : using group = evolution::OptionTags::SystemGroup; 75 : }; 76 : } // namespace OptionTags 77 : 78 : namespace Tags { 79 0 : struct ScalarMass : db::SimpleTag { 80 0 : using type = double; 81 0 : using option_tags = tmpl::list<OptionTags::ScalarMass>; 82 0 : static constexpr bool pass_metavariables = false; 83 0 : static double create_from_options(const double mass_psi) { return mass_psi; } 84 : }; 85 : 86 : /*! 87 : * \brief Prefix tag to avoid ambiguities when observing variables with the same 88 : * name in both parent systems. 89 : * \note Since we also add compute tags for these quantities, we do not make 90 : * this a derived class of `Tag`. Otherwise, we would have tags with repeated 91 : * base tags in the `ObservationBox`. 92 : */ 93 : template <typename Tag> 94 1 : struct Csw : db::PrefixTag, db::SimpleTag { 95 0 : using type = typename Tag::type; 96 0 : using tag = Tag; 97 : }; 98 : 99 : /*! 100 : * \brief Compute tag to retrieve the values of CurvedScalarWave variables 101 : * with the same name as in the ::gh systems. 102 : * \note Since we also add compute tags for these quantities, we do not make 103 : * this a derived class of `Tag`. Otherwise, we would have tags with repeated 104 : * base tags in the `ObservationBox`. 105 : */ 106 : template <typename Tag> 107 1 : struct CswCompute : Csw<Tag>, db::ComputeTag { 108 0 : using argument_tags = tmpl::list<Tag>; 109 0 : using base = Csw<Tag>; 110 0 : using return_type = typename base::type; 111 0 : static constexpr void function(const gsl::not_null<return_type*> result, 112 : const return_type& csw_var) { 113 : for (size_t i = 0; i < csw_var.size(); ++i) { 114 : make_const_view(make_not_null(&std::as_const((*result)[i])), csw_var[i], 115 : 0, csw_var[i].size()); 116 : } 117 : } 118 : }; 119 : 120 : /*! 121 : * \brief Computes the scalar-wave one-index constraint. 122 : * \details The one-index constraint is assigned to a wrapped tag to avoid 123 : * clashes with the ::gh constraints during observation. 124 : * \note We do not use ScalarTensor::Tags::CswCompute to retrieve the 125 : * CurvedScalarWave constraints since we do not want to add the bare compute 126 : * tags (::CurvedScalarWave::Tags::OneIndexConstraintCompute and 127 : * ::CurvedScalarWave::Tags::TwoIndexConstraintCompute) directly in the 128 : * ObservationBox, since that will make them observable and would lead to a 129 : * clash with the ::gh constraint tags. 130 : */ 131 : template <size_t Dim> 132 1 : struct CswOneIndexConstraintCompute 133 : : Csw<CurvedScalarWave::Tags::OneIndexConstraint<Dim>>, 134 : db::ComputeTag { 135 0 : using argument_tags = 136 : tmpl::list<::Tags::deriv<CurvedScalarWave::Tags::Psi, tmpl::size_t<Dim>, 137 : Frame::Inertial>, 138 : CurvedScalarWave::Tags::Phi<Dim>>; 139 0 : using return_type = tnsr::i<DataVector, Dim>; 140 0 : static constexpr void (*function)(const gsl::not_null<return_type*> result, 141 : const tnsr::i<DataVector, Dim>&, 142 : const tnsr::i<DataVector, Dim>&) = 143 : &CurvedScalarWave::one_index_constraint<Dim>; 144 0 : using base = Csw<CurvedScalarWave::Tags::OneIndexConstraint<Dim>>; 145 : }; 146 : 147 : /*! 148 : * \brief Computes the scalar-wave two-index constraint. 149 : * \details The two-index constraint is assigned to a wrapped tag to avoid 150 : * clashes with the ::gh constraints during observation. 151 : * \note We do not use ScalarTensor::Tags::CswCompute to retrieve the 152 : * CurvedScalarWave constraints since we do not want to add the bare compute 153 : * tags (::CurvedScalarWave::Tags::OneIndexConstraintCompute and 154 : * ::CurvedScalarWave::Tags::TwoIndexConstraintCompute) directly in the 155 : * ObservationBox, since that will make them observable and would lead to a 156 : * clash with the ::gh constraint tags. 157 : */ 158 : template <size_t Dim> 159 1 : struct CswTwoIndexConstraintCompute 160 : : Csw<CurvedScalarWave::Tags::TwoIndexConstraint<Dim>>, 161 : db::ComputeTag { 162 0 : using argument_tags = 163 : tmpl::list<::Tags::deriv<CurvedScalarWave::Tags::Phi<Dim>, 164 : tmpl::size_t<Dim>, Frame::Inertial>>; 165 0 : using return_type = tnsr::ij<DataVector, Dim>; 166 0 : static constexpr void (*function)(const gsl::not_null<return_type*> result, 167 : const tnsr::ij<DataVector, Dim>&) = 168 : &CurvedScalarWave::two_index_constraint<Dim>; 169 0 : using base = Csw<CurvedScalarWave::Tags::TwoIndexConstraint<Dim>>; 170 : }; 171 : 172 : } // namespace Tags 173 : 174 : } // namespace ScalarTensor