Skip to content

Commit de7d548

Browse files
committed
(BUGFIX) calculate triangle area without using numpy in cython
Ideally this should all be done using numpy vector operations
1 parent de13fa3 commit de7d548

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

LoopStructural/interpolators/cython/dsi_helper.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def cg(double [:,:,:] EG, long long [:,:] neighbours, long long [:,:] elements,d
7070
# we want to weight the cg by the area of the shared face
7171
# area of triangle is half area of parallelogram
7272
# https://math.stackexchange.com/questions/128991/how-to-calculate-the-area-of-a-3d-triangle
73-
area = 0.5*np.linalg.norm(norm)
73+
area = 0.5*sqrt(norm[0]*norm[0]+norm[1]*norm[1]+norm[2]*norm[2])#np.linalg.norm(norm)
7474
for itr_left in range(Na):
7575
idc[ncons,itr_left] = idl[itr_left]
7676
for i in range(3):
@@ -235,7 +235,7 @@ def fold_cg(double [:,:,:] EG, double [:,:] X, long long [:,:] neighbours, long
235235
norm[0] = v2[2]*v1[1] - v1[2]*v2[1]
236236
norm[1] = v1[2]*v2[0] - v1[0]*v2[2]
237237
norm[2] = v1[0]*v2[1] - v1[1]*v2[0]
238-
area = 0.5*np.linalg.norm(norm)
238+
area = 0.5*sqrt(norm[0]*norm[0]+norm[1]*norm[1]+norm[2]*norm[2])#np.linalg.norm(norm)
239239

240240
i = 0
241241
for itr_left in range(Na):

0 commit comments

Comments
 (0)