Base class for all lattice Boltzman simulations in Sailfish.
FieldPair(abstract, buffer)
Alias for field number 0
Alias for field number 1
ForcePair(numeric, symbolic)
Alias for field number 0
Alias for field number 1
KernelPair(primary, secondary)
Alias for field number 0
Alias for field number 1
Provides additional functionliaty to a simulation class.
Some attributes of objects descentant from this class are processed in addition to the corresponding attribution from a simulation class (LBSim descentant). These are:
 aux_code
 before_main_loop
 fields
Describes a specific type of a lattice Boltzmann simulation.
List of additional template files or inline code fragments to include
Set this to a class implementing the SubdomainRunner interface in order
How many layers of nearest neighbors nodes are required by the model.
Tuple of functions to call to get a list of expressions for the equilibrium
Returns a dict mapping names to values and defining global constants for the simulation.
Updates the context dicitionary containing variables used for code generation.
Verifies that fields have not accidentally been overridden.
Returns a grid object representing the connectivity of the lattice used in the simulation. If the simulation uses more than 1 grid, returns the grid with the highest connectivity.
Returns True when data will be required for output, based on command line parameters –from –every.
Called from SubdomainRunner.main().
Indicates whether computation/transfer of macroscopic fields is requested.
This is true if either data is to be output after the current step, or data was requested e.g. by after_step(). To get fields on the host in after_step(), set need_sync_flag to True. To get fields on the GPU only, set need_fields_flags to True.
Called from SubdomainRunner.main().
Returns True when a checkpoint is requested after the current iteration.
Called from the subdomain runner before entering the main loop of the simulation.
This function can be used to initialize additional buffers and kernels that are then going to be used in after_step().
Called from the main loop after the completion of every step.
Called after the main loop.
Parameters: 


Adds support for body forces.
This is a mixin class. When defining a new simulation, inherit from another LBSimbased class first.
Adds a constant global force field acting on the fluid.
Multiple calls to this function will add the value of force to any previously set value. Forces and accelerations are processed separately and are never mixed in this addition process.
Parameters: 


Makes it possible to use acceleration from force_grid when calculating velocity for the equlibrium of target_grid.
For instance, to use the acceleration from grid 0 in relaxation of grid 1, use the parameters (0, 1).
To disable acceleration on a grid, pass an invalid grid ID in force_grid (e.g. None or 1).
Note: this is currently only supported in the freeenergy MRT model. The force reassignment will be silently ignored in other models.
Parameters: 


Adds a ShanChen type coupling between two lattices.
Parameters: 


Used to track momentum exchange between the fluid and a solid object.
The exchanged momentum can be used to compute the value of the force acting on the solid object. See Ladd A. Effects of container walls on the velocity fluctuations of sedimenting spheres. Phys Rev Lett 2002; 88:048301 for more info about this procedure.
Parameters: 


Rvalue :  Ntuple of force components 

Classes for single fluid lattice Boltzmann simulations.
Simulates a single fluid.
LBFluidSim with alpha field tracking.
The alpha field is 2.0 in areas where the fluid dynamics is fully resolved. alpha < 2.0 means that the flow field is smoothened, while alpha > 2.0 indicates enhancement of flow perturbation.
Free surface lattice Boltzmann model.
Classes for binary fluid lattice Boltzmann simulations.
Base class for binary fluid simulations.
alias of NNSubdomainRunner
Binary fluid mixture using the freeenergy model.
Binary fluid mixture using the ShanChen model.
Classes to specify global LB simulation geometry and its partitions.
Describes the highlevel geometry of a LB simulation.
Describes the highlevel 2D geometry of a LB simulation.
Returns a 1element list containing a single 2D block covering the whole domain.
Describes the highlevel 3D geometry of a LB simulation.
Returns a 1element list containing a single 3D block covering the whole domain.
Divides a rectangular domain into a configurable number of equalsize subdomains connected along one of the base axes.
Divides a cuboid domain into a configurable number of equalsize subdomains connected along one of the base axes.
Intra and intersubdomain geometry processing.
ConnectionPair(src, dst)
Alias for field number 1
Alias for field number 0
SubdomainPair(real, virtual)
Alias for field number 0
Alias for field number 1
A lightweight class describing the location of a subdomain and its connections to other subdomains in the simulation.
This class does not contain any references to the actual GPU or host data structures necessary to run the simulation for this subdomain.
Xaxis periodicity within this subdomain.
Yaxis periodicity within this subdomain.
Makes the subdomain locally periodic along a given axis.
Returns a LBConnection object describing the connection to ‘subdomain_id’ via ‘face’.
Returns a list of pairs: (face, subdomain ID) representing connections to different subdomains.
Returns the axis number corresponding to a face constant.
Returns the normal vector for a face.
Creates a connection between this subdomain and another subdomain.
A connection can only be created when the subdomains are next to each other.
Returns:  True if the connection was successful 

Return type:  bool 
Holds all field and geometry information specific to the subdomain described by the corresponding SubdomainSpec. Objects of this class do not directly know about the details of memory management on the compute device.
Parameters: 


Populates active_node_mask with a dense Boolean array.
The array coreesponds to the volume described by SubdomainSpec, including ghost nodes. Nodes marked True indicate active nodes participating in the simulation.
Returns part of array corresponding to the subdomain.
Parameters:  array – array to select from; the array should cover ghost nodes 

Use this with arrays covering all nodes in the global simulation domain. Args are the index arrays hx, hy, [hz].
Sets the active node map from a wall map.
Takes care of ensuring that only a single layer of wall nodes is remains as active nodes. To be used in load_active_node_map().
Parameters:  wall_map – Boolean array covering all nodes, including ghosts. True indicates a solid node not participating in the simulation. These nodes would typically be set to NTFullBBWall or similar. 

Set a boundary condition at selected node(s).
Parameters: 


Updates a boundary condition at selected node(s).
Use this method only to update nodes in a _running_ simulation. See set_node for a description of params.
Creates direction tags for nodes that support it.
Direction tags are a way of summarizing which distributions at a node will be undefined after streaming.
Rvalue :  True if there are any nodes supporting tagging, False otherwise 

Computes an array indicating which distributions correspond to momentum trasferred from the object to the fluid.
Parameters:  fo – ForceObject description the object to analyze 

Rvalue :  dict: distribution index > Ntuple of arrays indicating coordinates of solid object nodes transferring momentum to the fluid in the direction corresponding to the distribution 
Node scratch space size expressed in number of floating point values.
Returns an unencoded type map for visualization/ postprocessing purposes.
Returns a boolean array indicating which nodes are “wet” ( represent fluid and have valid macroscopic fields).
Supporting code for different node types.
ScratchSize(dim2, dim3)
Alias for field number 0
Alias for field number 1
Base class for node types.
If True, the node undergoes normal relaxation process.
If True, the node does not participate in the simulation.
If True, the node participates in the propagation step only. This is necessary for some schemes that use propagation in shared memory.
If True, the node does not require any special processing to calculate macroscopic fluid quantities. Typical examples of nodes requiring special treatment are edge and corner nodes where not all mass fractions are known.
If True, the node needs a basic orientation vector (only primary directions are currently supported).
If True, the node supports tagging of active directions (i.e. of links that connect it to a fluid node.
Number of floating point values that the node needs to keep as additional information in global memory. This can be an int or an instance of ScratchSize.
Indicates the effective location of the boundary condition along the direction of the normal vector. Positive values indicate offset towards the fluid domain, negative values indicate offset away from the fluid domain.
Returns the required size (# of floats) of the scratch space.
Parameters:  dim – dimensionality of the simulation (2 or 3) 

Halfway bounceback (noslip) node.
The effective location of the wall is half a lattice spacing away from the bulk of the fluid. With such a location of the wall, this node type provides 2nd order spatial accuracy.
The idea of a halfway bounceback node is similar to the fullway bounceback, but the reflection takes only one time step .
For nonstationary flows the halfway bounceback rule is more accurate than the fullway bounceback. For stationary flows there is no difference between them as the one step time lag in the fullway bounceback rule does not impact the amount of momentum and mass transferred between the fluid and the boundary.
The wall normal vector is necessary for the halfway bounceback rule to work as only the unknown distributions (those for which there is no data streaming from other nodes) at the boundary nodes are replaced.
Fullway bounceback (noslip) node.
Use this node type if you need walls whose normal vector is unknown or is not aligned with the Cartesian axes.
The effective location of the wall is half a lattice spacing between the wall node and the fluid node. With such a location of the wall, this node type provides 2nd order spatial accuracy.
Fullway bounceback works as follows:
This can be summarized as since it takes two time steps for the reflected distributions to reach back the fluid nodes.
Wall boundary condition for turbulent flows, based on the TammMottSmith approximation.
For more info see: S.S. Chikatamarla, I.V. Karlin, “Entropic lattice Boltzmann method for turbulent flow simulations: Boundary conditions”, Physica A (2013), doi: 10.1016/j.physa.2012.12.034
Density boundary condition using the equilibrium distribution.
Density boundary condition using the regularized LB model and nonequilibrium bounceback.
See Phys. Rev. E 77, 056703 (2008) for more info.
Guo density.
ZouHe density.
Uses bounceback of the offequilibrium distributions.
Velocity boundary condition using the equilibrium distribution.
ZouHe velocity.
Uses bounceback of the offequilibrium distributions.
Velocity boundary condition using the regularized LB model and nonequilibrium bounceback.
See Phys. Rev. E 77, 056703 (2008) for more info.
Outflow node using Grad’s approximation.
Note: this node type currently only works with the AB memory layout.
Outflow node without any special processing for undefined distributions.
The value from the previous time step is retained for all undefined distributions (i.e. pointing into the domain at the boundary).
Using this boundary condition is only necessary with the AA memory layout. In the AB memory layout, leaving the outflow nodes defined as NTFluid works just fine.
Copies distributions from another node.
This can be used to implement a crude vanishing gradient boundary condition.
Implements the open boundary condition described in:
Yu, D., Mei, R. and Shyy, W. (2005) ‘Improved treatment of the open boundary in the method of lattice Boltzmann equation’, page 5.
This is an extrapolation based method, using data from nextnearest neighbors:
Implements a Neumann boundary condition.
This is a nonlocal boundary condition accessing the nearest neighbors. Note that this condition requires a layer of ghost nodes to be present in the direction pointed to by the normal vector.
Based on the NBC description in: Junk M, Yang Z, Outflow boundary conditions for the lattice Boltzmann method, Progress in Computational Fluid Dynamics, Vol. 8, Nos. 1–4, 2008
with:
 : boundary node
 : ghost node
 : fluid node at  2 * normal
 : incoming distributions
 : direction opposite to i
 : distribution after collision (prior to streaming)
Fullslip node.
Collapses a list of numpy arrays into a structured field that can be used for setting boundary condition parameters at multiple nodes at the same time.
Parameters: 


A node parameter that is evaluated on the device.
This is typically used for timedependent boundary conditions.
Parameters:  params – sympy expressions 

Returns True if any of the expressions used for this DynamicValue depends on at least one of the symbols provided as arguments.
Returns a generator iterating over all time series used in params.
A timedependent scalar data source based on a discrete time series.
A continuous scalar data source from a discrete time series.
Time series data points are linearly interpolated in order to generate values for points not present in the time series. The time series is wrapped in order to generate an infinite sequence.
Parameters: 


Returns a hash of the underying data series.
Helper code for symbolic processing and RTCG.
See Phys Rev Lett 97, 010201 (2006) for the expression.
Get a set of indices which have to be swapped for a full bounceback.
Generates a list of missing mass fractions given an orientation tag code.
Useful to debugging.
Parameters: 


Returns an iterable of missing distribution indices.
Parameters: 


Express density as a function of the distributions.
Parameters: 


Return type:  sympy expression for the density 
Express velocity as a function of the distributions.
Parameters: 


Return type:  sympy expression for the velocity in a given direction 
Computes a list of base vectors with a specific value of the X component (dir).
Computes a list of indices of distributions that would be transferred to a node pointed to by the vector ‘direction’.
Returns expressions for the Grad distributions as defined by Eq. 11 in EPL 74 (2), pp. 215221 (2006).
Parameters:  grid – a grid object 

Returns expressions for the nonequilibrium flux tensor contraction with the Q tensor, used for the regularized LB model.
Ortogonalize a set of vectors.
Given a set of vectors orthogonalize them using the GramSchmidt procedure. The vectors are then simplified (common factors are removed to keep their norm small).
Parameters:  vectors – a collection of vectors to orthogonalize 

Return type:  orthogonalized vectors 
Sailfish CUDA backend.
Code for controlling a single subdomain of a LB simulation.
KernelGrid(kernel, grid)
Alias for field number 1
Alias for field number 0
MacroKernels(distributions, macro)
Alias for field number 0
Alias for field number 1
Numpy array and a corresponding GPU buffer.
Runs the simulation for a single Subdomain.
The simulation proceeds into two streams, which is used for overlapping calculations with data transfers. The subdomain is divided into two regions – boundary and bulk. The nodes in the bulk region are those that do not send information to any nodes in other subdomains. The boundary region includes all the remaining nodes, including the ghost node envelope used for data storage only.:
calc stream data stream

boundary sim. step > collect data
bulk sim. step ...
distribute data
< sync >
An arrow above symbolizes a dependency between the two streams.
Parameters: 


Called by the codegen module.
Allocates a scalar NumPy array.
The array includes padding adjusted for the compute device (hidden from the end user), as well as space for any ghost nodes. The returned object is a view into the underlying array that hides all ghost nodes. Ghost nodes can still be accessed via the ‘base’ attribute of the returned ndarray.
Parameters:  register – if True, the field will be registered for output and for automated creation of equivalent field on the compute device. 

Rvalue :  tuple of: nonghost view into the backing array, sparse field (only when indirect addressing is enabled; None otherwise) 
Allocates several scalar arrays representing a vector field.
Returns an unencoded geometry map used for visualization.
Returns the total number of actual nodes (including padding) in the lattice.
Returns the total number of lattice nodes (including ghosts, excluding padding.
Returns the GPU copy of a field.
Returns a GPU dist array.
The kernels called in this function read data after propagation.
Runs a fluid simulation for a single subdomain.
This is a specialization of the SubdomainRunner class for models which require access to macroscopic fields from the nearest neighbor nodes. It changes the steps executed on the GPU as follows:
calc stream data stream

boundary macro fields > collect macro data
bulk macro fields ...
boundary sim. step < distribute macro data
> collect distrib. data
bulk sim. step ...
distribute distrib. data
< sync >
TODO(michalj): Try the alternative scheme:
calc stream data stream

boundary macro fields > collect macro data
bulk macro fields ...
bulk sim. step
boundary sim. step < distribute macro data
> collect distrib. data
...
distribute distrib. data
< sync >
An arrow above symbolizes a dependency between the two streams.
Runs one simulation step.
Runtime CUDA/OpenCL code generation.
Generates CUDA/OpenCL code for a simulation of a subdomain.
Classes for specifying and processing simulation configuration.
Specifies the configuration of a LB simulation.
This class carries all settings, specified programmatically from a script or manually via command line parameters.
Declares information about a machine.
Parameters: 


Additional keyword parameters will be stored in the machine’s LBConfig instance when a simulation is run.
Connector classes for exchanging data between block runners.
Handles directed data exchange between two subdomains using the multiprocessing module.
Called from the block runner of the sender block.
Handles directed data exchange between two subdomains using 0MQ.
Parameters: 


Called from the block runner of the sender block.
Handles directed data exchange between two subdomains on two different hosts.
Parameters: 

Like ZMQRemoteSubdomainConnector, but transfers compressed data.
Parameters: 

Simulation controller.
Assigns subdomains to cluster nodes.
Returns a list of ‘nodes’ lists of subdomains.
Transforms a set of SubdomainSpecs into a another set covering the same physical domain, but optimized for execution on the available hardware. Initializes logical connections between the subdomains based on their location.
Parameters: 


Controls the execution of a LB simulation.
Parameters: 


Dimensionality of the simulation: 2 or 3.
Runs a simulation.
Geometry encoding logic.
Returns the minimal number of bits necesary to encode num.
Takes information about geometry as specified by the simulation and encodes it into buffers suitable for processing on a GPU.
This is an abstract class. Its implementations provide a specific encoding scheme.
Encodes node type and parameters into a single uint32.
Optional parameters such as velocities, densities, etc. are stored in const memory and the packed value in the uint32 only contains an index inside a const memory array.
Parameters: 


Parameters:  orientation – numpy array with the same layout as _type_map, 

indicating the orientation of different nodes; this array will be modified if detect_orientation is True.
Returns ‘values’ float values which are pameters of the node at ‘location’.
Parameters: 


Machine master.
Coordinates simulation of multiple subdomains on a single host.
Controls execution of a LB simulation on a single physical machine (possibly with multiple GPUs and multiple LB subdomains being simulated).
Parameters: 


Miscellaneous utility functions.
TimingInfo(comp, bulk, bnd, coll, net_wait, recv, send, total, total_sq, subdomain_id)
Alias for field number 2
Alias for field number 1
Alias for field number 3
Alias for field number 0
Alias for field number 4
Alias for field number 5
Alias for field number 6
Alias for field number 9
Alias for field number 7
Alias for field number 8
Builds a Saiflish cluster definition based on LSF environment variables.
Builds a Sailfish cluster definition based on a PBS GPUFILE.
Wrapper around np.in1d which returns an array with the same shape as arr1
Faster version of in_anyd.
Parameters: 


Returns ith number from a set spaced evenly on a log scale, similar to np.logspace, the difference is that it gets one number, and it take values (not exponents) as min_, max_.
Parameters: 


Returns ith number from a set spaced evenly on a log scale, similar to np.logspace, the difference is that it gets one number, and it take values (not exponents) as min_, max_.
Parameters: 


Computes the mean kinetic energy of the fluid.
Computes the vorticity array from a 3D velocity vector array.
Computes the enstrophy (mean square vorticity).
Computes the longitudinal skewness factor.
Parameters: 


Calculates the energy spectrum E(k).
Parameters: 


Rvalue :  numpy array with the energy spectrum 