Convert a Gmsh Laminate Mesh to VABS#
Problem Description#
Convert an external Gmsh section mesh of a thin composite ply into a VABS input file.
This is the orthotropic counterpart of Convert a Gmsh Mesh to VABS. That example carries a single isotropic material, so its mesh needs neither a per-element local coordinate system nor a fiber rotation. A real composite layer needs both:
element_local_csys— the local material frame on each element, used by VABS to compute the per-elementtheta_1(layer plane angle).additional_rotation_2— a per-element scalar that, for a Gmsh section in thexyplane, maps to the layer-level VABStheta_3(fiber direction angle).
Solution#
The input consists of:
laminate_simple.msh— a single curved ply meshed in the Gmshxyplane, carrying$ElementData "element_local_csys"(the per-element material frame) and$ElementData "additional_rotation_2"(30° fiber rotation on every element).laminate_simple.sg.json— the SG manifest: Euler-Bernoulli beam model (BM1), model spacexy, and one orthotropic carbon-fiber materialmat_1bound to the ply physical group by itsid.
import logging
from pathlib import Path
import sgio
logging.basicConfig(level=logging.INFO)
cwd = Path(__file__).resolve().parent
# The SG manifest references laminate_simple.msh and adds what the mesh cannot
# carry: sgdim, model type, model space, materials and sections.
manifest = cwd / 'laminate_simple.sg.json'
output_file = cwd / 'laminate_simple.sg'
sg = sgio.read(str(manifest), 'sg_manifest')
print(sg)
# The manifest declares model_space='xy', so the writer projects:
# gmsh x -> VABS x2
# gmsh y -> VABS x3
# and picks ``additional_rotation_2`` from the mesh cell data as the per-layer
# VABS ``theta_3`` (fiber angle).
sgio.write(sg=sg, filename=str(output_file), file_format='vabs')
plotter = sgio.plot_sg_pyvista(
sg,
show_local_axes=True,
)
plotter.off_screen = True
plotter.show(screenshot=str(cwd / "pyvista.png"), auto_close=False)
plotter.close()
sgio.read() with 'sg_manifest' reads the manifest and the mesh, and
sgio.write() emits VABS input using the manifest’s model_space='xy'.
The writer then:
Projects nodes from the Gmsh
xyplane onto the VABSyzplane (gmsh_x → x2,gmsh_y → x3, VABSx1 = 0).Picks
additional_rotation_2fromcell_dataas the per-layertheta_3. The mapping depends onmodel_space:xy → rotation_2,yz → rotation_3,zx → rotation_1. All elements sharing oneproperty_idmust carry the same rotation value, since VABS allows only onetheta_3per layer.Translates
element_local_csysinto the per-elementtheta_1column of the VABS property block.
Result#
laminate_simple.sg is written, ready for VABS. Its single layer points at
material mat_1 with theta_3 = 30°.
uv run python examples/convert_gmsh_laminate_to_vabs/run.py
File List#
run.py: Main Python script
laminate_simple.msh: Gmsh ply mesh with local csys and rotation data
laminate_simple.sg.json: SG manifest
laminate_simple.sg: Generated VABS input
pyvista.png: PyVista mesh and local-axis preview