How to set refinement flag on the neighbouring cell when it is owned by another processor?

42 views
Skip to first unread message

Abbas Ballout

unread,
Jul 11, 2023, 10:23:15 AM7/11/23
to deal.II User Group
I have this in a mesh-worker mesh loop
const auto &q_points = fe_iv.get_quadrature_points();
const unsigned int n_q_points = q_points.size();


if(cell->material_id() != ncell->material_id())
for (unsigned int point = 0; point < n_q_points; ++point)
{
cell->set_refine_flag();
ncell->set_refine_flag();
}
I don't want to just set a refinement flag for my cell but I also want to set the refinement
flag for the neighbouring cell too and that is what ncellset_refine_flag(); does This doesn't work if the neighbouring cell is owned by another core

I have attached the paraview output below with the colouring representing what cells are owned with what core.
Unless the neighbouring cell is owned by the same core, I can't set the refinement flag that way.
A minimal code with cmake recreates this is below.

Any work-arounds?
Best, Abbas

mpi4.png
mpi1.png
exampleAB.zip
mpi2.png
mpi3.png

Wolfgang Bangerth

unread,
Jul 12, 2023, 9:17:59 PM7/12/23
to dea...@googlegroups.com
On 7/11/23 08:23, Abbas Ballout wrote:
> I don't want to just set a refinement flag for my cell but I also want to set
> the refinement
> flag for the neighbouring cell too and that is what ncellset_refine_flag();
> doesThis doesn't work if the neighbouring cell is owned by another core

Correct. That's because you can't set information on cells you don't own, in
particular because it isn't clear what should happen if different non-owning
processes (for which this cell is a ghost cell) disagree in their decisions on
what they want to set.

If you want to do this kind of thing, you probably want to collect a list of
(cell_id, value) that you want to send to each of the neighboring processes,
then send it via Utilities::MPI::isend(). Then you'd receive this kind of list
on each process via Utilities::MPI::irecv(), unpack it, and then set the value
on each of the cells in question.

If you want a higher-level interface, you can use the functions in
Utilities::MPI::ConsensusAlgorithms.

Best
Wolfgang

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/


Abbas Ballout

unread,
Jul 21, 2023, 7:10:12 AM7/21/23
to deal.II User Group
I ended up passing the assemble_own_interior_faces_both flag to mesh-worker mesh loop. 
I will probably have to use these Consensus algorithms sooner or later anyway. 

Thank you. 
Abbas 

Reply all
Reply to author
Forward
0 new messages