This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Manipulating vector values in parallel and using apply

+1 vote

Hi,

I'm still a little confused about the correct way of manipulating values of vectors in parallel. Consider the following situations:

  1. v0 is a vector of coefficients of a DG(0) function that I want to use as a cell-wise constant coefficient in my weak form (and possibly save to a .pvd file for inspection)

  2. v1 is a vector of coefficients of a CG(1) function (solution of the problem) that I am going to, e.g., use as an initial approximation for a KrylovSolver, compute a norm of, multiply with a matrix, save into a .pvd file, etc.

From the linked answer, I know that I need to call v1.apply("") after each call to v1.set_local(x). My questions are:

  1. Does the same hold also for v0? I suppose that inter-process boundaries of partitioned meshes do not run through cells, so are vectors representing DG(0) functions free of ghost indices?

  2. What is the difference between

    v.apply("insert")

    (present at many places in Dolfin sources after calls to set_local) and plain

    v.apply("")

  3. Why does the linked answer explicitly say "... get/set functions"? I suppose that I don't need to call v.apply after v.get_local, or am I wrong?

Thanks for the clarification!

related to an answer for: FEniCS 1.4.0 update() method needed?
asked Sep 4, 2014 by mhanus FEniCS Novice (930 points)

1 Answer

0 votes

You should always have a call to apply after setting values and before using the vector. Even without ghosts, it is possible to set values on remote processes, which is why apply must be called. DG0 spaces will in cases have ghost entries (when the mesh has ghost cells).

answered Sep 8, 2014 by Garth N. Wells FEniCS Expert (35,930 points)
...