G+Smo
24.08.0
Geometry + Simulation Modules
|
Class defining a multivariate (real or vector) function given by a string mathematical expression.
Numerous forms of functional and logic processing semantics are supported. The class is based on The C++ Mathematical Expression Toolkit Library (ExprTk), see
http://www.partow.net/programming/exprtk
and
https://github.com/ArashPartow/exprtk/blob/master/readme.txt
for more details.
The variables used are the ordered list:
x , y , z, w, u, v, t
Any function with domain dimension equal to 1 MUST use x as variable. the letters y...t are settable parameters. Any function with domain dimension equal to 2 MUST use x,y as variables. the letters z...t are settable parameters. Any function with domain dimension equal to 3 MUST use x,y,z as variables. the letters w...t are settable parameters. And so on.
Public Types | |
typedef memory::shared_ptr < gsFunctionExpr > | Ptr |
Shared pointer for gsFunctionExpr. | |
typedef memory::unique_ptr < gsFunctionExpr > | uPtr |
Unique pointer for gsFunctionExpr. | |
Public Member Functions | |
gsMatrix< index_t > | active (const gsMatrix< T > &u) const |
Returns the indices of active (nonzero) functions at points u, as a list of indices. More... | |
void | active_into (const gsMatrix< T > &u, gsMatrix< index_t > &result) const |
Indices of active (non-zero) function(s) for each point. More... | |
void | addComponent (const std::string &strExpression) |
Adds another component to this (vector) function. | |
const gsBasis< T > & | basis (const index_t k) const |
Helper which casts and returns the k-th piece of this function set as a gsBasis. | |
uPtr | clone () |
Clone methode. Produceds a deep copy inside a uPtr. | |
virtual void | compute (const gsMatrix< T > &in, gsFuncData< T > &out) const |
Computes function data. More... | |
virtual void | computeMap (gsMapData< T > &InOut) const |
Computes map function data. More... | |
gsFuncCoordinate< T > | coord (const index_t c) const |
Returns the scalar function giving the i-th coordinate of this function. | |
gsMatrix< T > | deriv (const gsMatrix< T > &u) const |
Evaluate the derivatives,. More... | |
gsMatrix< T > | deriv2 (const gsMatrix< T > &u) const |
Evaluates the second derivatives of active (i.e., non-zero) functions at points u. More... | |
virtual void | deriv2_into (const gsMatrix< T > &u, gsMatrix< T > &result) const |
Evaluate second derivatives of the function at points u into result. More... | |
virtual void | deriv_into (const gsMatrix< T > &u, gsMatrix< T > &result) const |
Evaluate derivatives of the function \(f:\mathbb{R}^n\rightarrow\mathbb{R}^m\) at points u into result. More... | |
virtual T | distanceL2 (gsFunction< T > const &) const |
Computes the L2-distance between this function and the field and a function func. | |
short_t | domainDim () const |
Dimension of the (source) domain. More... | |
gsMatrix< T > | eval (const gsMatrix< T > &u) const |
Evaluate the function,. More... | |
virtual void | eval_component_into (const gsMatrix< T > &u, const index_t comp, gsMatrix< T > &result) const |
Evaluate the function for component comp in the target dimension at points u into result. | |
virtual void | eval_into (const gsMatrix< T > &u, gsMatrix< T > &result) const |
Evaluate the function at points u into result. More... | |
std::vector< gsMatrix< T > > | evalAllDers (const gsMatrix< T > &u, int n, bool sameElement=false) const |
Evaluate all derivatives upto order n,. More... | |
virtual void | evalAllDers_into (const gsMatrix< T > &u, int n, std::vector< gsMatrix< T > > &result, bool sameElement=false) const |
Evaluate the nonzero functions and their derivatives up to order n at points u into result. More... | |
const gsFunction< T > & | function (const index_t k) const |
Helper which casts and returns the k-th piece of this function set as a gsFunction. | |
gsFunctionExpr () | |
Default empty constructor. | |
gsFunctionExpr (const std::string &expression_string, short_t ddim) | |
Constructor taking an expression string and the domain dimension (scalar function in variable) | |
gsFunctionExpr (const std::string &expression_string1, const std::string &expression_string2, short_t ddim) | |
Constructor taking two expression strings (2D vector valued function) | |
gsFunctionExpr (const std::string &expression_string1, const std::string &expression_string2, const std::string &expression_string3, short_t ddim) | |
Constructor taking three expression strings (3D vector valued function) | |
gsFunctionExpr (const std::string &expression_string1, const std::string &expression_string2, const std::string &expression_string3, const std::string &expression_string4, short_t ddim) | |
Constructor taking four expression strings (4D vector valued function) used for matrix coefficients. | |
gsFunctionExpr (const std::string &expression_string1, const std::string &expression_string2, const std::string &expression_string3, const std::string &expression_string4, const std::string &expression_string5, const std::string &expression_string6, const std::string &expression_string7, const std::string &expression_string8, const std::string &expression_string9, short_t ddim) | |
Constructor taking nine expression strings (9D vector valued function) used for (3x3) matrix coefficients. | |
virtual void | invertPoints (const gsMatrix< T > &points, gsMatrix< T > &result, const T accuracy=1e-6, const bool useInitialPoint=false) const |
gsMatrix< T > | laplacian (const gsMatrix< T > &u) const |
Evaluate the Laplacian at points u. More... | |
gsMatrix< T > * | mderiv (const gsMatrix< T > &u, const index_t k, const index_t j) const |
Mixed derivative wrt variables k and j. | |
int | newtonRaphson (const gsVector< T > &value, gsVector< T > &arg, bool withSupport=true, const T accuracy=1e-6, int max_loop=100, T damping_factor=1) const |
virtual index_t | nPieces () const |
Number of pieces in the domain of definition. | |
virtual gsMatrix< T > | parameterCenter () const |
Returns a "central" point inside inside the parameter domain. | |
gsMatrix< T > | parameterCenter (const boxCorner &bc) const |
Get coordinates of the boxCorner bc in the parameter domain. | |
gsMatrix< T > | parameterCenter (const boxSide &bs) const |
Get coordinates of the midpoint of the boxSide bs in the parameter domain. | |
virtual const gsFunctionExpr & | piece (const index_t) const |
Returns the piece(s) of the function(s) at subdomain k. | |
std::ostream & | print (std::ostream &os) const |
Prints the object as a string. | |
void | recoverPoints (gsMatrix< T > &xyz, gsMatrix< T > &uv, index_t k, const T accuracy=1e-6) const |
void | set_t (T const &t) const |
Sets the symbol "t" to a value. | |
void | set_u (T const &v) const |
Sets the symbol "u" to a value. | |
void | set_v (T const &v) const |
Sets the symbol "v" to a value. | |
void | set_w (T const &v) const |
Sets the symbol "w" to a value. | |
void | set_x (T const &v) const |
Sets the symbol "x" to a value. | |
void | set_y (T const &v) const |
Sets the symbol "y" to a value. | |
void | set_z (T const &v) const |
Sets the symbol "z" to a value. | |
index_t | size () const |
size More... | |
short_t | targetDim () const |
Dimension of the target space. More... | |
Evaluation functions | |
These functions allow one to evaluate the function as well as its derivatives at one or more points in the parameter space. See also Evaluation members. | |
virtual void | jacobian_into (const gsMatrix< T > &u, gsMatrix< T > &result) const |
Computes for each point u a block of result containing the Jacobian matrix. | |
void | div_into (const gsMatrix< T > &u, gsMatrix< T > &result) const |
Computes for each point u a block of result containing the divergence matrix. | |
gsMatrix< T > | jacobian (const gsMatrix< T > &u) const |
virtual void | hessian_into (const gsMatrix< T > &u, gsMatrix< T > &result, index_t coord=0) const |
virtual gsMatrix< T > | hessian (const gsMatrix< T > &u, index_t coord=0) const |
Static Public Member Functions | |
static uPtr | make (const std::string &expression_string, short_t ddim) |
Make function taking an expression string and the domain dimension (scalar function) | |
static uPtr | make (const std::string &expression_string1, const std::string &expression_string2, short_t ddim) |
Make function taking two expression strings (2D vector valued function) | |
static uPtr | make (const std::string &expression_string1, const std::string &expression_string2, const std::string &expression_string3, short_t ddim) |
Make function taking two expression strings (3D vector valued function) | |
static uPtr | make (const std::string &expression_string1, const std::string &expression_string2, const std::string &expression_string3, const std::string &expression_string4, short_t ddim) |
Make function taking four expression strings (4D vector valued function) used for matrix coefficients. | |
static uPtr | make (const std::string &expression_string1, const std::string &expression_string2, const std::string &expression_string3, const std::string &expression_string4, const std::string &expression_string5, const std::string &expression_string6, const std::string &expression_string7, const std::string &expression_string8, const std::string &expression_string9, short_t ddim) |
Make function taking nine expression strings (9D vector valued function) used for (3x3) matrix coefficients. | |
Returns the indices of active (nonzero) functions at points u, as a list of indices.
|
inlinevirtualinherited |
Indices of active (non-zero) function(s) for each point.
The columns are sorted in increasing order, if on a point there are less active then the number of rows in the result matrix (some other point has more actives) then the rest of the column is filled with 0s.
u | |
result |
Reimplemented from gsFunctionSet< T >.
|
virtualinherited |
Computes function data.
This function evaluates the functions and their derivatives at the points in and writes them in the corresponding fields of out. Which field to write (and what to compute) is controlled by the out.flags (see also gsFuncData).
The input points in are expected to be compatible with the implementation/representation of the function, i.e. they should be points inside the domain of definitition of the function
[in] | in | |
[out] | out |
Reimplemented in gsGeometry< T >, and gsConstantFunction< T >.
|
virtualinherited |
Computes map function data.
This function evaluates the functions and their derivatives at the points InOut.points and writes them in the corresponding fields of InOut. Which field to write (and what to compute) is controlled by the InOut.flags (see also gsMapData). This is intended for parametrizations only and it works on functions sets of cardinality 1 only.
[in,out] | InOut |
Evaluate the derivatives,.
Evaluates the second derivatives of active (i.e., non-zero) functions at points u.
See documentation for deriv2_into() (the one without input parameter coefs) for details.
[in] | u | Evaluation points in columns. |
Evaluate second derivatives of the function at points u into result.
Let n be the dimension of the source space ( n = domainDim() ).
Let m be the dimension of the image/target space ( m = targetDim() ).
Let N denote the number of evaluation points.
[in] | u | gsMatrix of size n x N, where each column of u represents one evaluation point. |
[out] | result | gsMatrix of size (S*m) x N, where S=n*(n+1)/2. Each column in result corresponds to one point (i.e., one column in u) and contains the following values (for n=3, m=3): \( (\partial_{xx} f^{(1)}, \partial_{yy} f^{(1)}, \partial_{zz} f^{(1)}, \partial_{xy} f^{(1)}, \partial_{xz} f^{(1)}, \partial_{yz} f^{(1)}, \partial_{xx} f^{(2)},\ldots,\partial_{yz} f^{(3)} )^T\) |
Reimplemented from gsFunction< T >.
Evaluate derivatives of the function \(f:\mathbb{R}^n\rightarrow\mathbb{R}^m\) at points u into result.
Let n be the dimension of the source space ( n = domainDim() ).
Let m be the dimension of the image/target space ( m = targetDim() ).
Let N denote the number of evaluation points.
Let \( f:\mathbb R^2 \rightarrow \mathbb R^3 \), i.e., \( f(x,y) = ( f^{(1)}(x,y), f^{(2)}(x,y), f^{(3)}(x,y) )^T\),
and let \( u = ( u_1, \ldots, u_N) = ( (x_1,y_1)^T, \ldots, (x_N, y_N)^T )\).
Then, result is of the form
\[ \left[ \begin{array}{cccc} \partial_x f^{(1)}(u_1) & \partial_x f^{(1)}(u_2) & \ldots & \partial_x f^{(1)}(u_N) \\ \partial_y f^{(1)}(u_1) & \partial_y f^{(1)}(u_2) & \ldots & \partial_y f^{(1)}(u_N) \\ \partial_x f^{(2)}(u_1) & \partial_x f^{(2)}(u_2) & \ldots & \partial_x f^{(2)}(u_N) \\ \partial_y f^{(2)}(u_1) & \partial_y f^{(2)}(u_2) & \ldots & \partial_x f^{(2)}(u_N) \\ \partial_x f^{(3)}(u_1) & \partial_x f^{(3)}(u_2) & \ldots & \partial_x f^{(3)}(u_N)\\ \partial_y f^{(3)}(u_1) & \partial_y f^{(3)}(u_2) & \ldots & \partial_y f^{(3)}(u_N) \end{array} \right] \]
[in] | u | gsMatrix of size n x N, where each column of u represents one evaluation point. |
[out] | result | gsMatrix of size (n * m) x N. Each row of result corresponds to one component in the target space and contains the gradients for each evaluation point, as row vectors, one after the other (see above for details on the format). |
Reimplemented from gsFunction< T >.
|
virtual |
Dimension of the (source) domain.
Implements gsFunctionSet< T >.
Evaluate the function,.
Evaluate the function at points u into result.
Let n be the dimension of the source space ( n = domainDim() ).
Let m be the dimension of the image/target space ( m = targetDim() ).
Let N denote the number of evaluation points.
[in] | u | gsMatrix of size n x N, where each column of u represents one evaluation point. |
[out] | result | gsMatrix of size m x N, where each column of u represents the result of the function at the respective valuation point. |
Implements gsFunction< T >.
|
inherited |
Evaluate all derivatives upto order n,.
|
virtualinherited |
Evaluate the nonzero functions and their derivatives up to order n at points u into result.
The derivatives (the 0-th derivative is the function value) are stored in a result. result is a std::vector, where result[i] is a gsMatrix which contains the i-th derivatives.
The entries in result[0], result[1], and result[2] are ordered as in eval_into(), deriv_into(), and deriv2_into(), respectively. For i > 2, the derivatives are stored in lexicographical order, e.g. for order i = 3 and dimension 2 the derivatives are stored as follows: \( \partial_{xxx}, \, \partial_{xxy}, \, \partial_{xyy}, \, \partial_{yyy}.\, \)
[in] | u | Evaluation points, each column corresponds to one evaluation point. |
[in] | n | All derivatives up to order n are computed and stored in result. |
[in,out] | result | See above for format. |
Reimplemented in gsTensorBSplineBasis< 1, T >, gsTensorBasis< d, T >, gsTensorBasis< 1, T >, gsGeometry< T >, gsMappedSingleBasis< d, T >, gsConstantFunction< T >, gsTHBSplineBasis< d, T >, gsMappedSingleSpline< d, T >, and gsSquaredDistance< T >.
|
inlinevirtualinherited |
Evaluates the Hessian (matrix of second partial derivatives) of coordinate coord at points u.
|
virtualinherited |
Takes the physical points and computes the corresponding parameter values. If the point cannot be inverted (eg. is not part of the geometry) the corresponding parameter values will be undefined
Evaluate the Laplacian at points u.
By default uses central finite differences with h=0.00001
Reimplemented from gsFunction< T >.
|
inherited |
Newton-Raphson method to find a solution of the equation f(arg) = value with starting vector arg. If the point cannot be inverted the corresponding parameter values will be undefined
|
inherited |
Recovers a point on the (geometry) together with its parameters uv, assuming that the k-th coordinate of the point xyz is not known (and has a random value as input argument).
|
inlinevirtualinherited |
size
Reimplemented from gsFunctionSet< T >.
Reimplemented in gsPiecewiseFunction< T >.
|
virtual |
Dimension of the target space.
Reimplemented from gsFunctionSet< T >.