[cig-commits] r13948 - short/3D/PyLith/branches/pylith-swig/libsrc/topology
brad at geodynamics.org
brad at geodynamics.org
Sun Jan 25 15:09:38 PST 2009
Author: brad
Date: 2009-01-25 15:09:37 -0800 (Sun, 25 Jan 2009)
New Revision: 13948
Modified:
short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.cc
short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.hh
short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.icc
Log:
Improved Mesh object- added communicator and debug flag as members; added createSieveMesh().
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.cc 2009-01-24 23:32:42 UTC (rev 13947)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.cc 2009-01-25 23:09:37 UTC (rev 13948)
@@ -18,10 +18,21 @@
// ----------------------------------------------------------------------
// Default constructor
-pylith::topology::Mesh::Mesh(const MPI_Comm& comm,
- const int dim) :
+pylith::topology::Mesh::Mesh(void) :
+ _coordsys(0),
+ _comm(PETSC_COMM_WORLD),
+ _debug(false)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Default constructor
+pylith::topology::Mesh::Mesh(const int dim,
+ const MPI_Comm& comm) :
_mesh(new SieveMesh(comm, dim)),
- _coordsys(0)
+ _coordsys(0),
+ _comm(comm),
+ _debug(false)
{ // constructor
} // constructor
@@ -33,6 +44,16 @@
} // destructor
// ----------------------------------------------------------------------
+// Create Sieve mesh.
+void
+pylith::topology::Mesh::createSieveMesh(const int dim)
+{ // createSieveMesh
+ _mesh.destroy();
+ _mesh = new SieveMesh(_comm, dim);
+ _mesh->setDebug(_debug);
+} // createSieveMesh
+
+// ----------------------------------------------------------------------
// Set coordinate system.
void
pylith::topology::Mesh::coordsys(const spatialdata::geocoords::CoordSys* cs)
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.hh 2009-01-24 23:32:42 UTC (rev 13947)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.hh 2009-01-25 23:09:37 UTC (rev 13948)
@@ -48,17 +48,26 @@
// PUBLIC METHODS ///////////////////////////////////////////////////////
public :
- /** Default constructor.
+ /// Default constructor.
+ Mesh(void);
+
+ /** Constructor with dimension and communicator.
*
+ * @param dim Dimension associated with mesh cells.
* @param comm MPI communicator for mesh.
- * @param dim Dimension associated with mesh cells.
*/
- Mesh(const MPI_Comm& comm =PETSC_COMM_WORLD,
- const int dim =3);
+ Mesh(const int dim,
+ const MPI_Comm& comm =PETSC_COMM_WORLD);
/// Default destructor
~Mesh(void);
+ /** Create Sieve mesh.
+ *
+ * @param dim Dimension associated with mesh cells.
+ */
+ void createSieveMesh(const int dim=3);
+
/** Get Sieve mesh.
*
* @returns Sieve mesh.
@@ -101,6 +110,12 @@
*/
int dimension(void) const;
+ /** Set MPI communicator associated with mesh.
+ *
+ * @param value MPI communicator.
+ */
+ void comm(const MPI_Comm value);
+
/** Get MPI communicator associated with mesh.
*
* @returns MPI communicator.
@@ -119,9 +134,11 @@
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- ALE::Obj<SieveMesh> _mesh; ///< Sieve mesh
- spatialdata::geocoords::CoordSys* _coordsys; ///< Coordinate system
-
+ ALE::Obj<SieveMesh> _mesh; ///< Sieve mesh.
+ spatialdata::geocoords::CoordSys* _coordsys; ///< Coordinate system.
+ MPI_Comm _comm; ///< MPI communicator for mesh.
+ bool _debug; ///< Debugging flag for mesh.
+
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.icc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.icc 2009-01-24 23:32:42 UTC (rev 13947)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.icc 2009-01-25 23:09:37 UTC (rev 13948)
@@ -39,28 +39,37 @@
inline
void
pylith::topology::Mesh::debug(const bool value) {
- _mesh->setDebug(value);
+ _debug = value;
+ if (!_mesh.isNull())
+ _mesh->setDebug(value);
}
// Get debug flag.
inline
bool
pylith::topology::Mesh::debug(void) const {
- return _mesh->debug();
+ return _debug;
}
// Get dimension of mesh.
inline
int
pylith::topology::Mesh::dimension(void) const {
- return _mesh->getDimension();
+ return (_mesh.isNull()) ? 0 : _mesh->getDimension();
}
+// Set MPI communicator associated with mesh.
+inline
+void
+pylith::topology::Mesh::comm(const MPI_Comm value) {
+ _comm = value;
+}
+
// Get MPI communicator associated with mesh.
inline
const MPI_Comm
pylith::topology::Mesh::comm(void) const {
- return _mesh->comm();
+ return _comm;
}
// Print mesh to stdout.
More information about the CIG-COMMITS
mailing list