enrichedfem.fenics_expressions package
Submodules
enrichedfem.fenics_expressions.fenics_expressions module
- class enrichedfem.fenics_expressions.fenics_expressions.AnisotropyExpr(params, degree, domain, pb_considered)[source]
Bases:
MyUserExpression22FEniCS expression for an anisotropic diffusion matrix.
This class represents a FEniCS expression for a 2x2 anisotropic diffusion matrix. It inherits from MyUserExpression22 to handle JIT compilation and evaluation of the matrix at given spatial points.
- Parameters:
params (list or tuple) – The parameters of the problem.
degree (int) – The degree of the finite element.
domain (dolfin.Mesh) – The mesh of the problem.
pb_considered – The problem being considered, which should have an anisotropy_matrix method for defining the matrix symbolically.
- eval(value, x)[source]
Evaluate the anisotropy matrix at a given point.
This method evaluates the 2x2 anisotropy matrix at a given spatial point x and stores the result in the value array.
- Parameters:
value (numpy.ndarray) – The array to store the evaluated matrix.
x (tuple) – The spatial coordinates of the point.
- class enrichedfem.fenics_expressions.fenics_expressions.MyUserExpression22(degree, domain)[source]
Bases:
BaseExpressionCustom FEniCS expression for 2x2 matrices.
This class extends FEniCS’s BaseExpression to represent 2x2 matrix-valued expressions. It facilitates the definition and evaluation of such expressions within FEniCS, enabling JIT compilation for efficient computation.
- Parameters:
degree (int) – The degree of the finite element.
domain (dolfin.Mesh) – The mesh of the problem.
- enrichedfem.fenics_expressions.fenics_expressions.get_expr_from_sympy(params, degree, domain, fct)[source]
Convert a symbolic function to a FEniCS expression.
This function takes a symbolic function defined using SymPy and converts it into a FEniCS expression that can be used within FEniCS computations. It handles parameter substitution and conversion to C++ code for JIT compilation.
- Parameters:
params (list or tuple) – The parameters of the problem.
degree (int) – The degree of the finite element.
domain (dolfin.Mesh) – The mesh of the problem.
fct (callable) – The symbolic function to convert, which should take SymPy, spatial variables, and parameters as arguments.
- Returns:
The FEniCS expression corresponding to the input symbolic function.
- Return type:
dolfin.Expression
- enrichedfem.fenics_expressions.fenics_expressions.get_f_expr(params, degree, domain, pb_considered)[source]
Convert the symbolic source term to a FEniCS expression.
This function converts the symbolic source term (f) of the considered problem to a FEniCS expression. It uses the get_expr_from_sympy function to perform the conversion.
- Parameters:
params (list or tuple) – The parameters of the problem.
degree (int) – The degree of the finite element.
domain (dolfin.Mesh) – The mesh of the problem.
pb_considered – The problem being considered, which should have a f attribute representing the symbolic source term.
- Returns:
The FEniCS expression corresponding to the source term.
- Return type:
dolfin.Expression
- enrichedfem.fenics_expressions.fenics_expressions.get_g_expr(params, degree, domain, pb_considered)[source]
Convert the symbolic Dirichlet boundary condition to a FEniCS expression.
This function converts the symbolic Dirichlet boundary condition (g) of the considered problem to a FEniCS expression. It uses the get_expr_from_sympy function to perform the conversion.
- Parameters:
params (list or tuple) – The parameters of the problem.
degree (int) – The degree of the finite element.
domain (dolfin.Mesh) – The mesh of the problem.
pb_considered – The problem being considered, which should have a g attribute representing the symbolic Dirichlet boundary condition.
- Returns:
The FEniCS expression corresponding to the Dirichlet boundary condition.
- Return type:
dolfin.Expression
- enrichedfem.fenics_expressions.fenics_expressions.get_gn_expr(params, degree, domain, pb_considered)[source]
Convert the symbolic Neumann boundary condition to a FEniCS expression.
This function converts the symbolic Neumann boundary condition (g) of the considered problem to a FEniCS expression. It uses the get_expr_from_sympy function to perform the conversion.
- Parameters:
params (list or tuple) – The parameters of the problem.
degree (int) – The degree of the finite element.
domain (dolfin.Mesh) – The mesh of the problem.
pb_considered – The problem being considered, which should have a g attribute representing the symbolic Neumann boundary condition.
- Returns:
The FEniCS expression corresponding to the Neumann boundary condition.
- Return type:
dolfin.Expression
- enrichedfem.fenics_expressions.fenics_expressions.get_gr_expr(params, degree, domain, pb_considered)[source]
Convert the symbolic Robin boundary condition to a FEniCS expression.
This function converts the symbolic Robin boundary condition (g) of the considered problem to a FEniCS expression. It uses the get_expr_from_sympy function to perform the conversion.
- Parameters:
params (list or tuple) – The parameters of the problem.
degree (int) – The degree of the finite element.
domain (dolfin.Mesh) – The mesh of the problem.
pb_considered – The problem being considered, which should have a g attribute representing the symbolic Robin boundary condition.
- Returns:
The FEniCS expression corresponding to the Robin boundary condition.
- Return type:
dolfin.Expression
- enrichedfem.fenics_expressions.fenics_expressions.get_h_ext_expr(params, degree, domain, pb_considered)[source]
Convert the symbolic exterior boundary condition to a FEniCS expression.
This function converts the symbolic exterior boundary condition (h_ext) of the considered problem to a FEniCS expression. It uses the get_expr_from_sympy function to perform the conversion. Used in the donut problem.
- Parameters:
params (list or tuple) – The parameters of the problem.
degree (int) – The degree of the finite element.
domain (dolfin.Mesh) – The mesh of the problem.
pb_considered – The problem being considered, which should have a h_ext attribute representing the symbolic exterior boundary condition.
- Returns:
The FEniCS expression corresponding to the exterior boundary condition.
- Return type:
dolfin.Expression
- enrichedfem.fenics_expressions.fenics_expressions.get_h_int_expr(params, degree, domain, pb_considered)[source]
Convert the symbolic interior boundary condition to a FEniCS expression.
This function converts the symbolic interior boundary condition (h_int) of the considered problem to a FEniCS expression. It uses the get_expr_from_sympy function to perform the conversion. Used in the donut problem.
- Parameters:
params (list or tuple) – The parameters of the problem.
degree (int) – The degree of the finite element.
domain (dolfin.Mesh) – The mesh of the problem.
pb_considered – The problem being considered, which should have a h_int attribute representing the symbolic interior boundary condition.
- Returns:
The FEniCS expression corresponding to the interior boundary condition.
- Return type:
dolfin.Expression
- enrichedfem.fenics_expressions.fenics_expressions.get_uex_expr(params, degree, domain, pb_considered)[source]
Convert the symbolic exact solution to a FEniCS expression.
This function converts the symbolic exact solution (u_ex) of the considered problem to a FEniCS expression. It uses the get_expr_from_sympy function to perform the conversion.
- Parameters:
params (list or tuple) – The parameters of the problem.
degree (int) – The degree of the finite element.
domain (dolfin.Mesh) – The mesh of the problem.
pb_considered – The problem being considered, which should have a u_ex attribute representing the symbolic exact solution.
- Returns:
The FEniCS expression corresponding to the exact solution.
- Return type:
dolfin.Expression