TimeDependence.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <limits>
8 #include <memory>
9 #include <string>
10 #include <unordered_map>
11 #include <vector>
12 
13 #include "Utilities/TMPL.hpp"
14 
15 /// \cond
16 namespace domain {
17 template <typename SourceFrame, typename TargetFrame, size_t Dim>
18 class CoordinateMapBase;
19 namespace FunctionsOfTime {
20 class FunctionOfTime;
21 } // namespace FunctionsOfTime
22 } // namespace domain
23 namespace Frame {
24 struct Grid;
25 struct Inertial;
26 } // namespace Frame
27 
29 template <size_t MeshDim>
30 class CubicScale;
31 template <size_t MeshDim>
32 class None;
33 class SphericalCompression;
34 template <size_t MeshDim>
35 class UniformRotationAboutZAxis;
36 template <size_t MeshDim>
37 class UniformTranslation;
38 template <typename TimeDependenceCompTag0, typename... TimeDependenceCompTags>
39 class Composition;
40 template <typename TimeDep, size_t Suffix>
41 struct TimeDependenceCompositionTag;
42 } // namespace domain::creators::time_dependence
43 /// \endcond
44 
45 namespace domain::creators {
46 /// \ingroup ComputationalDomainGroup
47 /// \brief Classes and functions for adding time dependence to a domain.
48 namespace time_dependence {
49 /// \brief The abstract base class off of which specific classes for adding
50 /// time dependence into a domain creator must inherit off of.
51 ///
52 /// The simplest examples of a `TimeDependence` are `None` and
53 /// `UniformTranslation`. The `None` class is treated in a special manner to
54 /// communicate to the code that the domain is time-independent.
55 template <size_t MeshDim>
57  private:
58  using creatable_classes_1d = tmpl::list<>;
59  using creatable_classes_2d = tmpl::list<UniformRotationAboutZAxis<2>>;
60  using creatable_classes_3d = tmpl::list<
67  using creatable_classes_any_dim =
68  tmpl::list<CubicScale<MeshDim>, None<MeshDim>,
70 
71  public:
72  using creatable_classes =
73  tmpl::append<creatable_classes_any_dim,
74  tmpl::conditional_t<
75  MeshDim == 1, creatable_classes_1d,
76  tmpl::conditional_t<MeshDim == 2, creatable_classes_2d,
77  creatable_classes_3d>>>;
78 
79  TimeDependence() = default;
80  virtual ~TimeDependence() = 0;
81  TimeDependence(const TimeDependence&) = default;
82  TimeDependence& operator=(const TimeDependence&) = default;
83  TimeDependence(TimeDependence&&) = default;
84  TimeDependence& operator=(TimeDependence&&) = default;
85 
86  /// Returns a `std::unique_ptr` pointing to a copy of the `TimeDependence`.
87  virtual auto get_clone() const noexcept
89 
90  /// Returns the coordinate maps from the `Frame::Grid` to the
91  /// `Frame::Inertial` frame for each block.
92  virtual auto block_maps(size_t number_of_blocks) const noexcept
94  Frame::Grid, Frame::Inertial, MeshDim>>> = 0;
95 
96  /// Returns the functions of time for the domain.
97  virtual auto functions_of_time() const noexcept -> std::unordered_map<
100 
101  /// Returns `true` if the instance is `None`, meaning no time dependence.
102  bool is_none() const noexcept {
103  return dynamic_cast<const None<MeshDim>*>(this) != nullptr;
104  }
105 };
106 
107 template <size_t MeshDim>
108 TimeDependence<MeshDim>::~TimeDependence() = default;
109 } // namespace time_dependence
110 } // namespace creators::namespace domain
111 
113 #include "Domain/CoordinateMaps/CoordinateMap.tpp"
114 #include "Domain/CoordinateMaps/TimeDependent/ProductMaps.hpp"
115 #include "Domain/CoordinateMaps/TimeDependent/ProductMaps.tpp"
116 #include "Domain/Creators/TimeDependence/Composition.hpp"
117 #include "Domain/Creators/TimeDependence/CubicScale.hpp"
118 #include "Domain/Creators/TimeDependence/None.hpp"
119 #include "Domain/Creators/TimeDependence/SphericalCompression.hpp"
120 #include "Domain/Creators/TimeDependence/UniformRotationAboutZAxis.hpp"
121 #include "Domain/Creators/TimeDependence/UniformTranslation.hpp"
domain::creators::time_dependence::UniformRotationAboutZAxis
A uniform rotation about the axis:
Definition: UniformRotationAboutZAxis.hpp:62
std::string
domain::creators::time_dependence::TimeDependence::functions_of_time
virtual auto functions_of_time() const noexcept -> std::unordered_map< std::string, std::unique_ptr< domain::FunctionsOfTime::FunctionOfTime >>=0
Returns the functions of time for the domain.
Frame::Inertial
Definition: IndexType.hpp:44
domain::CoordinateMapBase
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:45
Frame::Grid
Definition: IndexType.hpp:43
vector
domain::creators::time_dependence::TimeDependence::is_none
bool is_none() const noexcept
Returns true if the instance is None, meaning no time dependence.
Definition: TimeDependence.hpp:102
domain::creators
Defines classes that create Domains.
Definition: AlignedLattice.hpp:38
CoordinateMap.hpp
domain::creators::time_dependence::UniformTranslation
A uniform translation in the and direction.
Definition: UniformTranslation.hpp:62
domain::creators::time_dependence::Composition
A TimeDependence that is a composition of various other TimeDependences.
Definition: Composition.hpp:64
domain::creators::time_dependence::SphericalCompression
A spherical compression about some center, as given by domain::CoordinateMaps::TimeDependent::Spheric...
Definition: SphericalCompression.hpp:52
domain::creators::time_dependence::None
Make the mesh time independent so that it isn't moving.
Definition: None.hpp:40
cstddef
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:56
memory
domain::creators::time_dependence::TimeDependence::block_maps
virtual auto block_maps(size_t number_of_blocks) const noexcept -> std::vector< std::unique_ptr< domain::CoordinateMapBase< Frame::Grid, Frame::Inertial, MeshDim >>>=0
Returns the coordinate maps from the Frame::Grid to the Frame::Inertial frame for each block.
domain::creators::time_dependence::TimeDependenceCompositionTag
A tag used by the Composition class to generate a TimeDependence that is a composition of existing Ti...
Definition: Composition.hpp:36
limits
Frame
Definition: IndexType.hpp:36
domain::creators::time_dependence::TimeDependence::get_clone
virtual auto get_clone() const noexcept -> std::unique_ptr< TimeDependence >=0
Returns a std::unique_ptr pointing to a copy of the TimeDependence.
std::numeric_limits::max
T max(T... args)
std::unique_ptr
unordered_map
TMPL.hpp
domain::creators::time_dependence
Classes and functions for adding time dependence to a domain.
Definition: Composition.hpp:24
string