Skip to content

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AHartmaier committed Feb 6, 2024
1 parent ca8444c commit 916cf32
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/kanapy/grains.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,16 @@ def get_diameter(pts):

def project_pts(pts, ctr, axis):
"""
Project
Project points (pts) to plane defined via center (ctr) and normal vector (axis).
Parameters
----------
pts : (N, dim) ndarray
Point set in dim dimensions
ctr : (dim)-ndarray
Center point of the projection plane
axis : (dim)-ndarray
Unit vector for axis along which points are projected
Unit vector for plane normal
Returns
-------
Expand All @@ -220,30 +221,33 @@ def project_pts(pts, ctr, axis):
# define constants
voxel_res = np.divide(rve.size, rve.dim)
voxel_size = voxel_res[0]
RVE_min = np.amin(mesh.nodes, axis=0)
RVE_min = np.min(mesh.nodes, axis=0)
if np.any(RVE_min > 1.e-3) or np.any(RVE_min < -1.e-3):
raise ValueError('Irregular RVE geometry: RVE_min = {}'.format(RVE_min))
RVE_max = np.amax(mesh.nodes, axis=0)
Ng_max = np.amax(list(mesh.grain_dict.keys())) # highest grain number
RVE_max = np.max(mesh.nodes, axis=0)
Ng_max = np.max(list(mesh.grain_dict.keys())) # highest grain number
Ngr = len(mesh.grain_dict.keys()) # number of grains

# create dicts for GB facets, including fake facets at surfaces
geometry = dict()
geometry['Ngrains'] = mesh.ngrains_phase
grain_facesDict = dict() # {Grain: faces}
gb_vox_dict = dict()
for i in range(1, Ng_max + 7):
grain_facesDict[i] = dict()

# generate following objects:
# outer_faces: {face_id's of outer voxel faces} (potential GB facets)
# face_nodes: {face_id: list with 4 nodes}
# grain_facesDict: {grain_id: {face_id: list with 4 nodes}}
# gb_vox_dict: {face_id: list with voxels}
# Loop over all grains in microstructure
for gid, elset in mesh.grain_dict.items():
outer_faces = set()
face_nodes = dict()
nodeConn = [mesh.voxel_dict[el] for el in elset] # Nodal connectivity of a voxel
nodeConn = [mesh.voxel_dict[el] for el in elset] # list of node sets for each voxel in grain

# For each voxel, re-create its 6 faces
# For each voxel, re-create its 6 faces, each face is list of 4 nodes
for nc in nodeConn:
faces = [[nc[0], nc[1], nc[2], nc[3]], [nc[4], nc[5], nc[6], nc[7]],
[nc[0], nc[1], nc[5], nc[4]], [nc[3], nc[2], nc[6], nc[7]],
Expand Down

0 comments on commit 916cf32

Please sign in to comment.