libMesh
Public Types | 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 Types

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

Public Member Functions

 AnalyticFunction (OutputFunction fptr)
 
 AnalyticFunction (OutputVectorFunction fptr)
 
 AnalyticFunction (AnalyticFunction &&)=default
 The 5 special functions can be defaulted for this class. More...
 
 AnalyticFunction (const AnalyticFunction &)=default
 
AnalyticFunctionoperator= (const AnalyticFunction &)=default
 
AnalyticFunctionoperator= (AnalyticFunction &&)=default
 
virtual ~AnalyticFunction ()=default
 
virtual void init () override
 The actual initialization process. More...
 
virtual void clear () override
 Clears the function. More...
 
virtual std::unique_ptr< FunctionBase< Output > > clone () const override
 
virtual Output operator() (const Point &p, const Real time=0.) override
 
virtual void operator() (const Point &p, const Real time, DenseVector< Output > &output) 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

OutputFunction _number_fptr
 Pointer to user-provided function that computes the boundary values when an analytical expression is available. More...
 
OutputVectorFunction _vector_fptr
 Pointer to user-provided vector valued function. 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::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

◆ OutputFunction

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.

◆ OutputVectorFunction

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

◆ AnalyticFunction() [1/4]

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

Definition at line 130 of file analytic_function.h.

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

130  :
131  FunctionBase<Output> (),
132  _number_fptr (fptr),
133  _vector_fptr (nullptr)
134 {
135  libmesh_assert(fptr);
136  this->_initialized = true;
137 }
OutputFunction _number_fptr
Pointer to user-provided function that computes the boundary values when an analytical expression is ...
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
OutputVectorFunction _vector_fptr
Pointer to user-provided vector valued function.

◆ AnalyticFunction() [2/4]

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

Definition at line 143 of file analytic_function.h.

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

143  :
144  FunctionBase<Output> (),
145  _number_fptr (nullptr),
146  _vector_fptr (fptr)
147 {
148  libmesh_assert(fptr);
149  this->_initialized = true;
150 }
OutputFunction _number_fptr
Pointer to user-provided function that computes the boundary values when an analytical expression is ...
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
OutputVectorFunction _vector_fptr
Pointer to user-provided vector valued function.

◆ AnalyticFunction() [3/4]

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

The 5 special functions can be defaulted for this class.

◆ AnalyticFunction() [4/4]

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

◆ ~AnalyticFunction()

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

Member Function Documentation

◆ clear()

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

Clears the function.

Reimplemented from libMesh::FunctionBase< Output >.

Definition at line 168 of file analytic_function.h.

169 {
170  // We probably need a method to reset these later...
171  _number_fptr = nullptr;
172  _vector_fptr = nullptr;
173 
174  // definitely not ready
175  this->_initialized = false;
176 }
OutputFunction _number_fptr
Pointer to user-provided function that computes the boundary values when an analytical expression is ...
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
OutputVectorFunction _vector_fptr
Pointer to user-provided vector valued function.

◆ clone()

template<typename Output >
std::unique_ptr< FunctionBase< Output > > libMesh::AnalyticFunction< Output >::clone ( ) const
overridevirtual
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 183 of file analytic_function.h.

184 {
185  return std::unique_ptr<FunctionBase<Output>>
186  ( _number_fptr ?
187  new AnalyticFunction<Output>(_number_fptr) :
188  new AnalyticFunction<Output>(_vector_fptr) );
189 }
OutputFunction _number_fptr
Pointer to user-provided function that computes the boundary values when an analytical expression is ...
OutputVectorFunction _vector_fptr
Pointer to user-provided vector valued function.

◆ component()

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 >, libMesh::ParsedFunction< Output, OutputGradient >, libMesh::ParsedFunction< T >, SolutionGradient, SolutionGradient, SolutionGradient, libMesh::WrappedFunction< Output >, SolutionFunction, SolutionFunction, and SolutionFunction.

Definition at line 227 of file function_base.h.

230 {
231  DenseVector<Output> outvec(i+1);
232  (*this)(p, time, outvec);
233  return outvec(i);
234 }

◆ init()

template<typename Output >
void libMesh::AnalyticFunction< Output >::init ( )
overridevirtual

The actual initialization process.

Reimplemented from libMesh::FunctionBase< Output >.

Definition at line 155 of file analytic_function.h.

156 {
157  // dumb double-test
158  libmesh_assert ((_number_fptr != nullptr) || (_vector_fptr != nullptr));
159 
160  // definitely ready
161  this->_initialized = true;
162 }
OutputFunction _number_fptr
Pointer to user-provided function that computes the boundary values when an analytical expression is ...
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
OutputVectorFunction _vector_fptr
Pointer to user-provided vector valued function.

◆ initialized()

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

206 {
207  return (this->_initialized);
208 }
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
inherited
Returns
true when the function this object represents is actually time-dependent, false otherwise.

Definition at line 219 of file function_base.h.

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

220 {
221  return (this->_is_time_dependent);
222 }
bool _is_time_dependent
Cache whether or not this function is actually time-dependent.

◆ operator()() [1/3]

template<typename Output >
Output libMesh::AnalyticFunction< Output >::operator() ( const Point p,
const Real  time = 0. 
)
overridevirtual
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 107 of file analytic_function.h.

References libMesh::initialized().

109 {
110  libmesh_assert (this->initialized());
111  return (this->_number_fptr(p, time));
112 }
OutputFunction _number_fptr
Pointer to user-provided function that computes the boundary values when an analytical expression is ...
bool initialized() const

◆ operator()() [2/3]

template<typename Output >
void libMesh::AnalyticFunction< Output >::operator() ( const Point p,
const Real  time,
DenseVector< Output > &  output 
)
overridevirtual

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 118 of file analytic_function.h.

References libMesh::initialized().

121 {
122  libmesh_assert (this->initialized());
123  this->_vector_fptr(output, p, time);
124  return;
125 }
OutputVectorFunction _vector_fptr
Pointer to user-provided vector valued function.
bool initialized() const

◆ operator()() [3/3]

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

242 {
243  // Call the time-dependent function with t=0.
244  this->operator()(p, 0., output);
245 }
virtual Output operator()(const Point &p, const Real time=0.)=0

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ set_is_time_dependent()

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

213 {
215 }
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
protectedinherited

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

Definition at line 179 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
protectedinherited

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

Definition at line 184 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
protectedinherited

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

◆ _number_fptr

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 80 of file analytic_function.h.

◆ _vector_fptr

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

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: