Public Member Functions | |
ConstantFunction (const double value, const unsigned int n_components=1) | |
virtual | ~ConstantFunction () |
virtual double | value (const Point< dim > &p, const unsigned int component) const |
virtual void | vector_value (const Point< dim > &p, Vector< double > &return_value) const |
virtual void | value_list (const std::vector< Point< dim > > &points, std::vector< double > &values, const unsigned int component=0) const |
virtual void | vector_value_list (const std::vector< Point< dim > > &points, std::vector< Vector< double > > &values) const |
unsigned int | memory_consumption () const |
Protected Attributes | |
const double | function_value |
Provide a function which always returns the constant value handed to the constructor.
Obviously, the derivates of this function are zero, which is why we derive this class from ZeroFunction
: we then only have to overload the value functions, not all the derivatives. In some way, it would be more obvious to do the derivation in the opposite direction, i.e. let ZeroFunction
be a more specialized version of ConstantFunction
; however, this would be less efficient, since we could not make use of the fact that the function value of the ZeroFunction
is known at compile time and need not be looked up somewhere in memory.
You can pass to the constructor an integer denoting the number of components this function shall have. It defaults to one. If it is greater than one, then the function will return the constant value in all its components, which might not be overly useful a feature in most cases, however.
ConstantFunction< dim >::ConstantFunction | ( | const double | value, | |
const unsigned int | n_components = 1 | |||
) |
Constructor; takes the constant function value as an argument. The number of components is preset to one.
virtual ConstantFunction< dim >::~ConstantFunction | ( | ) | [virtual] |
Virtual destructor; absolutely necessary in this case.
virtual double ConstantFunction< dim >::value | ( | const Point< dim > & | p, | |
const unsigned int | component | |||
) | const [virtual] |
Return the value of the function at the given point for one component.
Reimplemented from ZeroFunction< dim >.
virtual void ConstantFunction< dim >::vector_value | ( | const Point< dim > & | p, | |
Vector< double > & | return_value | |||
) | const [virtual] |
Return the value of the function at the given point for all components.
Reimplemented from ZeroFunction< dim >.
Reimplemented in ComponentSelectFunction< dim >.
virtual void ConstantFunction< dim >::value_list | ( | const std::vector< Point< dim > > & | points, | |
std::vector< double > & | values, | |||
const unsigned int | component = 0 | |||
) | const [virtual] |
Set values
to the point values of the function at the points
, for the given component. It is assumed that values
already has the right size, i.e. the same size as the points
array.
Reimplemented from ZeroFunction< dim >.
virtual void ConstantFunction< dim >::vector_value_list | ( | const std::vector< Point< dim > > & | points, | |
std::vector< Vector< double > > & | values | |||
) | const [virtual] |
Set values
to the point values of the function at the points
, for all components. It is assumed that values
already has the right size, i.e. the same size as the points
array.
Reimplemented from ZeroFunction< dim >.
Reimplemented in ComponentSelectFunction< dim >.
unsigned int ConstantFunction< dim >::memory_consumption | ( | ) | const |
Determine an estimate for the memory consumption (in bytes) of this object. Since sometimes the size of objects can not be determined exactly (for example: what is the memory consumption of an STL std::map
type with a certain number of elements?), this is only an estimate. however often quite close to the true value.
Reimplemented from Function< dim >.
Reimplemented in ComponentSelectFunction< dim >.
const double ConstantFunction< dim >::function_value [protected] |
Store the constant function value.