upxo.meshing.gbconformant.fm_steel_abaqus package

Submodules

Module contents

FM-steel Abaqus decks for grain-conformal tetrahedral meshes.

Reads a raw feature export folder (label arrays, orientations and the raw_export.pkl bundle), resolves which raw feature each meshed grain stands for after cleaning and merging, and writes a partitioned C3D4 deck with element sets, materials, sections, node sets and a static step.

upxo.meshing.gbconformant.fm_steel_abaqus.applied_strain(settings, hierarchy)[source]

Engineering strain the applied displacement gives along the load axis.

The displacement and the coordinates share the length scale, so it cancels.

upxo.meshing.gbconformant.fm_steel_abaqus.domain_lengths(hierarchy, output_units=None, length_scale=1.0)[source]

Edge lengths of the structure along x, y and z in the output units.

class upxo.meshing.gbconformant.fm_steel_abaqus.BoxSpec(mode: str = 'index', lo: tuple = (0, 0, 0), hi: tuple | None = None, units: str | None = None)[source]

Bases: object

A box entered in one of three ways.

index: voxel indices, hi exclusive. percent: percent of the dataset along each axis. physical: lengths from the dataset origin in units. A hi of None means the full extent.

mode: str = 'index'
lo: tuple = (0, 0, 0)
hi: tuple | None = None
units: str | None = None
validate()[source]
upxo.meshing.gbconformant.fm_steel_abaqus.cut_statistics(parent_counts, crop_counts, small_threshold=4)[source]

What the box cuts: grains partly inside, and fragments below small_threshold.

upxo.meshing.gbconformant.fm_steel_abaqus.describe_box(lo, hi, shape, voxel_size=1.0, source_units=None, units=None)[source]

The same box in all three entry forms, for display and for mode switches.

upxo.meshing.gbconformant.fm_steel_abaqus.extract_labels(labels, lo, hi)[source]

Crop of labels as a new contiguous array.

upxo.meshing.gbconformant.fm_steel_abaqus.extract_subset(hierarchy, lo, hi)[source]

Hierarchy of the crop: same features, IDs and orientations, sizes recomputed.

upxo.meshing.gbconformant.fm_steel_abaqus.next_index(parent, width=3)[source]

One more than the largest NNN or NNN_suffix entry in parent.

upxo.meshing.gbconformant.fm_steel_abaqus.new_indexed_directory(parent, stem, width=3)[source]

Create parent/<stem>_NNN with the next free number and return its path.

upxo.meshing.gbconformant.fm_steel_abaqus.resolve_box(spec, shape, voxel_size=1.0, source_units=None)[source]

Voxel indices (lo, hi) of spec in a dataset of shape.

voxel_size is one voxel edge in source_units; physical entry is converted from spec.units (default: source_units). Indices are rounded to the nearest voxel boundary.

upxo.meshing.gbconformant.fm_steel_abaqus.subset_record(spec, lo, hi, shape, voxel_size=1.0, source_units=None, units=None, statistics=None)[source]

JSON-ready description of a crop (what was cut, in every entry form).

upxo.meshing.gbconformant.fm_steel_abaqus.write_subset_record(folder, record, name='subset.json')[source]
class upxo.meshing.gbconformant.fm_steel_abaqus.ComparisonSettings(include_rve_faces: bool = False, output_units: str | None = None, length_scale: float = 1.0, mesh_voxel_length: float = 1.0, symmetry: str = 'cubic')[source]

Bases: object

include_rve_faces: bool = False
output_units: str | None = None
length_scale: float = 1.0
mesh_voxel_length: float = 1.0
symmetry: str = 'cubic'
class upxo.meshing.gbconformant.fm_steel_abaqus.TextureSettings(pole_family: object = '100', crystal_symmetry: str = 'cubic', apply_sample_symmetry: bool = True, use_rd: bool = True, use_td: bool = True, use_nd: bool = True, half_width_deg: float = 7.5, grid_points: object = 'auto', unit_normalize: bool = True, plot_mode: str = 'density', projection: str = 'equal_area', hemisphere: str = 'upper', cmap: str = 'viridis', difference_cmap: str = 'RdBu_r', levels: int = 10, contour_scale: str = 'linear', colorbar_decimals: int | None = None, axis_labels: tuple = (None, None, None))[source]

Bases: object

pole_family: object = '100'
crystal_symmetry: str = 'cubic'
apply_sample_symmetry: bool = True
use_rd: bool = True
use_td: bool = True
use_nd: bool = True
half_width_deg: float = 7.5
grid_points: object = 'auto'
unit_normalize: bool = True
plot_mode: str = 'density'
projection: str = 'equal_area'
hemisphere: str = 'upper'
cmap: str = 'viridis'
difference_cmap: str = 'RdBu_r'
levels: int = 10
contour_scale: str = 'linear'
colorbar_decimals: int | None = None
axis_labels: tuple = (None, None, None)
validate()[source]
upxo.meshing.gbconformant.fm_steel_abaqus.compare_before_after(hierarchy, points, tetrahedra, tet_grain, identity, settings=None)[source]

Junction line lengths and sphere-equivalent diameters, before and after.

upxo.meshing.gbconformant.fm_steel_abaqus.compare_junction_lines(hierarchy, points, tetrahedra, resolved_grains, settings=None)[source]

Junction line lengths before (voxels) and after (tetrahedra).

upxo.meshing.gbconformant.fm_steel_abaqus.density_difference(eulers_before, eulers_after, settings, weights=(None, None))[source]

After-minus-before MUD density difference on a shared grid.

weights is (before, after): one weight per orientation or None for each side. Returns Xi, Yi, zi_diff and iqr (interquartile range of the difference field; a single-number summary, not a verdict).

upxo.meshing.gbconformant.fm_steel_abaqus.feature_diameters(hierarchy, points, tetrahedra, resolved_grains, settings=None)[source]

Sphere-equivalent diameter of every feature: raw voxels against mesh volume.

upxo.meshing.gbconformant.fm_steel_abaqus.format_summary(result)[source]

Plain-text tables of a compare_before_after() result, the columns named for what they hold.

upxo.meshing.gbconformant.fm_steel_abaqus.orientation_table(hierarchy, labels=None)[source]

(labels, eulers) of the features in labels (default: all), ascending.

upxo.meshing.gbconformant.fm_steel_abaqus.report_summary(result)[source]

JSON-friendly digest of compare_before_after() (no per-line arrays).

upxo.meshing.gbconformant.fm_steel_abaqus.grain_fidelity(hierarchy, points, tetrahedra, tet_grain, settings=None, *, shrink_limit=0.1)[source]

Volume, boundary area, neighbours and aspect ratio of every feature, before and after.

tet_grain is the resolved raw label of each tetrahedron. shrink_limit is the fraction of volume a feature may lose before it is flagged shrunk; a feature with no tetrahedra is lost. Returns {'units', 'columns', 'rows', 'stats', 'shrink_limit', 'flagged', 'lost'}.

upxo.meshing.gbconformant.fm_steel_abaqus.merge_log(hierarchy, identity, *, symmetry='cubic', prefixes=None)[source]

Misorientation between every absorbed raw feature and the winner of its merged grain.

identity is the IdentityMap; prefixes are the element-set name prefixes. Only cubic symmetry is available. Returns {'columns', 'rows', 'summary', 'symmetry'}.

upxo.meshing.gbconformant.fm_steel_abaqus.write_merge_log(folder, log)[source]

Write merge_log.json and merge_log.csv into folder; returns both paths.

class upxo.meshing.gbconformant.fm_steel_abaqus.BoundaryNodes(grain_boundary: ndarray, junction: ndarray, by_feature: dict = <factory>, n_nodes: int = 0)[source]

Bases: object

Node indices (0-based, as in the tetrahedra array) of the boundary sets.

grain_boundary: ndarray
junction: ndarray
by_feature: dict
n_nodes: int = 0
counts()[source]
upxo.meshing.gbconformant.fm_steel_abaqus.boundary_nodes(tetrahedra, tet_feature, n_nodes=None, chunk=200000)[source]

Boundary nodes from the tetrahedra (0-based node indices) and one feature label per tetrahedron.

upxo.meshing.gbconformant.fm_steel_abaqus.periodic_pairs(base_points, faces, tolerance)[source]

{axis letter: {‘pairs’: (k, 2) 1-based node numbers [low, high], ‘low’: n, ‘high’: n, ‘max_offset’: d}}.

faces maps XMIN..``ZMAX`` to 1-based node numbers of base_points. A pair is the nearest high-face node within tolerance in the two other coordinates; each node is used at most once.

upxo.meshing.gbconformant.fm_steel_abaqus.tetrahedron_fields(tet_feature, features, names, ids=None)[source]

Per-tetrahedron arrays from the feature of each tetrahedron.

features maps a feature label to an object with euler and global_id; names maps the label to the name of its element set; ids is {column: {label: int}} of further ids (the hierarchy levels, see features.id_columns()). Returns a dictionary with feature_label (M,), global_id (M,), euler_deg (M, 3), ipf_x/ipf_y/ipf_z (M, 3, floats in 0..1), ids ({column: (M,)}) and names ({label: name}).

upxo.meshing.gbconformant.fm_steel_abaqus.write_msh(path, points, tetrahedra, fields)[source]

Gmsh MSH 2.2 ASCII: physical groups named after the element sets, element data for the orientations.

upxo.meshing.gbconformant.fm_steel_abaqus.write_vtu(path, points, tetrahedra, fields)[source]

VTK unstructured grid with the cell data of tetrahedron_fields(); IPF colours as 8-bit RGB.

class upxo.meshing.gbconformant.fm_steel_abaqus.DeckSettings(material_format: str = 'reference_umat', n_depvar: int = 1, load_axis: str = 'z', applied_displacement: float = 0.2, step_time: float = 80.0, write_step: bool = True, initial_inc: float = 0.01, min_inc: float = 1e-08, max_inc: float = 1.0, max_increments: int = 10000, output_interval: float = 0.5, load_mode: str = 'displacement', load_case: str = 'monotonic', load_sense: str = 'tension', target_strain: float = 0.02, strain_rate: float = 0.0004, hold_time: float = 0.0, cycle_definition: str = 'min_max', strain_min: float = -0.01, strain_max: float = 0.01, strain_amplitude: float = 0.01, r_ratio: float = -1.0, cycles: int = 5, output_elset: str = '', job_scripts: bool = False, abaqus_command: str = 'abaqus', umat_file: str = '', job_name: str = 'fm_job', job_cpus: int = 4, job_memory_gb: float = 0.0, job_time_hours: float = 24.0, slurm_partition: str = '', element_outputs: tuple = ('LE', 'NE', 'S', 'SDV'), node_outputs: tuple = ('U', ), length_scale: float = 1.0, output_units: str | None = None, header_message: str = '', elset_prefixes: dict = <factory>, nset_names: dict = <factory>, face_tolerance: float = 1e-08, boundary_sets: bool = False, layer_sets: bool = False, boundary_classes: bool = False, low_angle_degrees: float = 15.0, crystal_symmetry: str = 'cubic', feature_table: bool = False, deck_check: bool = False, write_msh: bool = False, write_vtu: bool = False, prefix_gb_layer: str = 'es_gb_layer', prefix_interior: str = 'es_interior', set_provider: str = '', provider_options: dict = <factory>)[source]

Bases: object

material_format: str = 'reference_umat'
n_depvar: int = 1
load_axis: str = 'z'
applied_displacement: float = 0.2
step_time: float = 80.0
write_step: bool = True
initial_inc: float = 0.01
min_inc: float = 1e-08
max_inc: float = 1.0
max_increments: int = 10000
output_interval: float = 0.5
load_mode: str = 'displacement'
load_case: str = 'monotonic'
load_sense: str = 'tension'
target_strain: float = 0.02
strain_rate: float = 0.0004
hold_time: float = 0.0
cycle_definition: str = 'min_max'
strain_min: float = -0.01
strain_max: float = 0.01
strain_amplitude: float = 0.01
r_ratio: float = -1.0
cycles: int = 5
output_elset: str = ''
job_scripts: bool = False
abaqus_command: str = 'abaqus'
umat_file: str = ''
job_name: str = 'fm_job'
job_cpus: int = 4
job_memory_gb: float = 0.0
job_time_hours: float = 24.0
slurm_partition: str = ''
element_outputs: tuple = ('LE', 'NE', 'S', 'SDV')
node_outputs: tuple = ('U',)
length_scale: float = 1.0
output_units: str | None = None
header_message: str = ''
elset_prefixes: dict
nset_names: dict
face_tolerance: float = 1e-08
boundary_sets: bool = False
layer_sets: bool = False
boundary_classes: bool = False
low_angle_degrees: float = 15.0
crystal_symmetry: str = 'cubic'
feature_table: bool = False
deck_check: bool = False
write_msh: bool = False
write_vtu: bool = False
prefix_gb_layer: str = 'es_gb_layer'
prefix_interior: str = 'es_interior'
set_provider: str = ''

none.

Type:

Module that adds further sets to the deck (see extra_sets); empty

provider_options: dict

The provider’s options, as its options_from_config read them.

validate()[source]

Raise ValueError on an invalid setting; return output tuples.

class upxo.meshing.gbconformant.fm_steel_abaqus.Hierarchy(level: str, lgi: numpy.ndarray, features: dict, voxel_counts: dict, units: str, voxel_size: float, pag_order: list = <factory>, pck_order: list = <factory>, blk_order: list = <factory>, sblk_order: list = <factory>, global_ids: dict = <factory>, origin: tuple | None = None, parent_shape: tuple | None = None, names: dict = <factory>, material_names: dict = <factory>, extra: dict = <factory>, groups: dict = <factory>, system: str = 'FM steel')[source]

Bases: object

level: str
lgi: ndarray
features: dict
voxel_counts: dict
units: str
voxel_size: float
pag_order: list
pck_order: list
blk_order: list
sblk_order: list
global_ids: dict
origin: tuple | None = None
parent_shape: tuple | None = None
names: dict
material_names: dict
extra: dict
groups: dict
system: str = 'FM steel'
property level_text

grain for a structure that has only grains (twinned FCC), else the level code.

Type:

The level as a person reads it

ordered_features()[source]

Features in global-ID order, which is the deck’s material order.

exception upxo.meshing.gbconformant.fm_steel_abaqus.IdentityError[source]

Bases: RuntimeError

A grain’s tetrahedra do not lie over any of its own raw features.

class upxo.meshing.gbconformant.fm_steel_abaqus.IdentityMap(winner: dict, members: dict, survivor_raw: dict, rule: str, seed: int, report: dict = <factory>)[source]

Bases: object

Meshed label -> winning raw label, with the merge history.

winner: dict
members: dict
survivor_raw: dict
rule: str
seed: int
report: dict
lookup()[source]

Array lut with lut[meshed_label] = raw label (-1 if unused).

upxo.meshing.gbconformant.fm_steel_abaqus.detect_levels(folder, prefixes=None)[source]

Levels (coarse to fine) with both a label array and an orientation file.

upxo.meshing.gbconformant.fm_steel_abaqus.load_hierarchy(folder, level, prefixes=None)[source]

Read level of the raw export in folder into a Hierarchy.

upxo.meshing.gbconformant.fm_steel_abaqus.location_audit(points, tetrahedra, tet_grain, identity, hierarchy, mesh_voxel_length=1.0, chunk=500000)[source]

Compare each tetrahedron’s identity with the raw voxel under its centroid.

mesh_voxel_length is the length of one raw voxel in mesh coordinates. Smoothing and cleaning legitimately move boundaries, so a mismatch fraction is reported per feature; only a grain whose volume lies mostly over raw features outside its own merge history raises IdentityError.

upxo.meshing.gbconformant.fm_steel_abaqus.reallocation_report(raw_labels, meshed_labels, identity, hierarchy)[source]

Voxel ownership change between the raw labels and the meshed labels.

meshed_labels is the cleaned label array in pipeline labels (before any upscaling), the same array the grain surfaces were extracted from.

upxo.meshing.gbconformant.fm_steel_abaqus.resolve_identities(raw_sizes, *, shuffle_map=None, survivor_map=None, rule='larger', seed=0)[source]

Resolve the raw identity of every meshed grain.

Parameters:
  • raw_sizes (mapping raw label -> voxel count before any cleaning.)

  • shuffle_map (mapping raw label -> pipeline label (grain-ID shuffle);) – None means the pipeline used the raw labels unchanged.

  • survivor_map (mapping pipeline label -> pipeline label of the grain it) – was merged into (the small-grain removal’s original_to_survivor); None means no grain was merged.

  • rule ('larger' keeps the largest member’s identity; 'survivor') – keeps the identity of the grain that absorbed the others.

  • seed (seeds the pick between equally large members.)

upxo.meshing.gbconformant.fm_steel_abaqus.write_deck(directory, points, tetrahedra, tet_grain, hierarchy, identity, settings=None, *, mesh_voxel_length=1.0, meshed_labels=None, audit=True)[source]

Write the deck into a new directory; return a summary dictionary.

Parameters:
  • points (mesh coordinates (in units where one raw voxel edge is) – mesh_voxel_length) and 0-based node indices of linear tetrahedra (M, 4), or of linear hexahedra (M, 8) in C3D8 order (a voxel mesh).

  • tetrahedra (mesh coordinates (in units where one raw voxel edge is) – mesh_voxel_length) and 0-based node indices of linear tetrahedra (M, 4), or of linear hexahedra (M, 8) in C3D8 order (a voxel mesh).

  • tet_grain (meshed grain label of every element.)

  • hierarchy (Hierarchy of the chosen level.)

  • identity (IdentityMap for the meshed grains.)

  • meshed_labels (optional cleaned label array (pipeline labels); when given a) – voxel reallocation report is written as well.

  • audit (look up the raw voxel under every centroid and stop on an identity) – mismatch (IdentityError).