Line data Source code
1 1 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : /// \file 5 : /// Defines MathFunctions::PowX. 6 : 7 : #pragma once 8 : 9 : #include <memory> 10 : #include <pup.h> 11 : 12 : #include "Options/String.hpp" 13 : #include "PointwiseFunctions/MathFunctions/MathFunction.hpp" // IWYU pragma: keep 14 : #include "Utilities/Serialization/CharmPupable.hpp" 15 : #include "Utilities/TMPL.hpp" 16 : 17 : /// \cond 18 : class DataVector; 19 : /// \endcond 20 : 21 : namespace MathFunctions { 22 : template <size_t VolumeDim, typename Fr> 23 0 : class PowX; 24 : 25 : /*! 26 : * \ingroup MathFunctionsGroup 27 : * \brief Power of X \f$f(x)=x^X\f$ 28 : */ 29 : template <typename Fr> 30 1 : class PowX<1, Fr> : public MathFunction<1, Fr> { 31 : public: 32 0 : struct Power { 33 0 : using type = int; 34 0 : static constexpr Options::String help = { 35 : "The power that the double is raised to."}; 36 : }; 37 0 : using options = tmpl::list<Power>; 38 : 39 0 : static constexpr Options::String help = { 40 : "Raises the input value to a given power"}; 41 0 : PowX() = default; 42 : 43 0 : WRAPPED_PUPable_decl_base_template(SINGLE_ARG(MathFunction<1, Fr>), 44 : PowX); // NOLINT 45 0 : std::unique_ptr<MathFunction<1, Fr>> get_clone() const override; 46 : 47 0 : explicit PowX(int power); 48 : 49 0 : explicit PowX(CkMigrateMessage* /*unused*/) {} 50 : 51 1 : double operator()(const double& x) const override; 52 0 : DataVector operator()(const DataVector& x) const override; 53 : 54 1 : double first_deriv(const double& x) const override; 55 0 : DataVector first_deriv(const DataVector& x) const override; 56 : 57 1 : double second_deriv(const double& x) const override; 58 0 : DataVector second_deriv(const DataVector& x) const override; 59 : 60 1 : double third_deriv(const double& x) const override; 61 0 : DataVector third_deriv(const DataVector& x) const override; 62 : 63 0 : bool operator==(const MathFunction<1, Fr>& other) const override; 64 0 : bool operator!=(const MathFunction<1, Fr>& other) const override; 65 : 66 0 : bool operator==(const PowX<1, Fr>& other) const; 67 0 : bool operator!=(const PowX<1, Fr>& other) const; 68 : 69 : // NOLINTNEXTLINE(google-runtime-references) 70 0 : void pup(PUP::er& p) override; 71 : 72 : private: 73 0 : double power_{}; 74 : 75 : template <typename T> 76 0 : T apply_call_operator(const T& x) const; 77 : template <typename T> 78 0 : T apply_first_deriv(const T& x) const; 79 : template <typename T> 80 0 : T apply_second_deriv(const T& x) const; 81 : template <typename T> 82 0 : T apply_third_deriv(const T& x) const; 83 : }; 84 : 85 : } // namespace MathFunctions 86 : 87 : /// \cond 88 : template <typename Fr> 89 : PUP::able::PUP_ID MathFunctions::PowX<1, Fr>::my_PUP_ID = 0; // NOLINT 90 : /// \endcond