upxo.pxtal.vortess3d module

3D Voronoi tessellation grain structure for UPXO.

class upxo.pxtal.vortess3d.gtess3d(pxtals=None, gen_method='from_seed_points', phid=None)[source]

Bases: object

3D Voronoi tessellation polycrystal with hierarchical feature levels.

Geometric 3D grain structure supporting multi-level feature databases (base grains, twins, prior-austenitic packets / blocks / laths, boundary zones, precipitates) for visualisation (PyVista) and downstream meshing.

Valid gslevel codes (_valid_gslevels_)

  • base — primary grain structure

  • tw — twinned structures

  • pap / pap.bl / pap.bl.sbl / pap.bl.lath / pap.bl.sbl.lath — prior-austenitic packet hierarchy

  • base.bz — boundary zones on base grains

  • base.ppt — base with precipitates

  • supset — superset features

Name maps (_valid_gsnamemaps_) alias user strings (e.g. 'base') to internal FDB attributes (fdb_base, …). Feature names (_valid_fnames_) include phase, texture, twins, PAP blocks, voids, etc.

pxtals
sp
info
bounds
ninst
gen_method
instn

Setup the base GS feature database

fdb_base
fdb_subgrains
fdb_paps

Morphological properties.

mprop

Topological properties.

tprop
plot_sp(inst)[source]

Visualise sp using Matplotlib or PyVista.

classmethod from_seed_point_random(xbound=[0, 20], ybound=[0, 20], zbound=[0, 20], npnt=100, delnpnt=5, niter=100, repr_prop={'vol': {'consider_boundary_grains': True, 'mean': {'dev': 5, 'val': 10}}}, divergence_control=True)[source]

Construct from randomly distributed seed points.

Examples

bounding_box = [[0, 12], [0, 12], [0, 12]]
points = generate_random_lattice_bounded(bounding_box, 100)
classmethod from_regular_lattice(bounding_box, xincr, yincr, zincr, lattice='sc', lc=None, start_offset=True)[source]

Construct this instance from regular lattice.

classmethod from_mpoint3d(seed_points, bounds=None, periodic=None, block_size=1.0, phid=None, metadata=None, make_delaunay=True, alpha=0.0)[source]

Construct a PyVista-backed 3D seed structure from MPoint3d.

Parameters:
  • seed_points (MPoint3d) – UPXO multi-point seed object. Its coords array is retained as the canonical seed cloud and converted to pyvista.PolyData.

  • bounds (array-like, shape (3, 2), optional) – Tessellation RVE bounds. If omitted, seed_points.metadata['bounds'] is used when present; otherwise bounds are inferred from the seed coordinate extrema.

  • periodic (bool or iterable of bool, optional) – Periodic boundary flags. If omitted, seed metadata is used.

  • block_size (float, optional) – Retained for API compatibility with older calls.

  • phid (object, optional) – Phase ID assigned to the base cells.

  • metadata (dict, optional) – Extra user metadata stored in self.info['uinputs'].

  • make_delaunay (bool, optional) – If True, build a PyVista 3D Delaunay grid from the seed cloud.

  • alpha (float, optional) – Alpha value passed to PolyData.delaunay_3d. Default 0.0.

Notes

This path is a PyVista-native seed handoff layer. Exact bounded Voronoi cell recovery can be added later with VTK/PyVista-compatible machinery.

classmethod from_seed_points(seed_points, **kwargs)[source]

Construct from MPoint3d or raw (N, 3) seed coordinates.

classmethod from_seed_point_extrusion(sp_input='gen', seed_coords=None, xbound=[0, 50], ybound=[0, 100], zbound=[0, 75], nsp=600, n_instances=1, nsp_dev_ninstances=10, sp_distr='random', gr_tech='pds', smp_tech='bridson1', randuni_calc='by_points', lean='veryhigh', char_length=[3, 2], niter=500, ntrials=10, k_char_length_inc=0.1, k_char_length_dec=0.1, repr_prop={'vol': {'consider_boundary_grains': True, 'distr': {'filename': None, 'remol': [True, 25, 75]}, 'mean': {'dev': 5, 'val': 10}, 'use': 'mean'}}, make_point_objects=True, make_ckdtree=True, char_length_mean=0.24598, char_length_min=0.1111, char_length_max=0.9999, nt=10, space='linear', nchecks=10, sdf=0.75, divergence_control=True, periodic=[False, False, False])[source]

Generate multi-instance multi-parameter repr 3dvtess base pxtal.

Uses seed point distribution derived from.
  • extrusion based pesudo-Bridson sampling algorithm.

  • extrusion based dart sampling algorithm.

Currently supported list of morphological parameters useful for representativeness assessment:

  • mean grain volume

Parameters:

sp_input='gen'

:param : :param seed_coords=None: :param : :param xbound=[0: :param 50]: :param : :param ybound=[0: :param 100]: :param : :param zbound=[0: :param 75]: :param : :param nsp=600: :param : :param n_instances=1: :param : :param nsp_dev_ninstances=10: :param : :param sp_distr=’random’: :param : :param gr_tech=’pds’: :param smp_tech=’bridson1’: :param : :param randuni_calc=’by_points’: :param lean=’veryhigh’: :param : :param char_length=[3: :param 2]: :param niter=500: :param ntrials=10: :param : :param k_char_length_inc=0.1: :param k_char_length_dec=0.1: :param : :param repr_prop={‘vol’:

‘mean’: {‘val’: 10,

‘dev’: 5, },

‘distr’: {‘filename’: None,

‘remol’: [True, 25, 75]},

‘consider_boundary_grains’: True}

}

distr: distribution data filepath: full path of file containing distribution data

Only .csv or .dat file allowed.

remol: List for remove outliers in distr.

remol[0]: Flag to remove or retain outliers in distribution. remol[1]: Lower percentile value. remol[2]: Upper percentile value.

Parameters:

make_point_objects=True

:param : :param make_ckdtree=True: :param : :param char_length_mean=0.24598: :param char_length_min=0.1111: :param : :param char_length_max=0.9999: :param : :param nt=10: :param : :param space=’linear’: :param nchecks=10: :param sdf=0.75: :param : :param divergence_control=True: :param : :param periodic=[False: :param False: :param False]:

Examples

from upxo.pxtal.vortess3d import gtess3d
gt3d = gtess3d.from_seed_point_extrusion(sp_input='gen', seed_coords=None,
    xbound=[0, 15], ybound=[0, 15], nsp=200,
    n_instances=2, nsp_dev_ninstances=10,
    sp_distr='random',
    gr_tech='pds', smp_tech='bridson1',
    randuni_calc='by_points', lean='veryhigh',
    char_length=[3, 0], niter=500, ntrials=10,
    k_char_length_inc=0.1, k_char_length_dec=0.2,
    repr_prop={'vol': {'use': 'mean',
                       'mean': {'val': 10, 'dev': 5},
                       'distr': {'filename': None, 'remol': True},
                       'consider_boundary_grains': True}},
    make_point_objects=True, make_ckdtree=True,
    char_length_mean=0.24598,
    char_length_min=0.1111, char_length_max=0.9999,
    nt=10, space='linear', nchecks=10, sdf=0.75,
    divergence_control=True,
    periodic=[False, False, False])
gt3d.visualize_multiple_voronoi_cells(1, cell_indices=None, colors=None,
    alpha=1, edge_color='black')
static create_2d_base_seedpoints(spinput='gen', xbound=[0, 100], ybound=[0, 100], nsp=600, sp_distr='random', gridding_technique='pds', sampling_technique='bridson1', randuni_calc='by_points', lean='veryhigh', char_length=[3, 2], niter=500, make_point_objects=True, make_ckdtree=True, char_length_mean=0.24598, char_length_min=0.1111, char_length_max=0.9999, nt=10, space='linear')[source]

Build and return 2D base seed points.

static find_bounds_2dpoints(points)[source]

Find bounds 2dpoints.

static find_bounds_3dpoints(points)[source]

Find bounds 3dpoints.

visualize_voronoi_cell(ax=None, color='cyan', alpha=0.5, edge_color='black')[source]

Visualize voronoi cell.

visualize_multiple_voronoi_cells(inst, cell_indices=None, colors=None, alpha=0.5, edge_color='black')[source]

Visualize multiple voronoi cells.

construct_pyvista_surface()[source]

Construct pyvista surface.

generate_uniform_tet_mesh(resolution=5, maxvol=0.001)[source]

Generate uniform tet mesh.

fid
floc
cids_base
idmap_c_supc
idmap_c_subc
fdb_pix
fdb_pert
fdb_supset
uinputs
neighs_cid
xomap
n
gbjp
grain_locs
gpos
interactive_slice_view(tet_mesh)[source]

Interactive slice view.

interactive_slice_view_with_quality(tet_mesh, metric='aspect_ratio', cmap='nipy_spectral', clim=[1, 5])[source]

Interactive slice view with quality.

compute_cell_quality(tet_mesh, metric='aspect_ratio')[source]

Return the computed cell quality.

plot_multiple_meshes(scalars=None, cmap='viridis', clim=[0, 1], opacity=0.5, show_edges=True)[source]

Visualise multiple meshes using Matplotlib or PyVista.

interactive_slice_view_with_quality_multiple_meshes(tet_meshes, metric='aspect_ratio', cmaps=['nipy_spectral', 'viridis'], clim=[1, 5])[source]

Interactive slice view with quality multiple meshes.

generate_background_mesh(resolution=20, eps=1e-06)[source]

Generate background mesh.

sizing_function(focus_point=numpy.array, max_size=1.0, min_size=0.1)[source]

Sizing function.