- Create GMSH model.
- Mesh it, generate a
.mshfile. - Parse the
.mshfile within Python using MeshIO. - Push the mesh representation from MeshIO into a
Meshobject (discretedomain.Mesh) - Optionally partition the mesh into contiguous chunks - this will facilitate faster point location queries. See
discretedomain.Mesh.build_partitions(). - Create cell fields and vertex fields on
Mesh, seedemo_mesh.py:test_3d_tetra(). - Emit mesh data to binary file using
discretedomain.Mesh.write(). - Emit field data to binary file using
discretedomain.Mesh.write_fields(). - Emit vtu file of
Meshand any cell or vertex fields usingMesh.vtu().
- Load binary representation of
Meshusingparse.c:parse_mesh(). - Load binary representation of cell/vertex fields using
parse.c:parse_field(). - Perform point location queries using
point_in_tetra.c:PointLocation_PartitionedBoundingBox(),
-
MeshIO (https://pypi.org/project/meshio/1.2.0/)
pip install meshio -
METIS (http://glaros.dtc.umn.edu/gkhome/metis/metis/overview)
Installation instructions
- Download this file
http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz tar zxvf metis-xxx.tar.gzcd metis-5.1.0make config shared=1- Note
shared=1is required to ensure the build creates a shared / dynamic library which is essential for interoperability with Python.
- Note
make all- Lastly you will need to set the following environment variable
METIS_DLLto indicate the full path to the metis shared/dynamic library. For example
export METIS_DLL=${PWD}/build/Darwin-arm64/libmetis/libmetis.dylib
- Download this file
-
METIS for Python (https://metis.readthedocs.io/en/latest/)
pip install metis -
Compile
parse.c,point_in_tetra.cvia the followinggcc -c -O2 -Wall -std=c99 parse.cgcc -c -O2 -Wall -std=c99 point_in_tetra.c- A demo / testbed for the C routines are provided in
demo_parse.c. This can be compiled via the following
gcc -O2 -Wall -std=c99 demo_parse.c -o demo parse.o point_in_tetra.o
-
First execute the following
python parse_regions_from_gmsh.py. This will load a default .msh file and output the mesh and mesh partitions (md.bin) and the region data associated with the cells (region_cell.bin). The user can change the .msh file loaded using the option--filename my_file.msh, e.g.python parse_regions_from_gmsh.py --filename my_file.msh -
Now execute
./demo. This will loadmd.binandregion_cell.binand perform point locations on particles with randomly generated coordinates.