Convert Abaqus 3D Solid SG to SwiftComp#

Problem Description#

Given a 3D solid mesh built in Abaqus (sg33_cube.inp), convert it to a SwiftComp 2.1 input file for 3D solid homogenization using the SD1 model.

Solution#

The .inp file does not state sgdim or model_type. There are two ways to supply them, one script each; both write the same SwiftComp input.

Method 1: API arguments#

The SG parameters are arguments of sgio.convert().

"""Method 1: pass the SG parameters as arguments of ``sgio.convert``."""
import logging
from pathlib import Path

import sgio

logging.basicConfig(level=logging.INFO)

cwd = Path(__file__).resolve().parent

# The Abaqus file states neither the SG dimension nor the model type.
sg = sgio.convert(
    str(cwd / 'sg33_cube.inp'),
    str(cwd / 'sg33_cube_sc21.sg'),
    'abaqus',
    'sc',
    sgdim=3,
    file_version_out='2.1',
    model_type='SD1',
)

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)

On the command line:

sgio convert sg33_cube.inp sg33_cube_sc21.sg -ff abaqus -tf swiftcomp -tfv 2.1 -d 3 -m sd1

Method 2: SG manifest#

sg33_cube.sg.json (see SG Manifest) references the .inp file and holds the same parameters, so the conversion takes no SG arguments:

{
  "sg_manifest_version": 1,
  "model_file": {
    "path": "sg33_cube.inp",
    "format": "abaqus"
  },
  "sgdim": 3,
  "model_type": "SD1"
}
"""Method 2: read the SG parameters from the SG manifest."""
import logging
from pathlib import Path

import sgio

logging.basicConfig(level=logging.INFO)

cwd = Path(__file__).resolve().parent

# sg33_cube.sg.json references sg33_cube.inp and holds sgdim and model_type,
# so the conversion takes no SG arguments. It writes the same SwiftComp input
# as run_1_api.py.
sg = sgio.convert(
    str(cwd / 'sg33_cube.sg.json'),
    str(cwd / 'sg33_cube_sc21.sg'),
    'sg_manifest',
    'sc',
    file_version_out='2.1',
)

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)

On the command line:

sgio convert sg33_cube.sg.json sg33_cube_sc21.sg -ff sg_manifest -tf swiftcomp -tfv 2.1

Result#

A SwiftComp 2.1 input file sg33_cube_sc21.sg is written and ready for homogenization.

../_images/pyvista.png

Figure 1 PyVista preview of the converted three-dimensional Structure Gene.#

File List#