SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/AnalyticSolutions/Poisson - MathFunction.hpp Hit Total Coverage
Commit: eded15d6fcfa762a5dfde087b28df9bcedd8b386 Lines: 0 21 0.0 %
Date: 2024-04-15 22:23:51
Legend: Lines: hit not hit

          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 <pup.h>
       8             : 
       9             : #include "DataStructures/CachedTempBuffer.hpp"
      10             : #include "DataStructures/DataBox/Prefixes.hpp"
      11             : #include "DataStructures/Tensor/Tensor.hpp"
      12             : #include "Elliptic/Systems/Poisson/Tags.hpp"
      13             : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp"
      14             : #include "Options/String.hpp"
      15             : #include "PointwiseFunctions/InitialDataUtilities/AnalyticSolution.hpp"
      16             : #include "PointwiseFunctions/MathFunctions/MathFunction.hpp"
      17             : #include "Utilities/ContainerHelpers.hpp"
      18             : #include "Utilities/Gsl.hpp"
      19             : #include "Utilities/TMPL.hpp"
      20             : #include "Utilities/TaggedTuple.hpp"
      21             : 
      22             : namespace Poisson::Solutions {
      23             : 
      24             : namespace detail {
      25             : template <typename DataType, size_t Dim>
      26             : struct MathFunctionVariables {
      27             :   using Cache = CachedTempBuffer<
      28             :       Tags::Field,
      29             :       ::Tags::deriv<Tags::Field, tmpl::size_t<Dim>, Frame::Inertial>,
      30             :       ::Tags::Flux<Tags::Field, tmpl::size_t<Dim>, Frame::Inertial>,
      31             :       ::Tags::FixedSource<Tags::Field>>;
      32             : 
      33             :   const tnsr::I<DataType, Dim>& x;
      34             :   const ::MathFunction<Dim, Frame::Inertial>& math_function;
      35             : 
      36             :   void operator()(gsl::not_null<Scalar<DataType>*> field,
      37             :                   gsl::not_null<Cache*> cache, Tags::Field /*meta*/) const;
      38             :   void operator()(gsl::not_null<tnsr::i<DataType, Dim>*> field_gradient,
      39             :                   gsl::not_null<Cache*> cache,
      40             :                   ::Tags::deriv<Tags::Field, tmpl::size_t<Dim>,
      41             :                                 Frame::Inertial> /*meta*/) const;
      42             :   void operator()(gsl::not_null<tnsr::I<DataType, Dim>*> flux_for_field,
      43             :                   gsl::not_null<Cache*> cache,
      44             :                   ::Tags::Flux<Tags::Field, tmpl::size_t<Dim>,
      45             :                                Frame::Inertial> /*meta*/) const;
      46             :   void operator()(gsl::not_null<Scalar<DataType>*> fixed_source_for_field,
      47             :                   gsl::not_null<Cache*> cache,
      48             :                   ::Tags::FixedSource<Tags::Field> /*meta*/) const;
      49             : };
      50             : }  // namespace detail
      51             : 
      52             : template <size_t Dim>
      53           0 : class MathFunction : public elliptic::analytic_data::AnalyticSolution {
      54             :  public:
      55           0 :   struct Function {
      56           0 :     using type = std::unique_ptr<::MathFunction<Dim, Frame::Inertial>>;
      57           0 :     static constexpr Options::String help = "The solution function";
      58             :   };
      59             : 
      60           0 :   using options = tmpl::list<Function>;
      61           0 :   static constexpr Options::String help{
      62             :       "Any solution to the Poisson equation given by a MathFunction "
      63             :       "implementation, such as a Gaussian."};
      64             : 
      65           0 :   MathFunction() = default;
      66           0 :   MathFunction(const MathFunction&) = delete;
      67           0 :   MathFunction& operator=(const MathFunction&) = delete;
      68           0 :   MathFunction(MathFunction&&) = default;
      69           0 :   MathFunction& operator=(MathFunction&&) = default;
      70           0 :   ~MathFunction() override = default;
      71           0 :   std::unique_ptr<elliptic::analytic_data::AnalyticSolution> get_clone()
      72             :       const override;
      73             : 
      74           0 :   MathFunction(
      75             :       std::unique_ptr<::MathFunction<Dim, Frame::Inertial>> math_function);
      76             : 
      77           0 :   const ::MathFunction<Dim, Frame::Inertial>& math_function() const {
      78             :     return *math_function_;
      79             :   }
      80             : 
      81             :   /// \cond
      82             :   explicit MathFunction(CkMigrateMessage* m);
      83             :   using PUP::able::register_constructor;
      84             :   WRAPPED_PUPable_decl_template(MathFunction);  // NOLINT
      85             :   /// \endcond
      86             : 
      87             :   template <typename DataType, typename... RequestedTags>
      88           0 :   tuples::TaggedTuple<RequestedTags...> variables(
      89             :       const tnsr::I<DataType, Dim>& x,
      90             :       tmpl::list<RequestedTags...> /*meta*/) const {
      91             :     using VarsComputer = detail::MathFunctionVariables<DataType, Dim>;
      92             :     typename VarsComputer::Cache cache{get_size(*x.begin())};
      93             :     const VarsComputer computer{x, *math_function_};
      94             :     return {cache.get_var(computer, RequestedTags{})...};
      95             :   }
      96             : 
      97             :   // NOLINTNEXTLINE(google-runtime-references)
      98           0 :   void pup(PUP::er& p) override;
      99             : 
     100             :  private:
     101           0 :   std::unique_ptr<::MathFunction<Dim, Frame::Inertial>> math_function_;
     102             : };
     103             : 
     104             : template <size_t Dim>
     105           0 : bool operator==(const MathFunction<Dim>& lhs, const MathFunction<Dim>& rhs);
     106             : 
     107             : template <size_t Dim>
     108           0 : bool operator!=(const MathFunction<Dim>& lhs, const MathFunction<Dim>& rhs);
     109             : 
     110             : }  // namespace Poisson::Solutions

Generated by: LCOV version 1.14