yade.export module¶
Export (not only) geometry to various formats.
-
class
yade.export.
VTKExporter
[source]¶ Class for exporting data to VTK Simple Legacy File (for example if, for some reason, you are not able to use VTKRecorder). Export of spheres, facets, interactions and polyhedra is supported.
USAGE: create object vtkExporter = VTKExporter(‘baseFileName’), add to engines PyRunner with command=’vtkExporter.exportSomething(params)’ alternatively just use vtkExporter.exportSomething(...) at the end of the script for instance
Example: examples/test/vtk-exporter/vtkExporter.py, examples/test/unv-read/unvReadVTKExport.py.
Parameters: - baseName (string) – name of the exported files. The files would be named baseName-spheres-snapNb.vtk or baseName-facets-snapNb.vtk
- startSnap (int) – the numbering of files will start form startSnap
-
exportContactPoints
()[source]¶ exports constact points and defined properties.
:param [(int,int)] ids: see exportInteractions :param [tuple(2)] what: what to export. parameter is list of couple (name,command). Name is string under which it is save to vtk, command is string to evaluate. Note that the CPs are labeled as i in this function (sccording to their interaction). Scalar, vector and tensor variables are supported. For example, to export stiffness difference from certain value (1e9) (named as dStiff) you should write: ... what=[(‘dStiff’,’i.phys.kn-1e9’), ... :param {Interaction:Vector3} useRef: if not specified, current position used. Otherwise use position from dict using interactions as keys. Interactions not in dict are not exported :param string comment: comment to add to vtk file :param int numLabel: number of file (e.g. time step), if unspecified, the last used value + 1 will be used
-
exportFacets
()[source]¶ exports facets (positions) and defined properties. Facets are exported with multiplicated nodes
:param [int]|”all” ids: if “all”, then export all facets, otherwise only facets from integer list :param [tuple(2)] what: see exportSpheres :param string comment: comment to add to vtk file :param int numLabel: number of file (e.g. time step), if unspecified, the last used value + 1 will be used
-
exportFacetsAsMesh
()[source]¶ exports facets (positions) and defined properties. Facets are exported as mesh (not with multiplicated nodes). Therefore additional parameters connectivityTable is needed
:param [int]|”all” ids: if “all”, then export all facets, otherwise only facets from integer list :param [tuple(2)] what: see exportSpheres :param string comment: comment to add to vtk file :param int numLabel: number of file (e.g. time step), if unspecified, the last used value + 1 will be used :param [(float,float,float)|Vector3] nodes: list of coordinates of nodes :param [(int,int,int)] connectivityTable: list of node ids of individual elements (facets)
-
exportInteractions
()[source]¶ exports interactions and defined properties.
:param [(int,int)]|”all” ids: if “all”, then export all interactions, otherwise only interactions from (int,int) list :param [tuple(2)] what: what to export. parameter is list of couple (name,command). Name is string under which it is save to vtk, command is string to evaluate. Note that the interactions are labeled as i in this function. Scalar, vector and tensor variables are supported. For example, to export stiffness difference from certain value (1e9) (named as dStiff) you should write: ... what=[(‘dStiff’,’i.phys.kn-1e9’), ... :param [tuple(2|3)] verticesWhat: what to export on connected bodies. Bodies are labeled as ‘b’ (or ‘b1’ and ‘b2’ if you need treat both bodies differently) :param string comment: comment to add to vtk file :param int numLabel: number of file (e.g. time step), if unspecified, the last used value + 1 will be used
-
exportPeriodicCell
()[source]¶ exports spheres (positions and radius) and defined properties.
:param string comment: comment to add to vtk file :param int numLabel: number of file (e.g. time step), if unspecified, the last used value + 1 will be used
-
exportPolyhedra
()[source]¶ Exports polyhedrons and defined properties.
:param ids: if “all”, then export all polyhedrons, otherwise only polyhedrons from integer list :type ids: [int] | “all” :param what: what other than then position to export. parameter is list of couple (name,command). Name is string under which it is save to vtk, command is string to evaluate. Note that the bodies are labeled as b in this function. Scalar, vector and tensor variables are supported. For example, to export velocity (with name particleVelocity) and the distance form point (0,0,0) (named as dist) you should write: ... what=[(‘particleVelocity’,’b.state.vel’),(‘dist’,’b.state.pos.norm()’, ... :type what: [tuple(2)] :param string comment: comment to add to vtk file :param int numLabel: number of file (e.g. time step), if unspecified, the last used value + 1 will be used
-
exportSpheres
()[source]¶ exports spheres (positions and radius) and defined properties.
:param [int]|”all” ids: if “all”, then export all spheres, otherwise only spheres from integer list :param [tuple(2)] what: what other than then position and radius export. parameter is list of couple (name,command). Name is string under which it is save to vtk, command is string to evaluate. Note that the bodies are labeled as b in this function. Scalar, vector and tensor variables are supported. For example, to export velocity (with name particleVelocity) and the distance form point (0,0,0) (named as dist) you should write: ... what=[(‘particleVelocity’,’b.state.vel’),(‘dist’,’b.state.pos.norm()’, ... :param string comment: comment to add to vtk file :param int numLabel: number of file (e.g. time step), if unspecified, the last used value + 1 will be used :param bool useRef: if False (default), use current position of the spheres for export, use reference position otherwise
-
class
yade.export.
VTKWriter
[source]¶ USAGE: create object vtk_writer = VTKWriter(‘base_file_name’), add to engines PyRunner with command=’vtk_writer.snapshot()’
-
yade.export.
gmshGeo
(filename, comment='', mask=-1, accuracy=-1)[source]¶ Save spheres in geo-file for the following using in GMSH (http://www.geuz.org/gmsh/doc/texinfo/) program. The spheres can be there meshed.
Parameters: - filename (string) – the name of the file, where sphere coordinates will be exported.
- mask (int) – export only spheres with the corresponding mask export only spheres with the corresponding mask
- accuracy (float) – the accuracy parameter, which will be set for the poinst in geo-file. By default: 1./10. of the minimal sphere diameter.
Returns: number of spheres which were exported.
Return type: int
-
yade.export.
text
(filename, mask=-1)[source]¶ Save sphere coordinates into a text file; the format of the line is: x y z r. Non-spherical bodies are silently skipped. Example added to examples/regular-sphere-pack/regular-sphere-pack.py
Parameters: - filename (string) – the name of the file, where sphere coordinates will be exported.
- mask (int) – export only spheres with the corresponding mask
Returns: number of spheres which were written.
Return type: int
-
yade.export.
text2vtk
(inFileName, outFileName)[source]¶ Converts text file (created by export.textExt function) into vtk file. See examples/test/paraview-spheres-solid-section/export_text.py example
Parameters: - inFileName (str) – name of input text file
- outFileName (str) – name of output vtk file
-
yade.export.
text2vtkSection
(inFileName, outFileName, point, normal=(1, 0, 0))[source]¶ Converts section through spheres from text file (created by export.textExt function) into vtk file. See examples/test/paraview-spheres-solid-section/export_text.py example
Parameters: - inFileName (str) – name of input text file
- outFileName (str) – name of output vtk file
- point (Vector3|(float,float,float)) – coordinates of a point lying on the section plane
- normal (Vector3|(float,float,float)) – normal vector of the section plane
-
yade.export.
textClumps
(filename, format='x_y_z_r_clumpId', comment='', mask=-1)[source]¶ Save clumps-members into a text file. Non-clumps members are bodies are silently skipped.
Parameters: - filename (string) – the name of the file, where sphere coordinates will be exported.
- comment (string) – the text, which will be added as a comment at the top of file. If you want to create several lines of text, please use ‘\n#’ for next lines.
- mask (int) – export only spheres with the corresponding mask export only spheres with the corresponding mask
Returns: number of clumps, number of spheres which were written.
Return type: int
-
yade.export.
textExt
(filename, format='x_y_z_r', comment='', mask=-1, attrs=[])[source]¶ Save sphere coordinates and other parameters into a text file in specific format. Non-spherical bodies are silently skipped. Users can add here their own specific format, giving meaningful names. The first file row will contain the format name. Be sure to add the same format specification in ymport.textExt.
Parameters: - filename (string) – the name of the file, where sphere coordinates will be exported.
- format (string) – the name of output format. Supported ‘x_y_z_r’(default), ‘x_y_z_r_matId’, ‘x_y_z_r_attrs’ (use proper comment)
- comment (string) – the text, which will be added as a comment at the top of file. If you want to create several lines of text, please use ‘\n#’ for next lines. With ‘x_y_z_r_attrs’ format, the last (or only) line should consist of column headers of quantities passed as attrs (1 comment word for scalars, 3 comment words for vectors and 9 comment words for matrices)
- mask (int) – export only spheres with the corresponding mask export only spheres with the corresponding mask
- attrs ([str]) – attributes to be exported with ‘x_y_z_r_attrs’ format. Each str in the list is evaluated for every body exported with body=b (i.e. ‘b.state.pos.norm()’ would stand for distance of body from coordinate system origin)
Returns: number of spheres which were written.
Return type: int
-
yade.export.
textPolyhedra
(fileName, comment='', mask=-1, explanationComment=True, attrs=[])[source]¶ Save polyhedra into a text file. Non-polyhedra bodies are silently skipped.
Parameters: - filename (string) – the name of the output file
- comment (string) – the text, which will be added as a comment at the top of file. If you want to create several lines of text, please use ‘\n#’ for next lines.
- mask (int) – export only polyhedra with the corresponding mask
- explanationComment (str) – inclde explanation of format to the beginning of file
Returns: number of polyhedra which were written.
Return type: int