libMesh::WrappedFunctor< Output > Class Template Reference

#include <wrapped_functor.h>

Inheritance diagram for libMesh::WrappedFunctor< Output >:

Public Member Functions

 WrappedFunctor (const FunctionBase< Output > &func)
 
 WrappedFunctor (const WrappedFunctor &)=delete
 
WrappedFunctoroperator= (const WrappedFunctor &)=delete
 
 WrappedFunctor (WrappedFunctor &&)=default
 
WrappedFunctoroperator= (WrappedFunctor &&)=default
 
virtual ~WrappedFunctor ()=default
 
virtual std::unique_ptr< FEMFunctionBase< Output > > clone () const override
 
virtual Output operator() (const FEMContext &, const Point &p, const Real time=0.) override
 
virtual void operator() (const FEMContext &, const Point &p, const Real time, DenseVector< Output > &output) override
 
virtual Output component (const FEMContext &, unsigned int i, const Point &p, Real time=0.) override
 
virtual void init_context (const FEMContext &)
 
void operator() (const FEMContext &, const Point &p, DenseVector< Output > &output)
 

Protected Attributes

std::unique_ptr< FunctionBase< Output > > _func
 

Detailed Description

template<typename Output = Number>
class libMesh::WrappedFunctor< Output >

This class provides a wrapper with which to evaluate a (libMesh-style) function pointer in a FunctionBase-compatible interface. All overridden virtual functions are documented in fem_function_base.h.

Author
Roy Stogner
Date
2015

Definition at line 44 of file wrapped_functor.h.

Constructor & Destructor Documentation

◆ WrappedFunctor() [1/3]

template<typename Output = Number>
libMesh::WrappedFunctor< Output >::WrappedFunctor ( const FunctionBase< Output > &  func)
inline

Constructor to wrap FunctionBase functors in a FEMFunctionBase compatible shim.

Definition at line 52 of file wrapped_functor.h.

53  : _func(func.clone())
54  { }
std::unique_ptr< FunctionBase< Output > > _func

◆ WrappedFunctor() [2/3]

template<typename Output = Number>
libMesh::WrappedFunctor< Output >::WrappedFunctor ( const WrappedFunctor< Output > &  )
delete

This class can't be copy constructed or assigned because it contains a unique_ptr member.

◆ WrappedFunctor() [3/3]

template<typename Output = Number>
libMesh::WrappedFunctor< Output >::WrappedFunctor ( WrappedFunctor< Output > &&  )
default

The remaining 5 special functions can be defaulted.

◆ ~WrappedFunctor()

template<typename Output = Number>
virtual libMesh::WrappedFunctor< Output >::~WrappedFunctor ( )
virtualdefault

Member Function Documentation

◆ clone()

template<typename Output = Number>
virtual std::unique_ptr<FEMFunctionBase<Output> > libMesh::WrappedFunctor< Output >::clone ( ) const
inlineoverridevirtual
Returns
A new copy of the function.

The new copy should be as "deep" as necessary to allow independent destruction and simultaneous evaluations of the copies in different threads.

Implements libMesh::FEMFunctionBase< Output >.

Definition at line 70 of file wrapped_functor.h.

71  {
72  return std::unique_ptr<FEMFunctionBase<Output>>
73  (new WrappedFunctor<Output> (*_func));
74  }

◆ component()

template<typename Output = Number>
virtual Output libMesh::WrappedFunctor< Output >::component ( const FEMContext context,
unsigned int  i,
const Point p,
Real  time = 0. 
)
inlineoverridevirtual
Returns
The vector component i at coordinate p and time time.
Note
Subclasses aren't required to override this, since the default implementation is based on the full vector evaluation, which is often correct.
Subclasses are recommended to override this, since the default implementation is based on a vector evaluation, which is usually unnecessarily inefficient.

Reimplemented from libMesh::FEMFunctionBase< Output >.

Definition at line 87 of file wrapped_functor.h.

References libMesh::WrappedFunctor< Output >::_func.

91  { return _func->component(i, p, time); }
std::unique_ptr< FunctionBase< Output > > _func

◆ init_context()

template<typename Output = Number>
virtual void libMesh::FEMFunctionBase< Output >::init_context ( const FEMContext )
inlinevirtualinherited

Prepares a context object for use.

Most problems will want to reimplement this for efficiency, in order to call FE::get_*() as their particular function requires.

Reimplemented in libMesh::ParsedFEMFunction< Output >, and libMesh::ParsedFEMFunction< T >.

Definition at line 73 of file fem_function_base.h.

73 {}

◆ operator()() [1/3]

template<typename Output = Number>
virtual Output libMesh::WrappedFunctor< Output >::operator() ( const FEMContext ,
const Point p,
const Real  time = 0. 
)
inlineoverridevirtual
Returns
The scalar function value at coordinate p and time time, which defaults to zero.

Pure virtual, so you have to override it.

Implements libMesh::FEMFunctionBase< Output >.

Definition at line 76 of file wrapped_functor.h.

References libMesh::WrappedFunctor< Output >::_func.

79  { return _func->operator()(p, time); }
std::unique_ptr< FunctionBase< Output > > _func

◆ operator()() [2/3]

template<typename Output = Number>
virtual void libMesh::WrappedFunctor< Output >::operator() ( const FEMContext ,
const Point p,
const Real  time,
DenseVector< Output > &  output 
)
inlineoverridevirtual

Evaluation function for time-dependent vector-valued functions. Sets output values in the passed-in output DenseVector.

Pure virtual, so you have to override it.

Implements libMesh::FEMFunctionBase< Output >.

Definition at line 81 of file wrapped_functor.h.

References libMesh::WrappedFunctor< Output >::_func.

85  { _func->operator() (p, time, output); }
std::unique_ptr< FunctionBase< Output > > _func

◆ operator()() [3/3]

template<typename Output >
void libMesh::FEMFunctionBase< Output >::operator() ( const FEMContext context,
const Point p,
DenseVector< Output > &  output 
)
inlineinherited

Evaluation function for time-independent vector-valued functions. Sets output values in the passed-in output DenseVector.

Definition at line 145 of file fem_function_base.h.

148 {
149  // Call the time-dependent function with t=0.
150  this->operator()(context, p, 0., output);
151 }
virtual Output operator()(const FEMContext &, const Point &p, const Real time=0.)=0

◆ operator=() [1/2]

template<typename Output = Number>
WrappedFunctor& libMesh::WrappedFunctor< Output >::operator= ( const WrappedFunctor< Output > &  )
delete

◆ operator=() [2/2]

template<typename Output = Number>
WrappedFunctor& libMesh::WrappedFunctor< Output >::operator= ( WrappedFunctor< Output > &&  )
default

Member Data Documentation

◆ _func

template<typename Output = Number>
std::unique_ptr<FunctionBase<Output> > libMesh::WrappedFunctor< Output >::_func
protected

The documentation for this class was generated from the following file: