Commit c92134ad authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

changed grid interpolation method and tested accuracy

parent 5fe674c6
...@@ -6,6 +6,7 @@ from math import pi ...@@ -6,6 +6,7 @@ from math import pi
import trimesh as tm import trimesh as tm
import pymeshfix as pf import pymeshfix as pf
from scipy.spatial import KDTree from scipy.spatial import KDTree
from scipy.interpolate import LinearNDInterpolator
class Planner: class Planner:
...@@ -57,11 +58,23 @@ class Planner: ...@@ -57,11 +58,23 @@ class Planner:
print("Interpolating pointcloud to grid stresses") print("Interpolating pointcloud to grid stresses")
# get mean stress at each voxel # get mean stress at each voxel
self.centtree = KDTree(self.centers, leafsize=5) #kd tree for mapping grid points to fea mesh self.interpolator = LinearNDInterpolator(self.mesh.points, self.mesh['StressValues'])
print(time.time()- gs) print("Completed generating LinearND lookup")
self.gridstresses = np.zeros(self.centers.shape[0]) print(time.time()-gs) # up to 100s for mesh with 300k points
dd, ii = self.centtree.query(self.centers, k=4)
self.gridstress = np.sum(1/dd * self.mesh['StressValues'][ii], axis=1)/np.sum(1/dd, axis=1)
# print(time.time()- gs)
def check_interp1s(self, node_is):
"""
Works my removing nodes in list node_is from mehs and linear interpolating their stresses
and then comparing to true values
return predicted values and true values
# called with node_is = [i for i in range(0,308539, 1000)]
"""
s = time.time()
except_i = [i for i in np.arange(self.mesh.points.shape[0]) if i not in node_is]
interpolator = LinearNDInterpolator(self.mesh.points[except_i,:], self.mesh['StressValues'][except_i])
node_i_pred_stress = interpolator(self.mesh.points[node_is,:])
node_i_stress = self.mesh['StressValues'][node_is]
e = time.time()
print(e-s)
return node_i_pred_stress, node_i_stress
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment