\( \usepackage{euler} % must be loaded before fontspec for the whole doc (below); this must be kept for pngmath, however \usepackage{hyperref} \usepackage{amsmath} \usepackage{amsbsy} %\usepackage{mathabx} \usepackage{underscore} \usepackage[all]{xy} % Metadata of the pdf output \hypersetup{pdftitle={Yade Documentation}} \hypersetup{pdfauthor={Smilauer, V., et al.}} \hypersetup{pdfkeywords={Discrete element method, granular materials, contact law, hydromechanical coupling}} % symbols \renewcommand{\mat}{\boldsymbol} \renewcommand{\vec}{\boldsymbol} \renewcommand{\tens}{\boldsymbol} %normalized and locfram here \def\normalized#1{\widehat{#1}} \def\locframe#1{\widetilde{#1}} % timestep \def\Dt{\Delta t} \def\Dtcr{\Dt_{\rm cr}} % algorithm complexity \def\bigO#1{{\mathcal{O}(#1)}} % variants for greek symbols \let\epsilon\varepsilon \let\theta\vartheta \let\phi\varphi % shorthands \let\sig\sigma \let\eps\epsilon % variables at different points of time \def\prev#1{#1^-} \def\pprev#1{#1^\ominus} \def\curr#1{#1^{\circ}} \def\nnext#1{#1^\oplus} \def\next#1{#1^+} % shorthands for geometry \def\currn{\curr{\vec{n}}} \def\currC{\curr{\vec{C}}} \def\uT{\vec{u}_T} \def\curruT{\curr{\vec{u}}_T} \def\prevuT{\prev{\vec{u}}_T} \def\currn{\curr{\vec{n}}} \def\prevn{\prev{\vec{n}}} % motion \def\pprevvel{\pprev{\dot{\vec{u}}}} \def\nnextvel{\nnext{\dot{\vec{u}}}} \def\curraccel{\curr{\ddot{\vec{u}}}} \def\prevpos{\prev{\vec{u}}} \def\currpos{\curr{\vec{u}}} \def\nextpos{\next{\vec{u}}} \def\curraaccel{\curr{\dot{\vec{\omega}}}} \def\pprevangvel{\pprev{\vec{\omega}}} \def\nnextangvel{\nnext{\vec{\omega}}} \def\loccurr#1{\curr{\locframe{#1}}} \def\numCPU{n_{\rm cpu}} \DeclareMathOperator{\Align}{Align} \DeclareMathOperator{\sign}{sgn} % sorting algorithms \def\isleq#1{\currelem{#1}\ar@/^/[ll]^{\leq}} \def\isnleq#1{\currelem{#1}\ar@/^/[ll]^{\not\leq}} \def\currelem#1{\fbox{$#1$}} \def\sortSep{||} \def\sortInv{\hbox{\phantom{||}}} \def\sortlines#1{\xymatrix@=3pt{#1}} \def\crossBound{||\mkern-18mu<} \)

# yade.export module

Export (not only) geometry to various formats.

class yade.export.VTKExporter(inherits object)

  Class for exporting data to VTK Simple Legacy File (for example if, for some reason, you are not able to use VTKRecorder). Supported export of:

  - spheres

  - facets

  - polyhedra

  - PotentialBlocks

  - interactions

  - contact points

  - periodic cell

  Usage:

  - create object `vtkExporter = VTKExporter('baseFileName')`,

  - add to `O.engines` a `PyRunner` with `command='vtkExporter.exportSomething(...)'`

  - 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, e.g., `baseName-spheres-snapNb.vtk` or `baseName-facets-snapNb.vtk`

    - startSnap (int) – the numbering of files will start form `startSnap`

  exportContactPoints(ids='all', what={}, useRef={}, comment='comment', numLabel=None)

    exports contact points (CPs) and defined properties.

    Parameters:

      - ids ([(int,int)]) – see `exportInteractions()`

      - what (dictionary) – see `exportInteractions()`

      - useRef (bool) – see `exportInteractions()`

      - comment (string) – comment to add to vtk file

      - numLabel (int) – number of file (e.g. time step), if unspecified, the last used value + 1 will be used

  exportFacets(ids='all', what={}, comment='comment', numLabel=None)

    exports facets (positions) and defined properties. Facets are exported with multiplicated nodes

    Parameters:

      - ids ([int]|"all") – if “all”, then export all facets, otherwise only facets from integer list

      - what (dictionary) – see `exportSpheres()`

      - comment (string) – comment to add to vtk file

      - numLabel (int) – number of file (e.g. time step), if unspecified, the last used value + 1 will be used

  exportFacetsAsMesh(ids='all', connectivityTable=None, what={}, comment='comment', numLabel=None)

    exports facets (positions) and defined properties. Facets are exported as mesh (not with multiplicated nodes). Therefore additional parameters connectivityTable is needed

    Parameters:

      - ids ([int]|"all") – if “all”, then export all facets, otherwise only facets from integer list

      - what (dictionary) – see `exportSpheres()`

      - comment (string) – comment to add to vtk file

      - numLabel (int) – number of file (e.g. time step), if unspecified, the last used value + 1 will be used

      - nodes ([(float,float,float)|Vector3]) – list of coordinates of nodes

      - connectivityTable ([(int,int,int)]) – list of node ids of individual elements (facets)

  exportInteractions(ids='all', what={}, verticesWhat={}, comment='comment', numLabel=None, useRef=False)

    exports interactions and defined properties.

    Parameters:

      - ids ([(int,int)]|"all") – if “all”, then export all interactions, otherwise only interactions from (int,int) list

      - what (dictionary) – what to export. parameter is a name->command dictionary. Name is string under which it is saved 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 the stiffness difference (named as `dStiff`) from a certain value (1e9) you should write: `what=dict(dStiff='i.phys.kn-1e9', ... )`

      - verticesWhat (dictionary) – what to export on connected bodies. Bodies are labeled as `b` (or `b1` and `b2` if you need to treat both bodies differently)

      - comment (string) – comment to add to vtk file

      - numLabel (int) – number of file (e.g. time step), if unspecified, the last used value + 1 will be used

      - useRef (bool) – if False (default), use current position of the bodies for export, use reference position otherwise

  exportPeriodicCell(comment='comment', numLabel=None)

    exports the Cell geometry for periodic simulations.

    Parameters:

      - comment (string) – comment to add to vtk file

      - numLabel (int) – number of file (e.g. time step), if unspecified, the last used value + 1 will be used

  exportPolyhedra(ids='all', what={}, comment='comment', numLabel=None, useRef=False)

    Exports polyhedrons and defined properties.

    Parameters:

      - ids ([int] | "all") – if “all”, then export all polyhedrons, otherwise only polyhedrons from integer list

      - what (dictionary) – which additional quantities (in addition to the positions) to export. parameter is name->command dictionary. Name is string under which it is saved 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 (named as particleVelocity) and the distance from point (0,0,0) (named as dist) you should write: `what=dict(particleVelocity='b.state.vel',dist='b.state.pos.norm()', ... )`

      - comment (string) – comment to add to vtk file

      - numLabel (int) – number of file (e.g. time step), if unspecified, the last used value + 1 will be used

  exportPotentialBlocks(ids='all', what={}, comment='comment', numLabel=None, useRef=False)

    Exports Potential Blocks and defined properties.

    Parameters:

      - ids ([int] | "all") – if “all”, then export all Potential Blocks, otherwise only Potential Blocks from integer list

      - what (dictionary) – which additional quantities (in addition to the positions) to export. parameter is name->command dictionary. Name is string under which it is saved 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 (named as particleVelocity) and the distance from point (0,0,0) (named as dist) you should write: `what=dict(particleVelocity='b.state.vel',dist='b.state.pos.norm()', ... )`

      - comment (string) – comment to add to vtk file

      - numLabel (int) – number of file (e.g. time step), if unspecified, the last used value + 1 will be used

  exportSpheres(ids='all', what={}, comment='comment', numLabel=None, useRef=False)

    exports spheres (positions and radius) and defined properties.

    Parameters:

      - ids ([int]|"all") – if “all”, then export all spheres, otherwise only spheres from integer list

      - what (dictionary) – which additional quantities (other than the position and the radius) to export. parameter is name->command dictionary. 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=dict(particleVelocity='b.state.vel',dist='b.state.pos.norm()', ... )`

      - comment (string) – comment to add to vtk file

      - numLabel (int) – number of file (e.g. time step), if unspecified, the last used value + 1 will be used

      - useRef (bool) – if False (default), use current position of the spheres for export, use reference position otherwise

class yade.export.VTKWriter(inherits object)

  USAGE: create object vtk_writer = VTKWriter(‘base_file_name’), add to engines PyRunner with command=’vtk_writer.snapshot()’

  snapshot()

yade.export.gmshGeo(filename, comment='', mask=-1, accuracy=-1)

  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)

  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, comment='comment')

  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

    - comment (str) – optional comment in vtk file

yade.export.text2vtkSection(inFileName, outFileName, point, normal=(1, 0, 0))

  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)

  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=[])

  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=[])

  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