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/Tags.hpp"
19 : #include "Options/String.hpp"
20 : #include "PointwiseFunctions/AnalyticData/Tags.hpp"
21 : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
22 : #include "PointwiseFunctions/GeneralRelativity/GeneralizedHarmonic/ConstraintDampingTags.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::Tags::ConstraintGamma1, ::gh::Tags::ConstraintGamma2>;
89 0 : using dg_gridless_tags = tmpl::list<::Tags::Time>;
90 :
91 0 : std::optional<std::string> dg_ghost(
92 : gsl::not_null<tnsr::aa<DataVector, Dim, Frame::Inertial>*>
93 : spacetime_metric,
94 : gsl::not_null<tnsr::aa<DataVector, Dim, Frame::Inertial>*> pi,
95 : gsl::not_null<tnsr::iaa<DataVector, Dim, Frame::Inertial>*> phi,
96 : gsl::not_null<Scalar<DataVector>*> gamma1,
97 : gsl::not_null<Scalar<DataVector>*> gamma2,
98 : gsl::not_null<Scalar<DataVector>*> lapse,
99 : gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> shift,
100 : gsl::not_null<tnsr::II<DataVector, Dim, Frame::Inertial>*>
101 : inv_spatial_metric,
102 : const std::optional<
103 : tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/,
104 : const tnsr::i<DataVector, Dim, Frame::Inertial>& /*normal_covector*/,
105 : const tnsr::I<DataVector, Dim, Frame::Inertial>& /*normal_vector*/,
106 : const tnsr::I<DataVector, Dim, Frame::Inertial>& coords,
107 : const Scalar<DataVector>& interior_gamma1,
108 : const Scalar<DataVector>& interior_gamma2, double time) const;
109 :
110 : private:
111 0 : void lapse_shift_and_inv_spatial_metric(
112 : gsl::not_null<Scalar<DataVector>*> lapse,
113 : gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> shift,
114 : gsl::not_null<tnsr::II<DataVector, Dim, Frame::Inertial>*>
115 : inv_spatial_metric,
116 : const tnsr::aa<DataVector, Dim, Frame::Inertial>& spacetime_metric) const;
117 :
118 0 : std::unique_ptr<evolution::initial_data::InitialData> analytic_prescription_;
119 : };
120 : } // namespace gh::BoundaryConditions
|