Reference documentation for deal.II version 9.6.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Functions::SymbolicFunction< dim, RangeNumberType > Class Template Reference

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

Inheritance diagram for Functions::SymbolicFunction< dim, RangeNumberType >:

Public Types

using time_type
 

Public Member Functions

 SymbolicFunction (const std::vector< Differentiation::SD::Expression > &function, const Tensor< 1, dim, Differentiation::SD::Expression > &coordinate_symbols=get_default_coordinate_symbols(), const Differentiation::SD::Expression &time_symbol=Differentiation::SD::make_symbol("t"), const Differentiation::SD::types::substitution_map &user_substitution_map={})
 
 SymbolicFunction (const std::string &expressions)
 
void update_user_substitution_map (const Differentiation::SD::types::substitution_map &substitutions)
 
void set_additional_function_arguments (const Differentiation::SD::types::substitution_map &arguments)
 
const Tensor< 1, dim, Differentiation::SD::Expression > & get_coordinate_symbols () const
 
const Differentiation::SD::Expressionget_time_symbol () const
 
const std::vector< Differentiation::SD::Expression > & get_symbolic_function_expressions () const
 
const Differentiation::SD::types::substitution_mapget_user_substitution_map () const
 
SymbolicFunction< dim, RangeNumberType > time_derivative () const
 
virtual RangeNumberType value (const Point< dim > &p, const unsigned int component=0) const override
 
virtual Tensor< 1, dim, RangeNumberType > gradient (const Point< dim > &p, const unsigned int component=0) const override
 
virtual RangeNumberType laplacian (const Point< dim > &p, const unsigned int component=0) const override
 
virtual SymmetricTensor< 2, dim, RangeNumberType > hessian (const Point< dim > &p, const unsigned int component=0) const override
 
template<typename StreamType >
StreamType & print (StreamType &out) const
 
virtual void vector_value (const Point< dim > &p, Vector< double > &values) 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
 
virtual void vector_values (const std::vector< Point< dim > > &points, std::vector< std::vector< double > > &values) const
 
virtual void vector_gradient (const Point< dim > &p, std::vector< Tensor< 1, dim, double > > &gradients) const
 
virtual void gradient_list (const std::vector< Point< dim > > &points, std::vector< Tensor< 1, dim, double > > &gradients, const unsigned int component=0) const
 
virtual void vector_gradients (const std::vector< Point< dim > > &points, std::vector< std::vector< Tensor< 1, dim, double > > > &gradients) const
 
virtual void vector_gradient_list (const std::vector< Point< dim > > &points, std::vector< std::vector< Tensor< 1, dim, double > > > &gradients) const
 
virtual void vector_laplacian (const Point< dim > &p, Vector< double > &values) const
 
virtual void laplacian_list (const std::vector< Point< dim > > &points, std::vector< double > &values, const unsigned int component=0) const
 
virtual void vector_laplacian_list (const std::vector< Point< dim > > &points, std::vector< Vector< double > > &values) const
 
virtual void vector_hessian (const Point< dim > &p, std::vector< SymmetricTensor< 2, dim, double > > &values) const
 
virtual void hessian_list (const std::vector< Point< dim > > &points, std::vector< SymmetricTensor< 2, dim, double > > &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, double > > > &values) const
 
virtual std::size_t memory_consumption () const
 
numbers::NumberTraits< double >::real_type get_time () const
 
virtual void set_time (const numbers::NumberTraits< double >::real_type new_time)
 
virtual void advance_time (const numbers::NumberTraits< double >::real_type delta_t)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
Subscriptor functionality

Classes derived from Subscriptor provide a facility to subscribe to this object. This is mostly used by the SmartPointer class.

void subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
void unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
unsigned int n_subscriptions () const
 
template<typename StreamType >
void list_subscribers (StreamType &stream) const
 
void list_subscribers () const
 

Static Public Member Functions

static Tensor< 1, dim, Differentiation::SD::Expressionget_default_coordinate_symbols ()
 
static ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)
 
static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)
 

Public Attributes

const unsigned int n_components
 

Static Public Attributes

static constexpr unsigned int dimension
 

Private Types

using map_value_type = decltype(counter_map)::value_type
 
using map_iterator = decltype(counter_map)::iterator
 

Private Member Functions

Differentiation::SD::types::substitution_map create_evaluation_substitution_map (const Point< dim > &point) const
 
void update_values () const
 
void update_first_derivatives () const
 
void update_second_derivatives () const
 
void check_no_subscribers () const noexcept
 

Private Attributes

const std::vector< Differentiation::SD::Expressionuser_function
 
Differentiation::SD::types::substitution_map user_substitution_map
 
Differentiation::SD::types::substitution_map additional_function_arguments
 
std::vector< Differentiation::SD::Expressionfunction
 
std::vector< Tensor< 1, dim, Differentiation::SD::Expression > > function_gradient
 
std::vector< Tensor< 2, dim, Differentiation::SD::Expression > > function_hessian
 
std::vector< Differentiation::SD::Expressionfunction_laplacian
 
Tensor< 1, dim, Differentiation::SD::Expressioncoordinate_symbols
 
Differentiation::SD::Expression time_symbol
 
numbers::NumberTraits< double >::real_type time
 
std::atomic< unsigned intcounter
 
std::map< std::string, unsigned intcounter_map
 
std::vector< std::atomic< bool > * > validity_pointers
 
const std::type_info * object_info
 

Static Private Attributes

static std::mutex mutex
 

Detailed Description

template<int dim, typename RangeNumberType = double>
class Functions::SymbolicFunction< dim, RangeNumberType >

A Function class that leverages symbolic differentiation to compute gradients, Laplacians, Hessians, and time derivatives.

This class can be used to define functions using methods provided by the Differentiation::SD namespace. In particular, one can define a symbolic evaluation point (the argument of the function), as well as a symbolic expression.

The symbolic gradients and the symbolic Hessians are computed at construction time, and when a substitution in the symbolic functions is requested by the user using the method update_user_substitution_map().

Whenever one of the evaluation methods is called, a substitution is attempted with the coordinate symbols argument replaced by the evaluation point and the symbolic time replaced by the current time, as returned by the get_time() method. The user has to make sure that at evaluation time argument substitution provides a fully evaluated expression (i.e., no other symbols are contained in the function expression, except numerical values), or an exception will be thrown. Additional symbols can be partially evaluated or substituted by storing them in a user supplied substitution maps, that can be updated by calling update_user_substitution_map() or the set_additional_function_arguments() methods.

The simplest use case of this class is given in the following example:

SymbolicFunction<2> fun("x^2+y; t*x*y");
fun.set_time(3.0);
Point<2> p(1.0, 2.0);
auto a = fun.value(p, / * component * / 0); // a = 3.0
auto b = fun.value(p, / * component * / 1); // b = 6.0
auto df_dt = fun.time_derivative();
auto c = df_dt.value(p, / * component * / 0); // c = 0.0
auto d = df_dt.value(p, / * component * / 1); // d = 2.0
Definition point.h:111

where a Function with two components is defined using a string containing their expressions separated by semicolons.

A more involved example, that explicitly uses Differentiation::SD::Expression objects, is given by

using namespace Differentiation::SD;
// Create a position Tensor<1,2,Differentiation::SD::Expression>
// with symbols "x" and "y", and the symbol "t"
const auto t = make_symbol("t");
// Use directly x[0] (the symbol "x"), x[1] (the symbol "y"), and t
// (the symbol "t").
Expression f = std::sin(x[0])*std::cos(x[1])*std::sin(t);
// Alternatively, you can achieve the same result parsing a string:
// Expression f("sin(x)*cos(y)*sin(t)", true);
// Evaluate the function, its gradient, and its Laplacian
Point<2> p(1.0, 2.0);
auto fp = function.value(p);
auto gradfp = function.gradient(p);
auto lapfp = function.laplacian(p);
// Evaluate the time derivative of the function, its gradient, and its
// Laplacian
auto time_derivative = function.time_derivative();
auto dt_fp = time_derivative.value(p);
auto dt_gradfp = time_derivative.gradient(p);
auto dt_lapfp = time_derivative.laplacian(p);
static Tensor< 1, dim, Differentiation::SD::Expression > get_default_coordinate_symbols()
SymbolicFunction< dim, RangeNumberType > time_derivative() const
std::vector< Differentiation::SD::Expression > function
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)

Partial substitution is possible (i.e., you can define the function using additional symbols). However, as soon as you evaluate the function, you have to make sure that all extraneous symbols (i.e., those not referring to the spatial coordinate_symbols or to the time_symbol variable) have been substituted with numerical values, or expressions of the spatial or temporal argument, by calling the update_user_substitution_map() or the set_additional_function_arguments() methods.

If your function requires additional arguments to be evaluated, you can specify them by calling the set_additional_function_arguments() method.

If you call update_user_substitution_map() and set_additional_function_arguments() with the same argument, the effect on the function evaluation will be the same, however, the internal behavior and function derivatives will be different. The method update_user_substitution_map() performs the substitution once (the first time it is required), and then stores internally a copy of the resulting expression, together with its derivatives (if required). These are then used in all subsequent evaluations. Calling set_additional_function_arguments() will evaluate the passed substitution map on the fly during evaluation time, after all derivatives have been computed.

Note
The difference between this class and the FunctionParser class is that this class allows to compute first and second order derivatives (in a symbolic way), while the FunctionParser class computes first order derivatives only, using finite differences. For complicated expressions, this class may be slower than the FunctionParser class.

Definition at line 152 of file symbolic_function.h.

Member Typedef Documentation

◆ time_type

using Function< dim, double >::time_type
inherited

The scalar-valued real type used for representing time.

Definition at line 168 of file function.h.

◆ map_value_type

using Subscriptor::map_value_type = decltype(counter_map)::value_type
privateinherited

The data type used in counter_map.

Definition at line 229 of file subscriptor.h.

◆ map_iterator

using Subscriptor::map_iterator = decltype(counter_map)::iterator
privateinherited

The iterator type used in counter_map.

Definition at line 234 of file subscriptor.h.

Constructor & Destructor Documentation

◆ SymbolicFunction() [1/2]

template<int dim, typename RangeNumberType = double>
Functions::SymbolicFunction< dim, RangeNumberType >::SymbolicFunction ( const std::vector< Differentiation::SD::Expression > & function,
const Tensor< 1, dim, Differentiation::SD::Expression > & coordinate_symbols = get_default_coordinate_symbols(),
const Differentiation::SD::Expression & time_symbol = Differentiation::SD::make_symbol("t"),
const Differentiation::SD::types::substitution_map & user_substitution_map = {} )

Constructor.

The resulting Function object will have as many components as there are entries in the vector of symbolic expressions function.

The vector function should contain a list of symbolic expression involving the coordinate symbols argument coordinate_symbols and possibly the symbolic time argument time_symbol. It is possible to define it in terms of other symbols, as long as the optional parameter user_substitution_map replaces all symbols except coordinate_symbols and time_symbol. This is useful if, for example, you want to express formulas in terms of material parameters that you want to name symbolically, rather than through their numeric values when defining the formula, or when you want to express your formula in terms of polar coordinates rather than cartesian ones, and you want the symbolic engine to compute the derivatives for you. You may later update the symbol map contained in user_substitution_map by calling update_user_substitution_map().

Parameters
functionA vector of symbolic expressions of type Differentiation::SD::Expression, representing the components of this Function.
coordinate_symbolsA tensor of symbols representing coordinates, used as input argument in the symbolic expressions contained in the function vector. The default coordinate_symbols is a Tensor<1,dim,Differentiation::SD::Expression> containing the symbols "x" for dim equal to one, "x", "y" for dim equal to two, and "x", "y", "z" for dim equal to three.
time_symbolA symbolic variable representing time. It defaults to a symbolic variable named "t".
user_substitution_mapAny other symbol that may be contained in the symbolic function needs to be specified in this map. The map may be empty, and the functions may still contain unevaluated symbols, provided that you call update_user_substitution_map() and provide a replacement of all symbols except coordinate_symbols and time_symbol before any evaluation occurs.

◆ SymbolicFunction() [2/2]

template<int dim, typename RangeNumberType = double>
Functions::SymbolicFunction< dim, RangeNumberType >::SymbolicFunction ( const std::string & expressions)

Constructor that takes a single string that describes the function expression as a semicolon separated list of expressions.

The symbolic expression can use the default argument and the default symbolic time variable, plus any additional symbols that you may need, provided that you update the user substitution map that substitutes all of them before you try to evaluate the function or its derivatives, by calling update_user_substitution_map(), and that you provide all the additional function arguments of your function using the method set_additional_function_arguments().

Member Function Documentation

◆ update_user_substitution_map()

template<int dim, typename RangeNumberType = double>
void Functions::SymbolicFunction< dim, RangeNumberType >::update_user_substitution_map ( const Differentiation::SD::types::substitution_map & substitutions)

Store and apply the substitution map substitutions to each symbolic component of this Function object.

Notice that this method will trigger a recomputation of the gradients, Hessians, and Laplacians of each component.

◆ set_additional_function_arguments()

template<int dim, typename RangeNumberType = double>
void Functions::SymbolicFunction< dim, RangeNumberType >::set_additional_function_arguments ( const Differentiation::SD::types::substitution_map & arguments)

Set the additional arguments to be substituted in next evaluation step.

Notice that the arguments are substituted after evaluating the permanent_user_substitution_map, and after all derivatives are computed. If the additional arguments you pass still depend on the coordinate or time symbols, then evaluation of derivatives will result in a partial derivative evaluation.

This method provides a way to evaluate functions that depend on more arguments than simply the coordinates and time. If you want to compute the total derivative w.r.t. to complicated symbolic expressions, you should call update_user_substitution_map() instead.

◆ get_default_coordinate_symbols()

template<int dim, typename RangeNumberType = double>
static Tensor< 1, dim, Differentiation::SD::Expression > Functions::SymbolicFunction< dim, RangeNumberType >::get_default_coordinate_symbols ( )
static

Return a tensor of coordinate symbols that can be used to define the expressions of this symbolic function object.

The default argument is a Tensor<1,dim,Differentiation::SD::Expression> containing the symbols "x" for dim equal to one, "x", "y" for dim equal to two, and "x", "y", "z" for dim equal to three.

◆ get_coordinate_symbols()

template<int dim, typename RangeNumberType = double>
const Tensor< 1, dim, Differentiation::SD::Expression > & Functions::SymbolicFunction< dim, RangeNumberType >::get_coordinate_symbols ( ) const

Get the actual arguments used for the coordinates in the symbolic function. This object does not include any user-defined arguments.

◆ get_time_symbol()

template<int dim, typename RangeNumberType = double>
const Differentiation::SD::Expression & Functions::SymbolicFunction< dim, RangeNumberType >::get_time_symbol ( ) const

Get the actual symbolic time in use in this symbolic function.

◆ get_symbolic_function_expressions()

template<int dim, typename RangeNumberType = double>
const std::vector< Differentiation::SD::Expression > & Functions::SymbolicFunction< dim, RangeNumberType >::get_symbolic_function_expressions ( ) const

Get the actual symbolic expressions used in this symbolic function.

◆ get_user_substitution_map()

template<int dim, typename RangeNumberType = double>
const Differentiation::SD::types::substitution_map & Functions::SymbolicFunction< dim, RangeNumberType >::get_user_substitution_map ( ) const

Get the currently stored user_substitution_map.

◆ time_derivative()

template<int dim, typename RangeNumberType = double>
SymbolicFunction< dim, RangeNumberType > Functions::SymbolicFunction< dim, RangeNumberType >::time_derivative ( ) const

Return a SymbolicFunction object that represents the time derivative of this function. The spatial argument, the symbolic time, and the currently stored user substitution map are forwarded to the new function.

◆ value()

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

Return the value of the function at the given point. Unless there is only one component (i.e. the function is scalar), you should state the component you want to have evaluated; it defaults to zero, i.e. the first component.

Reimplemented from Function< dim, double >.

◆ gradient()

template<int dim, typename RangeNumberType = double>
virtual Tensor< 1, dim, RangeNumberType > Functions::SymbolicFunction< dim, RangeNumberType >::gradient ( const Point< dim > & p,
const unsigned int component = 0 ) const
overridevirtual

Return the gradient of the specified component of the function at the given point.

Reimplemented from Function< dim, double >.

◆ laplacian()

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

Compute the Laplacian of a given component at point p.

Reimplemented from Function< dim, double >.

◆ hessian()

template<int dim, typename RangeNumberType = double>
virtual SymmetricTensor< 2, dim, RangeNumberType > Functions::SymbolicFunction< dim, RangeNumberType >::hessian ( const Point< dim > & p,
const unsigned int component = 0 ) const
overridevirtual

Compute the Hessian of a given component at point p, that is the gradient of the gradient of the function.

Reimplemented from Function< dim, double >.

◆ print()

template<int dim, typename RangeNumberType >
template<typename StreamType >
StreamType & Functions::SymbolicFunction< dim, RangeNumberType >::print ( StreamType & out) const

Print the stored arguments and function expression, as it would be evaluated when calling the method value().

Definition at line 440 of file symbolic_function.h.

◆ create_evaluation_substitution_map()

template<int dim, typename RangeNumberType = double>
Differentiation::SD::types::substitution_map Functions::SymbolicFunction< dim, RangeNumberType >::create_evaluation_substitution_map ( const Point< dim > & point) const
private

Return a substitution map that replaces the argument with the values of point, the symbolic time with the value of this->get_time(), and any additional arguments with the substitution map given by additional_function_arguments.

◆ update_values()

template<int dim, typename RangeNumberType = double>
void Functions::SymbolicFunction< dim, RangeNumberType >::update_values ( ) const
private

Recompute the symbolic value of the function, applying the user substitution map. This may be an expensive computation, and it is called only if necessary.

◆ update_first_derivatives()

template<int dim, typename RangeNumberType = double>
void Functions::SymbolicFunction< dim, RangeNumberType >::update_first_derivatives ( ) const
private

Recompute the symbolic gradient of the function, applying the user substitution map. This may be an expensive computation, and it is called only if necessary.

◆ update_second_derivatives()

template<int dim, typename RangeNumberType = double>
void Functions::SymbolicFunction< dim, RangeNumberType >::update_second_derivatives ( ) const
private

Recompute the symbolic Hessian and the symbolic Lapalacian of the function. This may be an expensive computation, and it is called only if necessary.

◆ vector_value()

virtual void Function< dim, double >::vector_value ( const Point< dim > & p,
Vector< double > & values ) const
virtualinherited

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

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

The default implementation will call value() for each component.

Reimplemented in Functions::ConstantFunction< dim, double >.

◆ value_list()

virtual void Function< dim, double >::value_list ( const std::vector< Point< dim > > & points,
std::vector< double > & values,
const unsigned int component = 0 ) const
virtualinherited

Set values to the point values of the specified component of the function at the points. It is assumed that values already has the right size, i.e. the same size as the points array.

By default, this function repeatedly calls value() for each point separately, to fill the output array.

Reimplemented in Functions::ConstantFunction< dim, double >.

◆ vector_value_list()

virtual void Function< dim, double >::vector_value_list ( const std::vector< Point< dim > > & points,
std::vector< Vector< double > > & values ) const
virtualinherited

Set values to the point values of the function at the points. It is assumed that values already has the right size, i.e. the same size as the points array, and that all elements be vectors with the same number of components as this function has.

By default, this function repeatedly calls vector_value() for each point separately, to fill the output array.

Reimplemented in Functions::ConstantFunction< dim, double >.

◆ vector_values()

virtual void Function< dim, double >::vector_values ( const std::vector< Point< dim > > & points,
std::vector< std::vector< double > > & values ) const
virtualinherited

For each component of the function, fill a vector of values, one for each point.

The default implementation of this function in Function calls value_list() for each component. In order to improve performance, this can be reimplemented in derived classes to speed up performance.

◆ vector_gradient()

virtual void Function< dim, double >::vector_gradient ( const Point< dim > & p,
std::vector< Tensor< 1, dim, double > > & gradients ) const
virtualinherited

Return the gradient of all components of the function at the given point.

Reimplemented in Functions::ConstantFunction< dim, double >.

◆ gradient_list()

virtual void Function< dim, double >::gradient_list ( const std::vector< Point< dim > > & points,
std::vector< Tensor< 1, dim, double > > & gradients,
const unsigned int component = 0 ) const
virtualinherited

Set gradients to the gradients of the specified component of the function at the points. It is assumed that gradients already has the right size, i.e. the same size as the points array.

Reimplemented in Functions::ConstantFunction< dim, double >.

◆ vector_gradients()

virtual void Function< dim, double >::vector_gradients ( const std::vector< Point< dim > > & points,
std::vector< std::vector< Tensor< 1, dim, double > > > & gradients ) const
virtualinherited

For each component of the function, fill a vector of gradient values, one for each point.

The default implementation of this function in Function calls value_list() for each component. In order to improve performance, this can be reimplemented in derived classes to speed up performance.

◆ vector_gradient_list()

virtual void Function< dim, double >::vector_gradient_list ( const std::vector< Point< dim > > & points,
std::vector< std::vector< Tensor< 1, dim, double > > > & gradients ) const
virtualinherited

Set gradients to the gradients of the function at the points, for all components. It is assumed that gradients already has the right size, i.e. the same size as the points array.

The outer loop over gradients is over the points in the list, the inner loop over the different components of the function.

Reimplemented in Functions::ConstantFunction< dim, double >.

◆ vector_laplacian()

virtual void Function< dim, double >::vector_laplacian ( const Point< dim > & p,
Vector< double > & values ) const
virtualinherited

Compute the Laplacian of all components at point p and store them in values.

◆ laplacian_list()

virtual void Function< dim, double >::laplacian_list ( const std::vector< Point< dim > > & points,
std::vector< double > & values,
const unsigned int component = 0 ) const
virtualinherited

Compute the Laplacian of one component at a set of points.

◆ vector_laplacian_list()

virtual void Function< dim, double >::vector_laplacian_list ( const std::vector< Point< dim > > & points,
std::vector< Vector< double > > & values ) const
virtualinherited

Compute the Laplacians of all components at a set of points.

◆ vector_hessian()

virtual void Function< dim, double >::vector_hessian ( const Point< dim > & p,
std::vector< SymmetricTensor< 2, dim, double > > & values ) const
virtualinherited

Compute the Hessian of all components at point p and store them in values.

◆ hessian_list()

virtual void Function< dim, double >::hessian_list ( const std::vector< Point< dim > > & points,
std::vector< SymmetricTensor< 2, dim, double > > & values,
const unsigned int component = 0 ) const
virtualinherited

Compute the Hessian of one component at a set of points.

◆ vector_hessian_list()

virtual void Function< dim, double >::vector_hessian_list ( const std::vector< Point< dim > > & points,
std::vector< std::vector< SymmetricTensor< 2, dim, double > > > & values ) const
virtualinherited

Compute the Hessians of all components at a set of points.

◆ memory_consumption()

virtual std::size_t Function< dim, double >::memory_consumption ( ) const
virtualinherited

Return an estimate for the memory consumption, in bytes, of this object.

This function is virtual and can be overloaded by derived classes.

Reimplemented in ComponentSelectFunction< dim, RangeNumberType >, Functions::ConstantFunction< dim, RangeNumberType >, and Functions::ConstantFunction< dim, double >.

◆ get_time()

numbers::NumberTraits< double >::real_type FunctionTime< numbers::NumberTraits< double >::real_type >::get_time ( ) const
inherited

Return the value of the time variable.

◆ set_time()

virtual void FunctionTime< numbers::NumberTraits< double >::real_type >::set_time ( const numbers::NumberTraits< double >::real_type new_time)
virtualinherited

Set the time to new_time, overwriting the old value.

◆ advance_time()

virtual void FunctionTime< numbers::NumberTraits< double >::real_type >::advance_time ( const numbers::NumberTraits< double >::real_type delta_t)
virtualinherited

Advance the time by the given time step delta_t.

◆ subscribe()

void Subscriptor::subscribe ( std::atomic< bool > *const validity,
const std::string & identifier = "" ) const
inherited

Subscribes a user of the object by storing the pointer validity. The subscriber may be identified by text supplied as identifier.

Definition at line 135 of file subscriptor.cc.

◆ unsubscribe()

void Subscriptor::unsubscribe ( std::atomic< bool > *const validity,
const std::string & identifier = "" ) const
inherited

Unsubscribes a user from the object.

Note
The identifier and the validity pointer must be the same as the one supplied to subscribe().

Definition at line 155 of file subscriptor.cc.

◆ n_subscriptions()

unsigned int Subscriptor::n_subscriptions ( ) const
inlineinherited

Return the present number of subscriptions to this object. This allows to use this class for reference counted lifetime determination where the last one to unsubscribe also deletes the object.

Definition at line 300 of file subscriptor.h.

◆ list_subscribers() [1/2]

template<typename StreamType >
void Subscriptor::list_subscribers ( StreamType & stream) const
inlineinherited

List the subscribers to the input stream.

Definition at line 317 of file subscriptor.h.

◆ list_subscribers() [2/2]

void Subscriptor::list_subscribers ( ) const
inherited

List the subscribers to deallog.

Definition at line 203 of file subscriptor.cc.

◆ serialize()

template<class Archive >
void Subscriptor::serialize ( Archive & ar,
const unsigned int version )
inlineinherited

Read or write the data of this object to or from a stream for the purpose of serialization using the BOOST serialization library.

This function does not actually serialize any of the member variables of this class. The reason is that what this class stores is only who subscribes to this object, but who does so at the time of storing the contents of this object does not necessarily have anything to do with who subscribes to the object when it is restored. Consequently, we do not want to overwrite the subscribers at the time of restoring, and then there is no reason to write the subscribers out in the first place.

Definition at line 309 of file subscriptor.h.

◆ check_no_subscribers()

void Subscriptor::check_no_subscribers ( ) const
privatenoexceptinherited

Check that there are no objects subscribing to this object. If this check passes then it is safe to destroy the current object. It this check fails then this function will either abort or print an error message to deallog (by using the AssertNothrow mechanism), but will not throw an exception.

Note
Since this function is just a consistency check it does nothing in release mode.
If this function is called when there is an uncaught exception then, rather than aborting, this function prints an error message to the standard error stream and returns.

Definition at line 52 of file subscriptor.cc.

Member Data Documentation

◆ user_function

template<int dim, typename RangeNumberType = double>
const std::vector<Differentiation::SD::Expression> Functions::SymbolicFunction< dim, RangeNumberType >::user_function
private

The components of this symbolic function, before any subustitution took place. This is immutable, and generated at construction time.

Before any evaluation takes place, the user_substitution_map is applied to this object, and the result is stored in the internal variable function.

During evaluation, the symbolic_coordinate, the symbolic_time, and any remaining symbols are substituted with the input evaluation point, the current time, and the content of additional_function_arguments.

Definition at line 367 of file symbolic_function.h.

◆ user_substitution_map

template<int dim, typename RangeNumberType = double>
Differentiation::SD::types::substitution_map Functions::SymbolicFunction< dim, RangeNumberType >::user_substitution_map
private

Store the user substitution map used for expression substitutions. This may be updated with a call to update_user_substitution_map(). Notice that the function may still have unresolved symbols, provided that they are resolved by a call to set_additional_function_arguments().

Definition at line 375 of file symbolic_function.h.

◆ additional_function_arguments

template<int dim, typename RangeNumberType = double>
Differentiation::SD::types::substitution_map Functions::SymbolicFunction< dim, RangeNumberType >::additional_function_arguments
private

Store a user substitution map used for additional argument substitutions. This will be updated by a call to set_additional_function_arguments().

Definition at line 382 of file symbolic_function.h.

◆ function

template<int dim, typename RangeNumberType = double>
std::vector<Differentiation::SD::Expression> Functions::SymbolicFunction< dim, RangeNumberType >::function
mutableprivate

The actual components of this symbolic function. This is obtained from the user_function, after applying the user_substitution_map.

Definition at line 388 of file symbolic_function.h.

◆ function_gradient

template<int dim, typename RangeNumberType = double>
std::vector<Tensor<1, dim, Differentiation::SD::Expression> > Functions::SymbolicFunction< dim, RangeNumberType >::function_gradient
mutableprivate

The gradients of each component of this symbolic function. This is obtained by computing the symbolic gradient of the object function, that is, after applying the user_substitution_map to user_function.

Definition at line 396 of file symbolic_function.h.

◆ function_hessian

template<int dim, typename RangeNumberType = double>
std::vector<Tensor<2, dim, Differentiation::SD::Expression> > Functions::SymbolicFunction< dim, RangeNumberType >::function_hessian
mutableprivate

The Hessians of each component of this symbolic function. This is obtained by computing the symbolic Hessian of the object function, that is, after applying the user_substitution_map to user_function.

Definition at line 404 of file symbolic_function.h.

◆ function_laplacian

template<int dim, typename RangeNumberType = double>
std::vector<Differentiation::SD::Expression> Functions::SymbolicFunction< dim, RangeNumberType >::function_laplacian
mutableprivate

The Laplacians of each component of this symbolic function. This is obtained by computing the symbolic Laplacian of the object function, that is, after applying the user_substitution_map to user_function.

Definition at line 411 of file symbolic_function.h.

◆ coordinate_symbols

template<int dim, typename RangeNumberType = double>
Tensor<1, dim, Differentiation::SD::Expression> Functions::SymbolicFunction< dim, RangeNumberType >::coordinate_symbols
private

The coordinate symbols argument of the function.

Definition at line 416 of file symbolic_function.h.

◆ time_symbol

template<int dim, typename RangeNumberType = double>
Differentiation::SD::Expression Functions::SymbolicFunction< dim, RangeNumberType >::time_symbol
mutableprivate

The symbolic time argument of the function.

Definition at line 421 of file symbolic_function.h.

◆ dimension

unsigned int Function< dim, double >::dimension
staticconstexprinherited

Export the value of the template parameter as a static member constant. Sometimes useful for some expression template programming.

Definition at line 158 of file function.h.

◆ n_components

const unsigned int Function< dim, double >::n_components
inherited

Number of vector components.

Definition at line 163 of file function.h.

◆ time

numbers::NumberTraits< double >::real_type FunctionTime< numbers::NumberTraits< double >::real_type >::time
privateinherited

Store the present time.

Definition at line 112 of file function_time.h.

◆ counter

std::atomic<unsigned int> Subscriptor::counter
mutableprivateinherited

Store the number of objects which subscribed to this object. Initially, this number is zero, and upon destruction it shall be zero again (i.e. all objects which subscribed should have unsubscribed again).

The creator (and owner) of an object is counted in the map below if HE manages to supply identification.

We use the mutable keyword in order to allow subscription to constant objects also.

This counter may be read from and written to concurrently in multithreaded code: hence we use the std::atomic class template.

Definition at line 218 of file subscriptor.h.

◆ counter_map

std::map<std::string, unsigned int> Subscriptor::counter_map
mutableprivateinherited

In this map, we count subscriptions for each different identification string supplied to subscribe().

Definition at line 224 of file subscriptor.h.

◆ validity_pointers

std::vector<std::atomic<bool> *> Subscriptor::validity_pointers
mutableprivateinherited

In this vector, we store pointers to the validity bool in the SmartPointer objects that subscribe to this class.

Definition at line 240 of file subscriptor.h.

◆ object_info

const std::type_info* Subscriptor::object_info
mutableprivateinherited

Pointer to the typeinfo object of this object, from which we can later deduce the class name. Since this information on the derived class is neither available in the destructor, nor in the constructor, we obtain it in between and store it here.

Definition at line 248 of file subscriptor.h.

◆ mutex

std::mutex Subscriptor::mutex
staticprivateinherited

A mutex used to ensure data consistency when accessing the mutable members of this class. This lock is used in the subscribe() and unsubscribe() functions, as well as in list_subscribers().

Definition at line 271 of file subscriptor.h.


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