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 <type_traits>
10 : #include <unordered_map>
11 :
12 : #include "DataStructures/Tensor/TypeAliases.hpp"
13 : #include "Utilities/Gsl.hpp"
14 : #include "Utilities/Serialization/CharmPupable.hpp"
15 :
16 : /// \cond
17 : class DataVector;
18 : namespace domain::FunctionsOfTime {
19 : class FunctionOfTime;
20 : } // namespace domain::FunctionsOfTime
21 : /// \endcond
22 :
23 : /// Holds classes implementing DampingFunction (functions \f$R^n \to R\f$).
24 : namespace ConstraintDamping {
25 : /// \cond
26 : template <size_t VolumeDim, typename Fr>
27 : class Constant;
28 : template <size_t VolumeDim, typename Fr>
29 : class GaussianPlusConstant;
30 : class TimeDependentTripleGaussian;
31 : /// \endcond
32 :
33 : /*!
34 : * \brief Base class defining interface for constraint damping functions.
35 : *
36 : * Encodes a function \f$R^n \to R\f$ where n is `VolumeDim` that represents
37 : * a generalized-harmonic constraint-damping parameter (i.e., Gamma0,
38 : * Gamma1, or Gamma2).
39 : */
40 : template <size_t VolumeDim, typename Fr>
41 1 : class DampingFunction : public PUP::able {
42 : public:
43 0 : using creatable_classes = tmpl::conditional_t<
44 : (VolumeDim == 3 and std::is_same<Fr, Frame::Grid>::value),
45 : tmpl::list<ConstraintDamping::Constant<VolumeDim, Fr>,
46 : ConstraintDamping::GaussianPlusConstant<VolumeDim, Fr>,
47 : ConstraintDamping::TimeDependentTripleGaussian>,
48 : tmpl::list<ConstraintDamping::GaussianPlusConstant<VolumeDim, Fr>,
49 : ConstraintDamping::Constant<VolumeDim, Fr>>>;
50 0 : constexpr static size_t volume_dim = VolumeDim;
51 0 : using frame = Fr;
52 :
53 0 : WRAPPED_PUPable_abstract(DampingFunction); // NOLINT
54 :
55 0 : DampingFunction() = default;
56 0 : DampingFunction(const DampingFunction& /*rhs*/) = default;
57 0 : DampingFunction& operator=(const DampingFunction& /*rhs*/) = default;
58 0 : DampingFunction(DampingFunction&& /*rhs*/) = default;
59 0 : DampingFunction& operator=(DampingFunction&& /*rhs*/) = default;
60 0 : ~DampingFunction() override = default;
61 :
62 0 : explicit DampingFunction(CkMigrateMessage* msg) : PUP::able(msg) {}
63 :
64 : /// @{
65 : /// Returns the value of the function at the coordinate 'x'.
66 1 : virtual void operator()(
67 : const gsl::not_null<Scalar<double>*> value_at_x,
68 : const tnsr::I<double, VolumeDim, Fr>& x, double time,
69 : const std::unordered_map<
70 : std::string,
71 : std::unique_ptr<::domain::FunctionsOfTime::FunctionOfTime>>&
72 : functions_of_time) const = 0;
73 1 : virtual void operator()(
74 : const gsl::not_null<Scalar<DataVector>*> value_at_x,
75 : const tnsr::I<DataVector, VolumeDim, Fr>& x, double time,
76 : const std::unordered_map<
77 : std::string,
78 : std::unique_ptr<::domain::FunctionsOfTime::FunctionOfTime>>&
79 : functions_of_time) const = 0;
80 : /// @}
81 :
82 0 : virtual auto get_clone() const
83 : -> std::unique_ptr<DampingFunction<VolumeDim, Fr>> = 0;
84 : };
85 : } // namespace ConstraintDamping
86 :
87 : // NOLINTBEGIN(misc-header-include-cycle)
88 : #include "PointwiseFunctions/ConstraintDamping/Constant.hpp"
89 : #include "PointwiseFunctions/ConstraintDamping/GaussianPlusConstant.hpp"
90 : #include "PointwiseFunctions/ConstraintDamping/TimeDependentTripleGaussian.hpp"
91 : // NOLINTEND(misc-header-include-cycle)
|