20#ifndef LIBMESH_ANALYTIC_FUNCTION_H
21#define LIBMESH_ANALYTIC_FUNCTION_H
24#include "libmesh/function_base.h"
47template <
typename Output=Number>
91 virtual void init ()
override;
93 virtual void clear ()
override;
95 virtual std::unique_ptr<FunctionBase<Output>>
clone ()
const override;
98 const Real time=0.)
override;
109template <
typename Output>
115 libmesh_assert_msg(_number_fptr,
116 "You must construct AnalyticFunction with a scalar-valued "
117 "function in order to use this operator() override.");
118 return (this->_number_fptr(p, time));
123template <
typename Output>
130 libmesh_assert_msg(_vector_fptr,
131 "You must construct AnalyticFunction with a vector-valued "
132 "function in order to use this operator() override.");
133 this->_vector_fptr(output, p, time);
139template <
typename Output>
143 _vector_fptr (nullptr)
151template <
typename Output>
155 _number_fptr (nullptr),
164template <
typename Output>
168 libmesh_assert ((_number_fptr !=
nullptr) || (_vector_fptr !=
nullptr));
171 this->_initialized =
true;
176template <
typename Output>
181 _number_fptr =
nullptr;
182 _vector_fptr =
nullptr;
185 this->_initialized =
false;
190template <
typename Output>
192std::unique_ptr<FunctionBase<Output>>
195 return _number_fptr ?
196 std::make_unique<AnalyticFunction<Output>>(_number_fptr) :
197 std::make_unique<AnalyticFunction<Output>>(_vector_fptr);
Wraps a function pointer into a FunctionBase object.
AnalyticFunction(AnalyticFunction &&)=default
The 5 special functions can be defaulted for this class.
OutputFunction _number_fptr
Pointer to user-provided function that computes the boundary values when an analytical expression is ...
void(* OutputVectorFunction)(DenseVector< Output > &output, const Point &p, const Real time)
Vector return value function pointer type.
AnalyticFunction(OutputFunction fptr)
Constructor.
Output(* OutputFunction)(const Point &p, const Real time)
Scalar return value function pointer type.
OutputVectorFunction _vector_fptr
Pointer to user-provided vector valued function.
virtual std::unique_ptr< FunctionBase< Output > > clone() const override
AnalyticFunction(const AnalyticFunction &)=default
virtual void init() override
The actual initialization process.
AnalyticFunction & operator=(const AnalyticFunction &)=default
virtual void clear() override
Clears the function.
virtual ~AnalyticFunction()=default
virtual Output operator()(const Point &p, const Real time=0.) override
Defines a dense vector for use in Finite Element-type computations.
Base class for functors that can be evaluated at a point and (optionally) time.
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
A Point defines a location in LIBMESH_DIM dimensional Real space.
The libMesh namespace provides an interface to certain functionality in the library.
bool initialized()
Checks that library initialization has been done.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)