libMesh::AnalyticFunction< Output > Class Template Reference

#include <analytic_function.h>

Inheritance diagram for libMesh::AnalyticFunction< Output >:

Public Types

typedef Output(* OutputFunction) (const Point &p, const Real time)
 
typedef void(* OutputVectorFunction) (DenseVector< Output > &output, const Point &p, const Real time)
 

Public Member Functions

 AnalyticFunction (OutputFunction fptr)
 
 AnalyticFunction (OutputVectorFunction fptr)
 
 ~AnalyticFunction ()
 
virtual void init () libmesh_override
 
virtual void clear () libmesh_override
 
virtual std::unique_ptr< 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
 
void operator() (const Point &p, DenseVector< Output > &output)
 
virtual Output component (unsigned int i, const Point &p, Real time=0.)
 
bool initialized () const
 
void set_is_time_dependent (bool is_time_dependent)
 
bool is_time_dependent () const
 

Public Attributes

OutputFunction _number_fptr
 
OutputVectorFunction _vector_fptr
 

Protected Attributes

const FunctionBase_master
 
bool _initialized
 
bool _is_time_dependent
 

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.

Member Typedef Documentation

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

Constructor. Takes a function pointer for scalar return values.

Definition at line 54 of file analytic_function.h.

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

Constructor. Takes a function pointer for vector valued functions.

Definition at line 61 of file analytic_function.h.

Constructor & Destructor Documentation

template<typename Output >
libMesh::AnalyticFunction< Output >::AnalyticFunction ( OutputFunction  fptr)

Definition at line 127 of file analytic_function.h.

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

127  :
128  FunctionBase<Output> (),
129  _number_fptr (fptr),
131 {
132  libmesh_assert(fptr);
133  this->_initialized = true;
134 }
const class libmesh_nullptr_t libmesh_nullptr
OutputVectorFunction _vector_fptr
template<typename Output >
libMesh::AnalyticFunction< Output >::AnalyticFunction ( OutputVectorFunction  fptr)
inline

Definition at line 140 of file analytic_function.h.

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

140  :
141  FunctionBase<Output> (),
143  _vector_fptr (fptr)
144 {
145  libmesh_assert(fptr);
146  this->_initialized = true;
147 }
const class libmesh_nullptr_t libmesh_nullptr
OutputVectorFunction _vector_fptr
template<typename Output >
libMesh::AnalyticFunction< Output >::~AnalyticFunction ( )
inline

Destructor.

Definition at line 153 of file analytic_function.h.

154 {
155 }

Member Function Documentation

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

Clears the function.

Reimplemented from libMesh::FunctionBase< Output >.

Definition at line 173 of file analytic_function.h.

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

174 {
175  // We probably need a method to reset these later...
178 
179  // definitely not ready
180  this->_initialized = false;
181 }
const class libmesh_nullptr_t libmesh_nullptr
OutputVectorFunction _vector_fptr
template<typename Output >
std::unique_ptr< FunctionBase< Output > > libMesh::AnalyticFunction< 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::FunctionBase< Output >.

Definition at line 188 of file analytic_function.h.

References libMesh::AnalyticFunction< Output >::_number_fptr.

189 {
190  return std::unique_ptr<FunctionBase<Output>>
191  ( _number_fptr ?
192  new AnalyticFunction<Output>(_number_fptr) :
193  new AnalyticFunction<Output>(_vector_fptr) );
194 }
OutputVectorFunction _vector_fptr
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.
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 >, libMesh::ParsedFunction< Output, OutputGradient >, libMesh::ParsedFunction< T >, and libMesh::WrappedFunction< Output >.

Definition at line 231 of file function_base.h.

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

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

The actual initialization process.

Reimplemented from libMesh::FunctionBase< Output >.

Definition at line 160 of file analytic_function.h.

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

161 {
162  // dumb double-test
163  libmesh_assert ((_number_fptr != libmesh_nullptr) || (_vector_fptr != libmesh_nullptr));
164 
165  // definitely ready
166  this->_initialized = true;
167 }
const class libmesh_nullptr_t libmesh_nullptr
OutputVectorFunction _vector_fptr
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 209 of file function_base.h.

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

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

210 {
211  return (this->_initialized);
212 }
template<typename Output >
bool libMesh::FunctionBase< Output >::is_time_dependent ( ) const
inlineinherited
template<typename Output >
Output libMesh::AnalyticFunction< Output >::operator() ( 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::FunctionBase< Output >.

Definition at line 104 of file analytic_function.h.

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

106 {
107  libmesh_assert (this->initialized());
108  return (this->_number_fptr(p, time));
109 }
bool initialized() const
template<typename Output >
void libMesh::AnalyticFunction< Output >::operator() ( 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::FunctionBase< Output >.

Definition at line 115 of file analytic_function.h.

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

118 {
119  libmesh_assert (this->initialized());
120  this->_vector_fptr(output, p, time);
121  return;
122 }
bool initialized() const
OutputVectorFunction _vector_fptr
template<typename Output>
void libMesh::FunctionBase< Output >::operator() ( 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 244 of file function_base.h.

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

246 {
247  // Call the time-dependent function with t=0.
248  this->operator()(p, 0., output);
249 }
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)
inlineinherited

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 216 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().

217 {
219 }
bool is_time_dependent() const

Member Data Documentation

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

template<typename Output = Number>
OutputFunction libMesh::AnalyticFunction< Output >::_number_fptr

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

Definition at line 77 of file analytic_function.h.

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

template<typename Output = Number>
OutputVectorFunction libMesh::AnalyticFunction< Output >::_vector_fptr

Pointer to user-provided vector valued function.

Definition at line 82 of file analytic_function.h.

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


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