KristofferC / Phon

Insert cohesive elements between grains in microstructures
MIT License
29 stars 19 forks source link

fail to Import 2D mesh #3

Closed mrzhaojyi closed 9 years ago

mrzhaojyi commented 9 years ago

Hi, I generate a 2D mesh by neper and want to insert cohesive element in the grain boundary. The 2D mesh is generated using the code : gsl-randist 1 1000 flat 0 0.3 > x11 gsl-randist 2 150 flat 0.3 0.5 > x12 gsl-randist 2 40 flat 0.5 0.7 > x13 gsl-randist 2 40 flat 0.7 1 > x14 cat x11 x12 x13 x14> x1 gsl-randist 2 1200 flat 0 1 > y1 paste x1 y1 > coo1 neper -T -n 1200 -morpho @coo1 -id 2 -dim 2 neper -V n1200-id2.tess -datacellcol id -print img neper -M n1200-id2.tess -for inp

Then:

from phon.io.read.read_from_neper_inp import read_from_neper_inp from phon.mesh_tools.create_cohesive_elements import create_cohesive_elements from phon.io.write.export_to_abaqus import export_to_abaqus mesh = read_from_neper_inp("n1200-id2.inp") Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/phon/io/read/read_from_neper_inp.py", line 88, in read_from_neper_inp create_element_sides(mesh) File "/usr/local/lib/python2.7/dist-packages/phon/io/read/read_from_neper_inp.py", line 115, in create_element_sides for element_id in node_to_elements[face.vertices[0]]: IndexError: list index out of range

Could you tell me what's the problem?

KristofferC commented 9 years ago

Hello,

I pushed a commit to (partly) fix this: 097c310b5acb7bc04 . Before this commit read_from_neper_inp() took an argument telling it what mesh dimension was being read but I removed it so the same command you used before should now work to read the mesh file.

However, there is another problem. Neper does not currently export the 1D elements that sits in the interface between two grains in 2D. If you compare the file you got from Neper to the test 2D mesh https://github.com/KristofferC/Phon/blob/master/test/mesh2El2d.inp: you see that you lack the T3D2-elements and the element sets named "edge1, ...".

My coworker wrote a patch for Neper so it exports these elements and sets. However, he only has the changes local on his computer. If you want to get the version he made that includes the needed sets and elements I uploaded it for you here: http://web.student.chalmers.se/~kricarl/neper-2.0.2.zip

I used that version and generated a mesh in the same manner as you are doing but with 12 grains instead of 1200:

./neper -M n12-id2.tess -for inp -gmsh ~/gmsh/bin/gmsh -dim all

Make sure to use "-dim all" flag for neper -M when you generate the mesh.

I ran Phon on it with these commands:

inputfile = "n12-id2.inp"
mesh = read_from_neper_inp(inputfile)
create_cohesive_elements(mesh, mesh_dimension=2)
export_to_abaqus("n12-id2_coh.inp", mesh,  write_2d_elements=True)

And I get the expected output. See image from abaqus:

image

mrzhaojyi commented 9 years ago

Thank you

KristofferC commented 9 years ago

You should update your version of Phon since I now merged some improved functionality for 2D elements. Before this normals to the cohesive elements where not confirmed to be correct for 2D-elements.

The patch for Neper for exporting the 1D elements and element sets has made it into the neutral build for Neper: http://neper.sourceforge.net/docs/neper-neutral.tgz but not yet to the stable version.

mrzhaojyi commented 9 years ago

Yes, I will. Thank you very much! BTW, I am also in the neper reply-list so I was informed of this change.

On Fri, Jan 16, 2015 at 11:41 AM, KristofferC notifications@github.com wrote:

You should update your version of Phon since I now merged some improved functionality for 2D elements. Before this normals to the cohesive elements where not confirmed to be correct for 2D-elements.

The patch for Neper for exporting the 1D elements and element sets has made it into the neutral build for Neper: http://neper.sourceforge.net/docs/neper-neutral.tgz but not yet to the stable version.

— Reply to this email directly or view it on GitHub https://github.com/KristofferC/Phon/issues/3#issuecomment-70281786.