-
Notifications
You must be signed in to change notification settings - Fork 0
WindfieldLoader
Ronja Schnur edited this page Jan 16, 2023
·
3 revisions
Interface used to provide new windfield data during simulation runs.
Example implementation using the python netCDF4 library:
class netCDFLoader(pygranite.WindfieldLoader):
def __init__(self, files):
pygranite.WindfieldLoader.__init__(self) # do not use super()
self._files = files
self.reset()
def increment(self):
self._index = (self._index + amount) # % len(self._files)
def nextFile(self):
fn = self._files[self._index]
self.increment()
return fn
def reset(self):
self._index = 0
def hasNext(self): # interface method
return self._index < len(self._files)
def next(self): # interface method
fn = self.nextFile()
ds = netCDF4.Dataset(fn, 'r')
u = ds.variables['u'][:][0]
v = ds.variables['v'][:][0]
w = ds.variables['w'][:][0]
return [u, v, w]
__init__() -> WindfieldLoader
Constructor for inheritance.
hasNext() -> bool
If this function returns true, it is assumed that the next call of next()
will supply a valid windfield.
next() -> bool
Should return a list of either two or three (depending on space) windfields in order (x, y, [z]).
upLift(
time : float # timestep
) -> numpy.ndarray(dtype=float)
When using a different UpLiftMode than Off, this has to provide an array with the number of particles in your simulation fitting the space dimension.
- Space
- Integrator
- BorderMode
- CurvatureMode
- AbortReason
- AbortMode
- UpLiftMode
- WindfieldMode
- ConstantsMode
- AdditionalVolumeMode
- pgt.py : pygranite toolkit
- 2D : Visualization
- 3D : Visualization
- 3D : Reverse Computation
- 3D : Topography Test
- 3D : Total Curvature
- 3D : Individual Curvature
- 3D : Length
- 3D : Lift
- 3D : GPU Custom Computations