Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <memory> 7 : #include <optional> 8 : #include <pup.h> 9 : #include <string> 10 : #include <type_traits> 11 : 12 : #include "DataStructures/DataBox/Prefixes.hpp" 13 : #include "DataStructures/DataVector.hpp" 14 : #include "DataStructures/Tensor/Tensor.hpp" 15 : #include "DataStructures/Variables.hpp" 16 : #include "Evolution/BoundaryConditions/Type.hpp" 17 : #include "Evolution/Systems/GeneralizedHarmonic/BoundaryConditions/BoundaryCondition.hpp" 18 : #include "Evolution/Systems/GeneralizedHarmonic/ConstraintDamping/Tags.hpp" 19 : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp" 20 : #include "Options/String.hpp" 21 : #include "PointwiseFunctions/AnalyticData/Tags.hpp" 22 : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp" 23 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp" 24 : #include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp" 25 : #include "Utilities/Gsl.hpp" 26 : #include "Utilities/Serialization/CharmPupable.hpp" 27 : #include "Utilities/TMPL.hpp" 28 : 29 : /// \cond 30 : namespace Tags { 31 : struct Time; 32 : } // namespace Tags 33 : namespace domain::Tags { 34 : template <size_t Dim, typename Frame> 35 : struct Coordinates; 36 : } // namespace domain::Tags 37 : /// \endcond 38 : 39 : namespace gh::BoundaryConditions { 40 : /*! 41 : * \brief Sets Dirichlet boundary conditions using the analytic solution or 42 : * analytic data. 43 : */ 44 : template <size_t Dim> 45 1 : class DirichletAnalytic final : public BoundaryCondition<Dim> { 46 : public: 47 : /// \brief What analytic solution/data to prescribe. 48 1 : struct AnalyticPrescription { 49 0 : static constexpr Options::String help = 50 : "What analytic solution/data to prescribe."; 51 0 : using type = std::unique_ptr<evolution::initial_data::InitialData>; 52 : }; 53 : 54 0 : using options = tmpl::list<AnalyticPrescription>; 55 : 56 0 : static constexpr Options::String help{ 57 : "DirichletAnalytic boundary conditions setting the value of the " 58 : "spacetime metric and its derivatives Phi and Pi to the analytic " 59 : "solution or analytic data."}; 60 : 61 0 : DirichletAnalytic() = default; 62 0 : DirichletAnalytic(DirichletAnalytic&&) = default; 63 0 : DirichletAnalytic& operator=(DirichletAnalytic&&) = default; 64 0 : DirichletAnalytic(const DirichletAnalytic&); 65 0 : DirichletAnalytic& operator=(const DirichletAnalytic&); 66 0 : ~DirichletAnalytic() override = default; 67 : 68 0 : explicit DirichletAnalytic( 69 : std::unique_ptr<evolution::initial_data::InitialData> 70 : analytic_prescription); 71 : 72 0 : explicit DirichletAnalytic(CkMigrateMessage* msg); 73 : 74 0 : WRAPPED_PUPable_decl_base_template( 75 : domain::BoundaryConditions::BoundaryCondition, DirichletAnalytic); 76 : 77 0 : auto get_clone() const -> std::unique_ptr< 78 : domain::BoundaryConditions::BoundaryCondition> override; 79 : 80 0 : static constexpr evolution::BoundaryConditions::Type bc_type = 81 : evolution::BoundaryConditions::Type::Ghost; 82 : 83 0 : void pup(PUP::er& p) override; 84 : 85 0 : using dg_interior_evolved_variables_tags = tmpl::list<>; 86 0 : using dg_interior_temporary_tags = 87 : tmpl::list<domain::Tags::Coordinates<Dim, Frame::Inertial>, 88 : ::gh::ConstraintDamping::Tags::ConstraintGamma1, 89 : ::gh::ConstraintDamping::Tags::ConstraintGamma2>; 90 0 : using dg_gridless_tags = tmpl::list<::Tags::Time>; 91 : 92 0 : std::optional<std::string> dg_ghost( 93 : gsl::not_null<tnsr::aa<DataVector, Dim, Frame::Inertial>*> 94 : spacetime_metric, 95 : gsl::not_null<tnsr::aa<DataVector, Dim, Frame::Inertial>*> pi, 96 : gsl::not_null<tnsr::iaa<DataVector, Dim, Frame::Inertial>*> phi, 97 : gsl::not_null<Scalar<DataVector>*> gamma1, 98 : gsl::not_null<Scalar<DataVector>*> gamma2, 99 : gsl::not_null<Scalar<DataVector>*> lapse, 100 : gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> shift, 101 : gsl::not_null<tnsr::II<DataVector, Dim, Frame::Inertial>*> 102 : inv_spatial_metric, 103 : const std::optional< 104 : tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/, 105 : const tnsr::i<DataVector, Dim, Frame::Inertial>& /*normal_covector*/, 106 : const tnsr::I<DataVector, Dim, Frame::Inertial>& /*normal_vector*/, 107 : const tnsr::I<DataVector, Dim, Frame::Inertial>& coords, 108 : const Scalar<DataVector>& interior_gamma1, 109 : const Scalar<DataVector>& interior_gamma2, double time) const; 110 : 111 : private: 112 0 : void lapse_shift_and_inv_spatial_metric( 113 : gsl::not_null<Scalar<DataVector>*> lapse, 114 : gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> shift, 115 : gsl::not_null<tnsr::II<DataVector, Dim, Frame::Inertial>*> 116 : inv_spatial_metric, 117 : const tnsr::aa<DataVector, Dim, Frame::Inertial>& spacetime_metric) const; 118 : 119 0 : std::unique_ptr<evolution::initial_data::InitialData> analytic_prescription_; 120 : }; 121 : } // namespace gh::BoundaryConditions