sVC = area * amp.vert[amp.faces, 2].mean(axis=1) * amp.norm[:, 2]
if return_closed is True:
return sVC.sum(), amp
else:
return sVC.sum()
amp.norm[:, 2] can have negative values, giving a negative volume contributions. The .sum() contribution does not take this into account.
suggest replacing sVC.sum() with (np.abs(sVc)).sum()
Smaller issue more likely caused by poor meshing but I belive there is possible issue if a triangle face has a very small angle the two adjacent edges, may have very similar values and with rounding their cross product will be zero/the norm will end up with nan which then results in .sum() giving nan. Can be fixed by using np.nansum((np.abs(sVC))) instead of .sum()
amp.norm[:, 2] can have negative values, giving a negative volume contributions. The .sum() contribution does not take this into account.
suggest replacing sVC.sum() with (np.abs(sVc)).sum()
Smaller issue more likely caused by poor meshing but I belive there is possible issue if a triangle face has a very small angle the two adjacent edges, may have very similar values and with rounding their cross product will be zero/the norm will end up with nan which then results in .sum() giving nan. Can be fixed by using np.nansum((np.abs(sVC))) instead of .sum()