Setting entries of PETScVector
Created by: chleh
In PR #1130 a new setting function for vector entries has been introduced. However, that setting function does not completely work with PETSc. I.e., ghost entries will not be set since negative indices are not treated specially. Therefore probably solving nonlinear problems with PETSc will not work in some cases (when DIrichlet BCs have to be written to ghost nodes).
The code in question is that one: https://github.com/ufz/ogs/blob/master/MathLib/LinAlg/UnifiedMatrixSetters.cpp#L109
However, the given location is only one indicator of a bigger "problem": Currently there are two different semantics when writing (add/set) to PETSc vectors: (1) ignoring ghost nodes, e.g., in the FEM assembly, (2) not ignoring them, e.g., when setting Dirichlet BCs to the solution vector.
I have two possible solutions in mind:
- always communicate ghost entries after each bunch of writes (taking care about add vs. set)
- provide different add/set methods that write or don't write to ghost entries
For the time being, I think the second option is easier to implement, althoug we should keep the first one in mind.
There might be a third option: The caller always takes care about converting negative indices to positive ones if needed, e.g., by calling some general method absIndex(i, vector)
. But that's rather implicit and can be easily forgotten. So I'd vote against it.