libMesh
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
libMesh::AnalyticFunction< Output > Class Template Reference

Wraps a function pointer into a FunctionBase object. More...

#include <analytic_function.h>

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

Public Types

typedef Output(* OutputFunction) (const Point &p, const Real time)
 Scalar return value function pointer type.
 
typedef void(* OutputVectorFunction) (DenseVector< Output > &output, const Point &p, const Real time)
 Vector return value function pointer type.
 

Public Member Functions

 AnalyticFunction (OutputFunction fptr)
 Constructor.
 
 AnalyticFunction (OutputVectorFunction fptr)
 Constructor.
 
 AnalyticFunction (AnalyticFunction &&)=default
 The 5 special functions can be defaulted for this class.
 
 AnalyticFunction (const AnalyticFunction &)=default
 
AnalyticFunctionoperator= (const AnalyticFunction &)=default
 
AnalyticFunctionoperator= (AnalyticFunction &&)=default
 
virtual ~AnalyticFunction ()=default
 
virtual void init () override
 The actual initialization process.
 
virtual void clear () override
 Clears the function.
 
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.
 
void operator() (const Point &p, DenseVector< Output > &output)
 Evaluation function for time-independent vector-valued functions.
 
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.
 
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.
 
OutputVectorFunction _vector_fptr
 Pointer to user-provided vector valued function.
 

Protected Attributes

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 true.
 
bool _is_time_dependent
 Cache whether or not this function is actually time-dependent.
 

Detailed Description

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

Wraps a function pointer into a FunctionBase object.

This class provides function-like objects for which an analytical expression can be provided. The user may either provide a function pointer that returns a vector or a number. All overridden virtual functions are documented in function_base.h.

Author
Daniel Dreyer
Date
2003

Definition at line 48 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)

Scalar return value function pointer type.

Definition at line 53 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)

Vector return value function pointer type.

Definition at line 62 of file analytic_function.h.

Constructor & Destructor Documentation

◆ AnalyticFunction() [1/4]

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

Constructor.

Takes a function pointer for scalar return values.

Definition at line 140 of file analytic_function.h.

140 :
141 FunctionBase<Output> (),
143 _vector_fptr (nullptr)
144{
146 this->_initialized = true;
147}
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.
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
libmesh_assert(ctx)
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition projection.C:81

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

◆ AnalyticFunction() [2/4]

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

Constructor.

Takes a function pointer for vector valued functions.

Definition at line 153 of file analytic_function.h.

153 :
154 FunctionBase<Output> (),
155 _number_fptr (nullptr),
157{
159 this->_initialized = true;
160}

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

◆ 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 ( )
inlineoverridevirtual

Clears the function.

Reimplemented from libMesh::FunctionBase< Output >.

Definition at line 178 of file analytic_function.h.

179{
180 // We probably need a method to reset these later...
181 _number_fptr = nullptr;
182 _vector_fptr = nullptr;
183
184 // definitely not ready
185 this->_initialized = false;
186}

◆ clone()

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

194{
195 return _number_fptr ?
196 std::make_unique<AnalyticFunction<Output>>(_number_fptr) :
197 std::make_unique<AnalyticFunction<Output>>(_vector_fptr);
198}
AnalyticFunction(OutputFunction fptr)
Constructor.

◆ component()

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.
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 SolutionFunction< dim >, SolutionGradient< dim >, SolutionFunction< dim >, SolutionGradient< dim >, SolutionFunction< dim >, SolutionGradient< dim >, SolutionFunction< dim >, SolutionGradient< dim >, SolutionFunction< dim >, SolutionGradient< dim >, libMesh::CompositeFunction< Output >, libMesh::ParsedFunction< Output, OutputGradient >, libMesh::ParsedFunction< Number >, SolutionFunction< dim >, SolutionGradient< dim >, SolutionFunction< dim >, SolutionGradient< dim >, libMesh::WrappedFunction< Output >, PeriodicQuadFunction, and TripleFunction.

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 >
void libMesh::AnalyticFunction< Output >::init ( )
overridevirtual

The actual initialization process.

Reimplemented from libMesh::FunctionBase< Output >.

Definition at line 165 of file analytic_function.h.

166{
167 // dumb double-test
168 libmesh_assert ((_number_fptr != nullptr) || (_vector_fptr != nullptr));
169
170 // definitely ready
171 this->_initialized = true;
172}

References libMesh::libmesh_assert().

◆ initialized()

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

211{
212 return (this->_initialized);
213}

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

◆ is_time_dependent()

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

Definition at line 224 of file function_base.h.

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

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

◆ operator()() [1/3]

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

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

128{
130 libmesh_assert_msg(_vector_fptr,
131 "You must construct AnalyticFunction with a vector-valued "
132 "function in order to use this operator() override.");
133 this->_vector_fptr(output, p, time);
134 return;
135}

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

◆ operator()() [2/3]

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

113{
115 libmesh_assert_msg(_number_fptr,
116 "You must construct AnalyticFunction with a scalar-valued "
117 "function in order to use this operator() override.");
118 return (this->_number_fptr(p, time));
119}

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

◆ operator()() [3/3]

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 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=() [1/2]

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

◆ operator=() [2/2]

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

◆ set_is_time_dependent()

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

218{
220}
bool is_time_dependent() const

Member Data Documentation

◆ _initialized

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

◆ _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 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
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 178 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 84 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 89 of file analytic_function.h.


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