jorgensd / jorgensd/dolfinx_mpc
Efficient mpc creation with same dofs, different coefficient
- Dominant language
- Python
- Stars
- 62
- Forks
- 22
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 4
Description
# Motivation
Another feature request motivated by wave propagation: to compute a band structure for periodic media, we prescribe the wavevector $k$ through the Bloch boundary conditions, which are applied with a multipoint constraint, then solve the eigenvalue problem to obtain the eigenfrequencies. To produce the entire band structure, we iterate through a range of $k$ and repeatedly construct and solve the eigenvalue problem. Since the multipoint constraint is repeatedly applied to the same set of slave and master dofs, it is desirable to re-use the information about the slave and master dofs, and thus only need to update the coefficients of the mpc at each step of the iteration.
# Requested improvement
Make [`MultiPointConstraint.create_periodic_constraint_topological`](https://github.com/jorgensd/dolfinx_mpc/blob/main/python/dolfinx_mpc/multipointconstraint.py#L103) (and `create_periodic_constraint_geometrical`, etc.) return the `mpc_data` object that is generated by the C++ layer. Then it can be saved and the `mpc_data.coeffs` array updated at each iteration, e.g.
```python
mpc = MultiPointConstraint(V)
mpc_data = mpc.create_periodic_constraint_topological( ... )
for k in np.linspace(0, 1, N):
mpc_data.coeffs[:] = k
mpc = MultiPointConstraint(V)
mpc.add_constraint_from_mpc_data(mpc_data)
mpc.finalize()
# Solve eigenvalue problem
```
Note: this is already possible by directly accessing the C++ wrapper layer, i.e. with
```python
mpc_data = dolfinx_mpc.cpp.mpc.create_periodic_constraint_topological( ... )
```
but the suggested improvement would result in cleaner code and eliminate the need for users to directly call the C++ layer.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.