upxo.meshing.nonConformalMesher module

Structured (non-conformal) FE meshing from a labelled grain image (LFI).

nonConformalMesher builds a regular grid and assigns grain IDs as element sets. Classmethods for quad/tri/hex/tet exist; the quad paths are the most complete end-to-end. Export targets include Abaqus-style meshes via mesh(analysis_package=...).

class upxo.meshing.nonConformalMesher.nonConformalMesher(dim=2, etype='quad4', lfi=array([[20, 5, 56, 63, 89, 2, 47, 63, 77, 55], [7, 52, 62, 13, 40, 89, 95, 32, 1, 40], [23, 50, 68, 62, 17, 83, 72, 73, 93, 19], [61, 33, 83, 99, 2, 0, 84, 95, 9, 50], [77, 1, 25, 78, 3, 0, 89, 13, 69, 61], [46, 74, 13, 20, 26, 1, 91, 47, 31, 84], [57, 76, 67, 23, 57, 78, 31, 59, 49, 82], [62, 16, 49, 97, 60, 84, 99, 95, 65, 14], [4, 42, 26, 79, 24, 15, 6, 47, 30, 84], [24, 65, 89, 16, 60, 8, 62, 58, 14, 3]], dtype=int32), gids=None, nelx=10, nely=10, nelz=10, xstart=0, ystart=0, zstart=0, ellx=1, elly=1, ellz=1, plane_stress=True, reduced_integration=False, modifiedFormulation=False, axiSymmElements=False)[source]

Bases: object

Structured (non-conformal) FE mesh from a labelled grain image (LFI).

Builds a regular grid of elements and assigns grain IDs as element sets — grain boundaries are not geometrically conformal (edges do not follow GB curves). Prefer confMesh2dGMSH / mesh_gs() (2D) or gbconformant.d3v2p0 / gbconformant.d3v2p1 (3D) when conformal GB meshes are required.

Element types

  • 2D: Quad4, Quad8, Tri3, Tri6

  • 3D: Hex8, Hex20, Tet5 (classmethods; quad paths are most complete)

Export targets (mesh(analysis_package=...)): Abaqus, MOOSE, DAMASK.

Example

>>> from upxo.meshing.nonConformalMesher import nonConformalMesher as ncm
>>> m = ncm.quad4(lfi=lfi, gids=gids, nelx=4, nely=2,
...               xstart=0.0, ystart=0.0, ellx=0.2, elly=0.1)
>>> m.mesh(analysis_package='abaqus', elsetNamePrefix='gid_')
valid_image_data = ('lfi', 'phmap', 'custom')
valid_xoriTypes = ('bunge', 'zxz', 'matthies', 'mtex', 'zyz', 'roe', 'kocks', 'canova', 'miller', 'rot', 'quat', 'axisangle')
ABQ_ENAMES = {'c3d_hex': ['C3D8', 'C3D8R', 'C3D8I', 'C3D20', 'C3D20R'], 'c3d_pyramid': ['C3D5'], 'c3d_tet': ['C3D4', 'C3D10', 'C3D10M'], 'c3d_wedge': ['C3D6', 'C3D15'], 'cax': ['CAX3', 'CAX4', 'CAX4R', 'CAX6', 'CAX8', 'CAX8R'], 'cpe': ['CPE3', 'CPE4', 'CPE4R', 'CPE6', 'CPE8', 'CPE8R'], 'cps': ['CPS3', 'CPS4', 'CPS4R', 'CPS6', 'CPS8', 'CPS8R']}
dim
etype
lfi
nelx
nely
nelz
xstart
ystart
zstart
ellx
elly
ellz
plane_stress
reduced_integration
axiSymmElements
modifiedFormulation
vertexNodeIds
midSideNodeIds
boundaryNodeIds
nn
nel
nnInExRatio
nelInExRatio
floatDType
temp_container
xori
xoriType
xoriUnits
set_gids(gids=None)[source]

Set or update gids.

ignore_gids(gids_to_ignore)[source]

Ignore gids.

classmethod quad(lfi=array([[33, 8, 16, 98, 53, 18, 37, 90, 37, 69], [32, 48, 40, 12, 88, 44, 19, 10, 57, 18], [98, 87, 57, 21, 93, 58, 93, 23, 76, 31], [71, 88, 25, 71, 53, 47, 82, 66, 82, 0], [15, 70, 97, 29, 68, 95, 64, 68, 65, 21], [23, 10, 41, 71, 24, 13, 39, 16, 46, 32], [21, 34, 90, 89, 46, 86, 11, 24, 31, 3], [69, 66, 94, 33, 97, 81, 78, 3, 9, 30], [77, 76, 51, 97, 54, 64, 72, 79, 11, 95], [26, 59, 58, 99, 52, 96, 39, 15, 62, 91]], dtype=int32), gids=None, nelx=10, nely=10, nelz=0, xstart=0, ystart=0, zstart=0, ellx=1, elly=1, ellz=1, nnodes=4, plane_stress=True, reduced_integration=False, modifiedFormulation=False, axiSymmElements=False)[source]

Class method to create a nonConformalMesher instance with Quad elements.

Example

m = nonConformalMesher.quad(lfi=my_lfi, gids=my_gids, nelx=20, nely=20,

xstart=0.0, ystart=0.0, ellx=1.0, elly=1.0)

classmethod tri(lfi=array([[21, 52, 23, 78, 85, 56, 44, 29, 24, 94], [53, 79, 82, 64, 86, 16, 90, 33, 84, 82], [66, 43, 8, 39, 33, 0, 24, 40, 90, 77], [1, 13, 83, 57, 35, 18, 92, 88, 9, 14], [62, 78, 63, 71, 37, 2, 45, 74, 77, 59], [63, 88, 22, 2, 53, 11, 48, 7, 7, 40], [3, 38, 85, 68, 14, 79, 22, 9, 24, 66], [56, 30, 68, 92, 73, 15, 16, 71, 43, 97], [88, 69, 89, 69, 16, 3, 34, 89, 85, 33], [45, 82, 8, 44, 92, 41, 64, 9, 29, 75]], dtype=int32), gids=None, nelx=10, nely=10, nelz=0, xstart=0, ystart=0, zstart=0, ellx=1, elly=1, ellz=1, nnodes=3, plane_stress=True, reduced_integration=False, modifiedFormulation=False, axiSymmElements=False)[source]

Class method to create a nonConformalMesher instance with Tri elements.

Example

m = nonConformalMesher.tri(lfi=my_lfi, gids=my_gids, nelx=20, nely=20,

xstart=0.0, ystart=0.0, ellx=1.0, elly=1.0)

classmethod hex(lfi=array([[91, 95, 89, 70, 97, 89, 44, 99, 20, 61], [76, 48, 12, 21, 64, 77, 81, 0, 44, 72], [10, 2, 35, 88, 33, 95, 56, 65, 90, 29], [37, 83, 61, 73, 50, 93, 35, 59, 52, 47], [69, 91, 57, 9, 19, 82, 69, 74, 38, 74], [34, 15, 79, 55, 15, 86, 28, 13, 9, 35], [45, 45, 1, 30, 71, 65, 6, 49, 47, 39], [94, 31, 46, 1, 75, 88, 87, 54, 61, 72], [50, 41, 26, 4, 32, 66, 59, 16, 82, 25], [57, 40, 91, 46, 65, 10, 51, 56, 12, 89]], dtype=int32), gids=None, nelx=10, nely=10, nelz=10, xstart=0, ystart=0, zstart=0, ellx=1, elly=1, ellz=1, nnodes=8, reduced_integration=False, modifiedFormulation=False)[source]

Class method to create a nonConformalMesher instance with Hex8 elements.

Example

m = nonConformalMesher.hex8(lfi=my_lfi, gids=my_gids, nelx=20, nely=20, nelz=20,

xstart=0.0, ystart=0.0, zstart=0.0, ellx=1.0, elly=1.0, ellz=1.0)

classmethod tet(lfi=array([[10, 78, 37, 24, 62, 3, 23, 30, 62, 41], [39, 67, 59, 48, 27, 45, 31, 83, 8, 72], [42, 84, 14, 36, 93, 89, 91, 76, 35, 38], [23, 46, 32, 46, 91, 89, 28, 1, 70, 22], [33, 51, 53, 88, 52, 98, 46, 85, 40, 93], [12, 88, 0, 57, 50, 9, 54, 43, 98, 87], [57, 50, 49, 53, 35, 59, 72, 95, 25, 91], [87, 6, 2, 11, 28, 63, 77, 48, 72, 9], [54, 80, 19, 12, 84, 49, 84, 41, 84, 97], [23, 3, 13, 26, 0, 79, 0, 14, 29, 17]], dtype=int32), gids=None, nelx=10, nely=10, nelz=10, xstart=0, ystart=0, zstart=0, ellx=1, elly=1, ellz=1, nnodes=4, reduced_integration=False, modifiedFormulation=False)[source]

Example

m = nonConformalMesher.tet5(lfi=my_lfi, gids=my_gids, nelx=20, nely=20, nelz=20,

xstart=0.0, ystart=0.0, zstart=0.0, ellx=1.0, elly=1.0, ellz=1.0)

mesh(analysis_package='abaqus', elsetNamePrefixBasic='gid_')[source]

Core orchastrator function for non-conformal meshing in this class.

The function branches execution as per the element types and the analysis package. All parameters are updated to self object.

set_element_name(elname: str = None)[source]

Set or update element name.

set_analysis_package(analysis_package: str)[source]

Set or update analysis package.

set_pxtal_orientations(xori=None, xoriType='bunge', xoriUnits='degree')[source]

Set or update pxtal orientations.

map_pxtal_orientations_to_elements()[source]

Not implemented. Placeholder for mapping per-grain crystallographic orientations onto the non-conformal mesh’s elements.

Raises:

NotImplementedError – Always – this method is not yet implemented.

make_base_coordinates_ABQ(**kwargs)[source]

Build and return base coordinates ABQ.

cross_check_nel()[source]

Cross check nel.

define_nodeNumbers_ABQ(**kwargs)[source]

Example

define_nodeNumbers() # For ‘quad4’ num_valid_nodes, valid_mask_T = define_nodeNumbers() # For ‘quad8’

define_nodes_ABQ(**kwargs)[source]

Define nodes abq.

define_elementNumbers_ABQ(**kwargs)[source]

Define elementnumbers abq.

define_element_locations_ABQ(**kwargs)[source]

Define element locations abq.

define_connectivity_ABQ(**kwargs)[source]

Example

el_ids, connectivity = define_connectivity(elLoc, nnum)

get_element_node_coordinates_ABQ(**kwargs)[source]

Extract Element Node Coordinates

calculate_element_centroids_ABQ(**kwargs)[source]

Centroid Calculation

define_elements_ABQ(**kwargs)[source]

Create ELEMENTS dict

define_ABQ_elements()[source]

Create ELEMENTS dict

make_elsets_quad4_ABQ_basic(elsetNamePrefixBasic='gid_')[source]

Build and return elsets quad4 ABQ basic.

set_threshold_nel_for_large_mesh_elEdgePlot_(value: int)[source]

Set or update threshold nel for large mesh elEdgePlot .

see_mesh(figsize=(10, 5), dpi=150, imageDataType='lfi', imageData=None, imageDataTitle='LFI', featureName='grains', elsetType='basic', overlapOnIMAGE=True, cmap='nipy_spectral', showColorBar=True, IMAGEalpha=0.3, nodes=True, nodeMarker='s', nodeMarkerFaceColor='grey', nodeMarkerEdgeColor='black', nodeMarkerSize=8, nodeNumbers=True, nodeNumberTextColour='blue', nodeNumberTextLocOffsetFactor=20, nodeNumberTextFontSize=16, elementNumbers=True, elementNumberTextColour='red', elementNumberTextLocOffsetFactor=20, elementNumberTextFontSize=16, elementNumberTextFontWeight='bold', elementEdges=True, elementEdgeLineColor='grey', elementEdgeLineStyle='--', elementEdgeLineWidth=0.5, elementCentroids=True, elementCentroidMarker='o', elementCentroidMarkerSize=2, returnFigAx=False, includeLabels=False, xlabelText='', ylabelText='', xlabelTextFontSize=14, ylabelTextFontSize=14, xlabelTextFontWeight='normal', ylabelTextFontWeight='normal', includeTitle=False, titleText='', titleTextFontSize=14, titleTextFontWeight='normal')[source]

See mesh.

find_element_ids_to_remove(lfi_locs_to_remove)[source]

Find element ids to remove.

find_boundary_features(boundary_offsets)[source]

Find boundary features.

find_pruning_locations(pharr=None, dim=2, method='cellSize', measure='npixels', unitSize=1.0, threshold=[0, 0.5], phaseValue=1, thresholdingRule='quantile', exclude_boundary_features=True, boundary_offsets=[1, 1, 1, 1])[source]

Find pruning locations.

prune(lfi_locs_to_remove)[source]

Prune.

xincr
yincr
zincr
xbase
ybase
zbase
xndgrid
yndgrid
zndgrid
gids
ignored_gids
phmap
nnum
NODES
enum
elLoc
ELEMENTS
el_ids
nidStart
elifStart
boundaryElIds
ABQ_ELEMENTS
elsets
connectivity
elname
el_node_coords
elCentroids
analysis_package