Reference documentation for deal.II version 9.1.0-pre
Public Member Functions | Private Attributes | List of all members
VectorFunctionFromScalarFunctionObject< dim, RangeNumberType > Class Template Reference

#include <deal.II/base/function.h>

Inheritance diagram for VectorFunctionFromScalarFunctionObject< dim, RangeNumberType >:
[legend]

Public Member Functions

 VectorFunctionFromScalarFunctionObject (const std::function< RangeNumberType(const Point< dim > &)> &function_object, const unsigned int selected_component, const unsigned int n_components)
 
virtual RangeNumberType value (const Point< dim > &p, const unsigned int component=0) const override
 
virtual void vector_value (const Point< dim > &p, Vector< RangeNumberType > &values) const override
 
- Public Member Functions inherited from Function< dim, RangeNumberType >
 Function (const unsigned int n_components=1, const RangeNumberType initial_time=0.0)
 
virtual ~Function () override=0
 
Functionoperator= (const Function &f)
 
virtual void value_list (const std::vector< Point< dim >> &points, std::vector< RangeNumberType > &values, const unsigned int component=0) const
 
virtual void vector_value_list (const std::vector< Point< dim >> &points, std::vector< Vector< RangeNumberType >> &values) const
 
virtual void vector_values (const std::vector< Point< dim >> &points, std::vector< std::vector< RangeNumberType >> &values) const
 
virtual Tensor< 1, dim, RangeNumberType > gradient (const Point< dim > &p, const unsigned int component=0) const
 
virtual void vector_gradient (const Point< dim > &p, std::vector< Tensor< 1, dim, RangeNumberType >> &gradients) const
 
virtual void gradient_list (const std::vector< Point< dim >> &points, std::vector< Tensor< 1, dim, RangeNumberType >> &gradients, const unsigned int component=0) const
 
virtual void vector_gradients (const std::vector< Point< dim >> &points, std::vector< std::vector< Tensor< 1, dim, RangeNumberType >>> &gradients) const
 
virtual void vector_gradient_list (const std::vector< Point< dim >> &points, std::vector< std::vector< Tensor< 1, dim, RangeNumberType >>> &gradients) const
 
virtual RangeNumberType laplacian (const Point< dim > &p, const unsigned int component=0) const
 
virtual void vector_laplacian (const Point< dim > &p, Vector< RangeNumberType > &values) const
 
virtual void laplacian_list (const std::vector< Point< dim >> &points, std::vector< RangeNumberType > &values, const unsigned int component=0) const
 
virtual void vector_laplacian_list (const std::vector< Point< dim >> &points, std::vector< Vector< RangeNumberType >> &values) const
 
virtual SymmetricTensor< 2, dim, RangeNumberType > hessian (const Point< dim > &p, const unsigned int component=0) const
 
virtual void vector_hessian (const Point< dim > &p, std::vector< SymmetricTensor< 2, dim, RangeNumberType >> &values) const
 
virtual void hessian_list (const std::vector< Point< dim >> &points, std::vector< SymmetricTensor< 2, dim, RangeNumberType >> &values, const unsigned int component=0) const
 
virtual void vector_hessian_list (const std::vector< Point< dim >> &points, std::vector< std::vector< SymmetricTensor< 2, dim, RangeNumberType >>> &values) const
 
std::size_t memory_consumption () const
 
- Public Member Functions inherited from FunctionTime< RangeNumberType >
 FunctionTime (const RangeNumberTypeinitial_time=RangeNumberType(0.0))
 
virtual ~FunctionTime ()=default
 
RangeNumberType get_time () const
 
virtual void set_time (const RangeNumberTypenew_time)
 
virtual void advance_time (const RangeNumberTypedelta_t)
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
 Subscriptor (Subscriptor &&) noexcept
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
Subscriptoroperator= (Subscriptor &&) noexcept
 
void subscribe (const char *identifier=nullptr) const
 
void unsubscribe (const char *identifier=nullptr) const
 
unsigned int n_subscriptions () const
 
template<typename StreamType >
void list_subscribers (StreamType &stream) const
 
void list_subscribers () const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

const std::function< RangeNumberType(const Point< dim > &)> function_object
 
const unsigned int selected_component
 

Additional Inherited Members

- Static Public Member Functions inherited from Subscriptor
static::ExceptionBase & ExcInUse (int arg1, std::string arg2, std::string arg3)
 
static::ExceptionBase & ExcNoSubscriber (std::string arg1, std::string arg2)
 
- Public Attributes inherited from Function< dim, RangeNumberType >
const unsigned int n_components
 
- Static Public Attributes inherited from Function< dim, RangeNumberType >
static const unsigned int dimension = dim
 

Detailed Description

template<int dim, typename RangeNumberType = double>
class VectorFunctionFromScalarFunctionObject< dim, RangeNumberType >

This class is similar to the ScalarFunctionFromFunctionObject class in that it allows for the easy conversion of a function object to something that satisfies the interface of the Function base class. The difference is that here, the given function object is still a scalar function (i.e. it has a single value at each space point) but that the Function object generated is vector valued. The number of vector components is specified in the constructor, where one also selects a single one of these vector components that should be filled by the passed object. The result is a vector Function object that returns zero in each component except the single selected one where it returns the value returned by the given as the first argument to the constructor.

Note
In the above discussion, note the difference between the (scalar) "function object" (i.e., a C++ object x that can be called as in x(p)) and the capitalized (vector valued) "Function object" (i.e., an object of a class that is derived from the Function base class).

To be more concrete, let us consider the following example:

RangeNumberType
one(const Point<2> &p)
{
return 1.0;
}
VectorFunctionFromScalarFunctionObject<2> component_mask(&one, 1, 3);

Here, component_mask then represents a Function object that for every point returns the vector \((0, 1, 0)^T\), i.e. a mask function that could, for example, be passed to VectorTools::integrate_difference(). This effect can also be achieved using the ComponentSelectFunction class but is obviously easily extended to functions that are non-constant in their one component.

Author
Wolfgang Bangerth, 2011

Definition at line 768 of file function.h.

Constructor & Destructor Documentation

template<int dim, typename RangeNumberType = double>
VectorFunctionFromScalarFunctionObject< dim, RangeNumberType >::VectorFunctionFromScalarFunctionObject ( const std::function< RangeNumberType(const Point< dim > &)> &  function_object,
const unsigned int  selected_component,
const unsigned int  n_components 
)

Given a function object that takes a Point and returns a RangeNumberType value, convert this into an object that matches the Function<dim> interface.

Parameters
function_objectThe scalar function that will form one component of the resulting Function object.
n_componentsThe total number of vector components of the resulting Function object.
selected_componentThe single component that should be filled by the first argument.

Member Function Documentation

template<int dim, typename RangeNumberType = double>
virtual RangeNumberType VectorFunctionFromScalarFunctionObject< dim, RangeNumberType >::value ( const Point< dim > &  p,
const unsigned int  component = 0 
) const
overridevirtual

Return the value of the function at the given point. Returns the value the function given to the constructor produces for this point.

Reimplemented from Function< dim, RangeNumberType >.

template<int dim, typename RangeNumberType = double>
virtual void VectorFunctionFromScalarFunctionObject< dim, RangeNumberType >::vector_value ( const Point< dim > &  p,
Vector< RangeNumberType > &  values 
) const
overridevirtual

Return all components of a vector-valued function at a given point.

values shall have the right size beforehand, i.e. n_components.

Reimplemented from Function< dim, RangeNumberType >.

Member Data Documentation

template<int dim, typename RangeNumberType = double>
const std::function<RangeNumberType(const Point<dim> &)> VectorFunctionFromScalarFunctionObject< dim, RangeNumberType >::function_object
private

The function object which we call when this class's value() or value_list() functions are called.

Definition at line 810 of file function.h.

template<int dim, typename RangeNumberType = double>
const unsigned int VectorFunctionFromScalarFunctionObject< dim, RangeNumberType >::selected_component
private

The vector component whose value is to be filled by the given scalar function.

Definition at line 816 of file function.h.


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