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-element theta_1 (layer plane angle).

  • additional_rotation_2 — a per-element scalar that, for a Gmsh section in the xy plane, maps to the layer-level VABS theta_3 (fiber direction angle).

Solution#

The input consists of:

  • laminate_simple.msh — a single curved ply meshed in the Gmsh xy plane, 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 space xy, and one orthotropic carbon-fiber material mat_1 bound to the ply physical group by its id.

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:

  1. Projects nodes from the Gmsh xy plane onto the VABS yz plane (gmsh_x → x2, gmsh_y → x3, VABS x1 = 0).

  2. Picks additional_rotation_2 from cell_data as the per-layer theta_3. The mapping depends on model_space: xy → rotation_2, yz → rotation_3, zx → rotation_1. All elements sharing one property_id must carry the same rotation value, since VABS allows only one theta_3 per layer.

  3. Translates element_local_csys into the per-element theta_1 column 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
../_images/pyvista2.png

File List#