Basic Geometry, Numerical Algorithms and Interfaces
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
MxMesh Class Reference

Detailed Description

Mesh with dissimilar elements.

MxMesh is a simple container for meshes with different element types. It is meant to be primarily used as an intermediate data structure for conversion between file formats or as a 'dumb' storage after mesh generation.


See Also
MxMeshSection, MxMeshField, MxMeshBoco, MxMeshDeform

#include <mxmesh.h>

Inheritance diagram for MxMesh:
Collaboration diagram for MxMesh:

Public Member Functions

 MxMesh ()
 construct empty mesh
virtual ~MxMesh ()
 destroy mesh
uint nelements () const
 number of elements in all sections
uint nnodes () const
 number of nodes
const Vct3node (uint i) const
 access node
Vct3node (uint i)
 access node
const PointList< 3 > & nodes () const
 access node array
PointList< 3 > & nodes ()
 access node array
uint appendNode (const Vct3 &p)
 append a single vertex
uint appendNodes (const PointList< 3 > &nds)
 append nodes, return index of the first new node
template<class NodeIter >
uint appendNodes (NodeIter nbegin, NodeIter nend)
 append nodes, return index of the first new node
uint nsections () const
 number of sections
const MxMeshSectionsection (uint i) const
 access mesh section
MxMeshSectionsection (uint i)
 access mesh section
uint findSection (uint eix) const
 determine section of element eix
uint findSection (const std::string &sname) const
 determine section index from name
const uint * globalElement (uint gix, uint &n, uint &isec) const
 search global element data
void elementSections (const Indices &gix, ConnectMap &s2e) const
 assemble section-element connection
uint appendSection (const MxMeshSection &ms)
 add mesh section, return index
uint appendSection (Mx::ElementType t, const Indices &idx)
 add mesh section, return index
uint appendSection (const TriMesh &m)
 add triangular mesh as section
uint appendSection (const PointGrid< 3 > &pg)
 add point grid as Quad4 elements
uint appendSection (const PointList< 3 > &pts)
 add a set of lines connecting pts
uint appendSection (const CgMesh &cgm)
 add triangles from CgMesh
void eraseSection (uint k)
 erase a single section
uint mirrorCopyNodes (const Indices &snodes, const Plane &pln)
 insert mirror copies of nodes in set, return node index offset
uint mirrorCopySection (uint k, uint voff, const Indices &snodes, bool merge=true)
 create a mirror copy of section k (generates new nodes)
uint nbocos () const
 number of boundary condition sets
const MxMeshBocoboco (uint i) const
 access boundary condition spec
MxMeshBocoboco (uint i)
 access boundary condition spec
uint appendBoco (Mx::BocoType t, const Indices &idx)
 append boundary condition element group
uint appendBoco (const MxMeshBoco &bc)
 append boundary condition element group
uint appendBoco (MxMeshBoco &&bc)
 append boundary condition element group
void eraseBoco (uint k)
 erase element subset
void clearBocos ()
 erase all boundary condition sets
uint findBoco (const std::string &s) const
 find boco group by name
uint mappedSection (uint iboco) const
 determine which, if any, section maps exactly to iboco
uint containedInSection (uint iboco) const
 determine in which section, if any, iboco is contained
uint nfields () const
 number of fields
uint nDimFields (uint nd=3) const
 number of vector-valued fields with dimension nd
const MxMeshFieldfield (uint i) const
 access field i
MxMeshFieldfield (uint i)
 access field i
void bindFields ()
 bind misassigned fields to this
void reserveFields (uint n)
 reserve storage for n fields
uint appendField (const MxMeshField &f)
 add point-data field
uint appendField (MxMeshField &&f)
 add point-data field
uint swapField (MxMeshField &f)
 swap-in point-data field (deprecated)
uint appendField (const std::string &s, const Vector &v)
 add scalar real field
uint appendField (const std::string &s, const DVector< float > &v)
 add scalar real field
uint appendField (const std::string &s, const DVector< int > &v)
 add scalar integer field
uint appendField (const std::string &s, const PointList< 3 > &v)
 add 3-component vector field
uint appendField (const std::string &s, const PointList< 3, float > &v)
 add 3-component vector field
uint appendField (const std::string &s, const PointList< 6 > &v)
 add 6-component vector field
uint appendField (const std::string &s, const PointList< 6, float > &v)
 add 6-component vector field
uint appendRigidBodyMode (int mindex, const Vct3 &rotctr, Real gm=1.0, Real gk=0.0)
 generate artificial rigid-body modeshapes
uint findField (const std::string &s) const
 find field by name, return NotFound otherwise
void findFields (int valClass, Indices &flds) const
 find fields of class c
void eraseField (uint k)
 erase a single field
void clearFields ()
 remove all data fields
bool generateMaxFields (bool useMaxAbs)
 generate maximum value fields across multiple subcases
MxSolutionTreePtr solutionTree () const
 access global solution tree which contains hierarchy data for fields
void solutionTree (MxSolutionTreePtr p)
 access global solution tree which contains hierarchy data for fields
void merge (const MxMesh &a, bool mergeFieldsByName)
 another mesh, optionally merge fields
uint ndeform () const
 number of time-domain subspace nodal deformation fields
const MxMeshDeformdeform (uint i) const
 access subspace deformation field
MxMeshDeformdeform (uint i)
 access subspace deformation field
void eraseDeform (uint i)
 erase a deformation path
uint appendDeform (const MxMeshDeform &d)
 append externally created subspace deformation
uint appendTrajectory (const std::string &fn, const Indices &useCols=Indices())
 load trajectory from file
uint appendFlutterMode (Complex p, const CpxVector &z, int nsample=32)
 append a flutter mode based on all currently stored vector fields
void smoothTetNodes (uint npass=1, Real omega=0.5)
 smooth nodes connected to tetrahedral elements
uint planeCut (const Plane &p, Indices &ise) const
 determine a list of elements which intersect plane p
void nodesBelow (const Plane &p, std::vector< bool > &nbelow) const
 determine whether nodes are below plane p
virtual void reorder (const Indices &perm)
 change element index ordering
uint dropUnusedNodes ()
 drop unreferenced nodes from mesh (reorders)
uint dropDegenerateElements ()
 eliminate elements with duplicate vertices
uint mergeNodes (Real threshold=gmepsilon)
 drop duplicate nodes
virtual bool loadAny (const std::string &fname)
 try to load any of the supported formats from file
void importMvz (const MeshFields &mvz)
 import from older MeshFields format
TriMeshPtr toTriMesh () const
 generate a TriMesh from triangle sections (interfacing)
CgMeshPtr toCgMesh () const
 generate a CgMesh from surface element sections (for interfacing)
void writeAs (const std::string &fname, int fmt, int compression) const
 write in specified format, if possible
void writeSTL (const std::string &fname, bool binaryStl=false) const
 dump everything to triangles and export to STL format
void writePLY (const std::string &fname, bool binary) const
 dump everything to triangles and export to PLY format
void writeSmesh (const std::string &fname, const PointList< 3 > &holes=PointList< 3 >(), const PointList< 3 > &regionMarkers=PointList< 3 >(), const Vector &regionAttr=Vector()) const
 write 3-node triangles as smesh file for tetgen
void readTetgen (const std::string &basename, DVector< uint > *ftags=0)
 import from tetgen volume mesh files
void readCgns (const std::string &fname)
 read from CGNS file
void writeCgns (const std::string &fname, bool bcAsSections=false) const
 write to CGNS file
void readAbaqus (const std::string &fname)
 import mesh in ABAQUS text format
void writeAbaqus (const std::string &fname) const
 write mesh file in ABAQUS text format
void writeNastran (const std::string &fname, size_t nodeOffset=0, size_t eidOffset=0) const
 write mesh in NASTRAN bulk data format
void writeNastran (std::ostream &os, size_t nodeOffset, size_t eidOffset) const
 write mesh in NASTRAN bulk data format
BinFileNodePtr gbfNode (bool share=true) const
 create a binary file node
void fromGbf (const BinFileNodePtr &np, bool digestNode=false)
 retrieve data from gbf file node
virtual XmlElement toXml (bool share=false) const
 convert to xml representation
virtual void fromXml (const XmlElement &xe)
 retrieve section from xml representation
void writeZml (const std::string &fname, int compression=1) const
 convenience function : store to zipped xml
void readZml (const std::string &fname)
 convenience function : read from zipped xml
XmlElement toVTK () const
 export to VTK xml format (.vtu)
void writeLegacyVtk (const std::string &fname) const
 write legacy VTK format (version 2.0)
void readLegacyVtk (const std::string &fname)
 read unstructured grid datasets from legacy VTK files
void readAerel (const std::string &fname)
 read AERELPLOT file
void writeFFA (const std::string &fname) const
 write mesh in FFA format (bmsh)
void readFFA (const std::string &bmeshFile)
 read mesh in FFA format (bmsh)
bool appendFFAFields (const std::string &boutFile)
 append data fields from .bout file
size_t writeFieldsBdis (const std::string &basename) const
 write boundary displacement fields in bdis format
void writeSU2 (const std::string &fname) const
 write in SU2 plain text format
void readSU2 (const std::string &fname)
 read from SU2 plain text format
void writeEnsight (const std::string &basename) const
 write Ensight 7/gold format files
void readEnsight (const std::string &casename)
 read Ensight 7/gold format files
void fakeNastran (const std::string &fname) const
 write a faked bulk data / modal result file (nastran .f06 format)
void countElements ()
 update section element counts after change
void fixate ()
 compute connectivity data
const ConnectMapv2eMap () const
 access vertex-to-element connectivity map
void v2vMap (ConnectMap &v2v) const
 update an external vertex-vertex connectivity map
void e2eMap (ConnectMap &e2e) const
 generate an external element-to-element map
bool containsNodesOf (uint e1, uint e2) const
 test whether element e1 contains all vertices of e2
uint connectedComponents (Indices &ecmp, bool crossTypes=false) const
 Compute connected components. More...
virtual void clear ()
 clear out all data
virtual float megabytes () const
 memory requirements
int resetSectionColors (int hue, int sat=120, int val=140)
 set rotating colors for sections
int resetBocoColors (int hue, int sat=160, int val=170)
 set rotating colors for boundary conditions
- Public Member Functions inherited from MxAnnotated
 MxAnnotated ()
 empty annotations
 MxAnnotated (const MxAnnotated &)=default
 default copy
 MxAnnotated (MxAnnotated &&a)
 move constructor
virtual ~MxAnnotated ()
 meant as a base class
MxAnnotatedoperator= (const MxAnnotated &)=default
 default copy asignment
MxAnnotatedoperator= (MxAnnotated &&a)
 move assignment
void note (const XmlElement &xe)
 set the contents of the complete annotation object
const XmlElementnote () const
 retrieve xml annotation object
void annotate (const XmlElement &xe)
 append annotation element
XmlElement::const_iterator noteBegin () const
 iterate over annotations
XmlElement::const_iterator noteEnd () const
 iterate over annotations
void attribute (const std::string &key, const std::string &value)
 assign attribute, i.e. key-value pair in top-level annotation
std::string attribute (const std::string &key) const
 retrieve attribute; return empty string if not present

Static Public Member Functions

static uint nElementNodes (Mx::ElementType t)
 return the number of node for element type t

Protected Member Functions

void assembleVectorFields ()
 reassemble three-dimensional vector field after reading from cgns
virtual int readTetgenNodes (std::istream &is)
 read vertex coordinates from tetgen .node file
virtual void readTetgenFaces (std::istream &is, int offset, DVector< uint > *ptags=0)
 read boundary triangles from tetgen .face file
virtual void readTetgenElements (std::istream &is, int offset)
 read tet elements from tetgen .ele file
void readFFARegion (const FFANode &node)
 recover all sections from a FFA file region
void readFFABoundary (const FFANode &node)
 recover a section from a bmesh boundary section
MxSolutionTreePtr appendSubcase (FFANodePtr pregion)
 create a subcase with a set of fields from EDGE solution
std::string readAbaqusNodes (std::istream &in, DVector< int > &gid)
 read node coordinates and node ID numbers from Abaqus mesh file
std::string readAbaqusElements (const std::string &header, std::istream &in, DVector< int > &eid)
 create an element section while reading Abaqus mesh file
std::string readAbaqusSet (const std::string &header, const DVector< int > &eid, std::istream &in)
 create an element set/boco reading Abaqus mesh file
std::string readAbaqusKeyword (const std::string &header, std::istream &in, XmlElement &xabq)
 store Abaqus keyword line in XML annotation
MxSolutionTreePtr generateMaxFields (MxSolutionTreePtr root, bool useMaxAbs)
 generate maximum value fields across multiple subcases, start with tree

Static Protected Member Functions

static void fileFloatPrecision (TypeCode tc)
 globally change the precision stored in files that support conversion

Protected Attributes

PointList< 3 > vtx
 mesh vertices
std::vector< MxMeshSectionsections
 mesh sections
std::vector< MxMeshBocobocos
 boundary condition specs
std::vector< MxMeshFieldfields
 node- or element-centered data fields
std::vector< MxMeshDeformdeforms
 time-domain mesh deformation spec
MxSolutionTreePtr soltree
 global structure for solution fields (optional)
ConnectMap v2e
 vertex-to-element connectivity
std::string meshName
 mesh id
uint nelm
 number of elements present
- Protected Attributes inherited from MxAnnotated
XmlElement xnote
 xml annotation

Static Protected Attributes

static TypeCode s_fileFloatPrecision = TypeCode(TypeCode::Float64)
 global setting - store vertex data in single precision?

Member Function Documentation

uint MxMesh::connectedComponents ( Indices &  ecmp,
bool  crossTypes = false 
) const

Compute connected components.

Assign a component index to each element, spread component index to all reachable elements until all elements have been assigned to a component. Returns number of connected components. If crossTypes is true, than the walk will jump between element classes (volume/surface/line), otherwise, element class bondaries are component boundaries.

The documentation for this class was generated from the following files: