[Gmsh] How do I set the random number seed with a "Mesh.Seed" option for deterministic mesh generation?

Max Orok morok at mevex.com
Sat Oct 27 00:16:30 CEST 2018


Hi Thomas,

I first tried to set the random factors using:
Mesh.RandomFactor = 1e-9;
Mesh.RandomFactor3D = 1e-9;

I think the bug is elsewhere however...
With your file, I get a warning the first time and none the subsequent
times.
I think it is due to internal state with the mesher remembering the choice
of MeshAdapt?
Switching from Delauney to MeshAdapt halfway might cause different point
spacing etc.

Here are some pictures showing the two consecutive mesh logs

1st time:


2nd time (same window):


On closing Gmsh and trying again, this repeats.

Instead, to fix your problem, you can set the meshing algo to MeshAdapt
ahead of time by changing the line here:
Mesh.Algorithm = 1; // changed to MeshAdapt

Three repeated trials gave identical output files.

p.s. just in case, all of the current / modified options can be looked
through and searched using Ctrl-Shift-H or Help -> Current Options and
Workspace

Sincerely,
Max

On Fri, Oct 26, 2018 at 12:44 PM, Thomas Kiel <Thomas.Kiel at physik.hu-berlin.
de> wrote:

> 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
> <https://maps.google.com/?q=Newtonstra%C3%9Fe+15,+12489+Berlin&entry=gmail&source=g>
>
> Tel.:   +49 30 2093 7999
> E-Mail: thomas.kiel at physik.hu-berlin.de
> Web:    https://top.physik.hu-berlin.de/people/thomas-kiel
>
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh
>



-- 
Max Orok
Contractor
www.mevex.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20181026/8fe47df7/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 7261 bytes
Desc: not available
URL: <http://onelab.info/pipermail/gmsh/attachments/20181026/8fe47df7/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 9905 bytes
Desc: not available
URL: <http://onelab.info/pipermail/gmsh/attachments/20181026/8fe47df7/attachment-0003.png>


More information about the gmsh mailing list