Implement MPC and more generalised constraints
- Dominant language
- C++
- Stars
- 1.2k
- Forks
- 261
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 65
Description
## Adding MPC functionality to core dolfinx
MPC (multi-point constraints) can be thought of as a more generalised boundary condition, e.g.
```math
u_i = \sum c_j u_j + k_i
```
- see https://github.com/jorgensd/dolfinx_mpc
In order to implement this in `dolfinx` I suggest the following:
* a container for the constraints on a given `DofMap`
* an assembler which can insert local element tensors with the constrained dofs substituted.
* a post-assembly step, which applies the actual constraint.
Some of this has been sketched out in branch https://github.com/FEniCS/dolfinx/tree/chris/basic-mpc
Remaining questions:
* Should we have e.g. `MPC_rows` and `MPC_cols` in the assembler (for different row and column spaces)?
* Should DirichletBC be included (as it is covered by the equation above)?
* We could redesign the `assemble_matrix` code to be simpler (delegating BCs to the `mat_add` lambda).
* What happens if a user tries to "chain" constraints?
### Suggested user interface
```python3
# Create an MPC object with the list of constraints
V = FunctionSpace(...)
local_constrained_dofs = [23, 47]
global_ref_dofs = [[123], [125, 126]]
global_ref_coeffs = [[1.0], [0.5, 0.5]]
mpc = dolfinx.fem.MPC(V, local_constrained_dofs, global_ref_dofs, global_ref_coeffs)
a = form(...)
sp = create_sparsity_pattern(a)
# Add extra sparsity for constraint
dolfinx.fem.build_sparsity_pattern_mpc(sp, a, mpc)
sp.finalize()
A = dolfinx.cpp.la.petsc.create_matrix(mesh.comm, sp)
dolfinx.fem.petsc.assemble_matrix_mpc(mpc, A, a)
A.assemble()
```
Contributor guide
Research direction
Start by reading the linked dolfinx_mpc project and the basic-mpc branch, then compare their constraint container, assembly, and post-assembly approaches with the suggested Python interface. Resolve the listed design questions about row and column spaces, DirichletBC, chained constraints, and sparsity before implementing the feature; done means MPC constraints work through assembly and application with suitable tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100