Convert dump/local to VTK

Submitted by NTT1508 on Fri, 01/02/2015 - 00:31

Dear all,

Happy new year 2015 to all members,

To start a new year, I would like to be clarified concerning a solution to convert dump/local output to VTK file. Looking into several discussions in terms of this issue, I am enable to have EVTK and dump2forcenew.py ( or dump2force.py by Mark Bentley) routine however the running come out with error:

File "...LIGGGHTS/mylpp/src/dump2forcenew.py", line 74, in
if forcedata.snaps[fileindex].natoms !=0 and len(forcedata.snaps[0].atoms[0]) != 11:
IndexError: list index out of range

I have checked my dump file with satified index (pos, id, force), for example a typical segment below
#==========================================================================
ITEM: TIMESTEP
2210
ITEM: NUMBER OF ENTRIES
107
ITEM: BOX BOUNDS mm mm mm
-0.03 0.13
-0.03 0.13
0 0.2
ITEM: ENTRIES c_c1[1] c_c1[2] c_c1[3] c_c1[4] c_c1[5] c_c1[6] c_c1[7] c_c1[8] c_c1[9] c_c1[10] c_c1[11] c_c1[12]
0.00131065 6.05822e-05 0.00990905 -1.82881e-05 0.0178213 0.0188177 62 21 0 0.00214362 -0.108449 -0.101417
0.0266905 0.00603006 0.00988811 0.0466302 0.0052919 0.0098806 40 46 0 -0.131963 -0.279587 0.175844
#==========================================================================

I think some users and specliasts in the forum are familar with this routine and handling local dump file to VTK. Could anyone give me a hint on my problem? Is there any better solution to convert dump file of gran/local computation to VTK? It must be important for most of simulations to demonstrate interaction forces a mong particles and particle-wall on Paraview, I beliew.

Thank very much,

Regards,

Nathan,

P.S. Very impressive to Christian (User: Richti83) who still keep working and replying on holiday 1st, new year 2015 :). Thank you for your active and great contribution.

richti83's picture

richti83 | Fri, 01/02/2015 - 18:38

Hi Nathan,
I have a ParaView Reader for dump/local forcechain files to avoid the conversation prozess:
https://github.com/richti83/ParaView_Reader_for_LIGGGHTS/tree/master/rea...
See line 203ff in liggghts_forcechainreader.cxx for the expected format. The code is known to work with PV<=4.1.x

At the moment you need to compile it yourself (because everyone has another ParaView Version and different glibc. It is not possible to provide precompiled shared objects of the reader for all systems)

Here is a Video:
https://www.youtube.com/watch?v=A37B_5L-5Ao

The error message in your post tells us that the python script expects 11 entries, but you provided 12, I don't know the dump2forcenew.py script in detail, but maybe you can let out the image flag (c_c1[9]) of your dump local command.

Best,
Christian.

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

NTT1508 | Sat, 01/03/2015 - 02:55

Hi Christian,

That is a great idea to use dump file directly without converting to VTK. It brings remarkable convenience to LIGGGHTS users and possibly other playgrounds which relate to dump files as well.

I have downloaded your package including reader-src and pre-compiled folders. Due to my very limited knowledge of coding, could you tell me roughly how to compile them to Paraview? Do I need to copy them to src of Paraview and re-compile Paraview again?

By the way, I have some confusions regarding my modelling by LIGGGHTS that would be great to have your advices.

(1) I have a number of ball strings (balls bonded as beam or string) in a certain arrangement (a certain initial void fraction). I will compress these balls by external force to make them re-arranged and reduce void fraction. Is that possible to apply forces on boundary walls and these walls moves inward and compress the ball inside? I know we can apply velocity on the boundary walls but not sure about force on boundary wall.

(2) Can I visualise walls on Paraview? The normal walls created by LIGGGHTS (primitive) seem not be seen on Paraview I think.

(3) I want to simulate particle contact with respect to different level of overlapping among particles. For examples, due to external force on boundary, particles will move closer and reduce void fraction. The higher overlap area of particles in system is accepted, the lower void fraction can be achieved. Can I use kn and kt to adjust internal force and overlap area among particles in Public version of LIGGGHTS? I heard that Public version does not allow to release internal force due to overlapping. Why most of examples or tutorials that I have seen do not input kn, kt (except Young Modulus, Poison, Restitution)

Thank very much Christian,

Regards,

Ps. Your collection of simulation by LIGGGHTS is amazing work. I believe many users can learn from there. Very helpful !

richti83's picture

richti83 | Sat, 01/03/2015 - 11:28

Hi Nathan,

I've written up a very short how to compile PV Plugins:
http://techblog.richtisoft.de/?p=10

I also compiled the forcechain-reader for ParaView 4.3.0 RC1 on Ubuntu 14.04 and checked it with your sample data yesterday evening. Could you try this file:
https://raw.githubusercontent.com/richti83/ParaView_Reader_for_LIGGGHTS/...
(Note: you need to install PV 4.3.0-RC1 first because the API is only compatible to this version, this concerns to the self compiled code, too !)

About your questions:
I think you can not move primitive walls, but you can use stl-walls as mesh. To generate them I would prefer ParaView->Source->Plane, save as VTK (because in PV a plane is type quat but stl exporter only supports triangles). After you have a plane.vtk you can convert this vtk file with gmsh to a stl file:

gmsh -2 -o plane.stl plane.vtk

Than you are free to use fix move mesh or fix mesh/surface/stress/servo (attention ! feature is broken in 3.0.6 !)
2. You can not dump primitive walls I think. You could use planes in PV at the same place than the walls in LIGGGHTS. But I would suggest using stl walls and dump mesh/stl than you can see the moving walls in PV.
3. are you talking about bond-stiffness (kn/kt) or contact stiffness ? For contact stiffness kn and kt are calculated from YoungModulus and Poisson Number, you can not input it directly. See normal_model_hertz.h line 89-93 how ligggghts derives kn/kt from Y. You could try to use your own input parameter at this point.

Best,
Christian.

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

NTT1508 | Mon, 01/05/2015 - 00:59

Hi Christian,

Thank very much for your detailed response,

(1) Compile your liggghts_reader

I have tried to compile your liggght reader with my current Paraview 4.1 ( I guess it should work) which currently stored in ThirdParty-2.3.0. I copied the folder reader_src in your package to Plugins in Paraview-4.1.0 and ccmake as below.

/home/OpenFOAM/ThirdParty-2.3.0/ParaView-4.1.0/Plugins/reader_src/text_reader/build

configuration by ccmake gives following outcomes:

CMAKE_BUILD_TYPE
CMAKE_INSTALL_PREFIX /usr/local
ParaView_DIR /home/ntt1508/OpenFOAM/ThirdParty 2.3.0/platforms/linux64Gcc/ParaView-4.1.0/lib/cmake/paraview-4.1

After press "g" to generate, it then comes out with additional folders (CmakeTmp and liggghts_reader.dir) and files in Plugin/reader_src/text_reader. Also CmakeError.log appeared. I then tried to open my Paraview 4.1.0 and check in Manage Plugin but could not see any new plugin there (liggght reader...). I attach the CmakeError.log here to have your advice on that.

I also tried to install Paraview 4.3-RC1 and followed your procedure but the same CmakeError.log appeared. Furthermore, I am using Paraview 4.1, Do you know how to replace 4.1 by 4.3? My currently active version is 4.1 so when I type Paraview on Terminal, it calls only version 4.1. May I remove 4.1? I am quite happy with 4.1 so far.

CMakeError.log
==============================================
...........................
/home/ntt1508/ParaView-v4.3.0-RC1/Plugins/reader_src/text_reader/build/CMakeFiles/CMakeTmp/CheckSymbolExists.cxx:8:19: error: ‘Q_WS_WIN’ was not declared in this scope
return ((int*)(&Q_WS_WIN))[argc];
^
make[1]: *** [CMakeFiles/cmTryCompileExec576561698.dir/CheckSymbolExists.cxx.o] Error 1
make[1]: Leaving directory `/home/ntt1508/ParaView-v4.3.0-RC1/Plugins/reader_src/text_reader/build/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec576561698/fast] Error 2
..............................
==================================================================

(2) Create stl wall

Oh it is really convenient for me now to generate stl mesh from VTK format of Paraview. I did not know about this. I normally created stl mesh by Salome that's quite more time consuming.

Besides I have not tested how fix mesh/surface/stress/servo work but clearly it is not a good new to hear that version 3.0.6 has problem with it. Does this function work on previous versions of LIGGGHTS? I would like to model a confining pressure on particles contained in a box that might need to move the box walls inward. If It is possible to control motion of walls by pressure placed on them, it would be great to my model.

(3) Regarding bond kn/kt

I am playing with your beam.bonds modelling (bond_gran) in which you bending a beam by vertical force at the tip of beam. I would like to try with pulling such beam with horizontal force on the tip (axial tensile force). The bonding among particles (balls) should be broken when pull-out force reaches a certain value (depend on kn/kt and rb). In your beam.bonds script, you temporarily deactivated breaking condition, so that it might not work properly for axial tensile force I think.

Moreover, bonding properties are assigned equally along the beam, so under tensile force, breakage will happen in every bonds while in reality, there should be some certain weaker point on section.

Thank Christian. Your advices are very helpful to me.

Best regards,

Nathan,

richti83's picture

richti83 | Mon, 01/05/2015 - 13:21

Hi Nathan,

I think everything went right in your cmake step, I have the same error message in the CMakeError.log.
You did forget the make step, after cmake generated the needed files and closes after [g]. You need to type make to build the shared object of the plugin.
BUT I guess it will not work with the last code, because kitware changed some things in the API. You can try to checkout commit d4f2a2b44a7ed81d8d199fe5711e27a5ce74e3dc but in this commit the forcechainreader does not match the file format you posted in your first post. You need to add:

this->File->getline(line,sizeof(line)); //5th line = ITEM: BOX Bounds OR ITEM: ENTRIES
if (strncmp(line,"ITEM: BOX BOUNDS",15) == 0) {
//override ..
this->File->getline(line,sizeof(line)); //xlow xhi
this->File->getline(line,sizeof(line)); //ylow yhi
this->File->getline(line,sizeof(line)); //zlow zhi
this->File->getline(line,sizeof(line)); //Item Entries
}

after double shear = 0; in liggghts_forcechainreader.cxx to overide the BOX BOUNDS line in your dumpfiles.

To make it easy (for testing) I would recommend you install the PV 4.3.0 RC1 binary from kitware in your home directory.
Than you don't need to recompile anything.
To make it accessable from commandline edit your $HOME/.bashrc file and add:

alias paraDEM='$HOME/ParaView/bin/paraview'

adjust ParaView to the path where you extracted the kitware binary.
Than source .bashrc to reload the environment or open a new terminal.
Now you can type paraDEM to start ParaView 4.3.0 RC1 and add the precompiled reader as new plugin.

(3) what do you mean with I disable breaking condition ? The conditions are sigma>sigma_break and tau>tau_break, the break values are definded in line 62 and are very high. When you change line 137 to fix tipF tipball addforce $F 0 0 the force should pull in pos x-direction until the bond(s) breaks.
BUT: there is a bug in bond_gran.cpp which I found this moment, have a look in line 321 and 322, the negative sign is not correct because tau_break is positive and the force magnitude is positive too, change it to

bool nstress = sigman_break[type] < (nforce_mag/A + 2.*ttorque_mag/J*rb[type]);
bool tstress = tau_break[type] < (tforce_mag/A + ntorque_mag/J*rb[type]);

and the bonds will break when the criteria is met.

I will push corrected code to github.

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

NTT1508 | Tue, 01/06/2015 - 12:42

Hi Christian,

Thank Christian, a generous man :-)

1) Paraview 4.3.0 binary is obviously easy for a beginner like me :). I loaded your reader in pre_compiled folder and am able to see liggghts_forcechainreader at Manage Plugin. But I cannt open dump file of contact force. Dump files are normally ASCII text file. Do I need to convert these text files or copy their content to somewhere else. Moreover, what are the differences between Paraview source file, compiling and Paraview binary which users just need to download and use immediately ?

2) Sorry for my misunderstanding your beam.bond and bond_gran scripts. I havent tried again a case with different r_break, to see how the bonding is broken. I need more time to understand C++ actually.

By the way, I am trying to import coordinate of atom from text file (read_data). It runs smoothly with granular/sphere without bonding. Then I tried with atom_style of bond_gran (to bond the particles after importing from file). However I found soon that data file (read_data) does not have format for bond_gran Atom. It informs Error of incorrect format of Atoms in read_data (using hybrid and sub-style).

Do you have any idea to keep importing atom coordinate (I have a big number of atoms with specific coordinate) and bond them with respect to bond_gran style. Can I firstly import from text file with atom_style of granular/sphere then modify atom_style as bond_gran atom? For examples, I import atoms from text then write_restart to a file. I then create another script with atom_style here is hybrid (bond_gran...) and read_restart to import atom from previous script.

Great thank to you. Hope to show you fully my modelling one day.

Regards,

Nathan,

richti83's picture

richti83 | Tue, 01/06/2015 - 14:04

Hi Nathan,

(1) the forcechainreader expetcs *.dump as file-ending, maybe this is your problem ? I tried the reader with your data in 1st post and it worked well. Can you send me one forcechain dump file ? (see http://www.richtisoft.de/impress.php for address). Did you dump as file-series (asterisk in file name) or as one single big file ? You need to write every dumpstep into one single file.
The binary version is the simple way, but some systems uses incompatible glibc version and than the user needs to compile ParaView and the Reader by it self (e.g. on Red Hat the precompiled does not work). When you have the standard ubuntu 64bit installation you are fine with the precompiled. Fedora will work too.

(2) Note: for break type 1 r_break is not used, instead sigma_break and tau_break is evaluated.
The comment should be read this way:
bond_coeff 1 ${rb} $Y $G 1 1e10 1e10 #N rb Sn_bond St_bond TYPE_OF_BOND r_break|sigma_break tau_break (temp)
N=type-of-bond
rb=radius of zylinder representing the bond
SN=Normal-bond-stiffness (kn)
ST=Torsion bond stiffness (kt)
TYPE_OF_BOND: 0=rbreak condition, 1=sigma_break and tau_break condition
r_break OR sigma_break and tau_break values
(temp) optional a temperarure at which point the bond breaks

(2b) yes it is known that the hybrid pair style expects another file format, the question is: how did you generate your particle position ?
A hybrid granular gran_bond read-data file should look like this:

LAMMPS data file from restart file: timestep = 29101, procs = 1
#
76 atoms
140 bonds
#
2 atom types
1 bond types
#
8 extra bond per atom
#
-1.0199999999999999e-01 1.0199999999999999e-01 xlo xhi
-1.0199999999999999e-01 1.0199999999999999e-01 ylo yhi
-1.1200000000000000e-01 1.1200000000000000e-01 zlo zhi
#
Masses
#
1 1
2 1
#
Bond Coeffs
#
1 1 1e+11 1e+11
#
Atoms
#
53 1 -1.3406470775435653e-02 -1.5866811937932344e-02 1.5122543074658724e-02 1.9199999999999929e-02 2.4999999999999968e+03
{more coords}
#
Bonds
#
1 1 53 66
2 1 53 58
3 1 48 53

(note: # means a blank line, I inserted this bc. the code-block will break at empty line)
The Atoms line is
ID TYPE X Y Z DIAMETER DENSITY
The Bonds section format is
ID TYPE ATOM-ID1 ATOM-ID2
and is optional.
You can not restart a different pair_style. I have a little programm to convert any dump file to a read-data file, but it is very "special". Please read the code first (the column order of inputfile is hardcoded !):
http://www.richtisoft.de/transfer/dump2read.cpp (compile with g++ -o dump2read dump2read.cpp)
With this trick you can first read your file with granuar, dump it once, convert it to hybrid and read with hybrid granular bond style.

Best,
Christian

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

NTT1508 | Wed, 01/07/2015 - 11:37

Hi Christian,

1) Paraview 4.3

Yes I am using Ubuntu 14.04-64. It was quite a concern at the beginning that I couldnot zoom in and out on Paraview 4.3_RC by scrolling my mouse that might indicate a defect point. Finally I am aware that Paraview 4.3 has changed zooming mechanism (now by control+drag left mouse) :)).

You are a really super-user of Paraview to guess correctly that I did not use *.dump format and single dump files. I have changed these features and now it work like a charm. Thank you very much Christian. I am still wondering what are functions of other readers in your package (liggght reader, liggghts_rigid reader). You mentioned about your liggghts_reader can read all dump file without converting to vtk. So I believe based on this algorithm, it would work for other dump files too. Does liggghts_forcechain_reader work for wall-particle contact, Chistian? I am forced to say that your program to use dump file directly is much clearly better than whatever before.

2) read_data

To generate particle position, I use 3DCAD and a simple VBA to extract coordinate of particle. I think you know well about this technique.

I have tried your read_data for hybrid granular gran_bond and checked with manual. I dont think it work because format of Atoms lines in read_data file might not be OK. The manual mentions that for Atom styles granular, format of Atome lines should be: ID TYPE DIAMETER DENSITY X Y Z. For hybrid atom_style, it should be: ID,TYPE,X,Y,Z,Sub-style1,Sub_style2. Here the Sub_style1 is granular type (DIAMETER DENSITY). How about Sub_style 2 (bond_gran) ? I cannt see parameters of Sub_style 2 in your Atoms line sample.

When I run read_data followed your example, it comes out with error: ERROR: Incorrect atom format in data file (../atom.cpp:607)

My read_data file is below

===============================================================
4 atoms

2 atom types
1 bond types

6 extra bond per atom

-5.e-4 5.e-4 xlo xhi
-5.e-4 5.e-4 ylo yhi
0.0 2.e-3 zlo zhi

Masses

1 1
2 1

Bond Coeffs

1 4e-5 1e+6 1e+4 1 1 1 #values temporarily assumed.

Atoms

1 1 0.000E+000 0.000E+000 8.000E-004 5.00E-005 2500 #AtomID,Atomtype,X,Y,Z,Diameter,Density
.....
================================================================

The input script is basically similar to your beam.bonds file (atom_style hybrid...; bond_style gran; bond_coeffs...; fix bond/create/gran...)
Additionally, I think keywords Masses and Bond Coeffs are optional if they are laready described in script.

It's obviously hard for a beginner like me to understand your complicated code at this moment. I have to improve my C++ knowledge first. I roughly understand that after importing coordinate, you dump particle parameters to a file then convert them to bond_gran script. Sound simple but might cost me the rest of life to do it:). Thank very much for your clever and intensive work and contributions that will definitely be beneficial to many users. I will move back to your convert technique later.

Regards,

Nathan,

richti83's picture

richti83 | Wed, 01/07/2015 - 12:55


I am still wondering what are functions of other readers in your package (liggght reader, liggghts_rigid reader)

The liggghts reader can read any custom dump file with atom coords, velocity, forces created by

dump dmp all custom ${dump_rate} post/dump_*.liggghts id type x y z vx vy vz fx fy fz omegax omegay omegaz radius mass

The rigid reader reads local dump files for rigid bodies, as the compute rigid is only included in the Premium version it is useless for you. (see http://www.dcs-computing.com/premium-versions-liggghtsr-and-cfdemrcoupling)

I'll add a bond reader this week.

About the wall contact force chain reader: I never tried, but I think it is hard to map the contact point between a particle and a triangle from liggghts space in paraview space - I put it on my list for this year :-)

(2) About the read bond file: I tested this with liggghts 2.3.8 and it was working, I will prepare an example in near future (Today is the first day after christmas holiday in Germany, need to do some other work before :-) )

Best,
Christian.

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

richti83's picture

richti83 | Wed, 01/07/2015 - 15:14

Hi Nathan,

I just checked the error in read_data -> atom, your are right, there was a code change in LAMMPS regarding read_data which came over to LIGGGGHTS.
The correct format is:
ID TYPE X Y Z DIAMETER DENSITY MOLECULE_ID where MOL_ID can be zero.
A testcase can be found here:
https://github.com/richti83/LIGGGHTS-WITH-BONDS/tree/master/examples/bon...
(beam_read.bonds reads beam.pour where beam.pour was derived from post/dump1000.liggghts from a previous beam_tension.bonds run using dump2read)
For your VBA Macro just adapt the header and add a zero to every line :-)

Please open a new topic for more questions about the bond model or the reader-plugins because this discussion has nothing to do with your initial question yet :-)

Best,
Christian.

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

NTT1508 | Thu, 01/08/2015 - 00:01

Hi Christian,

You are right, I should have made several separate pages for each topic actually, I have packed too many in one slide :) that might be hard for other users to track on.
I have checked your liggghts_reader, it works well but It seem to not generate domain outline as lpp dump does.
Looking forward to see your bond reader.

Have a further successful year 2015 and more contribution to our community, Christian.

Thank you,

Regards,

Nathan,

richti83's picture

richti83 | Sat, 01/10/2015 - 19:36


Looking forward to see your bond reader.

And here it is:
https://github.com/richti83/ParaView_Reader_for_LIGGGHTS/tree/master/rea...

You need latest LIGGGHTS-WITH-BONDS commit:
https://github.com/richti83/LIGGGHTS-WITH-BONDS/commit/b425831934574ffa3...

just git pull from my github fork of LIGGGHTS(R).

Have a nice Weekend,
Christian.

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

NTT1508 | Sun, 01/11/2015 - 11:54

Hi Christian,

Many thanks Christian. Could you explain a little about its expected format of input (or output of simulation to be read by your bond_reader?). it doesnot contain README file which roughly explains about the Plugin as your previous products. It is interesting to observe bonding behaviour of particles definitely.

I have some ideas regarding walls and bonds that would be generated in other pages. Hope to have you there too.

Have a nice week,

Regards,

Nathan,

ckloss's picture

ckloss | Wed, 01/14/2015 - 18:37

Hi all,

just a short note from my side: There is a LIGGGHTS dump command planned for the following or next release that can directly dump the compute pair/gran local data into VTK

Best wishes
Christoph