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 : #include <unordered_map>
12 :
13 : #include "DataStructures/DataBox/PrefixHelpers.hpp"
14 : #include "DataStructures/DataBox/Prefixes.hpp"
15 : #include "DataStructures/DataVector.hpp"
16 : #include "DataStructures/Tensor/EagerMath/DeterminantAndInverse.hpp"
17 : #include "DataStructures/Tensor/Tensor.hpp"
18 : #include "DataStructures/Variables.hpp"
19 : #include "Domain/CoordinateMaps/CoordinateMap.hpp"
20 : #include "Domain/CoordinateMaps/Tags.hpp"
21 : #include "Domain/ElementMap.hpp"
22 : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
23 : #include "Domain/FunctionsOfTime/Tags.hpp"
24 : #include "Domain/Structure/Direction.hpp"
25 : #include "Domain/Tags.hpp"
26 : #include "Evolution/BoundaryConditions/Type.hpp"
27 : #include "Evolution/DgSubcell/GhostZoneLogicalCoordinates.hpp"
28 : #include "Evolution/DgSubcell/SliceTensor.hpp"
29 : #include "Evolution/DgSubcell/Tags/Coordinates.hpp"
30 : #include "Evolution/DgSubcell/Tags/Mesh.hpp"
31 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryConditions/BoundaryCondition.hpp"
32 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/ConservativeFromPrimitive.hpp"
33 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/FiniteDifference/Factory.hpp"
34 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/FiniteDifference/Reconstructor.hpp"
35 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/FiniteDifference/Tag.hpp"
36 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/Fluxes.hpp"
37 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/System.hpp"
38 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp"
39 : #include "NumericalAlgorithms/Spectral/Mesh.hpp"
40 : #include "Options/String.hpp"
41 : #include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp"
42 : #include "Utilities/ErrorHandling/Assert.hpp"
43 : #include "Utilities/Gsl.hpp"
44 : #include "Utilities/Serialization/CharmPupable.hpp"
45 : #include "Utilities/TMPL.hpp"
46 :
47 : /// \cond
48 : namespace Tags {
49 : struct Time;
50 : } // namespace Tags
51 : /// \endcond
52 :
53 : namespace grmhd::ValenciaDivClean::BoundaryConditions {
54 : /*!
55 : * \brief Sets Dirichlet boundary conditions using the analytic solution or
56 : * analytic data.
57 : */
58 1 : class DirichletAnalytic final : public BoundaryCondition {
59 : private:
60 : template <typename T>
61 0 : using Flux = ::Tags::Flux<T, tmpl::size_t<3>, Frame::Inertial>;
62 :
63 : public:
64 : /// \brief What analytic solution/data to prescribe.
65 1 : struct AnalyticPrescription {
66 0 : static constexpr Options::String help =
67 : "What analytic solution/data to prescribe.";
68 0 : using type = std::unique_ptr<evolution::initial_data::InitialData>;
69 : };
70 0 : using options = tmpl::list<AnalyticPrescription>;
71 0 : static constexpr Options::String help{
72 : "DirichletAnalytic boundary conditions using either analytic solution or "
73 : "analytic data."};
74 :
75 0 : DirichletAnalytic() = default;
76 0 : DirichletAnalytic(DirichletAnalytic&&) = default;
77 0 : DirichletAnalytic& operator=(DirichletAnalytic&&) = default;
78 0 : DirichletAnalytic(const DirichletAnalytic&);
79 0 : DirichletAnalytic& operator=(const DirichletAnalytic&);
80 0 : ~DirichletAnalytic() override = default;
81 :
82 0 : explicit DirichletAnalytic(CkMigrateMessage* msg);
83 :
84 0 : explicit DirichletAnalytic(
85 : std::unique_ptr<evolution::initial_data::InitialData>
86 : analytic_prescription);
87 :
88 0 : WRAPPED_PUPable_decl_base_template(
89 : domain::BoundaryConditions::BoundaryCondition, DirichletAnalytic);
90 :
91 0 : auto get_clone() const -> std::unique_ptr<
92 : domain::BoundaryConditions::BoundaryCondition> override;
93 :
94 0 : static constexpr evolution::BoundaryConditions::Type bc_type =
95 : evolution::BoundaryConditions::Type::Ghost;
96 :
97 0 : void pup(PUP::er& p) override;
98 :
99 0 : using dg_interior_evolved_variables_tags = tmpl::list<>;
100 0 : using dg_interior_temporary_tags =
101 : tmpl::list<domain::Tags::Coordinates<3, Frame::Inertial>>;
102 0 : using dg_interior_primitive_variables_tags = tmpl::list<>;
103 0 : using dg_gridless_tags = tmpl::list<::Tags::Time>;
104 :
105 0 : std::optional<std::string> dg_ghost(
106 : gsl::not_null<Scalar<DataVector>*> tilde_d,
107 : gsl::not_null<Scalar<DataVector>*> tilde_ye,
108 : gsl::not_null<Scalar<DataVector>*> tilde_tau,
109 : gsl::not_null<tnsr::i<DataVector, 3, Frame::Inertial>*> tilde_s,
110 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_b,
111 : gsl::not_null<Scalar<DataVector>*> tilde_phi,
112 :
113 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_d_flux,
114 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_ye_flux,
115 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_tau_flux,
116 : gsl::not_null<tnsr::Ij<DataVector, 3, Frame::Inertial>*> tilde_s_flux,
117 : gsl::not_null<tnsr::IJ<DataVector, 3, Frame::Inertial>*> tilde_b_flux,
118 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_phi_flux,
119 :
120 : gsl::not_null<Scalar<DataVector>*> lapse,
121 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> shift,
122 : gsl::not_null<tnsr::i<DataVector, 3,
123 : Frame::Inertial>*> /*spatial_velocity_one_form*/,
124 : gsl::not_null<Scalar<DataVector>*> /*rest_mass_density*/,
125 : gsl::not_null<Scalar<DataVector>*> /*electron_fraction*/,
126 : gsl::not_null<Scalar<DataVector>*> /*temperature*/,
127 : gsl::not_null<
128 : tnsr::I<DataVector, 3, Frame::Inertial>*> /*spatial_velocity*/,
129 : gsl::not_null<tnsr::II<DataVector, 3, Frame::Inertial>*>
130 : inv_spatial_metric,
131 :
132 : const std::optional<
133 : tnsr::I<DataVector, 3, Frame::Inertial>>& /*face_mesh_velocity*/,
134 : const tnsr::i<DataVector, 3, Frame::Inertial>& /*normal_covector*/,
135 : const tnsr::I<DataVector, 3, Frame::Inertial>& /*normal_vector*/,
136 : const tnsr::I<DataVector, 3, Frame::Inertial>& coords,
137 : [[maybe_unused]] double time) const;
138 :
139 0 : using fd_interior_evolved_variables_tags = tmpl::list<>;
140 0 : using fd_interior_temporary_tags =
141 : tmpl::list<evolution::dg::subcell::Tags::Mesh<3>>;
142 0 : using fd_interior_primitive_variables_tags = tmpl::list<>;
143 0 : using fd_gridless_tags =
144 : tmpl::list<::Tags::Time, ::domain::Tags::FunctionsOfTime,
145 : domain::Tags::ElementMap<3, Frame::Grid>,
146 : domain::CoordinateMaps::Tags::CoordinateMap<3, Frame::Grid,
147 : Frame::Inertial>,
148 : fd::Tags::Reconstructor>;
149 0 : void fd_ghost(
150 : gsl::not_null<Scalar<DataVector>*> rest_mass_density,
151 : gsl::not_null<Scalar<DataVector>*> electron_fraction,
152 : gsl::not_null<Scalar<DataVector>*> temperature,
153 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
154 : lorentz_factor_times_spatial_velocity,
155 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> magnetic_field,
156 : gsl::not_null<Scalar<DataVector>*> divergence_cleaning_field,
157 :
158 : gsl::not_null<std::optional<Variables<db::wrap_tags_in<
159 : Flux, typename grmhd::ValenciaDivClean::System::flux_variables>>>*>
160 : cell_centered_ghost_fluxes,
161 :
162 : const Direction<3>& direction,
163 :
164 : // fd_interior_temporary_tags
165 : const Mesh<3>& subcell_mesh,
166 :
167 : // fd_gridless_tags
168 : [[maybe_unused]] double time,
169 : const std::unordered_map<
170 : std::string,
171 : std::unique_ptr<::domain::FunctionsOfTime::FunctionOfTime>>&
172 : functions_of_time,
173 : const ElementMap<3, Frame::Grid>& logical_to_grid_map,
174 : const domain::CoordinateMapBase<Frame::Grid, Frame::Inertial, 3>&
175 : grid_to_inertial_map,
176 : const fd::Reconstructor& reconstructor) const;
177 :
178 : private:
179 0 : std::unique_ptr<evolution::initial_data::InitialData> analytic_prescription_;
180 : };
181 : } // namespace grmhd::ValenciaDivClean::BoundaryConditions
|