Constant.h

Note

The documentation on this page was automatically extracted from the DOLFIN C++ code and may need to be edited or expanded.

class Constant

Parent class(es)

This class represents a constant-valued expression.

explicit Constant(double value)

Create scalar constant

@param value (double)
The scalar to create a Constant object from.
@code{.cpp}
Constant c(1.0);

@endcode

Constant(double value0, double value1)

Create vector constant (dim = 2)

@param value0 (double)
The first vector element.
@param value1 (double)
The second vector element.
@code{.cpp}
Constant B(0.0, 1.0);

@endcode

Constant(double value0, double value1, double value2)

Create vector constant (dim = 3)

@param value0 (double)
The first vector element.
@param value1 (double)
The second vector element.
@param value2 (double)
The third vector element.
@code{.cpp}
Constant T(0.0, 1.0, 0.0);

@endcode

explicit Constant(std::vector<double> values)

Create vector-valued constant

@param values (std::vector<double>)
Values to create a vector-valued constant from.
Constant(std::vector<std::size_t> value_shape, std::vector<double> values)

Create tensor-valued constant for flattened array of values

@param value_shape (std::vector<std::size_t>)
Shape of tensor.
@param values (std::vector<double>)
Values to create tensor-valued constant from.
Constant(const Constant &constant)

Copy constructor

@param constant (Constant)
Object to be copied.
const Constant &operator=(const Constant &constant)

Assignment operator

@param constant (Constant)
Another constant.
const Constant &operator=(double constant)

Assignment operator

@param constant (double)
Another constant.
operator double() const

Cast to double (for scalar constants)

@return double
The scalar value.
std::vector<double> values() const

Return copy of this Constant’s current values

@return std::vector<double>
The vector of scalar values of the constant.