Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AHartmaier committed Feb 7, 2024
1 parent 916cf32 commit 6d946de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/kanapy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ def generate_grains(self):
ind.append(i)
igr.append(gblist[1])
if len(ind) > 0:
for i in ind.reverse():
logging.warning(f'Removing {gba[i]} from GBarea as grain {igr[i]} does not exist.')
ind.reverse()
igr.reverse()
for j, i in enumerate(ind):
logging.warning(f'Removing {gba[i]} from GBarea as grain {igr[j]} does not exist.')
gba.pop(i)
self.geometry['GBarea'] = gba

Expand Down
9 changes: 6 additions & 3 deletions src/kanapy/grains.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,17 +509,20 @@ def project_pts(pts, ctr, axis):
for igr in mesh.grain_dict.keys():
if grains[igr]['Volume'] < 1.e-5:
logging.warning(f'No tet assigned to grain {igr}.')
# remove grain from shared area list
if grains[igr]['Simplices']:
nf = len(grains[igr]['Simplices'])
logging.warning(f'Grain {igr} contains {nf} tets, but no volume')
grains.pop(igr)
continue
grains[igr]['eqDia'] = 2.0 * (3.0 * grains[igr]['Volume']
/ (4.0 * np.pi)) ** (1.0 / 3.0)
# Approximate smallest rectangular cuboid around points of grains
# to analyse prolate (aspect ratio > 1) and oblate (a.r. < 1) particles correctly
pts = grains[igr]['Points']
if len(pts) == 0:
logging.warning(f'Grain {igr} with few vertices: {grains[igr]["Vertices"]}')
if len(pts) < 4:
logging.warning(f'Removing grain {igr} with few vertices: {grains[igr]["Vertices"]}')
grains.pop(igr)
continue
dia = get_diameter(pts) # approx. of largest diameter of grain
len_a = np.linalg.norm(dia) # length of largest side
if len_a < 1.e-5:
Expand Down

0 comments on commit 6d946de

Please sign in to comment.