The following functions are handy functions when processing output generated by PySPH or to generate new files.
Dump the given particles and solver data to the given filename.
If mpi_comm is not passed or is set to None the local particles alone are dumped, otherwise only rank 0 dumps the output.
Get all solution files in a given directory, dirname.
Load and return data from an output (.npz) file dumped by PySPH.
For output file version 1, the function returns a dictionary with the keys:
"solver_data" : Solver constants at the time of output like time, time step and iteration count.
"arrays" : ParticleArrays keyed on names with the ParticleArray object as value.
>>> data = load('elliptical_drop_100.npz')
>>> data.keys()
['arrays', 'solver_data']
>>> arrays = data['arrays']
>>> arrays.keys()
['fluid']
>>> fluid = arrays['fluid']
>>> type(fluid)
pysph.base.particle_array.ParticleArray
>>> data['solver_data']
{'count': 100, 'dt': 4.6416394784204199e-05, 't': 0.0039955855395528766}
Load the results from multiple files.
Given a filename prefix and the number of processors, return a concatenated version of the dictionary returned via load.
This module provides a convenient class called interpolator.Interpolator which can be used to interpolate any scalar values from the points onto either a mesh or a collection of other points. SPH interpolation is performed with a simple Shepard filtering.
Bases: pysph.sph.equation.Equation
Bases: object
Convenient class to interpolate particle properties onto a uniform grid. This is particularly handy for visualization.
The x, y, z coordinates need not be specified, and if they are not, the bounds of the interpolated domain is automatically computed and num_points number of points are used in this domain uniformly placed.
Interpolate given property.
A numpy array suitably shaped with the property interpolated.
Set the domain to interpolate into.
Set the points on which we must interpolate the arrays.
If any of x, y, z is not passed it is assumed to be 0.0 and shaped like the other non-None arrays.
Call this for a new set of particle arrays which have the same properties as before.
For example, if you are reading the particle array data from files, each time you load a new file a new particle array is read with the same properties. Call this function to reset the arrays.
Find the size of the domain given a sequence of particle arrays.
If tight is True, the bounds are tight, if not the domain is stretched along each dimension by an amount stretch specified as a percentage of the length along that dimension is added in each dimension.
Utility module to read input mesh files. This is primarily for meshes generated using Gmsh. This module also provides some simple classes that allow one to create extruded 3D surfaces by generating a gmsh file in Python.
There is also a function to read VTK dataset and produce points from them. This is very useful as Gmsh can generate VTK datasets from its meshes and thus the meshes can be imported as point clouds that may be used in an SPH simulation.
Bases: object
Extrude a given set of surfaces by the displacements given along each directions.
Bases: object
Construct a Gmsh helper object that can be used to mesh objects.
Given a list of entities, return x, y, z arrays for the position.
Given a .geo file, generate a mesh and get the points from the mesh.
Bases: object
Create a Line Loop in Gmsh parlance but using a turtle-graphics like approach.
Use this to create a 2D closed surface. The surface is always in the x-y plane.
Here is a simple example:
>>> l1 = Loop((0.0, 0.0), mesh_size=0.1)
>>> l1.move(1.0).turn(90).move(1.0).turn(90).move(1.0).turn(90).move(1.0)
This will create a square shape.
Bases: object
Constructor.
Creates a 3D “P” with a hole inside it.
Simple example of a cube.
Note: this will only work if you have gmsh installed.
Given the coordinates, x, y, z and the TVTK transform instance, return the transformed coordinates.
Given a file containing a VTK dataset (currently only an old style .vtk file), convert it to a set of points that can be used for simulation with SPH.
x, y, z of the points.