A mesh modeling interface to the Gmsh-Python-API
Project description
Gmsh is a powerful tool for the generation of meshes for numerical simulations but the built-in scripting language makes the meshing procedure and especially an automatization really hard. Luckily, Gmsh provides a Python-API with which all the capabilites of Gmsh can be used within Python.
GmshModel is intended to be an extendable tool that facilitates the mesh generation by interfacing the Gmsh-Python-API: it provides a basic framework for an automated mesh generation for self-defined model types and, with that, allows to automate the generation of complex models as, e.g., representative volume elements. To this end, gmshModel divides the mesh modeling procedure into basic steps:
Setting up a geometry using basic geometric entities and boolean operations.
Adding the geometric objects to Gmsh, performing boolean operations and defining physical groups.
Creating a mesh with user-defined refinement fields.
Saving the mesh to various output formats.
Visualizing the resulting mesh.
So far, gmshModel is especially designed to automate the generation of representative volume elements that contain multiple inclusion objects and well-known unit cells with different types of inclusions. An extension of gmshModel is, however, possible by adding new geometric objects and model types to the framework.
It is not the purpose of gmshModel to replace the Gmsh scripting language or other great tools such as pygmsh for the generation of meshes. GmshModel rather tries to function as an interface to Gmsh to facilitate the automation of recurring, complex meshing tasks that require the full functionality of Gmsh within a nice and easy to use environment such as Python.
Installation
GmshModel is available from the Python Package Index and can be installed using the following command:
$ python3 -m pip install gmshModel
The integration of gmshModel into the conda-forge channel allows to use a similar procedure for Conda users:
$ conda install -c conda-forge gmshModel
It is also possible to download the source code from GitHub or PyPi and install gmshModel manually. For more details, check the installation page of the documentation.
Dependencies
GmshModel is an interface tool and makes use of many great contributions of other people. To experience the full functionality of Gmsh model, the following (non-standard) software packages are required:
a dynamically built Gmsh to use the Gmsh-Python-API
meshio for the conversion of meshes to various output formats
pyvista for the visualization of meshes
pythonocc for the visualization of the model geometry
Getting Started
To generate the above periodic box in a [20x20x20] domain which contains 200 spherical inclusions of radius 1, simply type:
# import required model type
from gmshModel.Model import RandomInclusionRVE as RVE
# initialize new RVE
myRVE=RVE(size=[20,20,20], inclusionType="Sphere", inclusionSets=[1, 200])
# create Gmsh model
myRVE.createGmshModel()
# generate mesh
myRVE.createMesh()
# save resulting mesh to vtk
myRVE.saveMesh("myRVE.vtk")
# visualize result
myRVE.visualizeMesh()
# finalize Gmsh-Python-API
myRVE.close()
Documentation
The gmshModel documentation is available here.
License
GmshModel is published under the GPLv3 license
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gmshModel-1.1.1.tar.gz
.
File metadata
- Download URL: gmshModel-1.1.1.tar.gz
- Upload date:
- Size: 89.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7c59982bc520fef6a5f5f9202612b715995685bb639a8e01042c99e12ee14e0 |
|
MD5 | 4c4fa299eca668ddaf7fe12c2ae673c4 |
|
BLAKE2b-256 | 39a38f6ae77e644b5352457d60a7e57515faad5fc9445e8830c7a8785f74242f |
File details
Details for the file gmshModel-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: gmshModel-1.1.1-py3-none-any.whl
- Upload date:
- Size: 81.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9dd91ccbae95bd6c1360717928565cf84784748be38fa69a3ad179a950454d9 |
|
MD5 | 297e97eff94b19b1db67edb9d94f4dff |
|
BLAKE2b-256 | 86d53690792208635f71fbf6e0a92aab77f464eb5eece5169725f3bcf3813976 |