Skip to main content

Advanced mesh generation and smoothing for hydrodynamic domains

Project description

CHILmesh: representing triangular, quadrangular and mixed-element (2D) meshes for advanced and automatic mesh generation for hydrodynamic domains.

Dominik Mattioli1†, Ethan Kubatko2
Corresponding author

1Penn State University
2Computational Hydrodynamics and Informatics Lab (CHIL), The Ohio State University

CHIL Lab @ OSU OSU CHIL ADMESH QuADMESH Thesis Google Scholar MathWorks File Exchange License: MIT

image

Releases

  • 2025/04/12 Python version of our code
  • 2023/09/19 MATLAB code revisited; repo initiated
  • 2017/08/01 Nascent MATLAB version of the code

Future Work

MADMESHR_Project

Table of Contents

Installation

Install via pip:

pip install chilmesh

Or:

git clone https://github.com/domattioli/CHILmesh && cd CHILmesh
python -m venv .myenv
source .myenv/bin/activate
.myenv/bin/pip install requirements.txt

Key Features

  • Minimal user input, automatic generation.
  • Support for triangular, quadrilateral, and mixed-element meshes.
  • Finite Element Method (FEM)-based and geometric mesh smoothing and other topological quality-improvement functionality.
  • Element quality evaluation (angular skewness) for quads & tris.
  • Novel [layer-based conceptualization for 2D meshes.
  • .fort.14 file input/output for ADCIRC models
  • API inspired by MATLAB’s delaunayTriangulation()

To-Do📌

  • Finish porting all functionality from original MATLAB code to python.
    • Add support for generating Delaunay meshes from scratch via zero-input CHILmesh().
    • Add support for delaunay trainagulation object input/output.
    • Add support for .gmsh input/output.
    • Extend .write_to_fort14() to support quadrilateral output
  • pip installation

Example Usage:

# Load mesh
import matplotlib.pyplot as plt
import numpy as np
from chilmesh import CHILmesh

# Randomly generate and triangulate points inside the donut domain.
domain_ffn = '/kaggle/working/CHILmesh/doc/domains/fort_14/annulus_200pts.fort.14'
mesh = CHILmesh.read_from_fort14( domain_ffn )
# mesh = CHILmesh() # random delaunay to-do

# Set up 2x3 subplot grid
fig, axs = plt.subplots(2, 3, figsize=(18, 10))
axs = axs.flatten()
fig.suptitle("Original vs Smoothed Mesh Comparison", fontsize=16)

# --- Original Mesh Plots ---
# 0. Original: Mesh + point/edge/element
_, ax = mesh.plot(ax=axs[0])
mesh.plot_point(1, ax=ax)
mesh.plot_edge(1, ax=ax)
mesh.plot_elem(1, ax=ax)
ax.set_title("Original: Mesh + Highlighted Entities")

# 1. Original: Layers
_, ax = mesh.plot_layer(ax=axs[1])
ax.set_title("Original: Mesh Layers")

# 2. Original: Quality
q0, _, stats0 = mesh.elem_quality( )
print( stats0 )
_, ax = mesh.plot_quality(ax=axs[2])
ax.set_title(f"Original: Quality Map (Median: {np.median(q0):.2f}, Std: {np.std(q0):.2f})")

# --- Smoothed Mesh Plots ---
# 3. Smoothed: Mesh + point/edge/element
mesh_smoothed = mesh.copy()
mesh_smoothed.smooth_mesh( method='fem', acknowledge_change=True )
_, ax = mesh_smoothed.plot(ax=axs[3])
mesh_smoothed.plot_point(1, ax=ax)
mesh_smoothed.plot_edge(1, ax=ax)
mesh_smoothed.plot_elem(1, ax=ax)
ax.set_title("Smoothed: Mesh + Highlighted Entities")

# 4. Smoothed: Layers
_, ax = mesh_smoothed.plot_layer(ax=axs[4])
ax.set_title("Smoothed: Mesh Layers")

# 5. Smoothed: Quality
q, _, stats = mesh_smoothed.elem_quality( )
print( stats )
_, ax = mesh_smoothed.plot_quality(ax=axs[5])
ax.set_title(f"Smoothed: Quality Map (Median: {np.median(q):.2f}, Std: {np.std(q):.2f})")

# Layout tidy
plt.tight_layout()
plt.subplots_adjust(top=0.9)  # leave space for suptitle
plt.show()
#fig.savefig("result.png", dpi=600, bbox_inches='tight')

result

Note: When mesh is mixed-element, connectivity (elem2vert adjacency) follows the format Node1-Node2-Node3-Node4, such that Node4 == Node3 for triangular elements.

BibTeX:

DO Mattioli (2017). QuADMESH+: A Quadrangular ADvanced Mesh Generator for Hydrodynamic Models [Master's thesis, Ohio State University]. OhioLINK Electronic Theses and Dissertations Center. http://rave.ohiolink.edu/etdc/view?acc_num=osu1500627779532088

@mastersthesis{mattioli2017quadmesh,
  author       = {Mattioli, Dominik O.},
  title        = {{QuADMESH+}: A Quadrangular ADvanced Mesh Generator for Hydrodynamic Models},
  school       = {The Ohio State University},
  year         = {2017},
  note         = {Master's thesis},
  url          = {http://rave.ohiolink.edu/etdc/view?acc_num=osu1500627779532088}
}

Acknowledgements

The following pieces of work inspired contributions to this repository:

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

chilmesh-0.1.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

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

chilmesh-0.1.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file chilmesh-0.1.0.tar.gz.

File metadata

  • Download URL: chilmesh-0.1.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for chilmesh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2d17bdeb2c904c96832743bee0255a4f0f1a79f488cdc87e719e6093ae92b864
MD5 4c979b061bdff749654680a4fba0e623
BLAKE2b-256 c78d26a361c845c218442449e2b6a4f6abb10295a27e59749081be8a3407729f

See more details on using hashes here.

File details

Details for the file chilmesh-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: chilmesh-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for chilmesh-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b12408221cd2fa99fd79b5ee864497db6e36cc9527d539eb0e641cd372c2736e
MD5 1f9bda76237ce5ee2729c940dfc2f433
BLAKE2b-256 268f059b1a999dc97dc3bc24fd8a1a0e68df543fee933d8f8eb89af262ea863a

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