triangulation.add_periodicity takes an enormous amount of time

30 views
Skip to first unread message

Andreas Rupp

unread,
Aug 27, 2019, 3:48:17 PM8/27/19
to deal.II User Group
Dear all,

I am trying to read from a mesh file and impose periodic boundary condition. This works out very well for small geometries in three spatial dimensions. However, if the read meshes tend to have more elements, the amount of time needed to create the mesh rises drastically. The time is spent within the routine triangulation.add_periodicity. Thus, I have created a minimal code example where cubes of side lengths 5, 20, and 50 are created. For each cube, the periodic face pairs are identified and collected. Afterwards, triangulation.add_periodicity is executed and the needed time is measured using the Timer class. The output of the attached code example looks as follows:

Starting Constructor with side length = 5
Periodic faces collected: Size of periodicity_vector = 75
Start triangulation.add_periodicity(periodicity_vector); after 0.018097 seconds
 Done triangulation.add_periodicity(periodicity_vector); after 3.0626 seconds

Starting Constructor with side length = 20
Periodic faces collected: Size of periodicity_vector = 1200
Start triangulation.add_periodicity(periodicity_vector); after 2.10931 seconds
 Done triangulation.add_periodicity(periodicity_vector); after 15749 seconds

Starting Constructor with side length = 50
Periodic faces collected: Size of periodicity_vector = 7500
Start triangulation.add_periodicity(periodicity_vector); after 298.734 seconds

I have stopped the simulation with side length 50 at this point. Any help and/or advice will be highly appreciated.

Thank you very much!

Best regards,
Andreas
deal_periodicity.cc

Daniel Arndt

unread,
Aug 28, 2019, 6:56:39 PM8/28/19
to deal.II User Group
Andreas,

I am trying to read from a mesh file and impose periodic boundary condition. This works out very well for small geometries in three spatial dimensions. However, if the read meshes tend to have more elements, the amount of time needed to create the mesh rises drastically. The time is spent within the routine triangulation.add_periodicity. Thus, I have created a minimal code example where cubes of side lengths 5, 20, and 50 are created. For each cube, the periodic face pairs are identified and collected. Afterwards, triangulation.add_periodicity is executed and the needed time is measured using the Timer class. The output of the attached code example looks as follows:

Starting Constructor with side length = 5
Periodic faces collected: Size of periodicity_vector = 75
Start triangulation.add_periodicity(periodicity_vector); after 0.018097 seconds
 Done triangulation.add_periodicity(periodicity_vector); after 3.0626 seconds

Starting Constructor with side length = 20
Periodic faces collected: Size of periodicity_vector = 1200
Start triangulation.add_periodicity(periodicity_vector); after 2.10931 seconds
 Done triangulation.add_periodicity(periodicity_vector); after 15749 seconds

Starting Constructor with side length = 50
Periodic faces collected: Size of periodicity_vector = 7500
Start triangulation.add_periodicity(periodicity_vector); after 298.734 seconds

Were you running in Debug or Release mode? I only tried Release mode and the timings weren't that terrible. I observed a runtime like three times larger in that function than for creating the mesh for up to 100 elements per side.
Still, there are some oppurtunities for improvement, see https://github.com/dealii/dealii/pull/8665. With these changes, creating the mesh and adding periodicity takes roughly about the same time.

Apart from that, it is much better to have a coarse mesh with few cells and refine a few times than starting with a rather fine coarse mesh (if you can do that).

Best,
Daniel

Andreas Rupp

unread,
Sep 3, 2019, 5:44:41 AM9/3/19
to deal.II User Group
Dear Daniel,
Thank you very much for your reply! You are absolutely right. I used the Debug mode where this issue occurs. In Release mode, the problem is gone.
Best,
Andreas
Reply all
Reply to author
Forward
0 new messages