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/Prefixes.hpp"
14 : #include "DataStructures/DataVector.hpp"
15 : #include "DataStructures/Tensor/Tensor.hpp"
16 : #include "Domain/CoordinateMaps/CoordinateMap.hpp"
17 : #include "Domain/CoordinateMaps/Tags.hpp"
18 : #include "Domain/ElementMap.hpp"
19 : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
20 : #include "Domain/FunctionsOfTime/Tags.hpp"
21 : #include "Domain/Structure/Direction.hpp"
22 : #include "Domain/Tags.hpp"
23 : #include "Evolution/BoundaryConditions/Type.hpp"
24 : #include "Evolution/DgSubcell/GhostZoneLogicalCoordinates.hpp"
25 : #include "Evolution/DgSubcell/Tags/Coordinates.hpp"
26 : #include "Evolution/DgSubcell/Tags/Mesh.hpp"
27 : #include "Evolution/Systems/GeneralizedHarmonic/ConstraintDamping/Tags.hpp"
28 : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
29 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/BoundaryConditions/BoundaryCondition.hpp"
30 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/FiniteDifference/Factory.hpp"
31 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/FiniteDifference/Reconstructor.hpp"
32 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/FiniteDifference/Tag.hpp"
33 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Tags.hpp"
34 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryConditions/HydroFreeOutflow.hpp"
35 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/ConservativeFromPrimitive.hpp"
36 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/Fluxes.hpp"
37 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp"
38 : #include "NumericalAlgorithms/Spectral/Mesh.hpp"
39 : #include "Options/String.hpp"
40 : #include "PointwiseFunctions/GeneralRelativity/Tags.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::GhValenciaDivClean::BoundaryConditions {
54 : /*!
55 : * \brief Sets Dirichlet boundary conditions using the analytic solution or
56 : * analytic data on the spacetime variables and hydro free outflow on the GRMHD
57 : * variables.
58 : */
59 1 : class DirichletFreeOutflow final : public BoundaryCondition {
60 : private:
61 : template <typename T>
62 0 : using Flux = ::Tags::Flux<T, tmpl::size_t<3>, Frame::Inertial>;
63 0 : std::unique_ptr<evolution::initial_data::InitialData> analytic_prescription_;
64 :
65 : public:
66 : /// \brief What analytic solution/data to prescribe.
67 1 : struct AnalyticPrescription {
68 0 : static constexpr Options::String help =
69 : "What analytic solution/data to prescribe.";
70 0 : using type = std::unique_ptr<evolution::initial_data::InitialData>;
71 : };
72 0 : using options = tmpl::list<AnalyticPrescription>;
73 0 : static constexpr Options::String help{
74 : "DirichletFreeOutflow boundary conditions using either analytic solution "
75 : "or analytic data for GH variables and hydro free outflow for GRMHD"};
76 :
77 0 : DirichletFreeOutflow() = default;
78 0 : DirichletFreeOutflow(DirichletFreeOutflow&&) = default;
79 0 : DirichletFreeOutflow& operator=(DirichletFreeOutflow&&) = default;
80 0 : DirichletFreeOutflow(const DirichletFreeOutflow&);
81 0 : DirichletFreeOutflow& operator=(const DirichletFreeOutflow&);
82 0 : ~DirichletFreeOutflow() override = default;
83 :
84 0 : explicit DirichletFreeOutflow(CkMigrateMessage* msg);
85 :
86 0 : explicit DirichletFreeOutflow(
87 : std::unique_ptr<evolution::initial_data::InitialData>
88 : analytic_prescription);
89 :
90 0 : WRAPPED_PUPable_decl_base_template(
91 : domain::BoundaryConditions::BoundaryCondition, DirichletFreeOutflow);
92 :
93 0 : auto get_clone() const -> std::unique_ptr<
94 : domain::BoundaryConditions::BoundaryCondition> override;
95 :
96 0 : static constexpr evolution::BoundaryConditions::Type bc_type =
97 : evolution::BoundaryConditions::Type::Ghost;
98 :
99 0 : void pup(PUP::er& p) override;
100 :
101 0 : using dg_interior_evolved_variables_tags = tmpl::list<>;
102 0 : using dg_interior_temporary_tags =
103 : tmpl::list<domain::Tags::Coordinates<3, Frame::Inertial>,
104 : ::gh::ConstraintDamping::Tags::ConstraintGamma1,
105 : ::gh::ConstraintDamping::Tags::ConstraintGamma2>;
106 0 : using dg_interior_primitive_variables_tags =
107 : tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
108 : hydro::Tags::ElectronFraction<DataVector>,
109 : hydro::Tags::SpecificInternalEnergy<DataVector>,
110 : hydro::Tags::SpatialVelocity<DataVector, 3>,
111 : hydro::Tags::MagneticField<DataVector, 3>,
112 : hydro::Tags::LorentzFactor<DataVector>,
113 : hydro::Tags::Pressure<DataVector>>;
114 0 : using dg_gridless_tags = tmpl::list<::Tags::Time>;
115 0 : std::optional<std::string> dg_ghost(
116 : gsl::not_null<tnsr::aa<DataVector, 3, Frame::Inertial>*> spacetime_metric,
117 : gsl::not_null<tnsr::aa<DataVector, 3, Frame::Inertial>*> pi,
118 : gsl::not_null<tnsr::iaa<DataVector, 3, Frame::Inertial>*> phi,
119 : gsl::not_null<Scalar<DataVector>*> tilde_d,
120 : gsl::not_null<Scalar<DataVector>*> tilde_ye,
121 : gsl::not_null<Scalar<DataVector>*> tilde_tau,
122 : gsl::not_null<tnsr::i<DataVector, 3, Frame::Inertial>*> tilde_s,
123 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_b,
124 : gsl::not_null<Scalar<DataVector>*> tilde_phi,
125 :
126 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_d_flux,
127 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_ye_flux,
128 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_tau_flux,
129 : gsl::not_null<tnsr::Ij<DataVector, 3, Frame::Inertial>*> tilde_s_flux,
130 : gsl::not_null<tnsr::IJ<DataVector, 3, Frame::Inertial>*> tilde_b_flux,
131 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_phi_flux,
132 :
133 : gsl::not_null<Scalar<DataVector>*> gamma1,
134 : gsl::not_null<Scalar<DataVector>*> gamma2,
135 : gsl::not_null<Scalar<DataVector>*> lapse,
136 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> shift,
137 : gsl::not_null<tnsr::II<DataVector, 3, Frame::Inertial>*>
138 : inv_spatial_metric,
139 :
140 : const std::optional<tnsr::I<DataVector, 3, Frame::Inertial>>&
141 : face_mesh_velocity,
142 : const tnsr::i<DataVector, 3, Frame::Inertial>& normal_covector,
143 : const tnsr::I<DataVector, 3, Frame::Inertial>& normal_vector,
144 :
145 : const Scalar<DataVector>& interior_rest_mass_density,
146 : const Scalar<DataVector>& interior_electron_fraction,
147 : const Scalar<DataVector>& interior_specific_internal_energy,
148 : const tnsr::I<DataVector, 3, Frame::Inertial>& interior_spatial_velocity,
149 : const tnsr::I<DataVector, 3, Frame::Inertial>& interior_magnetic_field,
150 : const Scalar<DataVector>& interior_lorentz_factor,
151 : const Scalar<DataVector>& interior_pressure,
152 :
153 : const tnsr::I<DataVector, 3, Frame::Inertial>& coords,
154 : const Scalar<DataVector>& interior_gamma1,
155 : const Scalar<DataVector>& interior_gamma2, double time) const;
156 :
157 0 : using fd_interior_evolved_variables_tags = tmpl::list<>;
158 0 : using fd_interior_temporary_tags =
159 : tmpl::list<evolution::dg::subcell::Tags::Mesh<3>>;
160 0 : using fd_interior_primitive_variables_tags =
161 : tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
162 : hydro::Tags::ElectronFraction<DataVector>,
163 : hydro::Tags::Temperature<DataVector>,
164 : hydro::Tags::Pressure<DataVector>,
165 : hydro::Tags::SpecificInternalEnergy<DataVector>,
166 : hydro::Tags::LorentzFactor<DataVector>,
167 : hydro::Tags::SpatialVelocity<DataVector, 3>,
168 : hydro::Tags::MagneticField<DataVector, 3>>;
169 0 : using fd_gridless_tags =
170 : tmpl::list<::Tags::Time, ::domain::Tags::FunctionsOfTime,
171 : domain::Tags::ElementMap<3, Frame::Grid>,
172 : domain::CoordinateMaps::Tags::CoordinateMap<3, Frame::Grid,
173 : Frame::Inertial>,
174 : fd::Tags::Reconstructor>;
175 0 : void fd_ghost(
176 :
177 : gsl::not_null<tnsr::aa<DataVector, 3, Frame::Inertial>*> spacetime_metric,
178 : gsl::not_null<tnsr::aa<DataVector, 3, Frame::Inertial>*> pi,
179 : gsl::not_null<tnsr::iaa<DataVector, 3, Frame::Inertial>*> phi,
180 : gsl::not_null<Scalar<DataVector>*> rest_mass_density,
181 : gsl::not_null<Scalar<DataVector>*> electron_fraction,
182 : gsl::not_null<Scalar<DataVector>*> temperature,
183 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*>
184 : lorentz_factor_times_spatial_velocity,
185 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> magnetic_field,
186 : gsl::not_null<Scalar<DataVector>*> divergence_cleaning_field,
187 : const Direction<3>& direction,
188 :
189 : // fd_interior_temporary_tags
190 : const Mesh<3>& subcell_mesh,
191 :
192 : // interior prim vars tags
193 : const Scalar<DataVector>& interior_rest_mass_density,
194 : const Scalar<DataVector>& interior_electron_fraction,
195 : const Scalar<DataVector>& interior_temperature,
196 : const Scalar<DataVector>& interior_pressure,
197 : const Scalar<DataVector>& interior_specific_internal_energy,
198 : const Scalar<DataVector>& interior_lorentz_factor,
199 : const tnsr::I<DataVector, 3, Frame::Inertial>& interior_spatial_velocity,
200 : const tnsr::I<DataVector, 3, Frame::Inertial>& interior_magnetic_field,
201 :
202 : // fd_gridless_tags
203 : double time,
204 : const std::unordered_map<
205 : std::string,
206 : std::unique_ptr<::domain::FunctionsOfTime::FunctionOfTime>>&
207 : functions_of_time,
208 : const ElementMap<3, Frame::Grid>& logical_to_grid_map,
209 : const domain::CoordinateMapBase<Frame::Grid, Frame::Inertial, 3>&
210 : grid_to_inertial_map,
211 : const fd::Reconstructor& reconstructor) const;
212 : };
213 : } // namespace grmhd::GhValenciaDivClean::BoundaryConditions
|