Convert VABS Cross-Section Mesh to Gmsh#
Problem Description#
Given a VABS cross-section file, export the mesh to Gmsh format for geometry inspection or visualization without running a full format conversion that includes materials.
Solution#
"""Example: Export one VABS section as a SG-on-Gmsh bundle."""
import logging
import sys
from pathlib import Path
import sgio
logging.basicConfig(level=logging.INFO)
cwd = Path(__file__).resolve().parent
sys.path.insert(0, str(cwd.parent))
from _bundle_helpers import write_gmsh_bundle_sidecars
input_file = str(cwd / 'cs_box_t_vabs41.sg')
main_msh = cwd / 'main.msh'
sg = sgio.read(
input_file,
file_format='vabs',
format_version='4.1',
model_type='BM2',
)
sgio.write(
sg=sg,
filename=str(main_msh),
file_format='gmsh',
format_version='4.1',
model_type='BM2',
binary=False,
)
write_gmsh_bundle_sidecars(sg, cwd)
print(sg)
The mesh_only=True flag skips material data so the output is a pure mesh file. model_type='BM2' is required to correctly interpret the VABS file layout.
Result#
A Gmsh .msh file is written. Open it with:
gmsh cs_box_t_vabs41.msh
or inspect it in ParaView.
File List#
convert_mesh_data_vabs2gmsh.py: Main Python script