neperfepx / neper

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

Bug when prescribing initial centroid coords #778

Closed afonsodmcb closed 10 months ago

afonsodmcb commented 10 months ago

Hello,

I have a .txt file with a list of 28 triplets of 3D coordinates corresponding to the desired centroids of 3-cells in a cubic domain and I want to use Neper to arrive at a Voronoi tesselation of the domain into those 3-cells. I tried the command, which, after running it, prompted me to report a bug here:

$ neper -T -n 28 -id test -morphooptiini "coo:file(centroids.txt),weight:0" -morpho voronoi

========================    N   e   p   e   r    =======================
Info   : A software package for polycrystal generation and meshing.
Info   : Version 4.7.1-4
Info   : Built with: gsl|muparser|opengjk|openmp|nlopt|libscotch (full)
Info   : Running on 8 threads.
Info   : <https://neper.info>
Info   : Copyright (C) 2003-2022, and GNU GPL'd, by Romain Quey.
Info   : Loading initialization file `/home/user/.neperrc'...
Info   : ---------------------------------------------------------------
Info   : MODULE  -T loaded with arguments:
Info   : [ini file] (none)
Info   : [com line] -n 28 -id test -morphooptiini
         coo:file(centroids.txt),weight:0 -morpho voronoi
Info   : ---------------------------------------------------------------
Info   : Reading input data...
Info   : Creating domain...
Info   : Creating tessellation...
Info   :   - Setting seeds... 
Info   :   - Running tessellation...
Error  : You have discovered a bug in Neper!  Please file an issue at
         https://github.com/rquey/neper/issues.  Thank you.

Aborted

The contents of the input file centroids.txt are:

0.50000000 0.12500000 0.12500000 0.12500000 0.50000000 0.12500000 0.25000000 0.25000000 0.25000000 0.12500000 0.12500000 0.50000000 0.87500000 0.50000000 0.12500000 0.75000000 0.25000000 0.25000000 0.87500000 0.12500000 0.50000000 0.50000000 0.87500000 0.12500000 0.25000000 0.75000000 0.25000000 0.75000000 0.75000000 0.25000000 0.37500000 0.37500000 0.37500000 0.62500000 0.37500000 0.37500000 0.37500000 0.62500000 0.37500000 0.62500000 0.62500000 0.37500000 0.12500000 0.87500000 0.50000000 0.87500000 0.87500000 0.50000000 0.37500000 0.37500000 0.62500000 0.25000000 0.25000000 0.75000000 0.62500000 0.37500000 0.62500000 0.75000000 0.25000000 0.75000000 0.50000000 0.12500000 0.87500000 0.37500000 0.62500000 0.62500000 0.25000000 0.75000000 0.75000000 0.12500000 0.50000000 0.87500000 0.62500000 0.62500000 0.62500000 0.75000000 0.75000000 0.75000000 0.87500000 0.50000000 0.87500000 0.50000000 0.87500000 0.87500000

Thank you for your assistance!

rquey commented 10 months ago

The bug comes from the fact that the seeds are arranged regularly, which corresponds to a degenerate configuration. Randomize the coordinates a bit, and it will work.

afonsodmcb commented 10 months ago

Thank you for your quick reply! What if I want the seeds to stay arranged regularly? My objective was to obtain the structure shown in the attached image (some 3-cells highlighted) fcc_1_edges_faces_volumes

rquey commented 10 months ago

It won't work, never. What you can do is to randomize slightly and then use -reg 1, which is likely to generate a structure very close to the original:

gsl-randist 1 28 flat -.00001 .00001 > x
gsl-randist 2 28 flat -.00001 .00001 > y
gsl-randist 3 28 flat -.00001 .00001 > z

paste centroids.txt x y z | awk '{print $1+$4,$2+$5,$3+$6}' > centroids2.txt

neper -T -n 28 -id test -morphooptiini "coo:file(centroids2.txt),weight:0" -morpho voronoi -reg 1

PS. The generated tessellation does not seem to correspond to the image, so, there must be something wrong (with the centroid coordinates or the approach).