CylindricalBinaryCompactObject.hpp
1 // 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"
17 #include "Domain/Creators/TimeDependence/TimeDependence.hpp"
18 #include "Domain/Domain.hpp"
19 #include "Options/Options.hpp"
20 #include "Utilities/TMPL.hpp"
21 
22 /// \cond
23 namespace domain {
24 namespace CoordinateMaps {
25 class Affine;
26 template <typename Map1, typename Map2>
27 class ProductOf2Maps;
28 template <typename Map1, typename Map2, typename Map3>
29 class ProductOf3Maps;
30 template <size_t VolumeDim>
31 class Wedge;
32 template <size_t VolumeDim>
33 class DiscreteRotation;
34 class CylindricalEndcap;
35 class CylindricalFlatEndcap;
36 class CylindricalFlatSide;
37 class CylindricalSide;
38 } // namespace CoordinateMaps
39 
40 template <typename SourceFrame, typename TargetFrame, typename... Maps>
41 class CoordinateMap;
42 
43 namespace FunctionsOfTime {
44 class FunctionOfTime;
45 } // namespace FunctionsOfTime
46 } // namespace domain
47 
48 namespace Frame {
49 struct Inertial;
50 struct Logical;
51 } // namespace Frame
52 /// \endcond
53 
54 namespace domain::creators {
55 
56 /*!
57  * \ingroup ComputationalDomainGroup
58  *
59  * \brief A general domain for two compact objects based on cylinders.
60  *
61  * Creates a 3D Domain that represents a binary compact object
62  * solution. This domain is described briefly in the Appendix of
63  * \cite Buchman:2012dw, and is illustrated in Figure 20 of that
64  * paper.
65  *
66  * In the code and options below, `ObjectA` and `ObjectB` refer to the
67  * two compact objects. In the grid frame, `ObjectA` is located to the
68  * right of (i.e. a more positive value of the x-coordinate than)
69  * `ObjectB`. The inner edge of the Blocks surrounding each of
70  * `ObjectA` and `ObjectB` is spherical in grid coordinates; the
71  * user must specify the center and radius of this surface for both
72  * `ObjectA` and `ObjectB`, and the user must specify the outer boundary
73  * radius. The outer boundary is a sphere centered at the origin.
74  *
75  * Note that Figure 20 of \cite Buchman:2012dw illustrates additional
76  * spherical shells inside the "EA" and "EB" blocks, and the caption
77  * of Figure 20 indicates that there are additional spherical shells
78  * outside the "CA" and "CB" blocks; `CylindricalBinaryCompactObject`
79  * does not have any of these spherical shells: the "EA" and "EB"
80  * blocks extend to the excision boundary and the "CA" and "CB" blocks
81  * extend to the outer boundary.
82  *
83  * If \f$c_A\f$ and \f$c_B\f$ are the input parameters center_A and
84  * center_B, \f$r_A\f$ and \f$r_B\f$ are the input parameters radius_A and
85  * radius_B, and \f$R\f$ is the outer boundary radius, we demand the
86  * following restrictions on parameters:
87  * - \f$c_A^0>0\f$; this is a convention to simplify the code.
88  * - \f$c_B^0<0\f$; this is a convention to simplify the code.
89  * - \f$|c_A^0|\le|c_B^0|\f$. We should roughly have \f$r_A c_A^0 + r_B c_B^0\f$
90  * close to zero; that is, for BBHs (where \f$r_A\f$ is roughly twice the
91  * mass of the heavier object A, and \f$r_B\f$ is roughly twice the mass
92  * of the lighter object B) the center of mass should be roughly
93  * at the origin.
94  * - \f$0 < r_B < r_A\f$
95  * - \f$R \ge 3(|c_A^0|-|c_B^0|)\f$; otherwise the blocks will be too compressed
96  * near the outer boundary.
97  *
98  */
100  public:
101  using maps_list = tmpl::list<
138 
139  struct CenterA {
140  using type = std::array<double, 3>;
141  static constexpr Options::String help = {
142  "Grid coordinates of center for Object A, which is at x>0."};
143  };
144  struct CenterB {
145  using type = std::array<double, 3>;
146  static constexpr Options::String help = {
147  "Grid coordinates of center for Object B, which is at x<0."};
148  };
149  struct RadiusA {
150  using type = double;
151  static constexpr Options::String help = {
152  "Grid-coordinate radius of grid boundary around Object A."};
153  };
154  struct RadiusB {
155  using type = double;
156  static constexpr Options::String help = {
157  "Grid-coordinate radius of grid boundary around Object B."};
158  };
159  struct OuterRadius {
160  using type = double;
161  static constexpr Options::String help = {
162  "Grid-coordinate radius of outer boundary."};
163  };
164 
166  using type = size_t;
167  static constexpr Options::String help = {
168  "Initial refinement level. Applied to each dimension."};
169  };
171  using type = size_t;
172  static constexpr Options::String help = {
173  "Initial number of grid points in each dim per element."};
174  };
175 
176  struct TimeDependence {
177  using type =
179  static constexpr Options::String help = {
180  "The time dependence of the moving mesh domain."};
181  };
182 
184  static constexpr Options::String help = "The boundary conditions to apply.";
185  };
186  template <typename BoundaryConditionsBase>
188  static std::string name() noexcept { return "InnerBoundary"; }
189  static constexpr Options::String help =
190  "Options for the inner boundary conditions.";
192  using group = BoundaryConditions;
193  };
194 
195  template <typename BoundaryConditionsBase>
197  static std::string name() noexcept { return "OuterBoundary"; }
198  static constexpr Options::String help =
199  "Options for the outer boundary conditions.";
201  using group = BoundaryConditions;
202  };
203 
204  using basic_options =
205  tmpl::list<CenterA, CenterB, RadiusA, RadiusB, OuterRadius,
207 
208  template <typename Metavariables>
209  using options = tmpl::conditional_t<
210  domain::BoundaryConditions::has_boundary_conditions_base_v<
211  typename Metavariables::system>,
213  basic_options,
216  typename Metavariables::system>>,
219  typename Metavariables::system>>>,
220  basic_options>;
221 
222  static constexpr Options::String help{
223  "The CylindricalBinaryCompactObject domain is a general domain for "
224  "two compact objects. The user must provide the (grid-frame) "
225  "centers and radii of the spherical inner edge of the grid surrounding "
226  "each of the two compact objects A and B."};
227 
229  typename CenterA::type center_A, typename CenterB::type center_B,
230  typename RadiusA::type radius_A, typename RadiusB::type radius_B,
231  typename OuterRadius::type outer_radius,
232  typename InitialRefinement::type initial_refinement,
233  typename InitialGridPoints::type initial_grid_points_per_dim,
235  time_dependence = nullptr,
237  inner_boundary_condition = nullptr,
239  outer_boundary_condition = nullptr,
240  const Options::Context& context = {});
241 
242  CylindricalBinaryCompactObject() = default;
243  CylindricalBinaryCompactObject(const CylindricalBinaryCompactObject&) =
244  delete;
245  CylindricalBinaryCompactObject(CylindricalBinaryCompactObject&&) noexcept =
246  default;
247  CylindricalBinaryCompactObject& operator=(
248  const CylindricalBinaryCompactObject&) = delete;
249  CylindricalBinaryCompactObject& operator=(
250  CylindricalBinaryCompactObject&&) noexcept = default;
251  ~CylindricalBinaryCompactObject() noexcept override = default;
252 
253  Domain<3> create_domain() const noexcept override;
254 
255  std::vector<std::array<size_t, 3>> initial_extents() const noexcept override;
256 
257  std::vector<std::array<size_t, 3>> initial_refinement_levels()
258  const noexcept override;
259 
260  auto functions_of_time() const noexcept -> std::unordered_map<
261  std::string,
262  std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
263 
264  private:
265  // Note that center_A_ and center_B_ are rotated with respect to the
266  // input centers (which are in the grid frame), so that we can
267  // construct the map in a frame where the centers are offset in the
268  // z direction. At the end, there will be another rotation back to
269  // the grid frame (where the centers are offset in the x direction).
270  typename CenterA::type center_A_{};
271  typename CenterB::type center_B_{};
272  typename RadiusA::type radius_A_{};
273  typename RadiusB::type radius_B_{};
274  typename OuterRadius::type outer_radius_{};
275  typename InitialRefinement::type initial_refinement_{};
276  typename InitialGridPoints::type initial_grid_points_per_dim_{};
277  // cut_spheres_offset_factor_ is eta in Eq. (A.9) of
278  // https://arxiv.org/abs/1206.3015. cut_spheres_offset_factor_
279  // could be set to unity to simplify the equations. Here we fix it
280  // to the value 0.99 used in SpEC, so that we reproduce SpEC's
281  // domain decomposition.
282  double cut_spheres_offset_factor_{0.99};
283  // z_cutting_plane_ is x_C in Eq. (A.9) of
284  // https://arxiv.org/abs/1206.3015 (but rotated to the z-axis).
285  double z_cutting_plane_{};
286  // number_of_blocks_ could be eliminated or just set to its
287  // constant value of 46. But this value will change with the
288  // next PR that adds support for domains with unequal-sized objects.
289  size_t number_of_blocks_{};
291  time_dependence_;
293  inner_boundary_condition_;
295  outer_boundary_condition_;
296 };
297 } // namespace domain::creators
domain::CoordinateMaps::ProductOf3Maps
Product of three one-dimensional CoordinateMaps.
Definition: ProductMaps.hpp:90
domain::creators::CylindricalBinaryCompactObject
A general domain for two compact objects based on cylinders.
Definition: CylindricalBinaryCompactObject.hpp:99
domain::BoundaryConditions::get_boundary_conditions_base
typename detail::get_boundary_conditions_base< T >::type get_boundary_conditions_base
Returns T::boundary_condition_base or a placeholder class.
Definition: GetBoundaryConditionsBase.hpp:33
std::string
Frame::Inertial
Definition: IndexType.hpp:44
domain::CoordinateMaps::CylindricalSide
Map from a 3D unit right cylindrical shell to a volume that connects portions of two spherical surfac...
Definition: CylindricalSide.hpp:91
Options.hpp
vector
Domain.hpp
domain::CoordinateMaps::ProductOf2Maps
Product of two codimension=0 CoordinateMaps.
Definition: ProductMaps.hpp:35
domain::creators
Defines classes that create Domains.
Definition: AlignedLattice.hpp:38
domain::creators::CylindricalBinaryCompactObject::InitialGridPoints
Definition: CylindricalBinaryCompactObject.hpp:170
CoordinateMap.hpp
Options::Context
Definition: Options.hpp:41
domain::creators::CylindricalBinaryCompactObject::BoundaryConditions
Definition: CylindricalBinaryCompactObject.hpp:183
domain::CoordinateMaps::DiscreteRotation
A CoordinateMap that swaps/negates the coordinate axes.
Definition: DiscreteRotation.hpp:32
domain::CoordinateMaps::Affine
Affine map from .
Definition: Affine.hpp:37
domain::push_back
CoordinateMap< SourceFrame, TargetFrame, Maps..., NewMap > push_back(CoordinateMap< SourceFrame, TargetFrame, Maps... > old_map, NewMap new_map) noexcept
Creates a CoordinateMap by appending the new map to the end of the old maps.
domain::creators::CylindricalBinaryCompactObject::OuterRadius
Definition: CylindricalBinaryCompactObject.hpp:159
domain::creators::CylindricalBinaryCompactObject::RadiusB
Definition: CylindricalBinaryCompactObject.hpp:154
domain::creators::CylindricalBinaryCompactObject::OuterBoundaryCondition
Definition: CylindricalBinaryCompactObject.hpp:196
cstddef
domain::creators::CylindricalBinaryCompactObject::InnerBoundaryCondition
Definition: CylindricalBinaryCompactObject.hpp:187
domain::CoordinateMaps::CylindricalFlatSide
Map from 3D unit right cylindrical shell to a volume that connects a portion of an annulus to a porti...
Definition: CylindricalFlatSide.hpp:89
domain::creators::time_dependence::TimeDependence
The abstract base class off of which specific classes for adding time dependence into a domain creato...
Definition: TimeDependence.hpp:60
array
domain::creators::CylindricalBinaryCompactObject::CenterA
Definition: CylindricalBinaryCompactObject.hpp:139
Domain
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:40
memory
DomainCreator
Base class for creating Domains from an option string.
Definition: DomainCreator.hpp:90
domain::creators::CylindricalBinaryCompactObject::RadiusA
Definition: CylindricalBinaryCompactObject.hpp:149
domain::creators::CylindricalBinaryCompactObject::TimeDependence
Definition: CylindricalBinaryCompactObject.hpp:176
domain::creators::CylindricalBinaryCompactObject::CenterB
Definition: CylindricalBinaryCompactObject.hpp:144
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Frame
Definition: IndexType.hpp:36
Frame::Logical
Definition: IndexType.hpp:42
DomainCreator.hpp
domain::CoordinateMaps::CylindricalEndcap
Map from 3D unit right cylinder to a volume that connects portions of two spherical surfaces.
Definition: CylindricalEndcap.hpp:135
domain::creators::CylindricalBinaryCompactObject::InitialRefinement
Definition: CylindricalBinaryCompactObject.hpp:165
std::unique_ptr< domain::creators::time_dependence::TimeDependence< 3 > >
unordered_map
TMPL.hpp
domain::CoordinateMaps::CylindricalFlatEndcap
Map from 3D unit right cylinder to a volume that connects a portion of a circle to a portion of a sph...
Definition: CylindricalFlatEndcap.hpp:82
domain::CoordinateMap
A coordinate map or composition of coordinate maps.
Definition: CoordinateMap.hpp:240
string