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

This class provides function-like objects for which an analytical expression can be provided. More...

#include <analytic_function.h>

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

Public Member Functions

 AnalyticFunction (Output fptr(const Point &p, const Real time))
 Constructor. More...
 
 AnalyticFunction (void fptr(DenseVector< Output > &output, const Point &p, const Real time))
 Constructor. More...
 
 ~AnalyticFunction ()
 Destructor. More...
 
virtual void init () libmesh_override
 The actual initialization process. More...
 
virtual void clear () libmesh_override
 Clears the function. More...
 
virtual UniquePtr< FunctionBase< Output > > clone () const libmesh_override
 
virtual Output operator() (const Point &p, const Real time=0.) libmesh_override
 
virtual void operator() (const Point &p, const Real time, DenseVector< Output > &output) libmesh_override
 Evaluation function for time-dependent vector-valued functions. More...
 
void operator() (const Point &p, DenseVector< Output > &output)
 Evaluation function for time-independent 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
 

Public Attributes

Output(* _number_fptr )(const Point &p, const Real time)
 Pointer to user-provided function that computes the boundary values when an analytical expression is available. More...
 
void(* _vector_fptr )(DenseVector< Output > &output, const Point &p, const Real time)
 Pointer to user-provided vector valued function. More...
 

Protected Attributes

const FunctionBase_master
 Const pointer to our master, initialized to NULL. 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::AnalyticFunction< Output >

This class provides function-like objects for which an analytical expression can be provided.

The user may either provide vector-return or number-return functions. All overridden virtual functions are documented in function_base.h.

Author
Daniel Dreyer
Date
2003

Definition at line 46 of file analytic_function.h.

Constructor & Destructor Documentation

template<typename Output = Number>
libMesh::AnalyticFunction< Output >::AnalyticFunction ( Output   fptrconst Point &p, const Real time)

Constructor.

Takes a function pointer for scalar return values.

Referenced by libMesh::AnalyticFunction< Output >::operator()().

template<typename Output = Number>
libMesh::AnalyticFunction< Output >::AnalyticFunction ( void   fptrDenseVector< Output > &output, const Point &p, const Real time)

Constructor.

Takes a function pointer for vector valued functions.

template<typename Output >
libMesh::AnalyticFunction< Output >::~AnalyticFunction ( )

Destructor.

Definition at line 157 of file analytic_function.h.

158 {
159 }

Member Function Documentation

template<typename Output >
void libMesh::AnalyticFunction< Output >::clear ( )
virtual

Clears the function.

Reimplemented from libMesh::FunctionBase< Output >.

Definition at line 177 of file analytic_function.h.

References libMesh::FunctionBase< Output >::_initialized, libMesh::AnalyticFunction< Output >::_number_fptr, libMesh::AnalyticFunction< Output >::_vector_fptr, and libmesh_nullptr.

178 {
179  // We probably need a method to reset these later...
182 
183  // definitely not ready
184  this->_initialized = false;
185 }
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
const class libmesh_nullptr_t libmesh_nullptr
void(* _vector_fptr)(DenseVector< Output > &output, const Point &p, const Real time)
Pointer to user-provided vector valued function.
Output(* _number_fptr)(const Point &p, const Real time)
Pointer to user-provided function that computes the boundary values when an analytical expression is ...
template<typename Output >
UniquePtr< FunctionBase< Output > > libMesh::AnalyticFunction< Output >::clone ( ) const
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.

Implements libMesh::FunctionBase< Output >.

Definition at line 192 of file analytic_function.h.

References libMesh::AnalyticFunction< Output >::_number_fptr, and libMesh::AnalyticFunction< Output >::_vector_fptr.

193 {
194  return UniquePtr<FunctionBase<Output>>
195  ( _number_fptr ?
196  new AnalyticFunction<Output>(_number_fptr) :
197  new AnalyticFunction<Output>(_vector_fptr) );
198 }
void(* _vector_fptr)(DenseVector< Output > &output, const Point &p, const Real time)
Pointer to user-provided vector valued function.
Output(* _number_fptr)(const Point &p, const Real time)
Pointer to user-provided function that computes the boundary values when an analytical expression is ...
template<typename Output >
Output libMesh::FunctionBase< Output >::component ( unsigned int  i,
const Point p,
Real  time = 0. 
)
virtualinherited
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 in libMesh::CompositeFunction< Output >, SolutionGradient, SolutionGradient, SolutionGradient, libMesh::ParsedFunction< Output, OutputGradient >, libMesh::ParsedFunction< T >, libMesh::WrappedFunction< Output >, SolutionFunction, SolutionFunction, and SolutionFunction.

Definition at line 230 of file function_base.h.

Referenced by libMesh::FunctionBase< Real >::clear().

233 {
234  DenseVector<Output> outvec(i+1);
235  (*this)(p, time, outvec);
236  return outvec(i);
237 }
template<typename Output >
void libMesh::AnalyticFunction< Output >::init ( )
virtual

The actual initialization process.

Reimplemented from libMesh::FunctionBase< Output >.

Definition at line 164 of file analytic_function.h.

References libMesh::FunctionBase< Output >::_initialized, libMesh::AnalyticFunction< Output >::_number_fptr, libMesh::AnalyticFunction< Output >::_vector_fptr, libMesh::libmesh_assert(), and libmesh_nullptr.

165 {
166  // dumb double-test
168 
169  // definitely ready
170  this->_initialized = true;
171 }
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
void(* _vector_fptr)(DenseVector< Output > &output, const Point &p, const Real time)
Pointer to user-provided vector valued function.
Output(* _number_fptr)(const Point &p, const Real time)
Pointer to user-provided function that computes the boundary values when an analytical expression is ...
template<typename Output >
bool libMesh::FunctionBase< Output >::initialized ( ) const
inherited
Returns
true when this object is properly initialized and ready for use, false otherwise.

Definition at line 208 of file function_base.h.

References libMesh::FunctionBase< Output >::_initialized.

Referenced by libMesh::FunctionBase< Real >::clear(), and libMesh::AnalyticFunction< Output >::operator()().

209 {
210  return (this->_initialized);
211 }
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
template<typename Output >
bool libMesh::FunctionBase< Output >::is_time_dependent ( ) const
inherited
template<typename Output >
Output libMesh::AnalyticFunction< Output >::operator() ( const Point p,
const Real  time = 0. 
)
virtual
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::FunctionBase< Output >.

Definition at line 105 of file analytic_function.h.

References libMesh::AnalyticFunction< Output >::_number_fptr, libMesh::FunctionBase< Output >::initialized(), and libMesh::libmesh_assert().

107 {
108  libmesh_assert (this->initialized());
109  return (this->_number_fptr(p, time));
110 }
bool initialized() const
libmesh_assert(j)
Output(* _number_fptr)(const Point &p, const Real time)
Pointer to user-provided function that computes the boundary values when an analytical expression is ...
template<typename Output >
void libMesh::AnalyticFunction< Output >::operator() ( const Point p,
const Real  time,
DenseVector< Output > &  output 
)
virtual

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::FunctionBase< Output >.

Definition at line 116 of file analytic_function.h.

References libMesh::FunctionBase< Output >::_initialized, libMesh::AnalyticFunction< Output >::_number_fptr, libMesh::AnalyticFunction< Output >::_vector_fptr, libMesh::AnalyticFunction< Output >::AnalyticFunction(), fptr(), libMesh::FunctionBase< Output >::initialized(), libMesh::libmesh_assert(), libmesh_nullptr, and libMesh::Real.

119 {
120  libmesh_assert (this->initialized());
121  this->_vector_fptr(output, p, time);
122  return;
123 }
bool initialized() const
libmesh_assert(j)
void(* _vector_fptr)(DenseVector< Output > &output, const Point &p, const Real time)
Pointer to user-provided vector valued function.
template<typename Output>
void libMesh::FunctionBase< Output >::operator() ( const Point p,
DenseVector< Output > &  output 
)
inherited

Evaluation function for time-independent vector-valued functions.

Sets output values in the passed-in output DenseVector.

Definition at line 243 of file function_base.h.

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

245 {
246  // Call the time-dependent function with t=0.
247  this->operator()(p, 0., output);
248 }
virtual Output operator()(const Point &p, const Real time=0.)=0
template<typename Output >
void libMesh::FunctionBase< Output >::set_is_time_dependent ( bool  is_time_dependent)
inherited

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 215 of file function_base.h.

References libMesh::FunctionBase< Output >::_is_time_dependent, and libMesh::FunctionBase< Output >::is_time_dependent().

Referenced by libMesh::FunctionBase< Real >::clear().

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

Member Data Documentation

template<typename Output = Number>
bool libMesh::FunctionBase< Output >::_initialized
protectedinherited
template<typename Output = Number>
bool libMesh::FunctionBase< Output >::_is_time_dependent
protectedinherited
template<typename Output = Number>
const FunctionBase* libMesh::FunctionBase< Output >::_master
protectedinherited

Const pointer to our master, initialized to NULL.

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

Definition at line 168 of file function_base.h.

template<typename Output = Number>
Output(* libMesh::AnalyticFunction< Output >::_number_fptr) (const Point &p, const Real time)

Pointer to user-provided function that computes the boundary values when an analytical expression is available.

Definition at line 75 of file analytic_function.h.

Referenced by libMesh::AnalyticFunction< Output >::clear(), libMesh::AnalyticFunction< Output >::clone(), libMesh::AnalyticFunction< Output >::init(), and libMesh::AnalyticFunction< Output >::operator()().

template<typename Output = Number>
void(* libMesh::AnalyticFunction< Output >::_vector_fptr) (DenseVector< Output > &output, const Point &p, const Real time)

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