libMesh::WrappedFunctor< Output > Class Template Reference

#include <wrapped_functor.h>

Inheritance diagram for libMesh::WrappedFunctor< Output >:

Public Member Functions

 WrappedFunctor (const FunctionBase< Output > &func)
 
virtual UniquePtr< FEMFunctionBase< Output > > clone () const libmesh_override
 
virtual Output operator() (const FEMContext &, const Point &p, const Real time=0.) libmesh_override
 
virtual void operator() (const FEMContext &, const Point &p, const Real time, DenseVector< Output > &output) libmesh_override
 
virtual Output component (const FEMContext &, unsigned int i, const Point &p, Real time=0.) libmesh_override
 
virtual void init_context (const FEMContext &)
 
void operator() (const FEMContext &, const Point &p, DenseVector< Output > &output)
 

Protected Attributes

UniquePtr< 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

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  { }
UniquePtr< FunctionBase< Output > > _func

Member Function Documentation

template<typename Output = Number>
virtual UniquePtr<FEMFunctionBase<Output> > libMesh::WrappedFunctor< Output >::clone ( ) const
inlinevirtual
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 56 of file wrapped_functor.h.

57  {
58  return UniquePtr<FEMFunctionBase<Output> >
59  (new WrappedFunctor<Output> (*_func));
60  }
template<typename Output = Number>
virtual Output libMesh::WrappedFunctor< Output >::component ( const FEMContext context,
unsigned int  i,
const Point p,
Real  time = 0. 
)
inlinevirtual
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 73 of file wrapped_functor.h.

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

77  { return _func->component(i, p, time); }
UniquePtr< FunctionBase< Output > > _func
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 71 of file fem_function_base.h.

References libMesh::FEMFunctionBase< Output >::clone(), libMesh::FEMFunctionBase< Output >::component(), libMesh::FEMFunctionBase< Output >::operator()(), and libMesh::Real.

71 {}
template<typename Output = Number>
virtual Output libMesh::WrappedFunctor< Output >::operator() ( const FEMContext ,
const Point p,
const Real  time = 0. 
)
inlinevirtual
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 62 of file wrapped_functor.h.

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

65  { return _func->operator()(p, time); }
UniquePtr< FunctionBase< Output > > _func
template<typename Output = Number>
virtual void libMesh::WrappedFunctor< Output >::operator() ( const FEMContext ,
const Point p,
const Real  time,
DenseVector< Output > &  output 
)
inlinevirtual

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 67 of file wrapped_functor.h.

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

71  { _func->operator() (p, time, output); }
UniquePtr< FunctionBase< Output > > _func
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 143 of file fem_function_base.h.

References libMesh::FEMFunctionBase< Output >::operator()().

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

Member Data Documentation

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

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