# Keeping mesh coordinates unchanged for Implict Region [duplicate]

I am trying to generate a 3D mesh for Finite Element simulations. I need to provide some precomputed inputs to the mesh points and will like my mesh to be the same for a given shape. However, everytime I run my code I am getting different numbers of nodes. Here is the example:

W = ImplicitRegion[x^2 + y^2 + z^2 <= 1, {x, y, z}];
mesh = ToElementMesh[W, "MaxBoundaryCellMeasure" -> 0.02, "MaxCellMeasure" -> 0.1, "MeshQualityGoal" -> 1];
pts = mesh["Coordinates"];
Dimensions[pts]


The dimension of pts keeps on changing every time I run the code. I will like to obtain the same number every time. However, if I do the same problem as:

mesh = ToElementMesh[Ball[], "MaxBoundaryCellMeasure" -> 0.02, "MaxCellMeasure" -> 0.1, "MeshQualityGoal" -> 1];
pts = mesh["Coordinates"];
Dimensions[pts]


then the dimension does not change. While this is a viable solution for sphere/ellipsoids, I will need it to work for ImplicitRegion since I will be looking into more general surfaces. Thanks in advance!

• I think this is a duplicate of the other question you have found. This W = ImplicitRegion[x^2 + y^2 + z^2 <= 1, {x, y, z}]; m1 = BoundaryDiscretizeRegion[W]; m2 = BoundaryDiscretizeRegion[W]; MeshCoordinates[m1] == MeshCoordinates[m2] False produces the same issue and I believe that this is because of the underling TetGen (that does the (boundary) mesh generation) is not fully deterministic. I have asked coworkers for their opinion and if they do not come up with something else then there is not much that can be done. I'll keep you posted if I find anything new. Jul 6 at 16:04
• One other thought is to put this in the possible issues section Jul 6 at 16:37
• No, I agree. I found that discussion as well. You are right. Jul 6 at 21:23
• I have added an example of this to the reference page of ToElementMesh in the possible issues section. This will be available in the next version (13.2?) Jul 7 at 4:31

Include intermediate step DiscretizeRegion[W]
ToElementMesh[DiscretizeRegion[W] , "MaxBoundaryCellMeasure" -> 1/50,"MaxCellMeasure" -> 1/10, "MeshQualityGoal" -> 1]

• Unfortunately this does not solve the problem. If you use: Dimensions[%["Coordinates"]] after your code then you will see that the dimension is changing every time you run it. Jul 6 at 13:23
• Perhaps ToBoundaryMesh[W, "MaxBoundaryCellMeasure" -> 0.02, "MaxCellMeasure" -> 0.1, "MeshQualityGoal" -> 1] is what you're looking for? Jul 6 at 13:41