neperfepx / neper

Polycrystal generation and meshing
http://neper.info
GNU General Public License v3.0
205 stars 53 forks source link

Vertices not on the same plane given by face_eq (specific to large seed weights) #497

Open jijn opened 2 years ago

jijn commented 2 years ago

To Reproduce

$ neper -T -n 5 -morpho "centroid:file(points.txt)" -domain "cube(4,4,5)" -o Test

========================    N   e   p   e   r    =======================
Info   : A software package for polycrystal generation and meshing.
Info   : Version 4.4.2-19
Info   : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info   : Running on 12 threads.
Info   : <https://neper.info>
Info   : Copyright (C) 2003-2022, and GNU GPL'd, by Romain Quey.
Info   : No initialization file found (`/home/xxxx/.neperrc').
Info   : ---------------------------------------------------------------
Info   : MODULE  -T loaded with arguments:
Info   : [ini file] (none)
Info   : [com line] -n 5 -morpho centroid:file(points.txt) -domain
         cube(4,4,5) -o Test
Info   : ---------------------------------------------------------------
Info   : Reading input data...
Info   : Creating domain...
Info   : Creating tessellation...
Info   :     [i] Parsing file `points.txt'...
Info   :     [i] Parsed file `points.txt'.
Info   :   - Setting seeds... 100%
Info   :   - Generating crystal orientations...
Info   :   - Running tessellation...
Info   :     > Initial solution: f   =0.095730898
Info   :     > Iteration    456: fmin=0.069831257 f=0.069831257
Info   :     > Final solution  : f   =0.069831257 (456 iterations)
Info   :     > Reached `eps' criterion.
Info   : Writing results...
Info   :     [o] Writing file `Test.tess'...
Info   :     [o] Wrote file `Test.tess'.
Info   : Elapsed time: 0.176 secs.
========================================================================

where points.txt is

3 2 2
1 3 2
1 1 2
2.1 2.1 3.6
1.9 2.0 0.62

The tess file generated is Test.txt

Describe the bug Taking face 4 as an example:

face_eq_d = -0.930434190184
face_eq_a = -0.947110782127
face_eq_b = 0.320850519182
face_eq_c = -0.006009219495

Vertex 9 is included in this face's vertex list, whose coordinate is

x = 1.804092808037
y = 1.735334891387
z = 0.980879348070

However, vertex 9 does not satisfy the face equation: a*x+b*y+c*z-d = -0.22735277871012516

Similarly, vertex 8 not satisfy face_eq 4. Vertices 9 and 14 not satisfy face_eq 10. Vertices 9 and 10 not satisfy face_eq 6.

rquey commented 2 years ago

Thanks for the bug report.

This bug is very specific to your inputs and won't occur in the general case.

If you add -statseed x,y,z,w, you will see that optimization leads to very large z coordinate and weight for the last seed. I think it then generates some error in the computation of the vertex coordinates...

The problem comes from the fact that your first three points have the same z coordinate, and only the last point has a lower z coordinate. For some reasons, optimization tends to make the three faces between each of the first three points and the last point coplanar (hence the parameters of the last seed).

A workaround to your problem is to use -morphooptidof x,y,z (to exclude the seed weights from the optimization parameters), or -morphooptideltamax <value> to constrain the range of possible values for the seed coordinates and weights. This will lead to different tessellations... Another possibility would be to revise your input.