Re-import an adaptively refined mesh (with hanging nodes)

105 views
Skip to first unread message

Matteo Malvestiti

unread,
Jan 12, 2025, 6:56:01 AM1/12/25
to deal.II User Group
Good morning.
I have a very fundamental question: in my project I do adaptive refinement on a mesh.
The task is then to store it and provide the interface for the research group to load it and proceed with their experiments.

A small outline of the process:
1) The initial conforming and coarse is initially created by gmsh
2) The grid is read in by GridIn
3) A Goal-oriented refinement algorithm (similar to step14) runs over different cycles and refines it adaptively
4) I store the mesh with GridOut (I'm using write_msh with all flags true)
Problem arise here, because when I import it again it's like the only "recognised" cells are those with the highest refinement level. (see picture)

What's the right way to store and import meshes?
I've read some concerning discussion here on the group hinting at the fact that it might not be achievable (?)

Thanks for your support.
Kind regards,
Matteo Malvestiti




reimport_mesh.png

blais...@gmail.com

unread,
Jan 12, 2025, 10:49:58 AM1/12/25
to deal.II User Group
Dear Matteo,
The best solution here would be to serialize the mesh so you can re-read it anew. This would be identical to what you would do when you restart a simulation.
We have a new tutorial that shows just how exactly this is done:

If you have any questions, please feel free to reach out and we will be glad to help you with this.
Best
Bruno

Matteo Malvestiti

unread,
Feb 14, 2025, 6:51:14 AM2/14/25
to deal.II User Group
Dear all,
I unfortunately still need your help on this issue.

Goal: Re-import a serial adaptively refined triangulation on another (distributed) code 
Saved mesh: has hanging nodes, has been refined with manifolds
External code: requires a distributed or fullydistribtued Triangulation

As suggested in the previous comment I read step-83 and implemented a checkpoint() in the A-project and a restart() in the B-project.
This works smoothly (at least across the same version of deal.II, and thf Boost, which is reasonable).
reimport.png

Problem now is: partitioning the Triangulation and maintaining the curved boundaries.
deal.II version: 9.5.0 or 9.5.1 (*)
Following the documentations of fullydistributed::Triangulation and GridTools this is what we do:
GridTools::partition_triangulation(Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD), tria_base);
const TriangulationDescription::Description<dim, dim> description =
      TriangulationDescription::Utilities::create_description_from_triangulation(tria_base, MPI_COMM_WORLD);
tria_pft.create_triangulation(description);
dof_handler.reinit(tria_pft);

First of all this is necessary to prevent holes form appearing somehow:
// Force vertex repositioning:
tria_base.prepare_coarsening_and_refinement();
for (auto cell : tria_base.active_cell_iterators())
   cell->clear_refine_flag(); // don't change the number of cells
tria_base.execute_coarsening_and_refinement();

But however there is the problem of the positing of the vertices, once placed thanks to the Manifold description, this is the result after partitioning
(only 1 process being used for test purposes)
after_partitioning.png

Any idea on how to solve this issue?
Are there other methods to export and reimport adaptively refined meshes on other projects?


Kind regards,
Matteo Malvestiti

(*) for a bug report on version 9.6.0 there is another issue open already, this post doesn't want to be a replica.

Wolfgang Bangerth

unread,
Feb 19, 2025, 5:06:54 PM2/19/25
to dea...@googlegroups.com

On 2/14/25 04:51, Matteo Malvestiti wrote:
>
> But however there is the problem of the positing of the vertices, once
> placed thanks to the Manifold description, this is the result _after
> partitioning_:
> (only 1 process being used for test purposes)
> after_partitioning.png
>
> Any idea on how to solve this issue?
> Are there other methods to export and reimport adaptively refined meshes
> on other projects?

Matteo:
Can you be explicit about what the problem is? I assume that you want
the vertex locations in the "after_partitioning" picture to be the same
as in the "reimport" one?

I will also assume that both of these are refined versions of
triangulations that originate from the same coarse mesh. Then it seems
to me like you're simply not attaching any manifolds to tria_pft before
you refine it, and consequently it does not place vertices in the right
place.

Best
W.
Reply all
Reply to author
Forward
0 new messages