82. plugins.neu_exp — Gambit neutral file exporter.

This module contains some functions to export pyFormex mesh models to a Gambit neutral file.

82.1. Functions defined in module plugins.neu_exp

plugins.neu_exp.writeHeading(fil, ncoords, nelems, ngroups, nbsets, heading)[source]

Write the heading of the Gambit neutral file.

plugins.neu_exp.writeNodes(fil, coords)[source]

Write the nodal coordinates to a Gambit neutral file

plugins.neu_exp.writeElems(fil, elems, eltyp, nplex)[source]

Write the element connectivity to a Gambit neutral file

plugins.neu_exp.writeGroups(fil, groups)[source]

Write element groups to a Gambit neutral file

plugins.neu_exp.writeBCsets(fil, bcsets, eltyp, order)[source]

Write boundary conditions to a Gambit neutral file

plugins.neu_exp.writeNEU(filename, M, bcsets={}, heading=None)[source]

Export a Mesh in Gambit neutral format

Parameters:
  • filename (path_like) – The output file name, commonly having a suffix ‘.neu’. If the suffix ends on ‘.gz’ or ‘.bz2’, the file will transparently be compressed during writing.

  • M (Mesh) – The Mesh to be be written to the file. If the Mesh has prop values, an element group will be added to the file for each of the unique values in M.prop. The prop value will be written as the material type number. If M has no prop values, a single group of all elements is written with material type number 0.

  • heading (str) – A title line to be shown in the .neu file header.

  • bcsets (dict) – A dictionary of boundary conditions where the keys are names and the values are arrays with two columns: column one are the element numbers and column two are the local face numbers. See Notes

See also

https

//web.stanford.edu/class/me469b/handouts/gambit_write.pdf

Notes

bcsets is currently limited to writing ELEMENT/SIDE boundary conditions for the faces of volume elements of eltype ‘tet4’, ‘hex8’ or ‘hex20’. The borderface arrays for use in bcsets can be obtained from the second return value in:

M.getFreeEntities(level=-1,return_indices=True)

or from matching a surface Mesh:

M.matchFaces(S)[1]

Examples

>>> from pyformex.mesh import Mesh
>>> f = Path('test_filewrite.neu')
>>> M = Mesh(eltype='quad4')
>>> writeNEU(f, M)
>>> print(f.read_text())
        CONTROL INFO 2.4.6
** GAMBIT NEUTRAL FILE
Generated by pyFormex ...
PROGRAM:                GAMBIT     VERSION:  2.4.6
...
     NUMNP     NELEM     NGRPS    NBSETS     NDFCD     NDFVL
         4         1         1         0         3         3
ENDOFSECTION
   NODAL COORDINATES 2.4.6
         1   0.00000000000e+00   0.00000000000e+00   0.00000000000e+00
         2   1.00000000000e+00   0.00000000000e+00   0.00000000000e+00
         3   1.00000000000e+00   1.00000000000e+00   0.00000000000e+00
         4   0.00000000000e+00   1.00000000000e+00   0.00000000000e+00
ENDOFSECTION
      ELEMENTS/CELLS 2.4.6
       1  2  4        1       2       3       4
ENDOFSECTION
       ELEMENT GROUP 2.4.6
GROUP:          1 ELEMENTS:          1 MATERIAL:          0 NFLAGS:          1
                          prop-0
       0
       0
ENDOFSECTION
>>> f.remove()