cell_problem
cell_problem
¶
Helper problems that are used to solve the cell problem in the HMM.
Classes:
| Name | Description |
|---|---|
PeriodicLinearProblem |
linear problem class that automatically adds periodic boundary conditions on boxes. |
hommx.cell_problem.PeriodicLinearProblem
¶
Bases: dolfinx_mpc.LinearProblem
Class for solving a linear variational problem with periodic boundary conditions with multi point constraints of the form \(a(u, v) = L(v)\) for all v using PETSc as a linear algebra backend.
The solution is only unique up to a constant. This is handled by telling the PETSc KSP solver about the nullspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
A bilinear UFL form, the left hand side of the variational problem. |
required | |
L
|
A linear UFL form, the right hand side of the variational problem. |
required | |
mpc
|
The multi point constraint. |
required | |
bcs
|
A list of Dirichlet boundary conditions. |
required | |
u
|
The solution function. It will be created if not provided. The function has to be based on the functionspace in the mpc, i.e. .. highlight:: python .. code-block:: python |
required | |
petsc_options
|
Parameters that is passed to the linear algebra backend PETSc. #type: ignore For available choices for the 'petsc_options' kwarg, see the PETSc-documentation https://www.mcs.anl.gov/petsc/documentation/index.html. |
required | |
form_compiler_options
|
Parameters used in FFCx compilation of this form. Run |
required | |
jit_options
|
Parameters used in CFFI JIT compilation of C code generated by FFCx. See https://github.com/FEniCS/dolfinx/blob/main/python/dolfinx/jit.py#L22-L37 for all available parameters. Takes priority over all other parameter values. |
required |
Examples: Example usage:
.. highlight:: python
.. code-block:: python
problem = LinearProblem(
a, L, mpc, [bc0, bc1], petsc_options={"ksp_type": "preonly", "pc_type": "lu"}
)
hommx.cell_problem.create_periodic_boundary_conditions
¶
create_periodic_boundary_conditions(function_space: fem.FunctionSpace, bcs: list[fem.DirichletBC] | None = None) -> dolfinx_mpc.MultiPointConstraint
Creates periodic boundary condition on the unit square or unit cube.
For implementation details see
_create_periodic_boundary_conditions_2d
and
_create_periodic_boundary_conditions_3d
hommx.cell_problem._create_periodic_boundary_conditions_2d
¶
_create_periodic_boundary_conditions_2d(msh: mesh.Mesh, function_space: fem.FunctionSpace, bcs: list[fem.DirichletBC] | None = None) -> dolfinx_mpc.MultiPointConstraint
Creates periodic boundary condition on the unit square using dolfinx_mpc.
This is done using create_periodic_constraints. We do this by forcing \(u(x, y_1) = u(x, y_0)\) and \(u(x_1, y) = u(x_0, y)\), on the unit square we would have \((x_0, x_1) = (y_0, y_1) = (0, 1)\) Internally we create slave DoFs at \(u(x, y_1)\) and \(u(x_1, y)\). Some attention need to be paid because the node at \((x_1,y_1)\) is constrained twice. We use a workaround adapted from: dolfinx_mpc
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msh
|
mesh.Mesh
|
Mesh that the boundary conditions should be applied to |
required |
function_space
|
fem.FunctionSpace
|
Function Space on whicht the bc should be applied |
required |
bcs
|
list[fem.DirichletBC] | None
|
Dirichlet Boundary Conditions, here the constraint is ignored |
None
|
hommx.cell_problem._create_periodic_boundary_conditions_3d
¶
_create_periodic_boundary_conditions_3d(msh: mesh.Mesh, function_space: fem.FunctionSpace, bcs: list[fem.DirichletBC] | None = None) -> dolfinx_mpc.MultiPointConstraint
Creates periodic boundary condition on the unit cube using dolfinx_mpc.
This is done using create_periodic_constraints. We do this by forcing \(u(x, y_1, z) = u(x, y_0, z)\) and so on for all directions on the unit square we would have \((z_0, z_1) = (x_0, x_1) = (y_0, y_1) = (0, 1)\) Internally we create slave DoFs at \(u(x, y_1, z)\) and \(u(x_1, y, z)\) etc. Some attention need to be paid because the nodes at \((x_1, y_1, z)\) are constrained twice etc for other edges And \((x_1, y_1, z_1)\) is constrained three times. We use a workaround adapted from: dolfinx_mpc
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msh
|
mesh.Mesh
|
Mesh that the boundary conditions should be applied to |
required |
function_space
|
fem.FunctionSpace
|
Function Space on which the bc should be applied |
required |
bcs
|
list[fem.DirichletBC] | None
|
Dirichlet Boundary Conditions, here the constraint is ignored |
None
|