update
This commit is contained in:
parent
1b46b2d188
commit
32f67d17c3
20
particle.py
20
particle.py
|
|
@ -163,6 +163,26 @@ class Particles:
|
|||
self.attr[key] %= self.period[axis]
|
||||
return
|
||||
|
||||
def extend_periodic(self,rep=1,axis=0):
|
||||
'''Duplicates particle along a periodic direction.'''
|
||||
assert axis<3, "'axis' must be smaller than 3."
|
||||
assert self.period[axis] is not None, "Cannot duplicate along non-periodic direction."
|
||||
npart = self.num*(rep+1)
|
||||
period = list(self.period)
|
||||
period[axis] *= (rep+1)
|
||||
attr = {}
|
||||
for key in self.attr:
|
||||
attr[key] = np.empty(npart,dtype=self.attr[key].dtype)
|
||||
offset = 0
|
||||
for irep in range(rep+1):
|
||||
attr['id'][offset:offset+self.num] = self.attr['id']+offset
|
||||
for key in self.attr:
|
||||
if key=='id': continue
|
||||
attr[key][offset:offset+self.num] = self.attr[key]
|
||||
attr[('x','y','z')[axis]][offset:offset+self.num] += irep*self.period[axis]
|
||||
offset += self.num
|
||||
return Particles(npart,self.time,attr,period)
|
||||
|
||||
def position_with_duplicates(self,ipart,padding=0.0):
|
||||
pos = np.array(
|
||||
(self.attr['x'][ipart],
|
||||
|
|
|
|||
32
visu.py
32
visu.py
|
|
@ -44,7 +44,7 @@ def camera_from_distance(pl,bounds,viewvec,dist,
|
|||
focal_point = get_focal_point(bounds,focus,is_focus_relative)
|
||||
position = focal_point-viewvec/np.linalg.norm(viewvec)*dist
|
||||
return camera_from_position(pl,
|
||||
bounds,viewvec,position,
|
||||
bounds,position,
|
||||
focus=focal_point,
|
||||
viewup=viewup,
|
||||
zoom=zoom,
|
||||
|
|
@ -150,3 +150,33 @@ def translate_circular(pd,translation,bounds,axis=0):
|
|||
pd_hi.translate(shift_back)
|
||||
# return the merged PolyData
|
||||
return pd_lo+pd_hi
|
||||
|
||||
def warped_surface_rectilinear(x,y,z,data,axis):
|
||||
import numpy as np
|
||||
import pyvista as pv
|
||||
x = np.array(x).flatten()
|
||||
y = np.array(y).flatten()
|
||||
z = np.array(z).flatten()
|
||||
if axis==0: assert x.shape[0]==1
|
||||
if axis==1: assert y.shape[0]==1
|
||||
if axis==2: assert z.shape[0]==1
|
||||
normal = [0,0,0]
|
||||
normal[axis] = 1
|
||||
grid = pv.RectilinearGrid(x,y,z)
|
||||
grid['warp'] = data.transpose().ravel()
|
||||
return grid.warp_by_scalar(normal=normal)
|
||||
|
||||
def warped_surface_uniform(origin,spacing,data,axis):
|
||||
import numpy as np
|
||||
import pyvista as pv
|
||||
assert data.shape[axis]==1
|
||||
normal = [0,0,0]
|
||||
normal[axis] = 1
|
||||
grid = pv.UniformGrid()
|
||||
grid.dimensions = data.shape
|
||||
grid.origin = origin
|
||||
grid.spacing = spacing
|
||||
grid['warp'] = data.transpose().ravel()
|
||||
return grid.warp_by_scalar(normal=normal)
|
||||
|
||||
#def extend_structuredgrid(sg,bounds,rep,axis):
|
||||
|
|
|
|||
Loading…
Reference in New Issue