Skip to content

Safely setting the solution vector #4028

Answered by dknez
rebpoli asked this question in Q&A
Discussion options

You must be logged in to vote

In the case that we're using PETSc, then the solution vector is a PETSc vector. In this case you can set non-local entries of a vector, and then when you call close(), it will do the necessary communication so that all processors have the relevant local values only.

But actually, you're asking about a simpler case. You're looping over local elements only and asking if you need to check first_local_dof/last_local_dof when you set vector values. It should work either way, but I think it's better to include the first_local_dof/last_local_dof check, since that will skip setting off-processor values that don't need to be set.

The case to keep in mind is when you have a node that's on the borde…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by roystgnr
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants