For reference, an update to the modifications below.

MVertexLessThanNum should be used instead if MVertexLessThanLexicographic.
For some reason that I do not understand, MVertexLessThanLexicographic leads to 
crashes in some cases.

Serban

From: gmsh [mailto:[email protected]] On Behalf Of Serban 
Georgescu
Sent: 05 December 2014 12:40
To: David Bernstein
Cc: [email protected] Geuzaine
Subject: Re: [Gmsh] Setting random seed in geo file

Hi,

Actually I had the same problem and in the last few days I put some time into 
finding the reason why this happens.
The random seeds are actually hard-coded, the reason for the lack of 
reproducibility comes from a few STL containers that store pointers and were 
left with the default ordering - which means that the order will be dependent 
on the pointer addresses - hence the lack of reproducibility.

Here are the modifications that you need to make in order to have full 
reproducibility:
Note that these are made with respect to the source code of Gmsh 2.8.5.

Mesh/meshGFace.cpp --> added ordering to the set

1080c1080
<   std::set<MVertex*, MVertexLessThanLexicographic> all_vertices, boundary;
---
>   std::set<MVertex*> all_vertices, boundary;

1155c1155
<     for(std::set<MVertex*, MVertexLessThanLexicographic>::iterator it = 
all_vertices.begin();
---
>     for(std::set<MVertex*>::iterator it = all_vertices.begin();

1173c1173
<   for(std::set<MVertex*, MVertexLessThanLexicographic>::iterator it = 
all_vertices.begin();
---
>   for(std::set<MVertex*>::iterator it = all_vertices.begin();

----------------
Mesh/meshGFaceBDS.cpp --> defined what happens when we have two identical 
values in the sort

482,489d481
< bool edges_sort (std::pair<double, BDS_Edge*> a , std::pair<double, 
BDS_Edge*> b)
< {
<             if (a.first == b.first)
<                             return ((*a.second) < (*b.second));
<             else
<                             return (a.first < b.first);
< }
<
505c497
<   std::sort(edges.begin(), edges.end(), edges_sort);
---
>   std::sort(edges.begin(), edges.end());
558c550
<   std::sort(edges.begin(), edges.end(), edges_sort);
---
>   std::sort(edges.begin(), edges.end());


----------------
Mesh/meshGRegion.cpp --> added ordering to the set
1417c1417
< static void getAllBoundingVertices(GRegion *gr, std::set<MVertex*, 
MVertexLessThanLexicographic> &allBoundingVertices)
---
> static void getAllBoundingVertices(GRegion *gr, std::set<MVertex*> 
> &allBoundingVertices)
1440c1440
<   std::set<MVertex*, MVertexLessThanLexicographic> allBoundingVertices;
---
>   std::set<MVertex*> allBoundingVertices;
1443c1443
<   std::set<MVertex*, MVertexLessThanLexicographic>::iterator itv = 
allBoundingVertices.begin();
---
>   std::set<MVertex*>::iterator itv = allBoundingVertices.begin();
1673,1680d1672
< struct GFaceOrderedByTag
< {
<             bool operator() (const GFace* first, const GFace* second) const
<             {
<                             return (first->tag() < second->tag());
<             }
< };
<
1713c1705
<     std::set<GFace*, GFaceOrderedByTag> mySet;
---
>     std::set<GFace*> mySet;


----------------

That's about it.
It would be nice if these modifications could be added to the SVN version.

Cheers,
Serban

From: gmsh [mailto:[email protected]] On Behalf Of David 
Bernstein
Sent: 02 November 2014 00:45
To: [email protected]<mailto:[email protected]> Geuzaine
Subject: [Gmsh] Setting random seed in geo file

Sorry, I missed this post back in May.  What is the geo file command to set the 
global random number seed?

Thanks,
Dave


Hello,



This issue has been fixed in the last versions. What is the version you are 
using ?



JFR

Le 22 mai 2014 à 23:29, David Bernstein <david at 
terafrac.org<http://www.geuz.org/mailman/listinfo/gmsh>> a écrit :



> Hi Everyone, I'm using Gmsh as a backend mesh generator in a project and it's 
> been working very well so far.  One issue that we've encountered is 
> reproducing a problem from a given set of simulation input parameters because 
> Gmsh produces a different mesh every time it's run with the same input.

>

> I've looked through the documentation and have not been able to find a way to 
> set a random number seed so that the same mesh is produced every time for a 
> given input .geo file.  If anyone knows a way to do this please let me know.

>

> Thanks,

> Dave

This e-mail is covered by the Electronic Communication Privacy Act, 18 U.S.C. 
Section 2510-2521 and may be legally privileged. If you have received this 
transmission in error, please notify the original sender immediately by return 
e-mail or by telephone at the telephone number provided above and delete/trash 
the original message from your system. Thank you for your assistance. The 
information contained herein is confidential information provided only for the 
use of the individual or entity for whom it was intended. If the reader of this 
message received it in error, is not the intended recipient, or if an 
attachment is made in error, the reader is hereby notified that any 
dissemination, distribution or copying of this communication is strictly 
prohibited.

______________________________________________________________________



 Fujitsu Laboratories of Europe Limited

 Hayes Park Central, Hayes End Road, Hayes, Middlesex, UB4 8FE

 Registered No. 4153469



 This e-mail and any attachments are for the sole use of addressee(s) and

 may contain information which is privileged and confidential. Unauthorised

 use or copying for disclosure is strictly prohibited. The fact that this

 e-mail has been scanned by Trendmicro Interscan does not guarantee that

 it has not been intercepted or amended nor that it is virus-free.



______________________________________________________________________

 Fujitsu Laboratories of Europe Limited
 Hayes Park Central, Hayes End Road, Hayes, Middlesex, UB4 8FE
 Registered No. 4153469

 This e-mail and any attachments are for the sole use of addressee(s) and
 may contain information which is privileged and confidential. Unauthorised
 use or copying for disclosure is strictly prohibited. The fact that this
 e-mail has been scanned by Trendmicro Interscan does not guarantee that
 it has not been intercepted or amended nor that it is virus-free.
_______________________________________________
gmsh mailing list
[email protected]
http://www.geuz.org/mailman/listinfo/gmsh

Reply via email to