Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume Mesher #369

Merged
merged 12 commits into from
Apr 22, 2019
Merged

Volume Mesher #369

merged 12 commits into from
Apr 22, 2019

Conversation

bbarroqueiro
Copy link
Contributor

@bbarroqueiro bbarroqueiro commented Apr 12, 2019

Hi Michael

Its a small code that generates volume mesh from a surface mesh...

This was a issue i had and looking ate forums it quite frequent....

This code needs:
pip install gmsh-sdk
or since this sdk is so small it can included inside module!

Let me know what you think...

I hope his helps...

regards

@mikedh
Copy link
Owner

mikedh commented Apr 13, 2019

Nice, that looks like it could be very useful! Thanks for the PR! A few suggestions:

  • I'd rename the submodule from trimesh.mesh3D to trimesh.volumetric or trimesh.fea, or something else
  • trimesh.mesh3D.mesh3D -> trimesh.fea.to_bdf
  • One goal of trimesh is to keep the mandatory dependencies to a minimum, so I'd like gmsh to be a "soft" dependency, i.e:
try:
    import gmsh
except ImportError:
    pass
  • rather than using id_name_in and id_name_out I'd prefer to use tempfile.NamedTemporaryFile for both input and output. An example of doing this is here
  • I'd rather the function returns the data from the bdf, and then the user can decide whether they want to write it to a file or not.

@bbarroqueiro
Copy link
Contributor Author

Hi,
I tried to follow your suggestions...
But, in the last comment i think you should keep it as is... But i leave the decision to you... I don't mind at all...

Just remember that a 200K elements surface mesh can easily generate a few millions elements of volumetric mesh (it an be memory pit even in Fortran codes and python can be memory hungry). I would leave it to file.

If you return it and save it memory to do what? It should be export to be viewed, analysed and maybe optimized in order codes, right?

@mikedh
Copy link
Owner

mikedh commented Apr 14, 2019

No worries, yeah I totally get not wanting to load a 20gb tet mesh into memory. Maybe a compromise would be:

generate(file_name=None, ... )
"""
Parameters
---------------------
file_name : None or str
  If specified, will save the output to a file at the specified location 
  If None, the data will be returned as bytes
"""

@bbarroqueiro
Copy link
Contributor Author

bbarroqueiro commented Apr 15, 2019

Hi, something like this code could be added:

if id_name_out != None:
    gmsh.write(id_name_out)
else:
    #Exports to disk for gmsh to read
    with tempfile.NamedTemporaryFile(suffix='.bdf') as id_out:
        pass
    gmsh.write(id_out.name)
    file = open(id_out.name, 'r') 
    return file.read() 

but it will be ascii since it is a input file for nastran or gmsh... I do not know how to work around this...

@mikedh
Copy link
Owner

mikedh commented Apr 16, 2019

Cool looks good! I'll try to merge this later this week, I want to play with it a bit more.

@mikedh mikedh mentioned this pull request Apr 16, 2019
@bbarroqueiro
Copy link
Contributor Author

I am been digging a little more in gmsh api. It should be possible to save the mesh in binary format using *.msh file extension. But it not working maybe i have an old SDK... i do not know...

For binary form it should be just

gmsh.option.setNumber("Mesh.Binary",1)

but doesn't work...

The Enhancement #206 is coved by this one and many other formats...
The gmsh script generates the 3D mesh based on the 2D mesh and exports everthing... So, if the 3D mesh is skiped the msh file will contain just the surface mesh...

@mikedh mikedh changed the base branch from master to merge/volume April 22, 2019 20:24
@mikedh mikedh merged commit 6fb2bb3 into mikedh:merge/volume Apr 22, 2019
mikedh added a commit that referenced this pull request Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants