[BUG]: different trial and test space with dirichlet boundary conditions should throw an error
- Dominant language
- C++
- Stars
- 1.2k
- Forks
- 261
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 71
Description
### Summarize the issue
I tried to solve a Petrov-Galerkin formulation with Fenicsx, where i used different Trial and Test spaces
```python
U = fem.functionspace(msh, ("Lagrange", 1))
V = fem.functionspace(msh, ("Lagrange", 1))
u = ufl.TrialFunction(U)
v = ufl.TestFunction(V)
```
You can find the full description here:
https://fenicsproject.discourse.group/t/petrov-gelerkin-formulations-and-fenicsx/18369?u=mfeuerle
Applying Dirichlet boundary conditions to at least one of these spaces results in a problem within `dolfinx` that is not captured accordingly, even if the same Dirichlet conditions are applied to both spaces, effectively resulting in the same space, but as two different objects.
When trying to solve the resulting system e.g. using `dolfinx.fem.petsc.LinearProblem` or when assembling the system e.g. using `dolfinx.fem.form` followed by `dolfinx.fem.assemble_matrix`, `dolfinx` leaves the system in an unfinished state: it sets all rows and columns to zero, but then, realizing that Trial and Test space are not equal and there might not be a 1one1 realition between trial dofs and test dofs, it (correctly) does not set the 1.0 on the diagonal (this approach on Dirichlet boundary condition is just not able to handle Petrov-Galerkin formulations where different Trial and Test spaces are used). It should raise an error stating that it is not able to correctly handle this setting (different Trial and Test space + Dirichlet condition), instead of leaving the system in an unfinished state (handling of BCs is stopped half way and the resulting matrix is singular).
This is a bug report, for not raising an appropriate error. For the Feature request to actually support this, see #3989
### How to reproduce the bug
See https://fenicsproject.discourse.group/t/petrov-gelerkin-formulations-and-fenicsx/18369?u=mfeuerle
### Minimal Example (Python)
```Python
```
### Output (Python)
```bash
```
### Version
main branch
### DOLFINx git commit
_No response_
### Installation
_No response_
### Additional information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.