pyoomph.expressions.generic module
- pyoomph.expressions.generic.Weak(a, b, *, dimensional_dx=False, coordinate_system=None)[source]
Shortcut for weak(a,b,dimensional_dx=dimensional_dx,lagrangian=True,coordinate_system=coordinate_system)
- Return type:
Expression
- pyoomph.expressions.generic.avg(f, at_facet=False)[source]
Calculate the average of the given expression for discontinuous Galerkin methods.
- Parameters:
f (ExpressionOrNum) – The expression to calculate the average for.
at_facet (bool, optional) – If True, calculate the average at the facet, i.e. between the values at the facet directly. If you wrap it on a spatial differential operator, you will get the average of e.g. the surface gradient. If False, calculate the average between the two bulk domains. Here, the bulk gradients will be taken when applied with e.g. a grad. Default is False.
- Returns:
The average across the interface. (f_inside + f_outside)/2.
- Return type:
Expression
- pyoomph.expressions.generic.contract(a, b)[source]
Contract a and b. If both are scalars, it is just a*b. If both are vectors, it is the dot product. If both are rank-2-tensors/matrices, it is the Frobenius product. If one is a vector and the other a matrix, it is the matrix-vector product. If one is a scalar, it is just the multiplication by a scalar.
- Parameters:
a (ExpressionOrNum) – Argument a (scalar, vector or matrix/tensor)
b (ExpressionOrNum) – Argument b (scalar, vector or matrix/tensor)
- Returns:
The symbolic contraction of a and b.
- Return type:
Expression
- pyoomph.expressions.generic.delayed_lambda_expansion(func)[source]
Wrapping a callable f, so that it will be evaluated only at the moment of code generation. Can be used to e.g. access potentially changing problem parameters the moment the code is generated.
- Parameters:
func (Callable[[], Expression]) – The function to be expanded when the code is generated.
- Returns:
An expression which you can combine with other expressions, f will be evaluated at code generation time.
- Return type:
Expression
- Raises:
RuntimeError – If the input func is not callable.
ValueError – If the result of the expansion cannot be converted into an expression.
- pyoomph.expressions.generic.diff(f, *arg)[source]
Compute the derivative of a given expression with respect to one or more variables.
- Parameters:
f (ExpressionOrNum) – The expression to differentiate.
*arg (Expression) – The variables with respect to which the differentiation is performed.
- Returns:
The resulting expression after differentiation.
- Return type:
Expression
- Raises:
ValueError – If no variables are provided for differentiation.
- pyoomph.expressions.generic.dot(a, b)[source]
Compute the dot product between two vectors.
Parameters: a: The first vector. String will be wrapped in a var expression. b: The second vector. String will be wrapped in a var expression.
Returns: Expression: The dot product of the two vectors.
- Return type:
Expression
- pyoomph.expressions.generic.double_dot(A, B)[source]
Compute the double dot product of two expressions A and B.
- Parameters:
A (Expression) – The first expression.
B (Expression) – The second expression.
- Returns:
The result of the double dot product.
- Return type:
Expression
- pyoomph.expressions.generic.dyadic(a, b)[source]
Compute the dyadic product of two expressions.
- Parameters:
a (Expression) – The first expression.
b (Expression) – The second expression.
- Returns:
The dyadic product of a and b.
- Return type:
Expression
- pyoomph.expressions.generic.evaluate_at_midpoint(expr, midpt=0.5)[source]
Evaluates the given expression by replacing each var by a blending between the history values.
- Parameters:
expr (
Union[Expression,int,float]) – The expression to be evaluated.midpt (
Union[float,int]) – The blending at which to evaluate the var statements. Defaults to 0.5, i.e. all variables are evaluated at the average between current and previous time step (midpoint rule)
- Return type:
Expression- Returns:
The evaluated expression.
- Raises:
RuntimeError – If the expression is not an Expression.
RuntimeError – If the midpoint is less than 0.
RuntimeError – If the midpoint is a variable fraction (not yet supported).
- pyoomph.expressions.generic.evaluate_in_domain(expr, domain)[source]
Evaluates the given expression within the specified domain. Each var inside the expression will be evaluated in the given domain. Useful to e.g. evaluate the expression in the bulk (domain=”
..”) when at an boundary element, or at the opposite side of the interface (domain=”|.”)- Parameters:
expr (ExpressionOrNum) – The expression to be evaluated.
domain (Union[str,_pyoomph.FiniteElementCode,None]) – The domain within which the expression should be evaluated. It can be a string representing the domain name or e.g. “
..” for the bulk, “|.” for the opposite interface side or “|..” for the opposite bulk side
- Returns:
The evaluated expression within the specified domain.
- pyoomph.expressions.generic.evaluate_in_past(expr, timestep_offset=1)[source]
Evaluate the given expression in the past at a specified time offset.
- Parameters:
expr (
Union[Expression,int,float]) – The expression to be evaluated.timestep_offset (
Union[int,float]) – The time offset in the past. Defaults to 1, i.e. the previously converged solution.
- Return type:
Expression- Returns:
The evaluated expression in the past.
- Raises:
RuntimeError – If the time offset is negative.
RuntimeError – If the time offset is a variable step.
Note
If the time offset is an integer, the function evaluates the expression at that specific time step. If the time offset is a float, the function linearly interpolates between the results of the two nearest time steps. If the time offset is a variable step, the function raises a RuntimeError.
- pyoomph.expressions.generic.get_order_of_space(space)[source]
Get the order of the given finite element space.
- Return type:
int
- pyoomph.expressions.generic.grad(arg, lagrangian=False, nondim=False, coordsys=None, vector=None)[source]
Compute the gradient of the given argument. On surfaces, i.e. with a co-dimension, it is the surface gradient.
Parameters: arg (ExpressionOrNum): The argument for which the gradient is computed. lagrangian (bool, optional): Flag indicating whether the computation is with respect to Lagrangian coordinates. Default is False. nondim (bool, optional): Flag indicating whether the computation is with respect to non-dimensional coordinates. Default is False. coordsys (OptionalCoordinateSystem, optional): The coordinate system in which the gradient is computed. Default is None, which is the coordinate system of the Equation, potential parent equations or given at problem level. vector (Union[None,bool], optional): Flag indicating whether the gradient is a vector. Default is None, meaning it will find out automatically.
Returns: Expression: The computed gradient expression.
- Return type:
Expression
Notes
if you calculate grad(u) on a boundary, you will get the surface gradient, even if u is defined in the bulk. To get the bulk gradient at the boundary, use grad(var(“u”,domain=”..”)) instead.
- pyoomph.expressions.generic.identity_matrix(dim=-1)[source]
Returns the identity matrix of the specified dimension.
- Parameters:
dim (int) – The dimension of the identity matrix. If not provided, the dimension is 3.
- Returns:
The identity matrix.
- Return type:
Expression
- pyoomph.expressions.generic.is_DG_space(space, allow_DL_and_D0=False)[source]
Check if the given space is a discontinuous Galerkin space. By default,
"DL"and"D0"are not considered DG spaces, so that it returnsTruefor"D2TB",``”D2”,”D1TB”`` and"D1"- Parameters:
space (
Literal['C1','C1TB','C2','C2TB','D1','D1TB','D2','D2TB','DL','D0']) – The space to check.allow_DL_and_D0 (
bool) – Flag indicating whether the pure elemental spaces"DL"and"D0"also should return True. Defaults to False.
- Returns:
Whether the space is a discontinuous Galerkin space.
- pyoomph.expressions.generic.is_zero(arg, parameters_to_float=False)[source]
Check if the given argument (Expression or numerical value) is zero.
Parameters: arg (ExpressionOrNum): The argument to be checked. parameters_to_float: Flag indicating whether to convert a global parameter to its float values. Defaults to False, i.e. always False applied on a global parameter.
Returns: bool: True if the argument is zero, False otherwise.
Raises: ValueError: If the argument cannot be tested for zero.
- Return type:
bool
- pyoomph.expressions.generic.jump(f, at_facet=False)[source]
Calculate the jump of the given expression for discontinuous Galerkin methods.
- Parameters:
f (ExpressionOrNum) – The expression to calculate the jump for.
at_facet (bool, optional) – If True, calculate the jump at the facet, i.e. between the values at the facet directly. If you wrap it on a spatial differential operator, you will get the jump of e.g. the surface gradient. If False, calculate the jump between the two bulk domains. Here, the bulk gradients will be taken when applied with e.g. a grad. Default is False.
- Returns:
The jump across the interface, f_inside - f_outside.
- Return type:
Expression
- pyoomph.expressions.generic.material_derivative(f, velocity, ALE='auto', dt_scheme=None, nondim=False, lagrangian=False, dt_factor=1, advection_factor=1, coordsys=None)[source]
Compute the material derivative of a function with respect to time, i.e. \(\partial_t f + \nabla f \cdot \vec{u}\). Note that for tensorial quantities, one usually uses the
upper_convected_derivative()instead.- Parameters:
f (
Union[Expression,int,float,str]) – Any scalar, vectorial or tensorial function to be advected.velocity (
Union[Expression,int,float,str]) – Expression for the velocity field.ALE (
Union[Literal['auto'],bool]) – Use ALE correction. If set to"auto", it will only be used if the coordinates are degrees of freedom.dt_scheme (
Optional[Literal['BDF1','BDF2','Newmark2','TPZ','MPT','Simpson','Boole','trapezoidal','Kepler','Milne','midpoint']]) – Used time stepping scheme. If set to None, the default time stepping scheme set at problem level will be used.nondim (
bool) – Using non-dimensional time. Defaults to False.lagrangian (
bool) – Using Lagrangian coordinates for the gradient.dt_factor (
Union[Expression,int,float]) – Factor to weight the \(\partial_t f\) term.advection_factor (
Union[Expression,int,float]) – Factor to weight the advection termcoordsys (
Optional[CustomCoordinateSystem]) – Optional coordinate system to use. Defaults to None, meaning the coordinate system at equation level, parent equation level or problem level.
- Return type:
Expression- Returns:
The material derivative of the expression
fadvected byvelocity.
- pyoomph.expressions.generic.matproduct(a, b)[source]
Compute the matrix product of two expressions.
Parameters: a (ExpressionOrNum): The first expression. b (ExpressionOrNum): The second expression.
Returns: Expression: The matrix product of a and b.
Note: - If either a or b is not an Expression, it will be converted to one. - If either a or b is zero, the function will return zero. - The matrix product can be computed for matrices as well as vectors.
- Return type:
Expression
- pyoomph.expressions.generic.matrix(mlist, fill_to_max_vector_dim=True, fill_identity=False)[source]
Create a GiNaC matrix from a list of lists.
- Parameters:
mlist (List[List[ExpressionOrNum]]) – The input matrix represented as a list of lists.
fill_to_max_vector_dim (bool, optional) – Whether to fill the matrix to the maximum vector dimension 3. Defaults to True.
fill_identity (bool, optional) – Whether to fill the matrix diagonal by 1 when filling to max_vector_dim of 3. Defaults to False.
- Returns:
The matrix expression created from the input.
- Return type:
Expression
- Raises:
ValueError – If the number of matrix rows exceeds the maximum vector dimension.
ValueError – If the input matrix is not a valid matrix.
ValueError – If a matrix row exceeds the maximum vector dimension.
- pyoomph.expressions.generic.mesh_velocity(scheme=None, nondim=False)[source]
Get the mesh velocity, i.e. the time derivative of the mesh coordinates without ALE correction.
- Returns:
Just a shorthand for partial_t(var(“mesh”),ALE=False).
- Return type:
Expression
- pyoomph.expressions.generic.nondim(arg, tag=[], domain=None, no_jacobian=False, no_hessian=False, only_base_mode=False, only_perturbation_mode=False)[source]
This returns the nondimensional equivalent of a field, i.e. it is the same as var(…)/scale_factor(…).
See var for further details.
- Return type:
Union[Expression,Tuple[Expression,...]]
- pyoomph.expressions.generic.partial_t(f, order=1, ALE='auto', scheme=None, nondim=False)[source]
Compute the partial derivative of a function with respect to time, i.e. .. \(\partial_t^n f\). With ALE=False, this is evaluated at the nodal values directly, i.e. co-moving with a moving mesh. To correct for it by the mesh velocity \(\dot{\vec{X}}\), use the ALE=True or ALE=”auto”. In the latter case, the correction will only be considered if equations for the moving mesh are present, i.e. if
activate_coordinates_as_dofs()has been called by anyEquationsadded to this or any parent domain.If you want to obtain the mesh velocity, please use it with ALE=False.
- Parameters:
f (
Union[Expression,int,float,str]) – The function to differentiate. It can be an expression or a string representing a variable.order (
int) – The order of the derivative. Defaults to 1, maximum is 2.ALE (
Union[Literal['auto'],bool]) – Flag indicating whether to use Arbitrary Lagrangian-Eulerian (ALE) formulation. Defaults to “auto”. “auto” will activate the ALE correction if you combine it with a moving mesh only.scheme (
Optional[Literal['BDF1','BDF2','Newmark2','TPZ','MPT','Simpson','Boole','trapezoidal','Kepler','Milne','midpoint']]) – The time stepping scheme to use. Defaults to None, meaning the default time stepping scheme set at problem level.nondim (
bool) – Flag indicating whether to use non-dimensional time. Defaults to False.
- Return type:
Expression- Returns:
The partial derivative of the function with respect to time.
- pyoomph.expressions.generic.rational_num(numer_or_float_str, denom=1)[source]
Create a rational number expression at full accuracy. Opposed to floats, this will not introduce any rounding errors.
- Parameters:
numer_or_float_str (Union[int, str]) – The numerator of the rational number. If a string is provided, it will be interpreted as a float that should be converted to a rational.
denom (int, optional) – The denominator of the rational number. Defaults to 1.
- Returns:
The rational number expression.
- Return type:
Expression
- Raises:
RuntimeError – If numer_or_float_str is a string and denom is not equal to 1.
- pyoomph.expressions.generic.scale_factor(arg, tag=[], domain=None)[source]
Returns the scale factor of an unknown used for nondimensionalization. Will be expanded during code generation. If you pass scale=… as keyword argument to Equations.define_scalar_field, .define_vector_field or .define_ode_variable, this determines the scale factor. If the scale factor is not set there, it will look at parent equations and ultimately at the problem level, where you can set it via Problem.set_scaling. All scales are by default 1.
- Parameters:
arg (Union[str, NameStrSequence]) – The field names for which to get the scale factors used for nondimensionalization
tag (List[str], optional) – Additional tags to associate with the scale factor. Defaults to an empty list.
domain (Union[str, "FiniteElementCodeGenerator", None], optional) – The domain for which to compute the scale factor. You might want to get e.g. the scale of a field on the opposite side of the interface via domain=”
|.”.
- Returns:
The scale factor(s), will be expanded only during code generation.
- Return type:
SingleOrMultipleExpressions
- pyoomph.expressions.generic.subexpression(what)[source]
Wraps the expression in a subexpression. This will be calculated and derived in beforehand during the code generation and can speed up the assembly. Does not work in symbolical Hessians at the moment.
- Parameters:
what (ExpressionOrNum) – What to wrap in a subexpression.
- Returns:
A resulting expression where the expression is marked to be calculated in beforehand.
- Return type:
Expression
- Raises:
None –
- pyoomph.expressions.generic.symbolic_diff(expr, x, hold_until_codegen=True)[source]
Compute the symbolic differentiation of an expression with respect to a variable. It will be held, i.e. not applied, until code generation by default.
- Parameters:
expr (ExpressionOrNum) – The expression to differentiate.
x (Union[Expression,str]) – The variable with respect to which to differentiate.
hold_until_codegen (bool, optional) – Whether to hold the expression until code generation. Defaults to True.
- Returns:
The result of the symbolic differentiation.
- Return type:
Expression
- Raises:
RuntimeError – If the differentiation cannot be performed.
- pyoomph.expressions.generic.test_scale_factor(arg, tag=[], domain=None)[source]
Returns the scale factor of a test function or multiple test functions used for nondimensionalization. Will be expanded during code generation. If you pass testscale=… as keyword argument to Equations.define_scalar_field, .define_vector_field or .define_ode_variable, this determines the test scale factor. If the test scale factor is not set there, it will look at parent equations, which gives an additional factor 1/scale_factor(“spatial”) per level, since the integration measure (e.g. dx and dS) is always nondimensional. All test scales are by default 1.
- Parameters:
arg (Union[str, NameStrSequence]) – The field names for which to get the scale factors used for nondimensionalization
tag (List[str], optional) – Additional tags to associate with the scale factor. Defaults to an empty list.
domain (Union[str, "FiniteElementCodeGenerator", None], optional) – The domain for which to compute the scale factor. You might want to get e.g. the scale of a field on the opposite side of the interface via domain=”
|.”.
- Returns:
The test scale factor(s), will be expanded only during code generation.
- Return type:
SingleOrMultipleExpressions
- pyoomph.expressions.generic.testfunction(arg, tag=[], domain=None, dimensional=True)[source]
Return the testfunction corresponding to the field(s)
- Parameters:
arg (
Union[str,Expression,Tuple[str],List[str],Tuple[Expression],List[Expression]]) – Select the test function either by by name or by a var expression (or a list thereof).tag (
List[str]) – A list of tags associated with the argument. Default is an empty list, see also the tag argument of the var function.domain (
Union[None,FiniteElementCode,str]) – The domain associated with the argument. Default is None, see also the domain argument of the var function.dimensional (
bool) – A boolean flag indicating whether the we should consider the dimensional test_scale of the testfunction. Default is True.
- Return type:
Union[Expression,Tuple[Expression,...]]- Returns:
The corresponding testfunction(s) as an expression or a tuple of expressions.
- pyoomph.expressions.generic.time_scheme(scheme, expr, only_implicit_terms=False)[source]
Selects a time stepping scheme for the given expression by replacing all partial_t terms by the corresponding time stepping and expanding all other terms by appropriate evalulations in the past.
- Parameters:
scheme (
Literal['BDF1','BDF2','Newmark2','TPZ','MPT','Simpson','Boole','trapezoidal','Kepler','Milne','midpoint']) – The time stepping scheme to apply (“BDF1”,”BDF2”,”Newmark2”,”TPZ”,”MPT”,”Simpson”,”Boole”)expr (
Union[Expression,int,float]) – The expression to apply the time stepping scheme to.only_implicit_terms (
bool) – Whether to only evaluate the implicit terms (history terms will be not affected). Defaults to False.
- Return type:
Expression- Returns:
The result of applying the time stepping scheme to the expression.
- Raises:
ValueError – If an unknown time stepping scheme is provided.
- pyoomph.expressions.generic.transpose(A)[source]
Transposes the given matrix.
- Parameters:
A (Expression) – The matrix expression to be transposed.
- Returns:
The transposed matrix.
- Return type:
Expression
- pyoomph.expressions.generic.unit_matrix(dim=-1)
Returns the identity matrix of the specified dimension.
- Parameters:
dim (int) – The dimension of the identity matrix. If not provided, the dimension is 3.
- Returns:
The identity matrix.
- Return type:
Expression
- pyoomph.expressions.generic.unit_vector(dir)[source]
Returns a unit vector in the specified direction.
- Parameters:
dir (Union[int, Literal["x", "y", "z"]]) – The direction of the unit vector. Can be either an integer (0, 1, or 2) or a string (“x”, “y”, or “z”).
- Returns:
A vector expression representing the unit vector in the specified direction.
- Return type:
Expression
- pyoomph.expressions.generic.upper_convected_derivative(A, velocity, ALE='auto', dt_scheme=None, nondim=False, lagrangian=False, dt_factor=1, advection_factor=1, coordsys=None)[source]
Returns the upper-convected derivative of a tensor field \(\mathbf{A}\), i.e. \(\partial_t \mathbf{A} + \vec{u}\cdot\nabla\mathbf{A}-(\nabla \vec{u})^\mathrm{T}\cdot \mathbf{A} - \mathbf{A}\cdot\nabla\vec{u}\).
- Parameters:
A (
Union[Expression,int,float]) – Rank-2 tensor field to be advected.velocity (
Union[Expression,int,float]) – Advection velocityALE (
Union[Literal['auto'],bool]) – Use ALE correction. If set to"auto", it will only be used if the coordinates are degrees of freedom.dt_scheme (
Optional[Literal['BDF1','BDF2','Newmark2','TPZ','MPT','Simpson','Boole','trapezoidal','Kepler','Milne','midpoint']]) – Used time stepping scheme. If set to None, the default time stepping scheme set at problem level will be used.nondim (
bool) – Using non-dimensional time. Defaults to False.lagrangian (
bool) – Using Lagrangian coordinates for the gradient.dt_factor (
Union[Expression,int,float]) – Factor to weight the \(\partial_t \mathbf{A}\) term.advection_factor (
Union[Expression,int,float]) – Factor to weight the advection termcoordsys (
Optional[CustomCoordinateSystem]) – Optional coordinate system to use. Defaults to None, meaning the coordinate system at equation level, parent equation level or problem level.
- Return type:
Expression- Returns:
The upper convected derivative of the tensor field \(\mathbf{A}\) advected by the velocity field \(\vec{u}\).
- pyoomph.expressions.generic.var(arg, *, tag=[], domain=None, no_jacobian=False, no_hessian=False, only_base_mode=False, only_perturbation_mode=False)[source]
Binds a variable or a list of variables for usage in an expression by supplying the name(s)
- Parameters:
arg (
Union[str,Tuple[str],List[str]]) – A single variable name or a sequence of variable names.tag (
List[str]) – A list of tags to associate with the variable(s). Defaults to [].domain (
Union[str,FiniteElementCodeGenerator,None]) – The domain of the variable(s). Defaults to None, meaning the current domain. To get the bulk domain, use"..", for the opposite side of the interface, use"|.", for the opposite bulk domain use"|..".no_jacobian (
bool) – Flag indicating whether derivatives in Jacobian should be ignored. Defaults to False.no_hessian (
bool) – Flag indicating whether derivatives in the Hessian should be ignored. Defaults to False.only_base_mode (
bool) – Flag indicating whether only the axisymmetric base mode of the azimuthal mode expansion should be considered. Defaults to False.only_perturbation_mode (
bool) – Flag indicating whether only the azimuthal perturbation mode should be considered. Defaults to False.
- Return type:
Union[Expression,Tuple[Expression,...]]- Returns:
A single expression or a tuple of expressions representing the variable(s) to be used in expressions.
Notes
- Special variable names are:
"time": Current time"coordinate": indepedent coordinate vector. Time derivatives of this variable are zero"coordinate_x": indepedent x-coordinate. Time derivatives of this variable are zero"coordinate_y": indepedent y-coordinate. Time derivatives of this variable are zero"coordinate_z": indepedent z-coordinate. Time derivatives of this variable are zero"mesh": mesh coordinate vector, similar to"coordinate", but the time derivative gives the mesh velocity"mesh_x": mesh x-coordinate, similar to"coordinate_x", but the time derivative gives the mesh x-velocity"mesh_y": mesh y-coordinate, similar to"coordinate_y", but the time derivative gives the mesh y-velocity"mesh_z": mesh z-coordinate, similar to"coordinate_z", but the time derivative gives the mesh z-velocity"lagrangian": Lagrangian coordinate vector. By default, initialized with the initial Eulerian"coordinate""lagrangian_x": Lagrangian x-coordinate"lagrangian_y": Lagrangian y-coordinate"lagrangian_z": Lagrangian z-coordinate"normal": Normal vector. To be used at elements with co-dimension, i.e. interface elements"normal_x": x-component of the normal"normal_y": y-component of the normal"normal_z": z-component of the normal"dx": Can be used like in FEniCS to expressweak(a,b)asa*b*var("dx"). It does not respect the functional determinant of the coordinate system, though."dX": Same as"dx", but for Lagrangian integrals"element_size_Eulerian": Eulerian integration of the volume/area/length of the current element. Uses the coordinate system of the element, i.e. considers e.g. \(2\\pi\:r\) in axisymmetry"cartesian_element_size_Eulerian": Same as above, but does not consider the coordinate system"element_size_Lagrangian": Same as “element_size_Eulerian”, but by Lagrangian integration"cartesian_element_size_Lagrangian": Same as"cartesian_element_size_Eulerian", but by Lagrangian integration"element_length_h": Typical length scale of the element, calculated by taking"element_size_Eulerian"to the power of one over the element dimension"cartesian_element_length_h": Typical length scale of the element, but calculated in a Cartesian coordinate system
- pyoomph.expressions.generic.vector(*args)[source]
Create a vector expression from the given components.
- Parameters:
*args (
Union[Expression,int,float,List[Union[Expression,int,float]]]) – Variable number of arguments representing the vector components. Each component can be either an Expression, float, or int. If a single list is provided as the first argument, it is treated as the list of vector components.- Returns:
The vector expression created from the given components.
- Return type:
Expression
- Raises:
RuntimeError – If the arguments are not provided correctly.
ValueError – If the vector has too many components or no components at all.
- pyoomph.expressions.generic.weak(a, b, *, dimensional_dx=False, lagrangian=False, coordinate_system=None)[source]
Construct a term of a weak form, i.e. (a,b)=integral_Omega a*b dOmega where Omega is the domain. a is usually an expression depending on unknowns and b is usually a test function or spatial differentiations thereof.
- Parameters:
a (ExpressionOrNum) – An expression, usually a expression depending on unknowns.
b (ExpressionOrNum) – A testfunction or any linear function/operator applied on a testfunction.
dimensional_dx (bool, optional) – Flag indicating whether consider spatial integration units (e.g. m, m^2, m^3). Defaults to False.
lagrangian (bool, optional) – Flag indicating whether to integrate with respect to the Lagrangian coordinates and domain. Defaults to False.
coordinate_system (OptionalCoordinateSystem, optional) – The coordinate system to use. Defaults to None, meaning the coordinate system at equation level, parent equation level or problem level.
- Returns:
A weak form that can be further used in expressions or added to the residuals of equations by the method add_residual.
- Return type:
Expression