Closed twmr closed 1 year ago
Looking at the code quoted above, it looks like the diagonal parameter is only used for diagonal blocks, see https://github.com/FEniCS/dolfinx/blob/428293070cd1a2843257669b254678b20864de43/python/dolfinx/fem/petsc.py#L449
Or am I missing something?
it looks like the diagonal parameter is only used for diagonal blocks,
Yes, it looks like it should do TRT, but it doesn't. Give me a couple of minutes to figure out why.
The if a_sub.function_spaces[0] is a_sub.function_spaces[1]
conditional is always (also for the off-diagonal) elements in my case.
Why I output the function spaces of all entries in my block-form a
, I get
# pp [entry.function_spaces for row in a for entry in row]
[[<dolfinx.cpp.fem.FunctionSpace object at 0x7fce6c3fa8b0>, <dolfinx.cpp.fem.FunctionSpace object at 0x7fce6c3fa8b0>],
[<dolfinx.cpp.fem.FunctionSpace object at 0x7fce6c3fa8b0>, <dolfinx.cpp.fem.FunctionSpace object at 0x7fce6c3fa8b0>],
[<dolfinx.cpp.fem.FunctionSpace object at 0x7fce6c3fa8b0>, <dolfinx.cpp.fem.FunctionSpace object at 0x7fce6c3fa8b0>],
[<dolfinx.cpp.fem.FunctionSpace object at 0x7fce6c3fa8b0>, <dolfinx.cpp.fem.FunctionSpace object at 0x7fce6c3fa8b0>]]
Function spaces in your block mixed formulation $(V_1 \times V_2 \times V_3 \times V_4)$ must be all different FunctionSpace
objects (but they could have the same FE and mesh). You can use FunctionSpace.clone()
method to get a new unique FS object, see the docstring of that method.
Thx for the info. I'll check if this solves my problem and will close the ticket if I don't have any further questions/problems.
How to reproduce the bug
I think that the diagonal parameter of assemble_matrix_block function https://github.com/FEniCS/dolfinx/blob/428293070cd1a2843257669b254678b20864de43/python/dolfinx/fem/petsc.py#L411
should only be used for the diagonal blocks of the block matrix and not for all blocks. Otherwise it is not possible to use the assembled block matrix in linear solvers.
Changing this, i.e., setting
diagonal
to 0.0 for the off-diagonal blocks, would fix the issue that was mentioned in https://fenicsproject.discourse.group/t/speed-up-block-matrix-assembly-by-merging-sparsitypattern-of-the-blocks/10002/7?u=deepspaceMinimal Example (Python)
No response
Output (Python)
No response
Version
main branch
DOLFINx git commit
No response
Installation
No response
Additional information
No response