TimeDependence.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <memory>
8 #include <string>
9 #include <unordered_map>
10 #include <vector>
11 
12 #include "Utilities/TMPL.hpp"
13 
14 /// \cond
15 namespace domain {
16 template <typename SourceFrame, typename TargetFrame, size_t Dim>
17 class CoordinateMapBase;
18 namespace FunctionsOfTime {
19 class FunctionOfTime;
20 } // namespace FunctionsOfTime
21 } // namespace domain
22 namespace Frame {
23 struct Grid;
24 struct Inertial;
25 } // namespace Frame
26 
27 namespace domain {
28 namespace creators {
29 namespace time_dependence {
30 template <size_t MeshDim>
31 class CubicScale;
32 template <size_t MeshDim>
33 class None;
34 template <size_t MeshDim>
35 class UniformRotationAboutZAxis;
36 template <size_t MeshDim>
37 class UniformTranslation;
38 } // namespace time_dependence
39 } // namespace creators
40 } // namespace domain
41 /// \endcond
42 
43 namespace domain {
44 namespace creators {
45 /// \ingroup ComputationalDomainGroup
46 /// \brief Classes and functions for adding time dependence to a domain.
47 namespace time_dependence {
48 /// \brief The abstract base class off of which specific classes for adding
49 /// time dependence into a domain creator must inherit off of.
50 ///
51 /// The simplest examples of a `TimeDependence` are `None` and
52 /// `UniformTranslation`. The `None` class is treated in a special manner to
53 /// communicate to the code that the domain is time-independent.
54 template <size_t MeshDim>
56  private:
57  using creatable_classes_1d = tmpl::list<>;
58  using creatable_classes_2d = tmpl::list<UniformRotationAboutZAxis<2>>;
59  using creatable_classes_3d = tmpl::list<UniformRotationAboutZAxis<3>>;
60  using creatable_classes_any_dim =
61  tmpl::list<CubicScale<MeshDim>, None<MeshDim>,
63 
64  public:
65  using creatable_classes =
66  tmpl::append<creatable_classes_any_dim,
67  tmpl::conditional_t<
68  MeshDim == 1, creatable_classes_1d,
69  tmpl::conditional_t<MeshDim == 2, creatable_classes_2d,
70  creatable_classes_3d>>>;
71 
72  TimeDependence() = default;
73  virtual ~TimeDependence() = 0;
74  TimeDependence(const TimeDependence&) = default;
75  TimeDependence& operator=(const TimeDependence&) = default;
76  TimeDependence(TimeDependence&&) = default;
77  TimeDependence& operator=(TimeDependence&&) = default;
78 
79  /// Returns a `std::unique_ptr` pointing to a copy of the `TimeDependence`.
80  virtual auto get_clone() const noexcept
82 
83  /// Returns the coordinate maps from the `Frame::Grid` to the
84  /// `Frame::Inertial` frame for each block.
85  virtual auto block_maps(size_t number_of_blocks) const noexcept
87  Frame::Grid, Frame::Inertial, MeshDim>>> = 0;
88 
89  /// Returns the functions of time for the domain.
90  virtual auto functions_of_time() const noexcept -> std::unordered_map<
93 
94  /// Returns `true` if the instance is `None`, meaning no time dependence.
95  bool is_none() const noexcept {
96  return dynamic_cast<const None<MeshDim>*>(this) != nullptr;
97  }
98 };
99 
100 template <size_t MeshDim>
101 TimeDependence<MeshDim>::~TimeDependence() = default;
102 } // namespace time_dependence
103 } // namespace creators
104 } // namespace domain
105 
106 #include "Domain/Creators/TimeDependence/CubicScale.hpp"
107 #include "Domain/Creators/TimeDependence/None.hpp"
108 #include "Domain/Creators/TimeDependence/UniformRotationAboutZAxis.hpp"
109 #include "Domain/Creators/TimeDependence/UniformTranslation.hpp"
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:46
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:95
domain::creators::time_dependence::UniformTranslation
A uniform translation in the and direction.
Definition: UniformTranslation.hpp:60
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:55
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.
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::unique_ptr
unordered_map
TMPL.hpp
string