libMesh::ConstFunction< Output > Class Template Reference

Function that returns a single value that never changes. More...

#include <const_function.h>

Inheritance diagram for libMesh::ConstFunction< Output >:

Public Member Functions

 ConstFunction (const Output &c)
 
 ConstFunction (ConstFunction &&)=default
 
 ConstFunction (const ConstFunction &)=default
 
ConstFunctionoperator= (const ConstFunction &)=default
 
ConstFunctionoperator= (ConstFunction &&)=default
 
virtual ~ConstFunction ()=default
 
virtual Output operator() (const Point &, const Real=0) override
 
virtual void operator() (const Point &, const Real, DenseVector< Output > &output) override
 
virtual std::unique_ptr< FunctionBase< Output > > clone () const override
 
virtual void init ()
 
virtual void clear ()
 
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
 

Protected Attributes

const FunctionBase_master
 
bool _initialized
 
bool _is_time_dependent
 

Private Attributes

Output _c
 

Detailed Description

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

Function that returns a single value that never changes.

Function that returns a single value that never changes. All overridden virtual functions are documented in function_base.h.

Author
Roy Stogner
Date
2012

Definition at line 42 of file const_function.h.

Constructor & Destructor Documentation

◆ ConstFunction() [1/3]

template<typename Output = Number>
libMesh::ConstFunction< Output >::ConstFunction ( const Output &  c)
inlineexplicit

◆ ConstFunction() [2/3]

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

The 5 special functions can be defaulted for this class.

◆ ConstFunction() [3/3]

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

◆ ~ConstFunction()

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

Member Function Documentation

◆ clear()

template<typename Output = Number>
virtual void libMesh::FunctionBase< Output >::clear ( )
inlinevirtualinherited

◆ clone()

template<typename Output = Number>
virtual std::unique_ptr<FunctionBase<Output> > libMesh::ConstFunction< 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 >.

Reimplemented in libMesh::ZeroFunction< Output >.

Definition at line 74 of file const_function.h.

References libMesh::ConstFunction< Output >::_c.

75  {
76  return std::unique_ptr<FunctionBase<Output>>
77  (new ConstFunction<Output>(_c));
78  }

◆ 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.

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

Definition at line 228 of file function_base.h.

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

◆ init()

template<typename Output = Number>
virtual void libMesh::FunctionBase< Output >::init ( )
inlinevirtualinherited

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

207 {
208  return (this->_initialized);
209 }

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

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

221 {
222  return (this->_is_time_dependent);
223 }

◆ operator()() [1/3]

template<typename Output = Number>
virtual Output libMesh::ConstFunction< 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 61 of file const_function.h.

References libMesh::ConstFunction< Output >::_c.

63  { return _c; }

◆ operator()() [2/3]

template<typename Output = Number>
virtual void libMesh::ConstFunction< 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 65 of file const_function.h.

References libMesh::ConstFunction< Output >::_c, and libMesh::DenseVector< T >::size().

68  {
69  unsigned int size = output.size();
70  for (unsigned int i=0; i != size; ++i)
71  output(i) = _c;
72  }
virtual unsigned int size() const override
Definition: dense_vector.h:92

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

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

template<typename Output = Number>
ConstFunction& libMesh::ConstFunction< Output >::operator= ( ConstFunction< 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 213 of file function_base.h.

214 {
216 }
bool is_time_dependent() const

Member Data Documentation

◆ _c

template<typename Output = Number>
Output libMesh::ConstFunction< Output >::_c
private

◆ _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 180 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 185 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 174 of file function_base.h.


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