Ghost values for beginners

Hello everyone,

Beginner question : what are precisely ghost values/dofs, and how they are to be used? I saw a few posts mentioning to update them or enabling “ghost mode” but i don’t know if I need it (in topology optimization in linear elasticity) and what I should do with it.

Thanks in advance.

Ghost degrees of freedom are only relevant when running code in parallel over multiple processes (using mpirun or mpiexec).

Image that you have 1000 000 degrees of freedom in your problem and execute your problem with two processes, you want each process to only own (have data in memory) half of these degrees of freedom each.
However, some degrees of freedom will be on the boundary between processes (image a unit square split in half into to rectangles). Along the boundary between the rectangles there are degrees of freedom both processes need to access. However, a degree of freedom is owned by a single process, and thus it is a ghost on the other process.

In legacy dolfin, you rarely have to think about Ghosts, as the work is done under the hood. In DOLFINx the Ghost communication is more explicit (to ensure efficiency)

4 Likes

thanks a lot, i’ll look at some exemples from your excellent tutorials and the docs

So, to be more specific, how can you know:

-what ghost mode you should choose?
-when you should update ghost values

Thanks again.

Rule of thumb:

  • As long as you do not do integrals over interior facets, ghostmode None is fine.
  • you Need to update Ghost values whenever you work on local vectors/matrices.

For instance assembly or interpolation. It is shown in the demos and tutorial several cases when it is necessary.

2 Likes

So in Ghost mode = none there is nothing to update?
iIf I understand well, ghost values are the equivalent of apply(“insert”) in legacy dolfin.
In any case, thank you for your answers.

There are still Ghost dofs ( values) to update.
It just means that your mesh does not have ghosted cells.

Hello,

Thank you for these clarifications.
In the case where we do have ghosted cells, is there a straightforward way to access only non ghosted coordinates with the ‘‘tabulate_dof_coordinates()’’ command?

Thanks

This depends on if you are using dolfin or dolfinx.

Sure, sorry, I am using dolfinx.

You can get the number of local degrees of freedom by calling
V.dofmap.index_map.size_local. Then if

num_local_dofs = V.dofmap.index_map.size_local
x = V.tabulate_dof_coordinates()
x_local = x[:num_local_dofs, :]

Thank you very much, this is quite useful!