[Gmsh] Painfully slow entity additions to GModel through the library API

Takuya OSHIMA oshima at eng.niigata-u.ac.jp
Mon Aug 22 04:17:07 CEST 2011


Dear Gmsh developers,

I am having a performance problem with Gmsh 2.5.0 library API where
entity additions (GModel::addVertex()/Line()/...) are painfully slow
(taking hours) with hundreds of thousands (100,000s) of entities. With
a bit of profiling it turned out that the problem was coming from
getMaxElementaryNumber() counting the max elementary number each time
an entity is added, which is obviously of an O(n^2) cost. Hence I
modified the relevant codes as attached in order to store the number
in a array instead. In my case the performance improved to order of 10
secondes which is more than 100x of speedup. The patch is only meant
to "work for me" which means it may not be generic enough for
everyone, but I hope this kind of improvement goes into the next
release of Gmsh.

Takuya

Takuya OSHIMA, Ph.D.
Faculty of Engineering, Niigata University
8050 Ikarashi-Ninocho, Nishi-ku, Niigata, 950-2181, JAPAN

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Performance-improvement-in-entity-insertions-to-GMod.patch
Type: text/x-patch
Size: 5868 bytes
Desc: not available
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20110822/5bab97b2/attachment.patch>