Miscellaneous Tools for PySPH¶
Input/Output of data files¶
The following functions are handy functions when processing output generated by PySPH or to generate new files.
Interpolator¶
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.
SPH Evaluator¶
This module provides a class that allows one to evaluate a set of equations on a collection of particle arrays. This is very handy for non-trivial post-processing that needs to be quick.
GMsh input/output¶
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.
-
class
pysph.tools.gmsh.
Extrude
(dx=0.0, dy=0.0, dz=1.0, surfaces=None)[source]¶ Bases:
object
Extrude a given set of surfaces by the displacements given along each directions.
Parameters: - dx (float) – Extrusion along x.
- dy (float) – Extrusion along y.
- dz (float) – Extrusion along z.
- surfaces (list) – List of surfaces to extrude.
-
class
pysph.tools.gmsh.
Gmsh
(gmsh=None)[source]¶ Bases:
object
Construct a Gmsh helper object that can be used to mesh objects.
Parameters: gmsh (str) – Path to gmsh executable. -
get_points
(entities, vertices=True, cell_centers=False)[source]¶ Given a list of entities, return x, y, z arrays for the position.
Parameters: - entities (list) – List of entities.
- vertices (bool) – If True, it converts the vertices to points.
- cell_centers (bool) – If True, converts the cell centers to points.
-
get_points_from_geo
(geo_file_name, vertices=True, cell_centers=False)[source]¶ Given a .geo file, generate a mesh and get the points from the mesh.
Parameters: - geo_file_name (str) – Filename of the .geo file.
- vertices (bool) – If True, it converts the vertices to points.
- cell_centers (bool) – If True, converts the cell centers to points.
-
-
class
pysph.tools.gmsh.
Loop
(start, mesh_size=0.1)[source]¶ 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.
Examples
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.
-
class
pysph.tools.gmsh.
Surface
(*loops)[source]¶ Bases:
object
Constructor.
Parameters: loops (tuple(Loop)) – Any additional positional arguments are treated as loop objects.
-
pysph.tools.gmsh.
example_3d_p
(fp=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]¶ Creates a 3D “P” with a hole inside it.
-
pysph.tools.gmsh.
example_cube
(fp=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]¶ Simple example of a cube.
-
pysph.tools.gmsh.
example_plot_3d_p
(gmsh)[source]¶ Note: this will only work if you have gmsh installed.
-
pysph.tools.gmsh.
transform_points
(x, y, z, transform)[source]¶ Given the coordinates, x, y, z and the TVTK transform instance, return the transformed coordinates.
-
pysph.tools.gmsh.
vtk_file_to_points
(fname, vertices=True, cell_centers=True)[source]¶ 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.
Parameters: - fname (str) – File name.
- vertices (bool) – If True, it converts the vertices to points.
- cell_centers (bool) – If True, converts the cell centers to points.
Returns: Return type: x, y, z of the points.
STL Converter¶
The following function can be used to convert an STL file to a set of grid points.