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 
28 namespace domain {
29 namespace creators {
30 namespace time_dependence {
31 template <size_t MeshDim>
32 class CubicScale;
33 template <size_t MeshDim>
34 class None;
35 template <size_t MeshDim>
36 class UniformRotationAboutZAxis;
37 template <size_t MeshDim>
38 class UniformTranslation;
39 template <typename TimeDependenceCompTag0, typename... TimeDependenceCompTags>
40 class Composition;
41 template <typename TimeDep, size_t Suffix>
42 struct TimeDependenceCompositionTag;
43 } // namespace time_dependence
44 } // namespace creators
45 } // namespace domain
46 /// \endcond
47 
48 namespace domain {
49 namespace creators {
50 /// \ingroup ComputationalDomainGroup
51 /// \brief Classes and functions for adding time dependence to a domain.
52 namespace time_dependence {
53 /// \brief The abstract base class off of which specific classes for adding
54 /// time dependence into a domain creator must inherit off of.
55 ///
56 /// The simplest examples of a `TimeDependence` are `None` and
57 /// `UniformTranslation`. The `None` class is treated in a special manner to
58 /// communicate to the code that the domain is time-independent.
59 template <size_t MeshDim>
61  private:
62  using creatable_classes_1d = tmpl::list<>;
63  using creatable_classes_2d = tmpl::list<UniformRotationAboutZAxis<2>>;
64  using creatable_classes_3d = tmpl::list<
71  using creatable_classes_any_dim =
72  tmpl::list<CubicScale<MeshDim>, None<MeshDim>,
74 
75  public:
76  using creatable_classes =
77  tmpl::append<creatable_classes_any_dim,
78  tmpl::conditional_t<
79  MeshDim == 1, creatable_classes_1d,
80  tmpl::conditional_t<MeshDim == 2, creatable_classes_2d,
81  creatable_classes_3d>>>;
82 
83  TimeDependence() = default;
84  virtual ~TimeDependence() = 0;
85  TimeDependence(const TimeDependence&) = default;
86  TimeDependence& operator=(const TimeDependence&) = default;
87  TimeDependence(TimeDependence&&) = default;
88  TimeDependence& operator=(TimeDependence&&) = default;
89 
90  /// Returns a `std::unique_ptr` pointing to a copy of the `TimeDependence`.
91  virtual auto get_clone() const noexcept
93 
94  /// Returns the coordinate maps from the `Frame::Grid` to the
95  /// `Frame::Inertial` frame for each block.
96  virtual auto block_maps(size_t number_of_blocks) const noexcept
98  Frame::Grid, Frame::Inertial, MeshDim>>> = 0;
99 
100  /// Returns the functions of time for the domain.
101  virtual auto functions_of_time() const noexcept -> std::unordered_map<
102  std::string,
104 
105  /// Returns `true` if the instance is `None`, meaning no time dependence.
106  bool is_none() const noexcept {
107  return dynamic_cast<const None<MeshDim>*>(this) != nullptr;
108  }
109 };
110 
111 template <size_t MeshDim>
112 TimeDependence<MeshDim>::~TimeDependence() = default;
113 } // namespace time_dependence
114 } // namespace creators
115 } // namespace domain
116 
118 #include "Domain/CoordinateMaps/CoordinateMap.tpp"
119 #include "Domain/CoordinateMaps/TimeDependent/ProductMaps.hpp"
120 #include "Domain/CoordinateMaps/TimeDependent/ProductMaps.tpp"
121 #include "Domain/Creators/TimeDependence/Composition.hpp"
122 #include "Domain/Creators/TimeDependence/CubicScale.hpp"
123 #include "Domain/Creators/TimeDependence/None.hpp"
124 #include "Domain/Creators/TimeDependence/UniformRotationAboutZAxis.hpp"
125 #include "Domain/Creators/TimeDependence/UniformTranslation.hpp"
domain::creators::time_dependence::UniformRotationAboutZAxis
A uniform rotation about the axis:
Definition: UniformRotationAboutZAxis.hpp:60
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:106
CoordinateMap.hpp
domain::creators::time_dependence::UniformTranslation
A uniform translation in the and direction.
Definition: UniformTranslation.hpp:60
domain::creators::time_dependence::Composition
A TimeDependence that is a composition of various other TimeDependences.
Definition: Composition.hpp:64
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:60
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
string