Read and Write SG Data#
Every format goes through one in-memory object. sgio.read() loads a
solver or mesh file into a sgio.StructureGene; sgio.write()
emits one.
flowchart LR
subgraph IN ["Input"]
direction TB
VABS_I["VABS<br/>.sg"]
SC_I["SwiftComp<br/>.sg"]
ABQ_I["Abaqus<br/>.inp"]
GMSH_I["Gmsh bundle<br/>.msh + .json"]
end
SG(["StructureGene"])
subgraph OUT ["Output"]
direction TB
VABS_O["VABS<br/>.sg"]
SC_O["SwiftComp<br/>.sg"]
ABQ_O["Abaqus<br/>.inp"]
GMSH_O["Gmsh<br/>.msh"]
VTK_O["VTK / VTU<br/>.vtk .vtu"]
end
VABS_I -- "read" --> SG
SC_I -- "read" --> SG
ABQ_I -- "read" --> SG
GMSH_I -- "read_sg_from_gmsh_bundle" --> SG
SG -- "write" --> VABS_O
SG -- "write" --> SC_O
SG -- "write" --> ABQ_O
SG -- "write" --> GMSH_O
SG -- "write" --> VTK_O
VTK and VTU are write-only, mesh-only export targets. A bare .msh carries no
material data, so Gmsh input is read as a bundle — see Prepare a Gmsh Mesh for SG Conversion.
sgio.convert() chains a read and a write in one call; see Convert SG Data.
Read#
import sgio
sg = sgio.read(
'airfoil.sg',
file_format='vabs',
model_type='BM2',
format_version='4.1',
)
file_format and model_type identifiers are listed in Formats and Model Types.
sgdim may be omitted when the format implies it — VABS is always 2D — and is
required for formats that do not, such as a 3D Abaqus solid:
sg = sgio.read('cube.inp', file_format='abaqus', model_type='SD1', sgdim=3)
Write#
import sgio
sgio.write(sg, 'cross_section.sg', file_format='vabs', format_version='4.1')
Node and element IDs are renumbered automatically when the target format requires it, with a warning.
Pass mesh_only=True to write geometry without materials or analysis
configuration — useful for visualization targets:
sgio.write(sg, 'visualization.msh', file_format='gmsh', mesh_only=True)
Full signatures are in I/O Functions.
See Also#
The Structure Gene — what the
StructureGeneholdsConvert SG Data — format conversion, API and CLI
Read Solver Output — reading solver output
Formats and Model Types — format, model-type, and conversion tables