def setup(self, h, part_dens): part_rad = math.pow((1./part_dens)*3./(4.*math.pi), 1./3.) #gather geometry information and init voxels minx = np.amin(self.vert[:,0]) miny = np.amin(self.vert[:,1]) minz = np.amin(self.vert[:,2]) maxx = np.amax(self.vert[:,0]) maxy = np.amax(self.vert[:,1]) maxz = np.amax(self.vert[:,2]) width = maxx - minx height = maxy - miny depth = maxz - minz minside = min(width, height, depth) minside_4h = minside + part_rad*2 res = int(minside_4h/h)*10 epsilon = (minside_4h/res)*(minside_4h/res)*0.2 fw = minside_4h/minside - 1. vol = voxelize(self.tri, self.vert, res=res, framewidth=fw, epsilon=epsilon, delta=epsilon*0.1) self.voldat = vol part_rad = math.pow((1./part_dens)*3./(4.*math.pi), 1./3.) offset = self.offset - part_rad count = int(self.voldat.get_volume(offset)*part_dens) print "count", count, offset, self.voldat.get_volume(offset) avgneighs = int(((4./3.)*math.pi*(h*0.5)**3)*part_dens) self.particles_pos = setup_in_volume(self.voldat.voxels, count, h/2., spc=self.voldat.spc, orig=self.voldat.orig, offset=offset, steps=100, fact=0.001*h, maxneighs=avgneighs*2, radius=part_rad)
def _cmp_vol(self, h, part_dens): part_rad = math.pow((1./part_dens)*3./(4.*math.pi), 1./3.) #gather geometry information and init voxels minx = np.amin(self.vert[:,0]) miny = np.amin(self.vert[:,1]) minz = np.amin(self.vert[:,2]) maxx = np.amax(self.vert[:,0]) maxy = np.amax(self.vert[:,1]) maxz = np.amax(self.vert[:,2]) width = maxx - minx height = maxy - miny depth = maxz - minz minside = min(width, height, depth) minside_4h = minside + part_rad*2 res = int(minside_4h/h)*10 epsilon = (minside_4h/res)*(minside_4h/res)*0.2 fw = minside_4h/minside - 1. vol = voxelize(self.tri, self.vert, res=res, framewidth=fw, epsilon=epsilon, delta=epsilon*0.1) print fw self.voldat = vol
""" Created on Wed Oct 21 16:28:45 2015 @author: Hagen """ # import useful modules from matplotlib import pyplot from meshtools import load_vtk_polydata, voxelize from numcl.tools import gradient_field import numpy as np tri, vert = load_vtk_polydata('/Users/Hagen/Code/Python/sphPy/Test.vtk') vol = voxelize(tri, vert, res=10, refine=1, framewidth=0.1) vol.shape = (vol.shape[0],vol.shape[1],vol.shape[2],1) grad = gradient_field(vol) for i in range(1): theslice = i x = np.zeros(vol.shape[2]) y = np.zeros(vol.shape[1]) u = np.zeros((grad.shape[1],grad.shape[2])) v = np.zeros((grad.shape[1],grad.shape[2])) for n in range(len(x)): x[n] = n for n in range(len(y)):