domi
May 17, 2025, 3:07am
1
Hello,
is it possible to change the way the dofmap is established while a mixed element space is built? To be more precise, in the following MWE
from dolfinx.mesh import create_unit_interval
from basix.ufl import element, mixed_element
from dolfinx.fem import functionspace
from mpi4py import MPI
msh = create_unit_interval(MPI.COMM_WORLD, 2)
cg1_elem = element("Lagrange", msh.basix_cell(), 1)
mix_elem = mixed_element(2 * [cg1_elem])
mix_elem_space = functionspace(msh, mix_elem)
v_space, v_dofmap = mix_elem_space.sub(0).collapse()
w_space, w_dofmap = mix_elem_space.sub(1).collapse()
v_dofmap = [0, 1, 4]
and w_dofmap = [2, 3, 5]
, i. e. the dofs are interweaved. However, what I would like to achieve is a flat dofmap, i.e. v_dofmap = [0, 1, 2]
and w_dofmap= [3, 4, 5]
.
Thank you for your help.
Best regards
domi
this is the exact reason for using the blocked assemblers in conjuncture with ufl.MixedFunctionSpace.
See for instance Stokes equations using Taylor-Hood elements — DOLFINx 0.9.0 documentation
for various illustrations.
Heads up - this api will be greatly simplified in the next release; see
main
← dokken/blocked_linear_solver
opened 08:23AM - 03 Apr 25 UTC
With the unification of `create_*`, `assemble_*` and `assign` for various PETSc … operators, I suggest we let `LinearProblem` support non-blocked and blocked problems, i.e.
```python
problem = LinearProblem(a, L, [bc0, bc1], petsc_options={"ksp_type": "preonly",
"pc_type": "lu",
"pc_factor_mat_solver_type":
"mumps"})
problem = LinearProblem([[a00,a01],[None, a11]], [L0, L1], bcs=[bc0, bc1],
u=[uh0, uh1])
```
For now, I've chosen to force the user to specify `u` for blocked problems, as it is hard extract the correct function spaces (`dolfinx.fem.FunctionSpace`, python class) from the nested list of forms with the current functions (`extract_function_spaces` work on the C++ function-spaces).
This also introduces an immediate solution vector `_x`, in the same fashion as within the proposed SNES solver.
It also adds the option of sending in a preconditioner to LinearProblem, as a `ufl.Form` or a nested sequence of Forms, which is then set to the krylov-solver.
main
← snes-solver-functional
opened 09:03PM - 24 Feb 25 UTC
A "functional" approach to the snes problem interface.
This reduced the code to… :
- One factory function: `create_snes_solver`, that returns the the user a `SNESObject` and a vector to solve into `x`
- A SNESSolver, that handles destruction of PETSc objects. It also store convenient wrappers to transfer data from your `dolfinx.fem.Function|list[dolfinx.fem.Function` (`u`) to the PETSc vector used for solving (`x`)
The tests now show examples of:
1. How to use `SNESSolver`, the highest level interface
2. How to use `create_snes_solver`, the mid-level interface
3. How to use the functions supplied in `dolfinx.nls.petsc` and `dolfinx.fem.petsc` to interact with your own snes solver instance.
for details