Convert a Gmsh Laminate Bundle 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 Bundle 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 bundle 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).sections.json— one orthotropic carbon-fiber materialmat_1, bound to the ply physical group by itslabel/id.config.json— Euler-Bernoulli homogenization setup (model = 1).
import logging
from pathlib import Path
import sgio
logging.basicConfig(level=logging.INFO)
cwd = Path(__file__).resolve().parent
main_msh = cwd / 'laminate_simple.msh'
sections_json = cwd / 'sections.json'
config_json = cwd / 'config.json'
output_file = cwd / 'laminate_simple.sg'
sg = sgio.read_sg_from_gmsh_bundle(
main_msh=main_msh,
sections_json=sections_json,
config_json=config_json,
model_type='BM1',
)
print(sg)
# Gmsh section lives in the xy plane, so the writer projects:
# gmsh x -> VABS x2
# gmsh y -> VABS x3
# With model_space='xy', the writer also 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',
model_type='BM1',
model_space='xy',
)
sgio.read_sg_from_gmsh_bundle() reads the bundle, and sgio.write()
emits VABS input with 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
sections.json: Orthotropic material definition
config.json: Analysis configuration
laminate_simple.sg: Generated VABS input