Line data Source code
1 1 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : /// \file
5 : /// Defines class FrustalCloak.
6 :
7 : #pragma once
8 :
9 : #include <array>
10 : #include <cstddef>
11 : #include <memory>
12 : #include <vector>
13 :
14 : #include "Domain/BoundaryConditions/BoundaryCondition.hpp"
15 : #include "Domain/BoundaryConditions/GetBoundaryConditionsBase.hpp"
16 : #include "Domain/Creators/DomainCreator.hpp"
17 : #include "Domain/Domain.hpp"
18 : #include "Domain/Structure/DirectionMap.hpp"
19 : #include "Options/Context.hpp"
20 : #include "Options/String.hpp"
21 : #include "Utilities/TMPL.hpp"
22 :
23 : /// \cond
24 : namespace domain {
25 : namespace CoordinateMaps {
26 : class Frustum;
27 : } // namespace CoordinateMaps
28 :
29 : template <typename SourceFrame, typename TargetFrame, typename... Maps>
30 : class CoordinateMap;
31 : } // namespace domain
32 : /// \endcond
33 :
34 : namespace domain {
35 : namespace creators {
36 : /*!
37 : * \brief Create a 3D cubical domain with two equal-sized abutting excised cubes
38 : * in the center. This is done by combining ten frusta.
39 : *
40 : * \image html FrustalCloak.png "A slice through the frustal cloak."
41 : */
42 1 : class FrustalCloak : public DomainCreator<3> {
43 : public:
44 0 : using maps_list =
45 : tmpl::list<domain::CoordinateMap<Frame::BlockLogical, Frame::Inertial,
46 : domain::CoordinateMaps::Frustum>>;
47 :
48 0 : struct InitialRefinement {
49 0 : using type = size_t;
50 0 : static constexpr Options::String help = {
51 : "Initial refinement level in each dimension."};
52 : };
53 :
54 0 : struct InitialGridPoints {
55 0 : using type = std::array<size_t, 2>;
56 0 : static constexpr Options::String help = {
57 : "Initial number of grid points in [r,angular]."};
58 : };
59 :
60 0 : struct UseEquiangularMap {
61 0 : using type = bool;
62 0 : static constexpr Options::String help = {
63 : "Use equiangular instead of equidistant coordinates."};
64 : };
65 :
66 0 : struct ProjectionFactor {
67 0 : using type = double;
68 0 : static constexpr Options::String help = {"Grid compression factor."};
69 : };
70 :
71 0 : struct LengthInnerCube {
72 0 : using type = double;
73 0 : static constexpr Options::String help = {"Side length of each inner cube."};
74 0 : static constexpr type lower_bound() { return 0.0; }
75 : };
76 :
77 0 : struct LengthOuterCube {
78 0 : using type = double;
79 0 : static constexpr Options::String help = {"Side length of the outer cube."};
80 0 : static constexpr type lower_bound() { return 0.0; }
81 : };
82 :
83 0 : struct OriginPreimage {
84 0 : using type = std::array<double, 3>;
85 0 : static constexpr Options::String help = {"The origin preimage in [x,y,z]."};
86 : };
87 :
88 : template <typename BoundaryConditionsBase>
89 0 : struct BoundaryCondition {
90 0 : static std::string name() { return "BoundaryCondition"; }
91 0 : static constexpr Options::String help =
92 : "The boundary condition to impose on all sides.";
93 0 : using type = std::unique_ptr<BoundaryConditionsBase>;
94 : };
95 :
96 0 : using basic_options =
97 : tmpl::list<InitialRefinement, InitialGridPoints, UseEquiangularMap,
98 : ProjectionFactor, LengthInnerCube, LengthOuterCube,
99 : OriginPreimage>;
100 :
101 : template <typename Metavariables>
102 0 : using options = tmpl::conditional_t<
103 : domain::BoundaryConditions::has_boundary_conditions_base_v<
104 : typename Metavariables::system>,
105 : tmpl::push_back<
106 : basic_options,
107 : BoundaryCondition<
108 : domain::BoundaryConditions::get_boundary_conditions_base<
109 : typename Metavariables::system>>>,
110 : basic_options>;
111 :
112 0 : static constexpr Options::String help{
113 : "Creates a cubical domain with two equal-sized abutting excised cubes\n"
114 : "in the center. This is done by combining ten frusta. The parameter\n"
115 : "`UseEquiangularMap` can be used to apply a tangent mapping to the xi\n"
116 : "and eta logical coordinates of each frustum, while the parameter\n"
117 : "`ProjectionFactor` can be used to apply a projective map to the zeta\n"
118 : "logical coordinate of each frustum. Increasing the\n"
119 : "`ProjectionFactor` value can give better gridpoint spacings in the\n"
120 : "z direction. The user also specifies values for `LengthInnerCube` and\n"
121 : "`LengthOuterCube`. This will create a cubical Domain of side"
122 : "length `LengthOuterCube` with the center excised. The size of the\n"
123 : "excised region is determined by the value set for `LengthInnerCube`.\n"
124 : "`OriginPreimage` moves the blocks such that the origin preimage is\n"
125 : "mapped to the origin. Note that the abutting excised cubes share a\n"
126 : "face in the x-direction. This Domain is primarily for testing the\n"
127 : "frustal cloak in the BinaryCompactObject Domain."};
128 :
129 0 : FrustalCloak(typename InitialRefinement::type initial_refinement_level,
130 : typename InitialGridPoints::type initial_number_of_grid_points,
131 : typename UseEquiangularMap::type use_equiangular_map = false,
132 : typename ProjectionFactor::type projection_factor = 1.0,
133 : typename LengthInnerCube::type length_inner_cube = 0.0,
134 : typename LengthOuterCube::type length_outer_cube = 0.0,
135 : typename OriginPreimage::type origin_preimage = {{0.0, 0.0,
136 : 0.0}},
137 : std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
138 : boundary_condition = nullptr,
139 : const Options::Context& context = {});
140 :
141 0 : FrustalCloak() = default;
142 0 : FrustalCloak(const FrustalCloak&) = delete;
143 0 : FrustalCloak(FrustalCloak&&) = default;
144 0 : FrustalCloak& operator=(const FrustalCloak&) = delete;
145 0 : FrustalCloak& operator=(FrustalCloak&&) = default;
146 0 : ~FrustalCloak() override = default;
147 :
148 0 : Domain<3> create_domain() const override;
149 :
150 : std::vector<DirectionMap<
151 : 3, std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>>>
152 1 : external_boundary_conditions() const override;
153 :
154 1 : std::vector<std::array<size_t, 3>> initial_extents() const override;
155 :
156 1 : std::vector<std::array<size_t, 3>> initial_refinement_levels() const override;
157 :
158 : private:
159 0 : typename InitialRefinement::type initial_refinement_level_{};
160 0 : typename InitialGridPoints::type initial_number_of_grid_points_{};
161 0 : typename UseEquiangularMap::type use_equiangular_map_ = false;
162 0 : typename ProjectionFactor::type projection_factor_{};
163 0 : typename LengthInnerCube::type length_inner_cube_{0.0};
164 0 : typename LengthOuterCube::type length_outer_cube_{0.0};
165 0 : typename OriginPreimage::type origin_preimage_{{0.0, 0.0, 0.0}};
166 : std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
167 0 : boundary_condition_;
168 : };
169 : } // namespace creators
170 : } // namespace domain
|