Chaste  Release::3.4
GmshMeshReader< ELEMENT_DIM, SPACE_DIM > Class Template Reference

#include <GmshMeshReader.hpp>

+ Inheritance diagram for GmshMeshReader< ELEMENT_DIM, SPACE_DIM >:
+ Collaboration diagram for GmshMeshReader< ELEMENT_DIM, SPACE_DIM >:

Public Member Functions

 GmshMeshReader (std::string pathBaseName, unsigned orderOfElements=1, unsigned orderOfBoundaryElements=1)
 
 ~GmshMeshReader ()
 
unsigned GetNumElements () const
 
unsigned GetNumNodes () const
 
unsigned GetNumFaces () const
 
unsigned GetNumCableElements () const
 
unsigned GetNumElementAttributes () const
 
unsigned GetNumFaceAttributes () const
 
unsigned GetNumCableElementAttributes () const
 
unsigned GetOrderOfElements ()
 
unsigned GetOrderOfBoundaryElements ()
 
void Reset ()
 
std::vector< doubleGetNextNode ()
 
ElementData GetNextElementData ()
 
ElementData GetNextFaceData ()
 
ElementData GetNextCableElementData ()
 
std::vector< doubleGetNodeAttributes ()
 
std::vector< doubleGetNode (unsigned index)
 
ElementData GetElementData (unsigned index)
 
ElementData GetFaceData (unsigned index)
 
- Public Member Functions inherited from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >
unsigned GetNumEdges () const
 
ElementData GetNextEdgeData ()
 
ElementData GetEdgeData (unsigned index)
 
virtual std::vector< unsignedGetContainingElementIndices (unsigned index)
 
virtual std::string GetMeshFileBaseName ()
 
virtual bool GetReadContainingElementOfBoundaryElement ()
 
virtual bool IsFileFormatBinary ()
 
virtual bool HasNclFile ()
 
virtual bool HasNodePermutation ()
 
virtual const std::vector
< unsigned > & 
rGetNodePermutation ()
 
ElementIterator GetElementIteratorBegin ()
 
ElementIterator GetElementIteratorBegin (const std::set< unsigned > &rIndices)
 
ElementIterator GetElementIteratorEnd ()
 
NodeIterator GetNodeIteratorBegin ()
 
NodeIterator GetNodeIteratorBegin (const std::set< unsigned > &rIndices)
 
NodeIterator GetNodeIteratorEnd ()
 

Private Member Functions

void ReadHeaders ()
 
void ReadNodeHeader ()
 
void ReadElementHeader ()
 
void ReadFaceHeader ()
 
void OpenFiles ()
 
void CloseFiles ()
 

Private Attributes

std::string mFileName
 
std::ifstream mNodeFile
 
std::ifstream mElementFile
 
std::ifstream mFaceFile
 
double mVersionNumber
 
unsigned mFileType
 
unsigned mDataSize
 
unsigned mNumNodes
 
unsigned mNumElements
 
unsigned mNumFaces
 
unsigned mTotalNumElementsAndFaces
 
unsigned mNumElementAttributes
 
unsigned mNumFaceAttributes
 
unsigned mOrderOfElements
 
unsigned mOrderOfBoundaryElements
 
unsigned mNodesPerElement
 
unsigned mNodesPerBoundaryElement
 

Detailed Description

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
class GmshMeshReader< ELEMENT_DIM, SPACE_DIM >

Class to enable reading of Gmsh format mesh files (see #2312).

Definition at line 68 of file GmshMeshReader.hpp.

Constructor & Destructor Documentation

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GmshMeshReader ( std::string  pathBaseName,
unsigned  orderOfElements = 1,
unsigned  orderOfBoundaryElements = 1 
)

Constructor.

Parameters
pathBaseNamethe base name of the files from which to read the mesh data (either absolute, or relative to the current directory)
orderOfElementsthe order of each element: 1 for linear, 2 for quadratic (defaults to 1)
orderOfBoundaryElementsthe order of each boundary element: 1 for linear, 2 for quadratic (defaults to 1. May or may not be different to orderOfElements

Definition at line 43 of file GmshMeshReader.cpp.

References GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mNodesPerBoundaryElement, GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mNodesPerElement, GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mOrderOfBoundaryElements, GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mOrderOfElements, GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::OpenFiles(), and GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::ReadHeaders().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::~GmshMeshReader ( )

Destructor

Definition at line 78 of file GmshMeshReader.cpp.

Member Function Documentation

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::CloseFiles ( )
private

Closes the .msh file descriptors

Definition at line 97 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
ElementData GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetElementData ( unsigned  index)
virtual

Normally throws an exception. Only implemented for tetrahedral mesh reader of binary files.

Parameters
indexThe global element index
Returns
a vector of the node indices of the element (and any attribute information, if there is any)

Reimplemented from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 468 of file GmshMeshReader.cpp.

References NEVER_REACHED.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
ElementData GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetFaceData ( unsigned  index)
virtual

Normally throws an exception. Only implemented for tetrahedral mesh reader of binary files.

Parameters
indexThe global face index
Returns
a vector of the node indices of the face (and any attribute/containment information, if there is any)

Reimplemented from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 474 of file GmshMeshReader.cpp.

References NEVER_REACHED.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
ElementData GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNextCableElementData ( )
virtual
Returns
a vector of the node indices of each cable element (and any attribute information, if there is any) in turn

Reimplemented from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 402 of file GmshMeshReader.cpp.

References NEVER_REACHED.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
ElementData GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNextElementData ( )
virtual
Returns
a vector of the nodes of each element (and any attribute information, if there is any) in turn

Implements AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 348 of file GmshMeshReader.cpp.

References ElementData::AttributeValue, and ElementData::NodeIndices.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
ElementData GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNextFaceData ( )
virtual
Returns
a vector of the nodes of each face in turn (synonym of GetNextEdgeData())

Implements AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 408 of file GmshMeshReader.cpp.

References ElementData::AttributeValue, and ElementData::NodeIndices.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::vector< double > GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNextNode ( )
virtual
Returns
a vector of the coordinates of each node in turn

Implements AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 321 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::vector< double > GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNode ( unsigned  index)
virtual

Normally throws an exception. Only implemented for tetrahedral mesh reader of binary files.

Parameters
indexThe global node index
Returns
a vector of the coordinates of the node

Reimplemented from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 462 of file GmshMeshReader.cpp.

References NEVER_REACHED.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::vector< double > GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNodeAttributes ( )
virtual
Returns
the vector of node attributes

Reimplemented from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 342 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNumCableElementAttributes ( ) const
virtual
Returns
the number of cable element attributes in the mesh

Reimplemented from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 304 of file GmshMeshReader.cpp.

References NEVER_REACHED.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNumCableElements ( ) const
virtual
Returns
the number of cable elements in the mesh

Reimplemented from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 273 of file GmshMeshReader.cpp.

References NEVER_REACHED.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNumElementAttributes ( ) const
virtual
Returns
the number of attributes in the mesh

Reimplemented from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 292 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNumElements ( ) const
virtual
Returns
the number of elements in the mesh

Implements AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 255 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNumFaceAttributes ( ) const
virtual
Returns
the number of attributes in the mesh

Reimplemented from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 298 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNumFaces ( ) const
virtual
Returns
the number of faces in the mesh (synonym of GetNumEdges())

Implements AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 267 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetNumNodes ( ) const
virtual
Returns
the number of nodes in the mesh

Implements AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 261 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetOrderOfBoundaryElements ( )
virtual
Returns
the expected order of the element file (1=linear, 2=quadratic)

Reimplemented from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 286 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GetOrderOfElements ( )
virtual

*

Returns
the expected order of the element file (1=linear, 2=quadratic)

Reimplemented from AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 280 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::OpenFiles ( )
private

Opens the .msh file descriptors

Definition at line 84 of file GmshMeshReader.cpp.

References EXCEPTION.

Referenced by GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GmshMeshReader().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::ReadElementHeader ( )
private

Read the element header from the mesh file.

Definition at line 168 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::ReadFaceHeader ( )
private

Read the face header from the mesh file.

Definition at line 213 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::ReadHeaders ( )
private

Read all the header information from the mesh file.

Definition at line 106 of file GmshMeshReader.cpp.

References EXCEPTION.

Referenced by GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GmshMeshReader().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::ReadNodeHeader ( )
private

Read the node header from the mesh file.

Definition at line 150 of file GmshMeshReader.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::Reset ( )
virtual

Resets pointers to beginning

Implements AbstractMeshReader< ELEMENT_DIM, SPACE_DIM >.

Definition at line 312 of file GmshMeshReader.cpp.

Member Data Documentation

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mDataSize
private

The number of floating point numbers in the file

Definition at line 186 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::ifstream GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mElementFile
private

A file stream used to read the volume elements of the file.

Definition at line 182 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::ifstream GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mFaceFile
private

A file stream used to read the boundary elements of the file.

Definition at line 183 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::string GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mFileName
private

The name of the mesh file.

Definition at line 180 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mFileType
private

The type of the mesh file being read (should always be 0)

Definition at line 185 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::ifstream GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mNodeFile
private

A file stream used to read the node (and header) part of the file.

Definition at line 181 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mNodesPerBoundaryElement
private

The number of nodes contained in each boundary element.

Definition at line 196 of file GmshMeshReader.hpp.

Referenced by GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GmshMeshReader().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mNodesPerElement
private

The number of nodes contained in each element.

Definition at line 195 of file GmshMeshReader.hpp.

Referenced by GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GmshMeshReader().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mNumElementAttributes
private

Is the number of attributes stored for each element.

Definition at line 191 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mNumElements
private

Number of elements in the mesh.

Definition at line 188 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mNumFaceAttributes
private

Is the number of attributes stored for each face.

Definition at line 192 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mNumFaces
private

Number of faces in the mesh.

Definition at line 189 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mNumNodes
private

Number of nodes in the mesh.

Definition at line 187 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mOrderOfBoundaryElements
private

The order of each element (1 for linear, 2 for quadratic).

Definition at line 194 of file GmshMeshReader.hpp.

Referenced by GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GmshMeshReader().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mOrderOfElements
private

The order of each element (1 for linear, 2 for quadratic).

Definition at line 193 of file GmshMeshReader.hpp.

Referenced by GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::GmshMeshReader().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
unsigned GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mTotalNumElementsAndFaces
private

Total number of elements and faces in the mesh.

Definition at line 190 of file GmshMeshReader.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
double GmshMeshReader< ELEMENT_DIM, SPACE_DIM >::mVersionNumber
private

The version number of the file.

Definition at line 184 of file GmshMeshReader.hpp.


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