PETSc distributed: stuck in execute_coarsening_and_refinement()

28 views
Skip to first unread message

Matteo Malvestiti

unread,
Feb 3, 2025, 12:15:59 PM2/3/25
to deal.II User Group
Good evening everybody,
I could really use some generous advice.

Distributed code, PETSc wrappers, adaptive refinements.
We get to the point of refining:

Vector<float> error_indicators(this->triangulation->n_active_cells());
... some strategy to compute error_indicators ...
parallel::distributed::GridRefinement::refine_and_coarsen_fixed_fraction(
   *this->triangulation,
   error_indicators,
   0.8,
   0.02);
cout<<"Rank "<<this->this_mpi_process<<" starts refining and coarsening"<<std::endl;
until here all fine
this->triangulation->execute_coarsening_and_refinement();
But here it breaks... sometimes.

Let me explain my bewilderment:
It may go well for 6 refinement cycles and break at the 7th.

Does anybody have any hint at what I should investigate to figure out the problem?

Thanks in advance!
Best,
Matteo Malvestiti

Wolfgang Bangerth

unread,
Feb 3, 2025, 12:25:50 PM2/3/25
to dea...@googlegroups.com
On 2/3/25 10:15, Matteo Malvestiti wrote:
> But here it breaks... sometimes.
>
> Let me explain my bewilderment:
> It may go well for 6 refinement cycles and break at the 7th.
>
> Does anybody have any hint at what I should investigate to figure out the problem?

A good starting point is to clearly articulate what happens. "it breaks" is
not a useful starting point for debugging :-) Presumably, there is some error
message, or other information that can help find the cause. I assume you've
also run the program in a debugger?

Best
W.

Matteo Malvestiti

unread,
Feb 3, 2025, 4:50:55 PM2/3/25
to deal.II User Group

I'm really sorry for the lack of professionally here, but I was really lost.
Even by using the JetBrains' CLion debugger, with the newly learned trick of file-based trigger and attaching the debugger to one of the processes, I hadn't got an answer.

But now I solved it.

The fix consists in calling just before 
this->triangulation->prepare_coarsening_and_refinement();
After that it works smoothly.
I hadn't seen this in tutorials like step-40, I though prepare_coarsening_and_refinement() was meant to be used only before doing SolutionTransfer, should it always be called in parallel triangulations?

Thanks a lot if anybody wants to clear to me this theoretical doubt, otherwise case closed :)

Best,
Matteo
Reply all
Reply to author
Forward
0 new messages