コード例 #1
0
    
    Voxelization (volume sampling) is controlled with 'grid', the integer dimensions of the target grid,
    and 'window', which sets the extent of the grid in coordinate-space.
    
    Change 'order' to 0, 1, or 2 to play with tetrahedral, trilinear, and triquadratic
    finite elements. 'tol' controls the accuracy of the voxelization in units of the voxel size. 
    Try varying it between 0 and 1.
    
    Fields to voxelize are requested via 'fields'. Setting 'm' to 'None' tells PSI to voxelize 
    the mass field to new numpy array.
    
'''

# initialize an element of a given order
order = 1
pos = psi.elementBase(order)
vel = np.zeros_like(pos)
mass = np.ones(1)

# perturb the control points, keeping them within the unit box
pos -= 0.5
pos *= 0.5 + 0.4 * np.random.sample(pos.shape)
pos += 0.5

# PyPSI voxelization options
fields = {'m': None}
grid = (64, 64, 64)
window = ((0.0, 0.0, 0.0), (1.0, 1.0, 1.0))
tol = 0.01
psi.elementMesh(fields, pos, vel, mass, grid=grid, window=window, tol=tol)
コード例 #2
0
    
    Voxelization (volume sampling) is controlled with 'grid', the integer dimensions of the target grid,
    and 'window', which sets the extent of the grid in coordinate-space.
    
    Change 'order' to 0, 1, or 2 to play with tetrahedral, trilinear, and triquadratic
    finite elements. 'tol' controls the accuracy of the voxelization in units of the voxel size. 
    Try varying it between 0 and 1.
    
    Fields to voxelize are requested via 'fields'. Setting 'm' to 'None' tells PSI to voxelize 
    the mass field to new numpy array.
    
'''

# initialize an element of a given order
order = 1
pos = psi.elementBase(order)
vel = np.zeros_like(pos)
mass = np.ones(1)

# perturb the control points, keeping them within the unit box
pos -= 0.5
pos *= 0.5 + 0.4*np.random.sample(pos.shape)
pos += 0.5

# PyPSI voxelization options
fields = {'m': None}
grid = (64, 64, 64)
window = ((0.0, 0.0, 0.0), (1.0, 1.0, 1.0))
tol = 0.01
psi.elementMesh(fields, pos, vel, mass, grid=grid, window=window, tol=tol)