Convert VABS Cross-Section Mesh to Gmsh#

Problem Description#

Given a VABS cross-section file, export it as a Gmsh mesh for inspection, visualization or Gmsh-based workflows, without losing the materials and SG parameters the mesh cannot hold.

Solution#

"""Example: Export one VABS section as a Gmsh mesh with its SG manifest."""
import logging
from pathlib import Path

import sgio

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

input_file = str(cwd / 'cs_box_t_vabs41.sg')

sg = sgio.read(
    input_file,
    file_format='vabs',
    format_version='4.1',
    model_type='BM2',
)
# Writes main.msh and the manifest main.sg.json that references it.
sgio.write(
    sg=sg,
    filename=str(cwd / 'main.sg.json'),
    file_format='sg_manifest',
    format_version='4.1',
    model_file='main.msh',
    model_file_format='gmsh',
)

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()

print(sg)

sgio.write() with 'sg_manifest' writes the Gmsh model file main.msh and the SG manifest main.sg.json that references it. The manifest carries sgdim, model type, model space, analysis configuration, materials and sections; see SG Manifest.

Result#

main.msh opens in Gmsh or ParaView:

gmsh main.msh

sgio.read('main.sg.json', 'sg_manifest') reads the full structure gene back.

../_images/pyvista6.png

File List#