Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <array> 7 : #include <cstddef> 8 : #include <limits> 9 : #include <memory> 10 : #include <string> 11 : #include <unordered_map> 12 : 13 : #include "DataStructures/Tensor/TypeAliases.hpp" 14 : #include "Evolution/Systems/GeneralizedHarmonic/ConstraintDamping/DampingFunction.hpp" 15 : #include "Options/String.hpp" 16 : #include "Utilities/Serialization/CharmPupable.hpp" 17 : #include "Utilities/TMPL.hpp" 18 : 19 : /// \cond 20 : class DataVector; 21 : namespace PUP { 22 : class er; 23 : } // namespace PUP 24 : namespace domain::FunctionsOfTime { 25 : class FunctionOfTime; 26 : } // namespace domain::FunctionsOfTime 27 : /// \endcond 28 : 29 1 : namespace gh::ConstraintDamping { 30 : /*! 31 : * \brief A constant function: \f$f = C\f$ 32 : * 33 : * \details Input file options are: `Value` \f$C\f$. The function takes input 34 : * coordinates of type `tnsr::I<T, VolumeDim, Fr>`, where `T` is e.g. `double` 35 : * or `DataVector`, `Fr` is a frame (e.g. `Frame::Inertial`), and `VolumeDim` is 36 : * the dimension of the spatial volume. 37 : */ 38 : template <size_t VolumeDim, typename Fr> 39 1 : class Constant : public DampingFunction<VolumeDim, Fr> { 40 : public: 41 0 : struct Value { 42 0 : using type = double; 43 0 : static constexpr Options::String help = {"The value."}; 44 : }; 45 0 : using options = tmpl::list<Value>; 46 : 47 0 : static constexpr Options::String help = {"Returns a constant value"}; 48 : 49 : /// \cond 50 : WRAPPED_PUPable_decl_base_template(SINGLE_ARG(DampingFunction<VolumeDim, Fr>), 51 : Constant); // NOLINT 52 : 53 : explicit Constant(CkMigrateMessage* msg); 54 : /// \endcond 55 : 56 0 : Constant(double value); 57 : 58 0 : Constant() = default; 59 0 : ~Constant() override = default; 60 0 : Constant(const Constant& /*rhs*/) = default; 61 0 : Constant& operator=(const Constant& /*rhs*/) = default; 62 0 : Constant(Constant&& /*rhs*/) = default; 63 0 : Constant& operator=(Constant&& /*rhs*/) = default; 64 : 65 1 : void operator()(const gsl::not_null<Scalar<double>*> value_at_x, 66 : const tnsr::I<double, VolumeDim, Fr>& x, double time, 67 : const std::unordered_map< 68 : std::string, 69 : std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>>& 70 : functions_of_time) const override; 71 1 : void operator()(const gsl::not_null<Scalar<DataVector>*> value_at_x, 72 : const tnsr::I<DataVector, VolumeDim, Fr>& x, double time, 73 : const std::unordered_map< 74 : std::string, 75 : std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>>& 76 : functions_of_time) const override; 77 : 78 0 : auto get_clone() const 79 : -> std::unique_ptr<DampingFunction<VolumeDim, Fr>> override; 80 : 81 : // NOLINTNEXTLINE(google-runtime-references) 82 0 : void pup(PUP::er& p) override; 83 : 84 : private: 85 0 : friend bool operator==(const Constant& lhs, const Constant& rhs) { 86 : return lhs.value_ == rhs.value_; 87 : } 88 : 89 : template <typename T> 90 0 : void apply_call_operator(const gsl::not_null<Scalar<T>*> value_at_x) const; 91 : 92 0 : double value_ = std::numeric_limits<double>::signaling_NaN(); 93 : }; 94 : 95 : template <size_t VolumeDim, typename Fr> 96 0 : bool operator!=(const Constant<VolumeDim, Fr>& lhs, 97 : const Constant<VolumeDim, Fr>& rhs) { 98 : return not(lhs == rhs); 99 : } 100 : } // namespace gh::ConstraintDamping 101 : 102 : /// \cond 103 : template <size_t VolumeDim, typename Fr> 104 : PUP::able::PUP_ID gh::ConstraintDamping::Constant<VolumeDim, Fr>::my_PUP_ID = 105 : 0; // NOLINT 106 : /// \endcond