libMesh::AnalyticFunction< Output > Class Template Reference

#include <analytic_function.h>

Inheritance diagram for libMesh::AnalyticFunction< Output >:

Public Member Functions

 AnalyticFunction (Output fptr(const Point &p, const Real time))
 
 AnalyticFunction (void fptr(DenseVector< Output > &output, const Point &p, const Real time))
 
 ~AnalyticFunction ()
 
void init ()
 
void clear ()
 
virtual AutoPtr< FunctionBase
< Output > > 
clone () const
 
Output operator() (const Point &p, const Real time=0.)
 
void operator() (const Point &p, const Real time, DenseVector< Output > &output)
 
void operator() (const Point &p, DenseVector< Output > &output)
 
virtual Output component (unsigned int i, const Point &p, Real time=0.)
 
bool initialized () const
 

Public Attributes

Output(* _number_fptr )(const Point &p, const Real time)
 
void(* _vector_fptr )(DenseVector< Output > &output, const Point &p, const Real time)
 

Protected Attributes

const FunctionBase_master
 
bool _initialized
 

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.

Author
Daniel Dreyer, 2003

Definition at line 50 of file analytic_function.h.

Constructor & Destructor Documentation

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

Constructor. Takes a function pointer for scalar return values.

Definition at line 150 of file analytic_function.h.

References libMesh::FunctionBase< Output >::_initialized, and libMesh::libmesh_assert().

151  :
152  FunctionBase<Output> (),
153  _number_fptr (fptr),
154  _vector_fptr (NULL)
155 {
156  libmesh_assert(fptr);
157  this->_initialized = true;
158 }
template<typename Output >
libMesh::AnalyticFunction< Output >::AnalyticFunction ( void   fptrDenseVector< Output > &output,const Point &p,const Real time)
inline

Constructor. Takes a function pointer for vector valued functions.

Definition at line 164 of file analytic_function.h.

References libMesh::FunctionBase< Output >::_initialized, and libMesh::libmesh_assert().

166  :
167  FunctionBase<Output> (),
168  _number_fptr (NULL),
169  _vector_fptr (fptr)
170 {
171  libmesh_assert(fptr);
172  this->_initialized = true;
173 }
template<typename Output >
libMesh::AnalyticFunction< Output >::~AnalyticFunction ( )
inline

Destructor.

Definition at line 179 of file analytic_function.h.

180 {
181 }

Member Function Documentation

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

Clears the function.

Reimplemented from libMesh::FunctionBase< Output >.

Definition at line 199 of file analytic_function.h.

200 {
201  // We probably need a method to reset these later...
202  _number_fptr = NULL;
203  _vector_fptr = NULL;
204 
205  // definitely not ready
206  this->_initialized = false;
207 }
template<typename Output >
AutoPtr< FunctionBase< Output > > libMesh::AnalyticFunction< Output >::clone ( ) const
inlinevirtual

Returns a new deep copy of the function.

Implements libMesh::FunctionBase< Output >.

Definition at line 214 of file analytic_function.h.

215 {
216  return AutoPtr<FunctionBase<Output> >
217  ( _number_fptr ?
218  new AnalyticFunction<Output>(_number_fptr) :
219  new AnalyticFunction<Output>(_vector_fptr) );
220 }
template<typename Output >
Output libMesh::FunctionBase< Output >::component ( unsigned int  i,
const Point p,
Real  time = 0. 
)
inlinevirtualinherited
Returns
the vector component i at coordinate p and time time. Subclasses aren't required to overload this, since the default implementation is based on the full vector evaluation, which is often correct. Subclasses are recommended to overload this, since the default implementation is based on a vector evaluation, which is usually unnecessarily inefficient.

Reimplemented in libMesh::ParsedFunction< Output >, and libMesh::WrappedFunction< Output >.

Definition at line 203 of file function_base.h.

Referenced by libMesh::ProjectSolution::operator()(), libMesh::ProjectFEMSolution::operator()(), and libMesh::BoundaryProjectSolution::operator()().

206 {
207  DenseVector<Output> outvec(i+1);
208  (*this)(p, time, outvec);
209  return outvec(i);
210 }
template<typename Output >
void libMesh::AnalyticFunction< Output >::init ( )
virtual

The actual initialization process.

Reimplemented from libMesh::FunctionBase< Output >.

Definition at line 186 of file analytic_function.h.

References libMesh::libmesh_assert().

187 {
188  // dumb double-test
189  libmesh_assert ((_number_fptr != NULL) || (_vector_fptr != NULL));
190 
191  // definitely ready
192  this->_initialized = true;
193 }
template<typename Output >
bool libMesh::FunctionBase< Output >::initialized ( ) const
inlineinherited
Returns
true when this object is properly initialized and ready for use, false otherwise.

Definition at line 194 of file function_base.h.

195 {
196  return (this->_initialized);
197 }
template<typename Output >
Output libMesh::AnalyticFunction< Output >::operator() ( const Point p,
const Real  time = 0. 
)
inlinevirtual
Returns
the value at point p and time time, which defaults to zero.

Implements libMesh::FunctionBase< Output >.

Definition at line 127 of file analytic_function.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

129 {
130  libmesh_assert (this->initialized());
131  return (this->_number_fptr(p, time));
132 }
template<typename Output >
void libMesh::AnalyticFunction< Output >::operator() ( const Point p,
const Real  time,
DenseVector< Output > &  output 
)
inlinevirtual

Like before, but returns the values in a writable reference.

Implements libMesh::FunctionBase< Output >.

Definition at line 138 of file analytic_function.h.

References libMesh::initialized(), and libMesh::libmesh_assert().

141 {
142  libmesh_assert (this->initialized());
143  this->_vector_fptr(output, p, time);
144  return;
145 }
template<typename Output>
void libMesh::FunctionBase< Output >::operator() ( const Point p,
DenseVector< Output > &  output 
)
inlineinherited

Return function for vectors. Returns in output the values of the data at the coordinate p.

Definition at line 216 of file function_base.h.

218 {
219  // Call the time-dependent function with t=0.
220  this->operator()(p, 0., output);
221 }

Member Data Documentation

template<typename Output>
bool libMesh::FunctionBase< Output >::_initialized
protectedinherited

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

Definition at line 166 of file function_base.h.

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

template<typename Output>
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 160 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 79 of file analytic_function.h.

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

Pointer to user-provided vector valued function.

Definition at line 85 of file analytic_function.h.


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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:58 UTC

Hosted By:
SourceForge.net Logo