Line data Source code
1 0 : // 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 "Domain/Structure/ObjectLabel.hpp" 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 Distorted; 25 : struct Grid; 26 : struct Inertial; 27 : } // namespace Frame 28 : 29 : namespace domain::creators::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 ScalingAndZRotation; 36 : template <domain::ObjectLabel Label> 37 : class Shape; 38 : class SphericalCompression; 39 : template <size_t MeshDim> 40 : class RotationAboutZAxis; 41 : template <size_t MeshDim, size_t Index = 0> 42 : class UniformTranslation; 43 : } // namespace domain::creators::time_dependence 44 : /// \endcond 45 : 46 : namespace domain::creators { 47 : /// \ingroup ComputationalDomainGroup 48 : /// \brief Classes and functions for adding time dependence to a domain. 49 : namespace time_dependence { 50 : /// \brief The abstract base class off of which specific classes for adding 51 : /// time dependence into a domain creator must inherit off of. 52 : /// 53 : /// The simplest examples of a `TimeDependence` are `None` and 54 : /// `UniformTranslation`. The `None` class is treated in a special manner to 55 : /// communicate to the code that the domain is time-independent. The 56 : /// `UniformTranslation` takes an extra template parameter `Index` so that its 57 : /// name is unique from other `UniformTranslation`s. 58 : template <size_t MeshDim> 59 1 : struct TimeDependence { 60 : private: 61 0 : using creatable_classes_1d = tmpl::list<>; 62 0 : using creatable_classes_2d = 63 : tmpl::list<RotationAboutZAxis<2>, ScalingAndZRotation<2>>; 64 0 : using creatable_classes_3d = 65 : tmpl::list<Shape<domain::ObjectLabel::A>, Shape<domain::ObjectLabel::B>, 66 : Shape<domain::ObjectLabel::None>, SphericalCompression, 67 : RotationAboutZAxis<3>, ScalingAndZRotation<3>>; 68 0 : using creatable_classes_any_dim = 69 : tmpl::list<CubicScale<MeshDim>, None<MeshDim>, 70 : UniformTranslation<MeshDim>>; 71 : 72 : public: 73 0 : using creatable_classes = 74 : tmpl::append<creatable_classes_any_dim, 75 : tmpl::conditional_t< 76 : MeshDim == 1, creatable_classes_1d, 77 : tmpl::conditional_t<MeshDim == 2, creatable_classes_2d, 78 : creatable_classes_3d>>>; 79 : 80 0 : TimeDependence() = default; 81 0 : virtual ~TimeDependence() = 0; 82 0 : TimeDependence(const TimeDependence&) = default; 83 0 : TimeDependence& operator=(const TimeDependence&) = default; 84 0 : TimeDependence(TimeDependence&&) = default; 85 0 : TimeDependence& operator=(TimeDependence&&) = default; 86 : 87 : /// Returns a `std::unique_ptr` pointing to a copy of the `TimeDependence`. 88 1 : virtual auto get_clone() const -> std::unique_ptr<TimeDependence> = 0; 89 : 90 : /// Returns the coordinate maps from the `Frame::Grid` to the 91 : /// `Frame::Inertial` frame for each block. 92 1 : virtual auto block_maps_grid_to_inertial(size_t number_of_blocks) const 93 : -> std::vector<std::unique_ptr<domain::CoordinateMapBase< 94 : Frame::Grid, Frame::Inertial, MeshDim>>> = 0; 95 : 96 : /// Returns the coordinate maps from the `Frame::Grid` to the 97 : /// `Frame::Distorted` frame for each block. 98 : /// Returns vector of nullptr if there is no distorted frame. 99 1 : virtual auto block_maps_grid_to_distorted(size_t number_of_blocks) const 100 : -> std::vector<std::unique_ptr<domain::CoordinateMapBase< 101 : Frame::Grid, Frame::Distorted, MeshDim>>> = 0; 102 : 103 : /// Returns the coordinate maps from the `Frame::Distorted` to the 104 : /// `Frame::Inertial` frame for each block. 105 : /// Returns vector of nullptr if is no distorted frame. 106 1 : virtual auto block_maps_distorted_to_inertial(size_t number_of_blocks) const 107 : -> std::vector<std::unique_ptr<domain::CoordinateMapBase< 108 : Frame::Distorted, Frame::Inertial, MeshDim>>> = 0; 109 : 110 : /// Returns the functions of time for the domain. 111 1 : virtual auto functions_of_time(const std::unordered_map<std::string, double>& 112 : initial_expiration_times = {}) const 113 : -> std::unordered_map< 114 : std::string, 115 : std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> = 0; 116 : 117 : /// Returns `true` if the instance is `None`, meaning no time dependence. 118 1 : bool is_none() const { 119 : return dynamic_cast<const None<MeshDim>*>(this) != nullptr; 120 : } 121 : }; 122 : 123 : template <size_t MeshDim> 124 : TimeDependence<MeshDim>::~TimeDependence() = default; 125 : } // namespace time_dependence 126 : } // namespace domain::creators 127 : 128 : #include "Domain/CoordinateMaps/CoordinateMap.hpp" 129 : #include "Domain/CoordinateMaps/CoordinateMap.tpp" 130 : #include "Domain/CoordinateMaps/TimeDependent/ProductMaps.hpp" 131 : #include "Domain/CoordinateMaps/TimeDependent/ProductMaps.tpp" 132 : #include "Domain/Creators/TimeDependence/CubicScale.hpp" 133 : #include "Domain/Creators/TimeDependence/None.hpp" 134 : #include "Domain/Creators/TimeDependence/RotationAboutZAxis.hpp" 135 : #include "Domain/Creators/TimeDependence/ScalingAndZRotation.hpp" 136 : #include "Domain/Creators/TimeDependence/Shape.hpp" 137 : #include "Domain/Creators/TimeDependence/SphericalCompression.hpp" 138 : #include "Domain/Creators/TimeDependence/UniformTranslation.hpp"