Importing External Tetrahedral Mesh

   2377   1   2
User Avatar
Member
5 posts
Joined: Dec. 2017
Offline
Hello,

I am trying to import an externally-computed tetrahedral mesh to use Houdini's FEM.
I can build my meshes using tetgen [wias-berlin.de] or gmsh [gmsh.info].

First, I was actually wondering if Houdini used a version of either (lots of programs use tetgen's base code)
Second, and most importantly, what would be the best approach at writing an importer for an external mesh?

My current approach is as follows:
1. Generate/modify geometry in Houdini
2. Export geometry as {.ply, .poly, and/or .off} (these are supported by TetGen)
3. Use command line to create a tetrahedral mesh (through TetGen) for {.ply, .poly, and/or .off} file(s) –is there a node that can execute the command prompt?
4. Write a custom python converter from TetGen output {.node, .face, .ele} to {.ply, .poly, and/or .off}
5. Import converted {.ply, .poly, and/or .off} into Houdini

–Status, I have not tested this approach yet!

Any words of advise would be appreciated!
Edited by fluviolobo - Oct. 15, 2019 21:26:55
User Avatar
Member
5 posts
Joined: Dec. 2017
Offline
Hello,

Just wanted to follow-up, just in case someone is interested

My approach described above worked (with a few mods.);

1. Starting from a simple FEM geo network (figure below), I used the file node to export the input sphere as a .OFF


2. In my Windows PC, I use TetGen [wias-berlin.de] to create a tetrahedral mesh from the exported .OFF file.
You will need to build TetGen on your windows… here is a quick set of steps [github.com]

2.1. TetGen actually comes with a viewer, called tetview [wias-berlin.de], which we can use to visualize the steps here on after. The figure below shows the exported .OFF file, just a surface polygon mesh…


2.2. I ran TetGen to tetrahedralize the exported .OFF file, using the following input flags:
tetgen.exe -pq1.2 -fCVO -a1.0 geo_mesh.off
Keep in mind that I first copied the .OFF file to the tetgen directory, from where I executed the above command
If you want to know more about the flags I used, see the documentation [wias-berlin.de]
In the end, the program should write the following files (figure below)


2.3. I ran tetview on the .face or .ele files to evaluate the mesh (figure below)


3. Here is where python comes in. I had to write a converter/writer that takes the .nodes and .face files to generate a new .OFF file. I made a version with a gui for selecting the input .OFF file (see attached). I also made the program in Python 2.7.x, as I plan to adapt this directly to Houdini. Executing the python script should result in a file ending in .conv.OFF

4. Back to Houdini! In the same geo network for FEM, I added a set of nodes that will import the conv.OFF file, “fix” the mesh, and bypass solid embed (figure below)


4.1. The imported file does not work by itself… when imported, it does not group neighboring polys as tetrahedrons… if we connect the raw input to the tetrahedralize node, the attributes are fixed and the problem goes away. I got super lucky here tbh

4.2. Connect the tetrahedralize node to the dopimport node and you can run the FEM!

—I will keep updating this post as I go!
Edited by fluviolobo - Oct. 16, 2019 23:10:53

Attachments:
network_pre.PNG (27.7 KB)
tetview_off.PNG (21.3 KB)
tetfiles.PNG (12.0 KB)
tetview_ele.PNG (32.1 KB)
_tetconvert_wgui.py (3.1 KB)
new_network.PNG (34.4 KB)

  • Quick Links