File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -335,13 +335,23 @@ def compute_areas(field_data):
335335 for inc , cell in enumerate (field_data .cells ):
336336 if field_data .cells [inc ].type == "triangle" :
337337 for point_inc in range (field_data .points .shape [0 ]):
338- field_data . point_data [ "Area" ][ point_inc ] = np .sum (
339- field_data .cell_data [ "Area" ][ inc ][
340- np . where ( field_data . cells [ inc ]. data == point_inc )[0 ]
341- ]
342- / 3
338+ valid_triangles = np .any (
339+ field_data .cells [ inc ]. data == point_inc , axis = 1
340+ ). nonzero ( )[0 ]
341+ field_data . point_data [ "Area" ][ point_inc ] = (
342+ np . sum ( field_data . cell_data [ "Area" ][ inc ][ valid_triangles ]) / 3
343343 )
344344
345+ elif field_data .cells [inc ].type == "quad" :
346+ for point_inc in range (field_data .points .shape [0 ]):
347+ for point_inc in range (field_data .points .shape [0 ]):
348+ valid_quads = np .any (
349+ field_data .cells [inc ].data == point_inc , axis = 1
350+ ).nonzero ()[0 ]
351+ field_data .point_data ["Area" ][point_inc ] = (
352+ np .sum (field_data .cell_data ["Area" ][inc ][valid_quads ]) / 4
353+ )
354+
345355 return field_data
346356
347357
You can’t perform that action at this time.
0 commit comments