MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / Expression

Class Expression

python/dolfinx/fem/function.py:101–332  ·  view source on GitHub ↗

An object for evaluating functions of finite element functions. Represents a mathematical expression evaluated at a pre-defined set of points on the reference cell. This class closely follows the concept of a UFC Expression. This functionality can be used to evaluate a gradient of

Source from the content-addressed store, hash-verified

99
100
101class Expression(Generic[Scalar]):
102 """An object for evaluating functions of finite element functions.
103
104 Represents a mathematical expression evaluated at a pre-defined set
105 of points on the reference cell. This class closely follows the
106 concept of a UFC Expression.
107
108 This functionality can be used to evaluate a gradient of a Function
109 at the quadrature points in all cells. This evaluated gradient can
110 then be used as input to a non-FEniCS function that calculates a
111 material constitutive model.
112
113 """
114
115 _ufl_expression: ufl.core.expr.Expr
116 _argument_space: FunctionSpace | None
117 _cpp_object: (
118 _cpp.fem.Expression_complex64
119 | _cpp.fem.Expression_complex128
120 | _cpp.fem.Expression_float32
121 | _cpp.fem.Expression_float64
122 )
123 _code: str
124
125 def __init__(
126 self,
127 e: ufl.core.expr.Expr,
128 X: np.ndarray,
129 comm: _MPI.Comm | None = None,
130 form_compiler_options: dict | None = None,
131 jit_options: dict | None = None,
132 dtype: npt.DTypeLike | None = None,
133 entity_maps: list[_EntityMap] | None = None,
134 ):
135 """Create an Expression.
136
137 Args:
138 e: UFL expression.
139 X: Array of points of shape ``(num_points, tdim)`` on the
140 reference element.
141 comm: Communicator that the Expression is defined on.
142 form_compiler_options: Options used in FFCx compilation of
143 this Expression. Run ``ffcx --help`` in the commandline
144 to see all available options.
145 jit_options: Options controlling JIT compilation of C code.
146 dtype: Type of the Expression values. If ``None``,
147 the dtype is deduced from the UFL expression.
148 entity_maps: Maps between different meshes.
149
150 Note:
151 This wrapper is responsible for the FFCx compilation of the
152 UFL Expr and attaching the correct data to the underlying
153 C++ Expression.
154 """
155 assert X.ndim < 3
156 num_points = X.shape[0] if X.ndim == 2 else 1
157 _X = np.reshape(X, (num_points, -1))
158

Calls

no outgoing calls

Tested by 15

test_nedelec_spatialFunction · 0.72
test_2D_lagrange_to_curlFunction · 0.72
test_de_rahm_2DFunction · 0.72
test_interpolate_subsetFunction · 0.72
test_rank0Function · 0.72
test_rank1_hdivFunction · 0.72
test_simple_evaluationFunction · 0.72