Convert a Gmsh Bundle to VABS#

Problem Description#

An external CAD + Gmsh workflow produces a 2D section mesh. Convert it into a VABS input file, with materials and analysis settings supplied alongside the mesh.

Solution#

The example uses the SG-on-Gmsh bundle convention, which keeps the three concerns in separate files (see SG-on-Gmsh Serialization Specification):

  • sg21_box_quad4_min_gmsh41.msh — the section mesh and its physical groups

  • sections.json — section and material payloads

  • config.json — the analysis configuration

import logging
from pathlib import Path

import sgio

logging.basicConfig(level=logging.INFO)
cwd = Path(__file__).resolve().parent

main_msh = cwd / 'sg21_box_quad4_min_gmsh41.msh'
sections_json = cwd / 'sections.json'
config_json = cwd / 'config.json'
output_file = cwd / 'sg21_box_quad4_min_gmsh41.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)

sgio.write(
    sg=sg,
    filename=str(output_file),
    file_format='vabs',
    model_type='BM1',
    model_space='yz',
)

sgio.read_sg_from_gmsh_bundle() reads the complete bundle into a sgio.StructureGene, which sgio.write() then emits as VABS input. This is the recommended path for external CAD + Gmsh workflows.

Result#

sg21_box_quad4_min_gmsh41.sg is written, ready for VABS.

uv run python examples/convert_gmsh_to_vabs/run.py

File List#