[Gmsh] How do I set the random number seed with a "Mesh.Seed" option for deterministic mesh generation?
Thomas Kiel
Thomas.Kiel at physik.hu-berlin.de
Fri Oct 26 18:44:08 CEST 2018
Dear Gmshers,
as I already pointed out in an earlier email (s.
http://onelab.info/pipermail/gmsh/2018/012045.html), I had problems with
reproducing the exact same mesh twice. Since this email was
unfortunately html encoded I think it was overlooked. Yet I like to
apologize to ask again, this time in text formatted email, how to set
the random number generator seed with an outside option?
I know, that a grep to "srand" within the gmsh git repository gives
several times hard-coded initialized seeds, e.g.
Geo/SOrientedBoundingBox.cpp:326: srand((unsigned)time(0));
Mesh/Levy3D.cpp:624: srand(time(NULL));
Mesh/Levy3D.cpp:1359: srand(time(NULL));
Mesh/meshGFaceRecombine.cpp:245: srand(time(NULL));
Mesh/meshGFaceLloyd.cpp:394: srand(time(NULL));
yet I am not sure whether these influence my mesh generation. A
minimalistic test file which causes different meshes at consecutive runs
in my case, is
//+
SetFactory("OpenCASCADE");
Mesh.CharacteristicLengthMin = 0.001;
Mesh.CharacteristicLengthMax = 2.0;
Mesh.CharacteristicLengthExtendFromBoundary = 1;
Mesh.Algorithm = 5;
Mesh.Smoothing = 3;
Mesh.Algorithm3D = 1;
Box(1) = {0, -0.5, -0.5, 1, 1, 1};
Box(2) = {-1, -0.5, -0.5, 1, 1, 1};
Sphere(3) = {0.5, 0.0, 0.0, 0.3, -Pi/2, Pi/2, 2*Pi};
Coherence;
surfs_box1() = Unique(Abs(Boundary{ Volume{4}; } ));
lines_box1() = Unique(Abs(Boundary{ Surface{surfs_box1()}; } ));
pts_box1() = Unique(Abs(Boundary{ Line{lines_box1()}; } ));
surfs_sphere() = Unique(Abs(Boundary{ Volume{3}; } ));
lines_sphere() = Unique(Abs(Boundary{ Surface{surfs_sphere()}; } ));
pts_sphere() = Unique(Abs(Boundary{ Line{lines_sphere()}; } ));
surfs_box2() = Unique(Abs(Boundary{ Volume{2}; } ));
lines_box2() = Unique(Abs(Boundary{ Surface{surfs_box2()}; } ));
pts_box2() = Unique(Abs(Boundary{ Line{lines_box2()}; } ));
// sorted from largest to smallest:
Characteristic Length{pts_box2()} = 0.5;
Characteristic Length{pts_sphere()} = 0.2;
Characteristic Length{pts_box1()} = 0.1;
I tested this on a machine running Ubuntu 16.04 and installed the
out-of-the-box gmsh 4.0.4 version from the webpage. If any further
detail on the running machine is required please tell me.
I hope you can help me out.
Thanks a lot in advance and best regards,
Thomas Kiel
--
Thomas Kiel
Theoretische Optik und Photonik
Humboldt-Universität zu Berlin, Institut für Physik
Newtonstraße 15, 12489 Berlin
Tel.: +49 30 2093 7999
E-Mail: thomas.kiel at physik.hu-berlin.de
Web: https://top.physik.hu-berlin.de/people/thomas-kiel
More information about the gmsh
mailing list