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
- 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
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
- 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()
- 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
# 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')
Note: When mesh is mixed-element, connectivity (elem2vert adjacency) follows the format
Node1-Node2-Node3-Node4
, such thatNode4 == Node3
for triangular elements.
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}
}
The following pieces of work inspired contributions to this repository:
- ADMESH
- See the rest of the citations in the thesis QuADMESH-Thesis.pdf
- Original work was funded by Aquaveo and contributed to by Alan Zundel.
- FEM Smoother paper
- Angle-Based Smoother paper
- The MATLAB code was originally developed for a master's thesis research project (2015–2017) at The Ohio State University.