libMesh
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
libMesh::FunctionBase< Output > Class Template Referenceabstract

Base class for functors that can be evaluated at a point and (optionally) time. More...

#include <dirichlet_boundaries.h>

Inheritance diagram for libMesh::FunctionBase< Output >:
[legend]

Public Member Functions

 FunctionBase (FunctionBase &&)=default
 The 5 special functions can be defaulted for this class. More...
 
 FunctionBase (const FunctionBase &)=default
 
FunctionBaseoperator= (const FunctionBase &)=default
 
FunctionBaseoperator= (FunctionBase &&)=default
 
virtual ~FunctionBase ()=default
 
virtual void init ()
 The actual initialization process. More...
 
virtual void clear ()
 Clears the function. More...
 
virtual std::unique_ptr< FunctionBase< Output > > clone () const =0
 
virtual Output operator() (const Point &p, const Real time=0.)=0
 
void operator() (const Point &p, DenseVector< Output > &output)
 Evaluation function for time-independent vector-valued functions. More...
 
virtual void operator() (const Point &p, const Real time, DenseVector< Output > &output)=0
 Evaluation function for time-dependent vector-valued functions. More...
 
virtual Output component (unsigned int i, const Point &p, Real time=0.)
 
bool initialized () const
 
void set_is_time_dependent (bool is_time_dependent)
 Function to set whether this is a time-dependent function or not. More...
 
bool is_time_dependent () const
 

Protected Member Functions

 FunctionBase (const FunctionBase *master=nullptr)
 Constructor. More...
 

Protected Attributes

const FunctionBase_master
 Const pointer to our master, initialized to nullptr. More...
 
bool _initialized
 When init() was called so that everything is ready for calls to operator() (...), then this bool is true. More...
 
bool _is_time_dependent
 Cache whether or not this function is actually time-dependent. More...
 

Detailed Description

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

Base class for functors that can be evaluated at a point and (optionally) time.

Instances of FunctionBase represent functions (in the mathematical sense) of time and space, \( f(\mathbf{x},t) = \mbox{\texttt{v}} \), where v may be either a Number or a DenseVector<Number>. Children of this base class implement different styles of data retrieval for these functions. Use the constructors of the derived classes for creating new objects. The required input of each derived class thwarts the effective use of the commonly used build() member. But afterward the virtual members allow the convenient and libMesh-common usage through a FunctionBase *.

Note
For functor objects for vector-valued variables, it is assumed each component is indexed contiguously; e.g. if u_var is a 3d vector-valued variable at index 3, following some scalar-valued variables at indices 0, 1, and 2, then libMesh expects the x-component of u_var to be at index 3, the y-component at index 4, and the z-component at index 5.
For 2-D elements in 3 spatial dimensions, libMesh is expecting 2 components (i.e. mesh_dimension() number of components).
Author
Daniel Dreyer
Date
2003

Definition at line 44 of file dirichlet_boundaries.h.

Constructor & Destructor Documentation

◆ FunctionBase() [1/3]

template<typename Output >
libMesh::FunctionBase< Output >::FunctionBase ( const FunctionBase< Output > *  master = nullptr)
inlineexplicitprotected

Constructor.

Optionally takes a master.

Definition at line 199 of file function_base.h.

199  :
200  _master (master),
201  _initialized (false),
202  _is_time_dependent (true) // Assume we are time-dependent until the user says otherwise
203 {
204 }
const FunctionBase * _master
Const pointer to our master, initialized to nullptr.
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
bool _is_time_dependent
Cache whether or not this function is actually time-dependent.

◆ FunctionBase() [2/3]

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

The 5 special functions can be defaulted for this class.

◆ FunctionBase() [3/3]

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

◆ ~FunctionBase()

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

Member Function Documentation

◆ clear()

template<typename Output = Number>
virtual void libMesh::FunctionBase< Output >::clear ( )
inlinevirtual

◆ clone()

template<typename Output = Number>
virtual std::unique_ptr<FunctionBase<Output> > libMesh::FunctionBase< Output >::clone ( ) const
pure virtual
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.

Implemented in libMesh::ParsedFunction< Output, OutputGradient >, libMesh::ParsedFunction< T >, TripleFunction, libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction, libMesh::CompositeFunction< Output >, libMesh::MeshFunction, SolutionGradient< dim >, libMesh::ParsedFunction< Output, OutputGradient >, libMesh::ParsedFunction< T >, SolutionGradient< dim >, SolutionGradient< dim >, SolutionGradient< dim >, SolutionGradient< dim >, SolutionGradient< dim >, SolutionGradient< dim >, libMesh::AnalyticFunction< Output >, libMesh::WrappedFunction< Output >, libMesh::GradientMeshFunction, libMesh::MeshlessInterpolationFunction, libMesh::ConstFunction< Output >, BdyFunction, BdyFunction, SolutionFunction< dim >, libMesh::MeshlessInterpolationFunction, SolutionFunction< dim >, SolutionFunction< dim >, SolutionFunction< dim >, libMesh::ZeroFunction< Output >, BdyFunction, ExampleOneFunction, ExampleOneFunction, SolutionFunction< dim >, SolutionFunction< dim >, SolutionFunction< dim >, PeriodicQuadFunction, and SkewFunc.

Referenced by libMesh::ExactErrorEstimator::attach_exact_deriv(), libMesh::ExactSolution::attach_exact_deriv(), libMesh::ExactErrorEstimator::attach_exact_hessian(), libMesh::ExactSolution::attach_exact_hessian(), libMesh::ExactErrorEstimator::attach_exact_value(), libMesh::ExactSolution::attach_exact_value(), libMesh::CompositeFunction< Output >::attach_subfunction(), libMesh::DirichletBoundary::DirichletBoundary(), libMesh::MeshTools::Modification::redistribute(), and libMesh::Poly2TriTriangulator::set_desired_area_function().

◆ component()

template<typename Output >
Output libMesh::FunctionBase< Output >::component ( 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.
The default implementation calls operator() with a DenseVector of size i+1 which will result in unexpected behaviour if operator() makes any access beyond that limit.

Reimplemented in TripleFunction, libMesh::CompositeFunction< Output >, SolutionGradient< dim >, SolutionGradient< dim >, SolutionGradient< dim >, SolutionGradient< dim >, libMesh::ParsedFunction< Output, OutputGradient >, libMesh::ParsedFunction< T >, SolutionGradient< dim >, libMesh::WrappedFunction< Output >, SolutionGradient< dim >, SolutionGradient< dim >, SolutionFunction< dim >, PeriodicQuadFunction, SolutionFunction< dim >, SolutionFunction< dim >, SolutionFunction< dim >, SolutionFunction< dim >, SolutionFunction< dim >, and SolutionFunction< dim >.

Definition at line 232 of file function_base.h.

235 {
236  DenseVector<Output> outvec(i+1);
237  (*this)(p, time, outvec);
238  return outvec(i);
239 }

◆ init()

template<typename Output = Number>
virtual void libMesh::FunctionBase< Output >::init ( )
inlinevirtual

◆ initialized()

template<typename Output >
bool libMesh::FunctionBase< Output >::initialized ( ) const
inline
Returns
true when this object is properly initialized and ready for use, false otherwise.

Definition at line 210 of file function_base.h.

Referenced by libMesh::MeshFunction::MeshFunction().

211 {
212  return (this->_initialized);
213 }
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...

◆ is_time_dependent()

template<typename Output >
bool libMesh::FunctionBase< Output >::is_time_dependent ( ) const
inline
Returns
true when the function this object represents is actually time-dependent, false otherwise.

Definition at line 224 of file function_base.h.

Referenced by libMesh::CompositeFunction< Output >::attach_subfunction(), CompositeFunctionTest::testTimeDependence(), and ParsedFunctionTest::testTimeDependence().

225 {
226  return (this->_is_time_dependent);
227 }
bool _is_time_dependent
Cache whether or not this function is actually time-dependent.

◆ operator()() [1/3]

template<typename Output = Number>
virtual Output libMesh::FunctionBase< Output >::operator() ( const Point p,
const Real  time = 0. 
)
pure virtual

◆ operator()() [2/3]

template<typename Output>
void libMesh::FunctionBase< Output >::operator() ( const Point p,
DenseVector< Output > &  output 
)
inline

Evaluation function for time-independent vector-valued functions.

Sets output values in the passed-in output DenseVector.

Definition at line 245 of file function_base.h.

247 {
248  // Call the time-dependent function with t=0.
249  this->operator()(p, 0., output);
250 }
virtual Output operator()(const Point &p, const Real time=0.)=0

◆ operator()() [3/3]

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ set_is_time_dependent()

template<typename Output >
void libMesh::FunctionBase< Output >::set_is_time_dependent ( bool  is_time_dependent)
inline

Function to set whether this is a time-dependent function or not.

This is intended to be only used by subclasses who cannot natively determine time-dependence. In such a case, this function should be used immediately following construction.

Definition at line 217 of file function_base.h.

218 {
220 }
bool is_time_dependent() const
bool _is_time_dependent
Cache whether or not this function is actually time-dependent.

Member Data Documentation

◆ _initialized

template<typename Output = Number>
bool libMesh::FunctionBase< Output >::_initialized
protected

When init() was called so that everything is ready for calls to operator() (...), then this bool is true.

Definition at line 184 of file function_base.h.

Referenced by libMesh::AnalyticFunction< Output >::AnalyticFunction(), libMesh::ConstFunction< Output >::ConstFunction(), and libMesh::WrappedFunction< Output >::WrappedFunction().

◆ _is_time_dependent

template<typename Output = Number>
bool libMesh::FunctionBase< Output >::_is_time_dependent
protected

Cache whether or not this function is actually time-dependent.

Definition at line 189 of file function_base.h.

Referenced by libMesh::CompositeFunction< Output >::attach_subfunction(), and libMesh::ConstFunction< Output >::ConstFunction().

◆ _master

template<typename Output = Number>
const FunctionBase* libMesh::FunctionBase< Output >::_master
protected

Const pointer to our master, initialized to nullptr.

There may be cases where multiple functions are required, but to save memory, one master handles some centralized data.

Definition at line 178 of file function_base.h.


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