Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

953 Commits

Repository files navigation

PyMeshGen License

中文说明 · Packaging Guide

PyMeshGen GUI

PyMeshGen is an open-source Python project for unstructured mesh generation aimed at CFD/FEA preprocessing and algorithm research. The actively maintained runtime focuses on 2D workflows built around Fluent .cas boundary input, quadtree sizing, boundary-layer growth, advancing-front meshing, and a Delaunay pipeline with Bowyer-Watson and Triangle backends.

Highlights

  • Fluent .cas-driven boundary import for meshing workflows
  • VTK and STL import/export support
  • PyQt5 GUI and command-line entry points
  • Boundary-layer generation plus interior triangular and hybrid tri/quad meshing
  • Quadtree-based sizing field and post-meshing optimization
  • Experimental neural-network and reinforcement-learning smoothing modules under neural/

Requirements

  • Python 3.8+
  • Core runtime dependencies:
pip install -r requirements.txt

Optional heavyweight dependencies are split out:

pip install -r requirements-optional.txt

Some optional workflows, especially geometry import/export and neural/ML smoothing, rely on packages such as pythonocc-core, torch, torch-geometric, stable-baselines3, and trimesh.

Installation

PyPI (preferred after publication)

pip install pymeshgen

Optional extras:

pip install "pymeshgen[ml]"
pip install "pymeshgen[occ]"

pythonocc-core may be easier to install via conda-forge on some platforms.

Available entry points after installation:

pymeshgen --case ".\config\30p30n.json"
pymeshgen-gui

Local development

pip install -e .

For full local feature coverage:

pip install -r requirements.txt
pip install -r requirements-optional.txt

Quick start

Command line

python PyMeshGen.py --case ".\config\30p30n.json"

If --case is omitted, Parameters falls back to config\main.json, which points to the active case JSON.

GUI

python start_gui.py

The GUI bootstraps project paths automatically and also adds 3rd_party\meshio\src to sys.path for bundled meshio compatibility.

Library usage

fromdata_structure.parametersimportParametersfromPyMeshGenimportPyMeshGenparams=Parameters("FROM_CASE_JSON", r".\config\30p30n.json")
mesh=PyMeshGen(params)

Configuration model

Case JSON files live under config/ and typically define:

  • input_file / output_file
  • mesh_type
  • delaunay_backend
  • triangle_point_strategy
  • global sizing / visualization options
  • parts, where each part must provide at least part_name

Common part-level options include max_size, PRISM_SWITCH, first_height, growth_rate, max_layers, full_layers, and multi_direction.

Meshing pipelines

mesh_typePipeline
1, 2Triangular mesh generation through the advancing-front pipeline
3Hybrid tri/quad generation; triangle_to_quad_method == "q_morph" uses a triangle-first path
4Delaunay triangulation through delaunay.create_bowyer_watson_mesh()

Notes for mesh_type == 4:

  • delaunay_backend defaults to bowyer_watson
  • triangle_point_strategy defaults to equilateral
  • when boundary layers are enabled, the effective interior backend is forced to triangle to improve robustness near layered fronts

Project structure

PathResponsibility
PyMeshGen.pyCLI entry and lightweight library wrapper
start_gui.pyGUI launcher
core.pyMain orchestration pipeline
data_structure/Parameters, fronts, cells, and Unstructured_Grid
meshsize/Quadtree sizing-field construction
adfront2/Boundary-layer and advancing-front interior generation
delaunay/Bowyer-Watson core, Triangle backend, validation, and postprocess helpers
fileIO/CAS/VTK/STL/OCC input-output utilities
gui/PyQt5 GUI modules
optimize/Mesh optimization and smoothing
unittests/Regression and unit tests

Testing

Run the existing repository test entry points:

cd unittests
python run_tests.py
python run_quick_tests.py

Run a focused unittest target from the repository root when working on Delaunay or boundary-layer logic:

python -m unittest unittests.test_bowyer_watson.TestBowyerWatsonJSONConfig.test_anw_bowyer_watson

Documentation

Packaging

PyMeshGen now prioritizes Python package distribution through PyPI.

For standard Python source and wheel builds:

python -m pip install build
python -m build

For PyPI publishing and release workflow details, see README_PACKAGING.md. Optional Windows desktop packaging tools now live under packaging/windows/.

License

PyMeshGen is distributed under GPLv2+. See LICENSE.txt.

Contact

About

An open-source Python-based unstructured Mesh Generator(PyMeshGen) for CFD/FEA analysis, providing basic 2D mesh generation tools and study platform of widely used algorithms.

Topics

Resources

Stars

41 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages