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 <string>
9 :
10 : #include "DataStructures/DataVector.hpp"
11 : #include "DataStructures/Tensor/Tensor.hpp"
12 : #include "Evolution/BoundaryConditions/Type.hpp"
13 : #include "Evolution/Systems/CurvedScalarWave/Tags.hpp"
14 : #include "Evolution/Systems/ScalarTensor/BoundaryConditions/BoundaryCondition.hpp"
15 : #include "Options/String.hpp"
16 : #include "PointwiseFunctions/GeneralRelativity/GeneralizedHarmonic/ConstraintDampingTags.hpp"
17 : #include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp"
18 : #include "Utilities/Gsl.hpp"
19 : #include "Utilities/Serialization/CharmPupable.hpp"
20 : #include "Utilities/TMPL.hpp"
21 :
22 : /// \cond
23 : namespace Tags {
24 : struct Time;
25 : } // namespace Tags
26 : namespace domain::Tags {
27 : template <size_t Dim, typename Frame>
28 : struct Coordinates;
29 : } // namespace domain::Tags
30 : /// \endcond
31 :
32 : namespace ScalarTensor::BoundaryConditions {
33 : /*!
34 : * \brief Sets Dirichlet boundary conditions using the analytic solution or
35 : * analytic data.
36 : */
37 1 : class DirichletAnalytic final : public BoundaryCondition {
38 : public:
39 : /// \brief What analytic solution/data to prescribe.
40 1 : struct AnalyticPrescription {
41 0 : static constexpr Options::String help =
42 : "What analytic solution/data to prescribe.";
43 0 : using type = std::unique_ptr<evolution::initial_data::InitialData>;
44 : };
45 0 : struct Amplitude {
46 0 : using type = double;
47 0 : static constexpr Options::String help = {
48 : "Amplitude of the scalar at the boundary"};
49 : };
50 :
51 0 : using options = tmpl::list<AnalyticPrescription, Amplitude>;
52 :
53 0 : static constexpr Options::String help{
54 : "DirichletAnalytic boundary conditions."};
55 :
56 0 : DirichletAnalytic() = default;
57 0 : DirichletAnalytic(DirichletAnalytic&&) = default;
58 0 : DirichletAnalytic& operator=(DirichletAnalytic&&) = default;
59 0 : DirichletAnalytic(const DirichletAnalytic&);
60 0 : DirichletAnalytic& operator=(const DirichletAnalytic&);
61 0 : ~DirichletAnalytic() override = default;
62 :
63 0 : DirichletAnalytic(std::unique_ptr<evolution::initial_data::InitialData>
64 : analytic_prescription,
65 : double amplitude);
66 :
67 0 : explicit DirichletAnalytic(CkMigrateMessage* msg);
68 :
69 0 : WRAPPED_PUPable_decl_base_template(
70 : domain::BoundaryConditions::BoundaryCondition, DirichletAnalytic);
71 :
72 0 : auto get_clone() const -> std::unique_ptr<
73 : domain::BoundaryConditions::BoundaryCondition> override;
74 :
75 0 : static constexpr evolution::BoundaryConditions::Type bc_type =
76 : evolution::BoundaryConditions::Type::Ghost;
77 :
78 0 : void pup(PUP::er& p) override;
79 :
80 0 : using dg_interior_evolved_variables_tags = tmpl::list<>;
81 0 : using dg_interior_temporary_tags =
82 : tmpl::list<domain::Tags::Coordinates<3, Frame::Inertial>,
83 : ::gh::Tags::ConstraintGamma1, ::gh::Tags::ConstraintGamma2,
84 : ::CurvedScalarWave::Tags::ConstraintGamma1,
85 : ::CurvedScalarWave::Tags::ConstraintGamma2>;
86 0 : using dg_gridless_tags = tmpl::list<::Tags::Time>;
87 :
88 0 : std::optional<std::string> dg_ghost(
89 : // GH evolved variables
90 : gsl::not_null<tnsr::aa<DataVector, 3, Frame::Inertial>*> spacetime_metric,
91 : gsl::not_null<tnsr::aa<DataVector, 3, Frame::Inertial>*> pi,
92 : gsl::not_null<tnsr::iaa<DataVector, 3, Frame::Inertial>*> phi,
93 : // Scalar evolved variables
94 : gsl::not_null<Scalar<DataVector>*> psi_scalar,
95 : gsl::not_null<Scalar<DataVector>*> pi_scalar,
96 : gsl::not_null<tnsr::i<DataVector, 3, Frame::Inertial>*> phi_scalar,
97 : // GH temporary variables
98 : gsl::not_null<Scalar<DataVector>*> gamma1,
99 : gsl::not_null<Scalar<DataVector>*> gamma2,
100 : gsl::not_null<Scalar<DataVector>*> lapse,
101 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> shift,
102 : // Scalar temporary variables
103 : gsl::not_null<Scalar<DataVector>*> gamma1_scalar,
104 : gsl::not_null<Scalar<DataVector>*> gamma2_scalar,
105 : // Inverse metric
106 : gsl::not_null<tnsr::II<DataVector, 3, Frame::Inertial>*>
107 : inv_spatial_metric,
108 : // Mesh variables
109 : const std::optional<tnsr::I<DataVector, 3, Frame::Inertial>>&
110 : face_mesh_velocity,
111 : const tnsr::i<DataVector, 3, Frame::Inertial>& normal_covector,
112 : const tnsr::I<DataVector, 3, Frame::Inertial>& normal_vector,
113 : // GH interior variables
114 : const tnsr::I<DataVector, 3, Frame::Inertial>& coords,
115 : const Scalar<DataVector>& interior_gamma1,
116 : const Scalar<DataVector>& interior_gamma2,
117 : // Scalar interior variables
118 : const Scalar<DataVector>& gamma1_interior_scalar,
119 : const Scalar<DataVector>& gamma2_interior_scalar, double time) const;
120 :
121 : private:
122 0 : std::unique_ptr<evolution::initial_data::InitialData> analytic_prescription_;
123 0 : double amplitude_ = std::numeric_limits<double>::signaling_NaN();
124 : };
125 : } // namespace ScalarTensor::BoundaryConditions
|