Public Member Functions | Protected Member Functions | Private Attributes
Sundance::MeshSourceBase Class Reference

MeshSourceBase provides the internal interface for mesh sources, i.e., objects such as mesh generators and file readers that can produce a mesh object. More...

Inheritance diagram for Sundance::MeshSourceBase:
Sundance::Handleable< MeshSourceBase > Sundance::Printable Sundance::Noncopyable Sundance::ObjectWithClassVerbosity< MeshSourceBase > Sundance::DefaultObjectWithVerbosity Sundance::ObjectWithVerbosityBase Sundance::HNMesher2D Sundance::HNMesher3D Sundance::MeshReaderBase Sundance::OneTetMesher Sundance::OneTriangleMesher Sundance::PartitionedLineMesher Sundance::PartitionedRectangleMesher Sundance::PeanoMesher2D Sundance::PeanoMesher3D Sundance::PeriodicLineMesher

List of all members.

Public Member Functions

 MeshSourceBase (const MeshType &meshType, const MPIComm &comm)
 Construct with a mesh type and MPI communicator.
 MeshSourceBase (const ParameterList &params)
 Construct from a parameter list.
virtual ~MeshSourceBase ()
 virtual dtor
Mesh getMesh () const
 Get a mesh from the source.
Extraction of attributes
void getAttributes (RCP< Array< Array< double > > > &nodeAttributes, RCP< Array< Array< double > > > &elemAttributes) const
Printable interface
virtual void print (std::ostream &os) const
 Print to a stream.
Describable interface
virtual std::string description () const
 Print to a stream.
const MPIComm & comm () const
 access to the MPI communicator

Protected Member Functions

int myRank () const
 Get processor rank.
int nProc () const
 Get number of processors.
virtual Mesh fillMesh () const =0
 Fill a mesh object with data from the source.
Mesh createMesh (int dim) const
 createMesh() physically allocates the mesh object
RCP< Array< Array< double > > > & nodeAttributes () const
 internal access to the node attributes
RCP< Array< Array< double > > > & elemAttributes () const
 internal access to the element attributes

Private Attributes

Mesh cachedMesh_
bool hasCachedMesh_
MeshType meshType_
MPIComm comm_
RCP< Array< Array< double > > > elemAttributes_
RCP< Array< Array< double > > > nodeAttributes_

Detailed Description

MeshSourceBase provides the internal interface for mesh sources, i.e., objects such as mesh generators and file readers that can produce a mesh object.

The action of a mesh source should be independent of the internal mesh representation used. To allow user-level specification of the type of internal mesh representation to be used, a MeshSourceBase is constructed with a MeshType object which acts as a factory to produce empty meshes.

Mesh sources are constructed with a MPI communicator. If the communicator has more than one processor, the mesh created will be distributed.

Writing your own MeshSourceBase subtype

The only method you will need to override is

which is where you fill in a mesh object and return it. This method should usually physically create the mesh with a call to createMesh(), ensuring that the correct mesh representation type is created using the MeshType factory with which the source was constructed.

See the PartitionedLineMesher source code for a very simple example of how to write a mesh source subtype.

Optionally, you can override the description() method to provide more informative descriptive output than the std::string "MeshSourceBase[unknown subtype]".

Definition at line 79 of file SundanceMeshSourceBase.hpp.


Constructor & Destructor Documentation

MeshSourceBase::MeshSourceBase ( const MeshType meshType,
const MPIComm &  comm 
)

Construct with a mesh type and MPI communicator.

Definition at line 13 of file SundanceMeshSourceBase.cpp.

MeshSourceBase::MeshSourceBase ( const ParameterList &  params)

Construct from a parameter list.

Definition at line 24 of file SundanceMeshSourceBase.cpp.

virtual Sundance::MeshSourceBase::~MeshSourceBase ( ) [inline, virtual]

virtual dtor

Definition at line 94 of file SundanceMeshSourceBase.hpp.


Member Function Documentation

const MPIComm& Sundance::MeshSourceBase::comm ( ) const [inline]

access to the MPI communicator

Definition at line 121 of file SundanceMeshSourceBase.hpp.

References comm_.

Referenced by Sundance::PartitionedLineMesher::fillMesh(), myRank(), and nProc().

Mesh MeshSourceBase::createMesh ( int  dim) const [protected]
virtual std::string Sundance::MeshSourceBase::description ( ) const [inline, virtual]
RCP<Array<Array<double> > >& Sundance::MeshSourceBase::elemAttributes ( ) const [inline, protected]

internal access to the element attributes

Definition at line 146 of file SundanceMeshSourceBase.hpp.

References elemAttributes_.

Referenced by Sundance::ExodusMeshReader::fillMesh(), Sundance::TriangleMeshReader::readElems(), and Sundance::BamgMeshReader::readMesh().

virtual Mesh Sundance::MeshSourceBase::fillMesh ( ) const [protected, pure virtual]
void MeshSourceBase::getAttributes ( RCP< Array< Array< double > > > &  nodeAttributes,
RCP< Array< Array< double > > > &  elemAttributes 
) const

Definition at line 55 of file SundanceMeshSourceBase.cpp.

Mesh MeshSourceBase::getMesh ( ) const

Get a mesh from the source.

If a mesh has already been created, this method will return the cached mesh, otherwise it will build on with a call to fillMesh()

Definition at line 35 of file SundanceMeshSourceBase.cpp.

References cachedMesh_, fillMesh(), hasCachedMesh_, Sundance::Mesh::numCells(), Sundance::Mesh::spatialDim(), and Sundance::DefaultObjectWithVerbosity::verb().

int Sundance::MeshSourceBase::myRank ( ) const [inline, protected]
RCP<Array<Array<double> > >& Sundance::MeshSourceBase::nodeAttributes ( ) const [inline, protected]

internal access to the node attributes

Definition at line 142 of file SundanceMeshSourceBase.hpp.

References nodeAttributes_.

Referenced by Sundance::ExodusMeshReader::fillMesh(), Sundance::BamgMeshReader::readMesh(), and Sundance::TriangleMeshReader::readNodes().

int Sundance::MeshSourceBase::nProc ( ) const [inline, protected]
virtual void Sundance::MeshSourceBase::print ( std::ostream &  os) const [inline, virtual]

Print to a stream.

Implements Sundance::Printable.

Definition at line 111 of file SundanceMeshSourceBase.hpp.

References description().


Member Data Documentation

Definition at line 154 of file SundanceMeshSourceBase.hpp.

Referenced by createMesh(), and getMesh().

Definition at line 163 of file SundanceMeshSourceBase.hpp.

Referenced by comm(), and createMesh().

RCP<Array<Array<double> > > Sundance::MeshSourceBase::elemAttributes_ [mutable, private]

Definition at line 166 of file SundanceMeshSourceBase.hpp.

Referenced by elemAttributes().

Definition at line 157 of file SundanceMeshSourceBase.hpp.

Referenced by createMesh(), and getMesh().

Definition at line 160 of file SundanceMeshSourceBase.hpp.

Referenced by createMesh().

RCP<Array<Array<double> > > Sundance::MeshSourceBase::nodeAttributes_ [mutable, private]

Definition at line 169 of file SundanceMeshSourceBase.hpp.

Referenced by nodeAttributes().

Site Contact