Skip to main content

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:

  1. Setting up a geometry using basic geometric entities and boolean operations.

  2. Adding the geometric objects to Gmsh, performing boolean operations and defining physical groups.

  3. Creating a mesh with user-defined refinement fields.

  4. Saving the mesh to various output formats.

  5. Visualizing the resulting mesh.

So far, gmshModel is especially designed to automate the generation of representative volume elements that contain multiple inclusion objects. 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 one of the following commands:

# for a basic installation of gmshModel
pip install gmshModel

# for additional export and visualization features
pip install gmshModel[all]

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:

  1. a dynamically built Gmsh to use the Gmsh-Python-API

  2. meshio for the conversion of meshes to various output formats

  3. pyvista for the visualization of meshes

  4. pythonocc for the visualization of the model geometry

If the visualization functionality is not required and meshes exported in the Gmsh-internal .msh format are sufficient, a working installation of Gmsh and its Python-API is enough.

Getting Started

Sample Geometry and Mesh

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 MIT-License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gmshModel-1.0.1.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gmshModel-1.0.1-py3-none-any.whl (44.8 kB view details)

Uploaded Python 3

File details

Details for the file gmshModel-1.0.1.tar.gz.

File metadata

  • Download URL: gmshModel-1.0.1.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for gmshModel-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b66229daea371347803337a52c968b5a4a2d41ea18b257a9a63e5d0c9714bf46
MD5 3da7ddd87528b97e4d23a12fdfb96aa5
BLAKE2b-256 88224f324b80300f9e500692663f10c22482c983d8de3876b2a0fe05a2258627

See more details on using hashes here.

File details

Details for the file gmshModel-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: gmshModel-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 44.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for gmshModel-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 01116f09475b6341b159145e133a6d905928ae47bcb9c1f5873bee8569863b9b
MD5 759b4f566ed2c2cd7e91a7b030383a3b
BLAKE2b-256 ae96fa52563a8fe01542eb1605ee1f188a1f3562f0603e7dbaf0c0431ebf6a6a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page