Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <array>
7 : #include <cstddef>
8 : #include <memory>
9 : #include <string>
10 : #include <unordered_map>
11 : #include <vector>
12 :
13 : #include "Domain/BoundaryConditions/BoundaryCondition.hpp"
14 : #include "Domain/BoundaryConditions/GetBoundaryConditionsBase.hpp"
15 : #include "Domain/CoordinateMaps/Distribution.hpp"
16 : #include "Domain/Creators/DomainCreator.hpp"
17 : #include "Domain/Creators/TimeDependence/TimeDependence.hpp"
18 : #include "Domain/Domain.hpp"
19 : #include "Domain/Structure/DirectionMap.hpp"
20 : #include "Options/Context.hpp"
21 : #include "Options/String.hpp"
22 : #include "Utilities/TMPL.hpp"
23 :
24 : /// \cond
25 : namespace domain {
26 : namespace CoordinateMaps {
27 : class Interval;
28 : template <typename Map1, typename Map2, typename Map3>
29 : class ProductOf3Maps;
30 : } // namespace CoordinateMaps
31 :
32 : template <typename SourceFrame, typename TargetFrame, typename... Maps>
33 : class CoordinateMap;
34 : } // namespace domain
35 : /// \endcond
36 :
37 : namespace domain::creators {
38 : /// Create a 3D Domain that is topologically a line. The 2nd and 3rd
39 : /// dimensions use Cartoon bases with Killing vectors along the \f$\theta\f$ and
40 : /// \f$\phi\f$ directions.
41 1 : class CartoonSphere1D : public DomainCreator<3> {
42 : public:
43 0 : using maps_list = tmpl::list<domain::CoordinateMap<
44 : Frame::BlockLogical, Frame::Inertial,
45 : CoordinateMaps::ProductOf3Maps<CoordinateMaps::Interval,
46 : CoordinateMaps::Identity<1>,
47 : CoordinateMaps::Identity<1>>>>;
48 :
49 0 : static std::string name() { return "CartoonSphere1D"; }
50 :
51 0 : struct InnerRadius {
52 0 : using type = double;
53 0 : static constexpr Options::String help = {
54 : "Inner radius of domain, which is a sphere if set to 0, otherwise a "
55 : "spherical shell."};
56 : };
57 :
58 0 : struct OuterRadius {
59 0 : using type = double;
60 0 : static constexpr Options::String help = {"Outer radius of domain."};
61 : };
62 :
63 0 : struct InitialRadialRefinement {
64 0 : using type = std::variant<size_t, std::vector<size_t>>;
65 0 : static constexpr Options::String help = {
66 : "Initial refinement level for the radial direction. If one value is "
67 : "given, it will be applied to all blocks, or every block can be "
68 : "specified individually."};
69 : };
70 :
71 0 : struct InitialNumberOfRadialGridPoints {
72 0 : using type = std::variant<size_t, std::vector<size_t>>;
73 0 : static constexpr Options::String help = {
74 : "Initial number of radial grid points. If one input is given, it "
75 : "will be applied to all blocks, or every block can be specified "
76 : "individually."};
77 : };
78 :
79 0 : struct RadialPartitioning {
80 0 : using type = std::vector<double>;
81 0 : static constexpr Options::String help = {
82 : "Radial coordinates of the boundaries splitting the radial blocks, "
83 : "strictly between InnerRadius and OuterRadius. They must be given in "
84 : "ascending order."};
85 : };
86 :
87 0 : struct RadialDistributions {
88 0 : using type = std::variant<CoordinateMaps::Distribution,
89 : std::vector<CoordinateMaps::Distribution>>;
90 0 : static constexpr Options::String help = {
91 : "Distribution of grid points along the radial blocks. A single input "
92 : "will be applied to all blocks, or every block can be specified "
93 : "individually, in which case for N partitions, there must be N+1 "
94 : "distributions."};
95 : };
96 :
97 : template <typename BoundaryConditionsBase>
98 0 : struct InnerBoundaryCondition {
99 0 : static constexpr Options::String help =
100 : "Options for the boundary conditions at the inner boundary.";
101 0 : using type = std::unique_ptr<BoundaryConditionsBase>;
102 : };
103 :
104 : template <typename BoundaryConditionsBase>
105 0 : struct OuterBoundaryCondition {
106 0 : static constexpr Options::String help =
107 : "Options for the boundary conditions at the outer boundary.";
108 0 : using type = std::unique_ptr<BoundaryConditionsBase>;
109 : };
110 :
111 0 : struct TimeDependence {
112 0 : using type =
113 : std::unique_ptr<domain::creators::time_dependence::TimeDependence<3>>;
114 0 : static constexpr Options::String help = {
115 : "The time dependence of the moving mesh domain. Specify `None` for no "
116 : "time dependant maps."};
117 : };
118 :
119 0 : using basic_options =
120 : tmpl::list<InnerRadius, OuterRadius, InitialRadialRefinement,
121 : InitialNumberOfRadialGridPoints, RadialPartitioning,
122 : RadialDistributions, TimeDependence>;
123 :
124 : template <typename Metavariables>
125 0 : using options = tmpl::conditional_t<
126 : domain::BoundaryConditions::has_boundary_conditions_base_v<
127 : typename Metavariables::system>,
128 : tmpl::push_back<
129 : basic_options,
130 : InnerBoundaryCondition<
131 : domain::BoundaryConditions::get_boundary_conditions_base<
132 : typename Metavariables::system>>,
133 : OuterBoundaryCondition<
134 : domain::BoundaryConditions::get_boundary_conditions_base<
135 : typename Metavariables::system>>>,
136 : basic_options>;
137 :
138 0 : static constexpr Options::String help{
139 : "A sphere domain that requires/enforces spherical symmetry, resulting in "
140 : "a 1D computational domain (the radial axis). It uses Cartoon partial "
141 : "derivatives for the angular directions not in the computational "
142 : "domain."};
143 :
144 0 : CartoonSphere1D(
145 : double inner_bound, double outer_bound,
146 : typename InitialRadialRefinement::type&& initial_refinement_levels,
147 : typename InitialNumberOfRadialGridPoints::type&& initial_num_points,
148 : std::vector<double> radial_partitioning = {},
149 : const typename RadialDistributions::type& radial_distributions =
150 : domain::CoordinateMaps::Distribution::Linear,
151 : std::unique_ptr<domain::creators::time_dependence::TimeDependence<3>>
152 : time_dependence = nullptr,
153 : std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
154 : inner_boundary_condition = nullptr,
155 : std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
156 : outer_boundary_condition = nullptr,
157 : const Options::Context& context = {});
158 :
159 0 : CartoonSphere1D() = default;
160 0 : CartoonSphere1D(const CartoonSphere1D&) = delete;
161 0 : CartoonSphere1D(CartoonSphere1D&&) = default;
162 0 : CartoonSphere1D& operator=(const CartoonSphere1D&) = delete;
163 0 : CartoonSphere1D& operator=(CartoonSphere1D&&) = default;
164 0 : ~CartoonSphere1D() override = default;
165 :
166 0 : Domain<3> create_domain() const override;
167 :
168 : std::vector<DirectionMap<
169 : 3, std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>>>
170 1 : external_boundary_conditions() const override;
171 :
172 1 : std::vector<std::array<size_t, 3>> initial_extents() const override;
173 :
174 1 : std::vector<std::array<size_t, 3>> initial_refinement_levels() const override;
175 :
176 : // The block names are Block0, Block1, ..., starting with the innermost
177 : // Block.
178 1 : std::vector<std::string> block_names() const override;
179 :
180 : // The block groups are Block0, Block1, ..., starting with the innermost
181 : // Block.
182 : std::unordered_map<std::string, std::unordered_set<std::string>>
183 1 : block_groups() const override;
184 :
185 1 : auto functions_of_time(const std::unordered_map<std::string, double>&
186 : initial_expiration_times = {}) const
187 : -> std::unordered_map<
188 : std::string,
189 : std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
190 :
191 : private:
192 0 : double inner_bound_{};
193 0 : double outer_bound_{};
194 0 : std::vector<size_t> initial_refinement_levels_{};
195 0 : std::vector<size_t> initial_num_points_{};
196 0 : std::vector<double> radial_partitioning_{};
197 0 : std::vector<CoordinateMaps::Distribution> radial_distributions_{};
198 : std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
199 0 : inner_boundary_condition_{};
200 : std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
201 0 : outer_boundary_condition_{};
202 : std::unique_ptr<domain::creators::time_dependence::TimeDependence<3>>
203 0 : time_dependence_;
204 0 : size_t num_blocks_{};
205 0 : std::vector<std::string> block_names_{};
206 : std::unordered_map<std::string, std::unordered_set<std::string>>
207 0 : block_groups_{};
208 : };
209 :
210 : } // namespace domain::creators
|