SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/AnalyticSolutions/Poisson - MathFunction.hpp Hit Total Coverage
Commit: 2b1666de0ae5e27fe0a0cb0c0d54fe4ae87ef1d3 Lines: 0 21 0.0 %
Date: 2024-10-13 19:48:05
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<DataType>,
      29             :       ::Tags::deriv<Tags::Field<DataType>, tmpl::size_t<Dim>, Frame::Inertial>,
      30             :       ::Tags::Flux<Tags::Field<DataType>, tmpl::size_t<Dim>, Frame::Inertial>,
      31             :       ::Tags::FixedSource<Tags::Field<DataType>>>;
      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,
      38             :                   Tags::Field<DataType> /*meta*/) const;
      39             :   void operator()(gsl::not_null<tnsr::i<DataType, Dim>*> field_gradient,
      40             :                   gsl::not_null<Cache*> cache,
      41             :                   ::Tags::deriv<Tags::Field<DataType>, tmpl::size_t<Dim>,
      42             :                                 Frame::Inertial> /*meta*/) const;
      43             :   void operator()(gsl::not_null<tnsr::I<DataType, Dim>*> flux_for_field,
      44             :                   gsl::not_null<Cache*> cache,
      45             :                   ::Tags::Flux<Tags::Field<DataType>, tmpl::size_t<Dim>,
      46             :                                Frame::Inertial> /*meta*/) const;
      47             :   void operator()(gsl::not_null<Scalar<DataType>*> fixed_source_for_field,
      48             :                   gsl::not_null<Cache*> cache,
      49             :                   ::Tags::FixedSource<Tags::Field<DataType>> /*meta*/) const;
      50             : };
      51             : }  // namespace detail
      52             : 
      53             : template <size_t Dim>
      54           0 : class MathFunction : public elliptic::analytic_data::AnalyticSolution {
      55             :  public:
      56           0 :   struct Function {
      57           0 :     using type = std::unique_ptr<::MathFunction<Dim, Frame::Inertial>>;
      58           0 :     static constexpr Options::String help = "The solution function";
      59             :   };
      60             : 
      61           0 :   using options = tmpl::list<Function>;
      62           0 :   static constexpr Options::String help{
      63             :       "Any solution to the Poisson equation given by a MathFunction "
      64             :       "implementation, such as a Gaussian."};
      65             : 
      66           0 :   MathFunction() = default;
      67           0 :   MathFunction(const MathFunction&) = delete;
      68           0 :   MathFunction& operator=(const MathFunction&) = delete;
      69           0 :   MathFunction(MathFunction&&) = default;
      70           0 :   MathFunction& operator=(MathFunction&&) = default;
      71           0 :   ~MathFunction() override = default;
      72           0 :   std::unique_ptr<elliptic::analytic_data::AnalyticSolution> get_clone()
      73             :       const override;
      74             : 
      75           0 :   MathFunction(
      76             :       std::unique_ptr<::MathFunction<Dim, Frame::Inertial>> math_function);
      77             : 
      78           0 :   const ::MathFunction<Dim, Frame::Inertial>& math_function() const {
      79             :     return *math_function_;
      80             :   }
      81             : 
      82             :   /// \cond
      83             :   explicit MathFunction(CkMigrateMessage* m);
      84             :   using PUP::able::register_constructor;
      85             :   WRAPPED_PUPable_decl_template(MathFunction);  // NOLINT
      86             :   /// \endcond
      87             : 
      88             :   template <typename DataType, typename... RequestedTags>
      89           0 :   tuples::TaggedTuple<RequestedTags...> variables(
      90             :       const tnsr::I<DataType, Dim>& x,
      91             :       tmpl::list<RequestedTags...> /*meta*/) const {
      92             :     using VarsComputer = detail::MathFunctionVariables<DataType, Dim>;
      93             :     typename VarsComputer::Cache cache{get_size(*x.begin())};
      94             :     const VarsComputer computer{x, *math_function_};
      95             :     return {cache.get_var(computer, RequestedTags{})...};
      96             :   }
      97             : 
      98             :   // NOLINTNEXTLINE(google-runtime-references)
      99           0 :   void pup(PUP::er& p) override;
     100             : 
     101             :  private:
     102           0 :   std::unique_ptr<::MathFunction<Dim, Frame::Inertial>> math_function_;
     103             : };
     104             : 
     105             : template <size_t Dim>
     106           0 : bool operator==(const MathFunction<Dim>& lhs, const MathFunction<Dim>& rhs);
     107             : 
     108             : template <size_t Dim>
     109           0 : bool operator!=(const MathFunction<Dim>& lhs, const MathFunction<Dim>& rhs);
     110             : 
     111             : }  // namespace Poisson::Solutions

Generated by: LCOV version 1.14