symfem.functionals
¶
Functionals used to define the dual sets.
Module Contents¶
Classes¶
A functional. |
|
A point evaluation. |
|
A point evaluation. |
|
A point evaluation of a given derivative. |
|
A point evaluation of a derivative in a fixed direction. |
|
A point evaluation of a normal derivative. |
|
A point evaluation of a component of a second derivative. |
|
An evaluation of an inner product at a point. |
|
A point evaluation in a given direction. |
|
A point evaluation of the divergence. |
|
An integral against a function. |
|
An integral of the divergence against a function. |
|
An integral of a directional derivative of a scalar function. |
|
An integral moment. |
|
An integral moment of the derivative of a scalar function. |
|
An integral moment of the divergence of a vector function. |
|
An integral moment in the tangential direction. |
|
An integral moment in the normal direction. |
|
An integral moment in the normal direction. |
|
An integral moment of the inner product with a vector. |
|
An integral moment of the inner product with the normal direction. |
Functions¶
|
Convert an expresson to TeX. |
|
Add th, st or nd to a number. |
Attributes¶
- symfem.functionals.ScalarValueOrFloat¶
- symfem.functionals._to_tex(f: symfem.functions.FunctionInput, tfrac: bool = False) str ¶
Convert an expresson to TeX.
- Parameters:
f – the function
tfrac – Should \tfrac be used in the place of \frac?
- Returns:
The function as TeX
- symfem.functionals._nth(n: int) str ¶
Add th, st or nd to a number.
- Parameters:
n – The number
- Returns:
The string (n)th, (n)st, (n)rd or (n)nd
- class symfem.functionals.BaseFunctional(reference: symfem.references.Reference, entity: Tuple[int, int], mapping: str | None)¶
Bases:
abc.ABC
A functional.
- name = 'Base functional'¶
- entity_dim() int ¶
Get the dimension of the entity this DOF is associated with.
- Returns:
The dimension of the entity this DOF is associated with
- entity_number() int ¶
Get the number of the entity this DOF is associated with.
- Returns:
The number of the entity this DOF is associated with
- perform_mapping(fs: List[symfem.functions.AnyFunction], map: symfem.geometry.PointType, inverse_map: symfem.geometry.PointType) List[symfem.functions.AnyFunction] ¶
Map functions to a cell.
- Parameters:
fs – functions
map – Map from the reference cell to a physical cell
inverse_map – Map to the reference cell from a physical cell
- Returns:
Mapped functions
- entity_tex() str ¶
Get the entity the DOF is associated with in TeX format.
- Returns:
TeX representation of entity
- entity_definition() str ¶
Get the definition of the entity the DOF is associated with.
- Returns:
The definition
- dof_direction() symfem.geometry.PointType | None ¶
Get the direction of the DOF.
- Returns:
The direction
- eval(function: symfem.functions.AnyFunction, symbolic: bool = True) symfem.functions.ScalarFunction | float ¶
Apply to the functional to a function.
- Parameters:
function – The function
symbolic – Should it be applied symbolically?
- Returns:
The value of the functional for the function
- abstract dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- adjusted_dof_point() symfem.geometry.PointType ¶
Get the adjusted position of the DOF in the cell for plotting.
- Returns:
The point
- eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.ScalarFunction ¶
Symbolically apply the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- abstract _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- abstract get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.PointEvaluation(reference: symfem.references.Reference, point_in: symfem.functions.FunctionInput, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
BaseFunctional
A point evaluation.
- name = 'Point evaluation'¶
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- adjusted_dof_point() symfem.geometry.PointType ¶
Get the adjusted position of the DOF in the cell for plotting.
- Returns:
The point
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.WeightedPointEvaluation(reference: symfem.references.Reference, point_in: symfem.functions.FunctionInput, weight: sympy.core.expr.Expr, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
BaseFunctional
A point evaluation.
- name = 'Weighted point evaluation'¶
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- adjusted_dof_point() symfem.geometry.PointType ¶
Get the adjusted position of the DOF in the cell for plotting.
- Returns:
The point
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.DerivativePointEvaluation(reference: symfem.references.Reference, point_in: symfem.functions.FunctionInput, derivative: Tuple[int, Ellipsis], entity: Tuple[int, int], mapping: str | None = None)¶
Bases:
BaseFunctional
A point evaluation of a given derivative.
- name = 'Point derivative evaluation'¶
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- adjusted_dof_point() symfem.geometry.PointType ¶
Get the adjusted position of the DOF in the cell for plotting.
- Returns:
The point
- perform_mapping(fs: List[symfem.functions.AnyFunction], map: symfem.geometry.PointType, inverse_map: symfem.geometry.PointType) List[symfem.functions.AnyFunction] ¶
Map functions to a cell.
- Parameters:
fs – functions
map – Map from the reference cell to a physical cell
inverse_map – Map to the reference cell from a physical cell
- Returns:
Mapped functions
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.PointDirectionalDerivativeEvaluation(reference: symfem.references.Reference, point_in: symfem.functions.FunctionInput, direction_in: symfem.functions.FunctionInput, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
BaseFunctional
A point evaluation of a derivative in a fixed direction.
- name = 'Point evaluation of directional derivative'¶
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- dof_direction() symfem.geometry.PointType | None ¶
Get the direction of the DOF.
- Returns:
The direction
- adjusted_dof_point() symfem.geometry.PointType ¶
Get the adjusted position of the DOF in the cell for plotting.
- Returns:
The point
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.PointNormalDerivativeEvaluation(reference: symfem.references.Reference, point_in: symfem.functions.FunctionInput, edge: symfem.references.Reference, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
PointDirectionalDerivativeEvaluation
A point evaluation of a normal derivative.
- name = 'Point evaluation of normal derivative'¶
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.PointComponentSecondDerivativeEvaluation(reference: symfem.references.Reference, point_in: symfem.functions.FunctionInput, component: Tuple[int, int], entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
BaseFunctional
A point evaluation of a component of a second derivative.
- name = 'Point evaluation of Jacobian component'¶
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- adjusted_dof_point() symfem.geometry.PointType ¶
Get the adjusted position of the DOF in the cell for plotting.
- Returns:
The point
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.PointInnerProduct(reference: symfem.references.Reference, point_in: symfem.functions.FunctionInput, lvec: symfem.functions.FunctionInput, rvec: symfem.functions.FunctionInput, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
BaseFunctional
An evaluation of an inner product at a point.
- name = 'Point inner product'¶
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- dof_direction() symfem.geometry.PointType | None ¶
Get the direction of the DOF.
- Returns:
The direction
- adjusted_dof_point() symfem.geometry.PointType ¶
Get the adjusted position of the DOF in the cell for plotting.
- Returns:
The point
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.DotPointEvaluation(reference: symfem.references.Reference, point_in: symfem.functions.FunctionInput, vector_in: symfem.functions.FunctionInput, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
BaseFunctional
A point evaluation in a given direction.
- name = 'Dot point evaluation'¶
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- dof_direction() symfem.geometry.PointType | None ¶
Get the direction of the DOF.
- Returns:
The direction
- adjusted_dof_point() symfem.geometry.PointType ¶
Get the adjusted position of the DOF in the cell for plotting.
- Returns:
The point
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.PointDivergenceEvaluation(reference: symfem.references.Reference, point_in: symfem.functions.FunctionInput, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
BaseFunctional
A point evaluation of the divergence.
- name = 'Point evaluation of divergence'¶
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- dof_direction() symfem.geometry.PointType | None ¶
Get the direction of the DOF.
- Returns:
The direction
- adjusted_dof_point() symfem.geometry.PointType ¶
Get the adjusted position of the DOF in the cell for plotting.
- Returns:
The point
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.IntegralAgainst(reference: symfem.references.Reference, f_in: symfem.functions.FunctionInput, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
BaseFunctional
An integral against a function.
- name = 'Integral against'¶
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- dot(function: symfem.functions.AnyFunction) symfem.functions.ScalarFunction ¶
Dot a function with the moment function.
- Parameters:
function – The function
- Returns:
The product of the function and the moment function
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.IntegralOfDivergenceAgainst(reference: symfem.references.Reference, f_in: symfem.functions.FunctionInput, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
BaseFunctional
An integral of the divergence against a function.
- name = 'Integral of divergence against'¶
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- dot(function: symfem.functions.ScalarFunction) symfem.functions.ScalarFunction ¶
Dot a function with the moment function.
- Parameters:
function – The function
- Returns:
The product of the function and the moment function
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.IntegralOfDirectionalMultiderivative(reference: symfem.references.Reference, directions: symfem.geometry.SetOfPoints, orders: Tuple[int, Ellipsis], entity: Tuple[int, int], scale: int = 1, mapping: str | None = 'identity')¶
Bases:
BaseFunctional
An integral of a directional derivative of a scalar function.
- name = 'Integral of a directional derivative'¶
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- perform_mapping(fs: List[symfem.functions.AnyFunction], map: symfem.geometry.PointType, inverse_map: symfem.geometry.PointType) List[symfem.functions.AnyFunction] ¶
Map functions to a cell.
- Parameters:
fs – functions
map – Map from the reference cell to a physical cell
inverse_map – Map to the reference cell from a physical cell
- Returns:
Mapped functions
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.IntegralMoment(reference: symfem.references.Reference, f_in: symfem.functions.FunctionInput, dof: BaseFunctional, entity: Tuple[int, int], mapping: str | None = 'identity', map_function: bool = True)¶
Bases:
BaseFunctional
An integral moment.
- name = 'Integral moment'¶
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- dot(function: symfem.functions.AnyFunction) symfem.functions.ScalarFunction ¶
Dot a function with the moment function.
- Parameters:
function – The function
- Returns:
The product of the function and the moment function
- dof_point() symfem.geometry.PointType ¶
Get the location of the DOF in the cell.
- Returns:
The point
- dof_direction() symfem.geometry.PointType | None ¶
Get the direction of the DOF.
- Returns:
The direction
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.DerivativeIntegralMoment(reference: symfem.references.Reference, f: symfem.functions.FunctionInput, dot_with_in: symfem.functions.FunctionInput, dof: BaseFunctional, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
IntegralMoment
An integral moment of the derivative of a scalar function.
- name = 'Derivative integral moment'¶
- dot(function: symfem.functions.AnyFunction) symfem.functions.ScalarFunction ¶
Dot a function with the moment function.
- Parameters:
function – The function
- Returns:
The product of the function and the moment function
- dof_direction() symfem.geometry.PointType | None ¶
Get the direction of the DOF.
- Returns:
The direction
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- class symfem.functionals.DivergenceIntegralMoment(reference: symfem.references.Reference, f_in: symfem.functions.FunctionInput, dof: BaseFunctional, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
IntegralMoment
An integral moment of the divergence of a vector function.
- name = 'Integral moment of divergence'¶
- _eval_symbolic(function: symfem.functions.AnyFunction) symfem.functions.AnyFunction ¶
Apply to the functional to a function.
- Parameters:
function – The function
- Returns:
The value of the functional for the function
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.TangentIntegralMoment(reference: symfem.references.Reference, f_in: symfem.functions.FunctionInput, dof: BaseFunctional, entity: Tuple[int, int], mapping: str | None = 'covariant')¶
Bases:
IntegralMoment
An integral moment in the tangential direction.
- name = 'Tangential integral moment'¶
- dof_direction() symfem.geometry.PointType | None ¶
Get the direction of the DOF.
- Returns:
The direction
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.NormalIntegralMoment(reference: symfem.references.Reference, f_in: symfem.functions.FunctionInput, dof: BaseFunctional, entity: Tuple[int, int], mapping: str | None = 'contravariant')¶
Bases:
IntegralMoment
An integral moment in the normal direction.
- name = 'Normal integral moment'¶
- dof_direction() symfem.geometry.PointType | None ¶
Get the direction of the DOF.
- Returns:
The direction
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.NormalDerivativeIntegralMoment(reference: symfem.references.Reference, f_in: symfem.functions.FunctionInput, dof: BaseFunctional, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
DerivativeIntegralMoment
An integral moment in the normal direction.
- name = 'Normal derivative integral moment'¶
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.InnerProductIntegralMoment(reference: symfem.references.Reference, f_in: symfem.functions.FunctionInput, inner_with_left_in: symfem.functions.FunctionInput, inner_with_right_in: symfem.functions.FunctionInput, dof: BaseFunctional, entity: Tuple[int, int], mapping: str | None = 'identity')¶
Bases:
IntegralMoment
An integral moment of the inner product with a vector.
- name = 'Inner product integral moment'¶
- dot(function: symfem.functions.AnyFunction) symfem.functions.ScalarFunction ¶
Take the inner product of a function with the moment direction.
- Parameters:
function – The function
- Returns:
The inner product of the function and the moment direction
- dof_direction() symfem.geometry.PointType | None ¶
Get the direction of the DOF.
- Returns:
The direction
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- class symfem.functionals.NormalInnerProductIntegralMoment(reference: symfem.references.Reference, f_in: symfem.functions.FunctionInput, dof: BaseFunctional, entity: Tuple[int, int], mapping: str | None = 'double_contravariant')¶
Bases:
InnerProductIntegralMoment
An integral moment of the inner product with the normal direction.
- name = 'Normal inner product integral moment'¶
- get_tex() Tuple[str, List[str]] ¶
Get a representation of the functional as TeX, and list of terms involved.
- Returns:
Representation of the functional as TeX, and list of terms involved
- symfem.functionals.ListOfFunctionals¶