upxo.pxtal.fm_steel_3d.mesh_exporter_3d module
MeshExporter3D — Abaqus FEM mesh export for FM steel 3-D microstructures.
Supported element types
C3D8 Linear hexahedral (1 element / voxel) C3D4 Linear tetrahedral, Kuhn decomposition (6 elements / voxel) C3D20 Quadratic hexahedral (1 element / voxel, 20 nodes: 8 corners + 12 mid-edge) C3D10 Quadratic tetrahedral (6 elements / voxel, 10 nodes each: 4 corners + 6 mid-edge)
Output structure
- <output_base>/<folder_name>1/
model_master.inp — heading + *INCLUDE pointers 01_nodes.inp 02_elements.inp 03a_elsets_pag.inp 03b_elsets_pck.inp 03c_elsets_blk.inp 03d_elsets_subblk.inp — omitted when no sub-blocks present 04_nsets_bc.inp — ns.x-, ns.x+, ns.y-, ns.y+, ns.z-, ns.z+ 05_materials.inp — *User Material stubs with Bunge-Euler angles 06_sections.inp — *Solid Section (lowest hierarchy level only) 07_interactions.inp — stub 08_steps_output.inp — stub
Elset naming
es_pag_{pag_id} es_pck_{pag_id}_{local_pkt_idx} es_blk_{pag_id}_{local_pkt_idx}_{blk_local} es_subblk_{pag_id}_{local_pkt_idx}_{blk_local}_{sb_local} es_iso_{grain_id}
Global elset ID (A in *User Material)
- Every elset is assigned a unique 0-based integer in write order:
PAG elsets → packet elsets → block elsets → [sub-block elsets] → [isolated grain elsets (sorted by grain ID, if any exist)]
At block level A ∈ {n+m … n+m+p−1} ∪ {n+m+p … n+m+p+k−1} At sub-block level A ∈ {n+m+p … n+m+p+q−1} ∪ {n+m+p+q … n+m+p+q+k−1} (n=PAGs, m=packets, p=blocks, q=sub-blocks, k=isolated grains)
Element numbering
C3D8 / C3D20: elem_id(i,j,k) = i*NY*NZ + j*NZ + k + 1 (1-based, one per voxel) C3D4 / C3D10: elem_id = 6*(i*NY*NZ + j*NZ + k) + tet_local + 1 (tet_local in 0..5)
- class upxo.pxtal.fm_steel_3d.mesh_exporter_3d.MeshExporter3D(verbosity: int = 0, phase_id: int = 2, mat_data_flag: int = 0)[source]
Bases:
objectWorker for generating Abaqus FEM meshes from FM steel 3-D microstructures.
Usage example
exporter = MeshExporter3D(verbosity=1) exporter.set_output_units(‘mm’) exporter.set_output_base_path(r’C:/MyProject/FEMInputs’) exporter.ignore_lfi_ids([0]) out_dir = exporter.export_c3d8(fm_state, ‘run_001’,
custom_message=’Made by Dr. A. Smith, Univ. X’)
- material_format
- n_depvar
- load_axis
- applied_displacement
- step_time
- write_step
- initial_inc
- min_inc
- max_inc
- max_increments
- output_interval
- element_outputs
- node_outputs
- length_scale
- configure_analysis(*, material_format='reference_umat', n_depvar=1, load_axis='z', applied_displacement=0.2, step_time=80.0, write_step=True, initial_inc=0.01, min_inc=1e-08, max_inc=1.0, max_increments=10000, output_interval=0.5, element_outputs=('LE', 'NE', 'S', 'SDV'), node_outputs=('U',), length_scale=1.0)[source]
- set_output_units(unit: str) None[source]
Set physical unit for node coordinates written to .inp files.
- set_voxel_limit(elem_type: str, new_max: int, new_warn: int | None = None) None[source]
Override hard voxel limit (and optionally warn threshold) for one element type.
- set_output_base_path(path: str) None[source]
Override default output base directory. The path must already exist.
- ignore_lfi_ids(ids: List[int]) None[source]
Register feature IDs to treat as voids before meshing. IDs <= 0 are always void regardless of this list.
- check_voxel_threshold(n_vox: int, elem_type: str, max_voxels_override: int | None = None) Dict[source]
Pure (no I/O, no prompting) size/threshold check – the computation _preflight_check uses internally, exposed as its own public method so a caller that cannot answer an interactive input() prompt (the hard-limit branch of _preflight_check blocks on input() when no stdin is attached, e.g. when run from a background thread) can decide up front whether to ask for confirmation by its own means, then call export with force=True to bypass the interactive prompt entirely.
- Returns:
dict with keys
- Return type:
exceeds_hard, exceeds_warn, hard, warn, est_mb
- export_c3d8(fm_state, folder_name: str, output_unit: str | None = None, max_voxels: int | None = None, force: bool = False, custom_message: str = '', phase_id: int | None = None, mat_data_flag: int | None = None) Path[source]
Export as C3D8 (linear hexahedral) Abaqus mesh.
- Parameters:
fm_state – FM steel pipeline state: FMSteel3DWithPAGs, …WithBlocks, …WithOrientations, or …WithSubBlocks.
folder_name (str) – Base folder name; suffix ‘1’ appended, auto-incremented if taken.
output_unit (str, optional) – Override output unit for this call (‘microns’, ‘mm’, ‘m’).
max_voxels (int, optional) – Override C3D8 hard voxel limit for this call.
force (bool) – Skip the consent prompt even when hard limit is exceeded.
custom_message (str) – Written to *Heading (e.g. ‘Made by Dr. A. Smith, Univ. X’).
phase_id (int, optional) – Override instance phase_id for this call (must be 2).
mat_data_flag (int, optional) – Override instance mat_data_flag for this call (0 or 1).
- Returns:
Path to created output directory.
- Return type:
Path
- export_c3d4(fm_state, folder_name: str, output_unit: str | None = None, max_voxels: int | None = None, force: bool = False, custom_message: str = '', phase_id: int | None = None, mat_data_flag: int | None = None) Path[source]
Export as C3D4 (linear tet) Abaqus mesh — 6 Kuhn tets per voxel.
- Parameters:
export_c3d8) ((same as)
- Returns:
Path to created output directory.
- Return type:
Path
- export_c3d20(fm_state, folder_name: str, output_unit: str | None = None, max_voxels: int | None = None, force: bool = False, custom_message: str = '', phase_id: int | None = None, mat_data_flag: int | None = None) Path[source]
Export as C3D20 (quadratic hexahedral) Abaqus mesh.
Each voxel maps to one 20-node element (8 corners + 12 mid-edge nodes). Hard limit 1.5 M voxels; warn at 750 k.
- export_c3d10(fm_state, folder_name: str, output_unit: str | None = None, max_voxels: int | None = None, force: bool = False, custom_message: str = '', phase_id: int | None = None, mat_data_flag: int | None = None) Path[source]
Export as C3D10 (quadratic tetrahedral) Abaqus mesh.
Each voxel is decomposed into 6 Kuhn tets, each with 10 nodes (4 corners + 6 mid-edge nodes). Hard limit 1 M voxels; warn at 500 k.