20#ifndef LIBMESH_WRAPPED_FUNCTOR_H
21#define LIBMESH_WRAPPED_FUNCTOR_H
24#include "libmesh/fem_function_base.h"
25#include "libmesh/function_base.h"
26#include "libmesh/int_range.h"
27#include "libmesh/point.h"
28#include "libmesh/wrapped_function.h"
46template <
typename Output=Number>
65 const std::string & sys_name,
66 const std::string & unknown_name) =
nullptr,
68 unsigned int varnum=0) :
95 virtual std::unique_ptr<FEMFunctionBase<Output>>
clone ()
const override
97 return std::make_unique<WrappedFunctor<Output>>(*_func);
102 const Real time = 0.)
override
103 {
return _func->operator()(p, time); }
109 {
_func->operator() (p, time, output); }
114 Real time=0.)
override
115 {
return _func->component(i, p, time); }
119 std::unique_ptr<FunctionBase<Output>>
_func;
123template <
typename Output>
129 const std::vector<unsigned int> * active = c.
active_vars();
131 auto check_and_init = [&c](
unsigned int v,
unsigned short dim)
135 libmesh_assert_msg(fe,
"FEAbstract pointer is null for variable "
136 << v <<
" in dimension " <<
dim);
143 for (
const auto v : *active)
144 check_and_init(v,
dim);
147 check_and_init(v,
dim);
Defines a dense vector for use in Finite Element-type computations.
unsigned int n_vars() const
Number of variables in solution.
This class forms the foundation from which generic finite elements may be derived.
This class provides all data required for a physics package (e.g.
const std::set< unsigned char > & elem_dimensions() const
const std::vector< unsigned int > * active_vars() const
Return a pointer to the vector of active variables being computed for, or a null pointer if all varia...
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh.
FEMFunctionBase is a base class from which users can derive in order to define "function-like" object...
Base class for functors that can be evaluated at a point and (optionally) time.
This class provides the ability to map between arbitrary, user-defined strings and several data types...
A Point defines a location in LIBMESH_DIM dimensional Real space.
Manages consistently variables, degrees of freedom, and coefficient vectors.
Wrap a libMesh-style function pointer into a FunctionBase object.
This class provides a wrapper with which to evaluate a (libMesh-style) function pointer in a Function...
WrappedFunctor(const FunctionBase< Output > &func)
Constructor to wrap FunctionBase functors in a FEMFunctionBase compatible shim.
WrappedFunctor(WrappedFunctor &&)=default
The remaining 5 special functions can be defaulted.
WrappedFunctor(const System &sys, Output fptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name)=nullptr, const Parameters *parameters=nullptr, unsigned int varnum=0)
Constructor to wrap scalar-valued function pointers.
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const override
virtual Output operator()(const FEMContext &, const Point &p, const Real time=0.) override
std::unique_ptr< FunctionBase< Output > > _func
virtual ~WrappedFunctor()=default
WrappedFunctor & operator=(const WrappedFunctor &)=delete
virtual void init_context(const FEMContext &c) override
Tell the context we don't need anything from it.
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.) override
virtual void init() override
Any post-construction initialization.
WrappedFunctor(const WrappedFunctor &)=delete
This class can't be copy constructed or assigned because it contains a unique_ptr member.
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)