Compare commits
2 Commits
1756a7a916
...
e2fe40c460
| Author | SHA1 | Date |
|---|---|---|
|
|
e2fe40c460 | |
|
|
0619930cfa |
3
field.py
3
field.py
|
|
@ -273,7 +273,8 @@ class Field3d:
|
||||||
mesh.dimensions = self.dim(axis=None)
|
mesh.dimensions = self.dim(axis=None)
|
||||||
mesh.origin = self.origin
|
mesh.origin = self.origin
|
||||||
mesh.spacing = self.spacing
|
mesh.spacing = self.spacing
|
||||||
mesh.point_arrays['data'] = self.data.flatten(order='F')
|
# order needs to be F no matter how array is stored in memory
|
||||||
|
mesh.point_arrays['data'] = self.data.ravel(order='F')
|
||||||
return mesh
|
return mesh
|
||||||
|
|
||||||
def vtk_contour(self,val):
|
def vtk_contour(self,val):
|
||||||
|
|
|
||||||
18
particle.py
18
particle.py
|
|
@ -76,7 +76,7 @@ class Particles:
|
||||||
attr = {}
|
attr = {}
|
||||||
for key in self.attr:
|
for key in self.attr:
|
||||||
attr[key] = self.attr[key].copy()
|
attr[key] = self.attr[key].copy()
|
||||||
return Particles(self.num,self.time,attr,period)
|
return Particles(self.num,self.time,attr,self.period)
|
||||||
def add_attribute(self,key,val):
|
def add_attribute(self,key,val):
|
||||||
import numpy
|
import numpy
|
||||||
if isinstance(val,(tuple,list,numpy.ndarray)):
|
if isinstance(val,(tuple,list,numpy.ndarray)):
|
||||||
|
|
@ -125,6 +125,22 @@ class Particles:
|
||||||
key = ('x','y','z')[axis]
|
key = ('x','y','z')[axis]
|
||||||
self.attr[key] %= self.period[axis]
|
self.attr[key] %= self.period[axis]
|
||||||
return
|
return
|
||||||
|
def to_vtk(self,deep=False):
|
||||||
|
import pyvista as pv
|
||||||
|
import numpy as np
|
||||||
|
position = np.vstack([self.attr[key] for key in ('x','y','z')]).transpose()
|
||||||
|
mesh = pv.PolyData(position,deep=deep)
|
||||||
|
for key in self.attr:
|
||||||
|
mesh[key] = self.attr[key]
|
||||||
|
return mesh
|
||||||
|
|
||||||
|
def glyph(self,theta_resolution=10,phi_resolution=10,deep=False):
|
||||||
|
import pyvista as pv
|
||||||
|
assert self.has_attribute('r'), "Attribute 'r' required."
|
||||||
|
geom = pv.Sphere(radius=1,theta_resolution=theta_resolution,
|
||||||
|
phi_resolution=phi_resolution)
|
||||||
|
return self.to_vtk(deep=deep).glyph(scale='r',factor=1,geom=geom)
|
||||||
|
|
||||||
class Trajectories:
|
class Trajectories:
|
||||||
def __init__(self,part,unraveled=False,copy_particles=False):
|
def __init__(self,part,unraveled=False,copy_particles=False):
|
||||||
import numpy
|
import numpy
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue