[cig-commits] r14006 - in short/3D/PyLith/branches/pylith-swig: . libsrc/topology modulesrc/topology pylith pylith/topology unittests/libtests/bc unittests/pytests/topology
brad at geodynamics.org
brad at geodynamics.org
Sun Feb 1 18:36:41 PST 2009
Author: brad
Date: 2009-02-01 18:36:40 -0800 (Sun, 01 Feb 2009)
New Revision: 14006
Added:
short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Field.i
short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldBase.i
short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldSubMesh.i
short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SubMesh.i
short/3D/PyLith/branches/pylith-swig/pylith/topology/SubMesh.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestSubMesh.py
Removed:
short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMulti.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMulti.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.hh
Modified:
short/3D/PyLith/branches/pylith-swig/TODO
short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh
short/3D/PyLith/branches/pylith-swig/libsrc/topology/FieldBase.hh
short/3D/PyLith/branches/pylith-swig/libsrc/topology/FieldSubMesh.hh
short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Makefile.am
short/3D/PyLith/branches/pylith-swig/modulesrc/topology/topology.i
short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am
short/3D/PyLith/branches/pylith-swig/pylith/topology/Field.py
short/3D/PyLith/branches/pylith-swig/pylith/topology/Mesh.py
short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/Makefile.am
short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/Makefile.am
short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/testdriver.py
Log:
Worked on topology module and Python unit tests.
Modified: short/3D/PyLith/branches/pylith-swig/TODO
===================================================================
--- short/3D/PyLith/branches/pylith-swig/TODO 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/TODO 2009-02-02 02:36:40 UTC (rev 14006)
@@ -5,11 +5,10 @@
0. SWIG conversion
TestMesh.test_view()
TestMesh.test_checkMaterialIds()
+
+ libtests/bc/TestDirichletBoundary::testVertexField()
+ libtests/bc/TestDirichletBoundary::testBoundaryMesh()
- meshio
- lib
- module
-
FieldsManager (change to SolutionFields)
DirichletPoints (Python) - rate == None -> dbRate == 0
@@ -34,7 +33,7 @@
Integrator::normalizer()
DataWriter::normalizer()
-3. Mesh, Field, and FieldUniform objects [Brad]
+3. Mesh and Field objects [Brad]
Change name of FieldsManager to SolutionFields
(more accurate description).
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh 2009-02-02 02:36:40 UTC (rev 14006)
@@ -11,7 +11,7 @@
//
/**
- * @file pylith/topology/Field.hh
+ * @file libsrc/topology/Field.hh
*
* @brief Vector field over the vertices or cells of a finite-element
* mesh.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/FieldBase.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/FieldBase.hh 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/FieldBase.hh 2009-02-02 02:36:40 UTC (rev 14006)
@@ -11,7 +11,7 @@
//
/**
- * @file pylith/topology/FieldBase.hh
+ * @file libsrc/topology/FieldBase.hh
*
* @brief Vector field over the vertices or cells of a finite-element
* mesh or subset of a finite-element mesh.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/FieldSubMesh.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/FieldSubMesh.hh 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/FieldSubMesh.hh 2009-02-02 02:36:40 UTC (rev 14006)
@@ -11,7 +11,7 @@
//
/**
- * @file pylith/topology/FieldSubMesh.hh
+ * @file libsrc/topology/FieldSubMesh.hh
*
* @brief Vector field over the vertices or cells of a lower dimension
* portion of a finite-element mesh.
Added: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Field.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Field.i (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Field.i 2009-02-02 02:36:40 UTC (rev 14006)
@@ -0,0 +1,104 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/Field.hh
+ *
+ * @brief Python interface to C++ Field object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ class Field : public FieldBase
+ { // Field
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /** Default constructor.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ Field(const Mesh& mesh);
+
+ /// Destructor.
+ ~Field(void);
+
+ /** Get spatial dimension of domain.
+ *
+ * @returns Spatial dimension of domain.
+ */
+ int spaceDim(void) const;
+
+ /// Create sieve section.
+ void newSection(void);
+
+ /** Create sieve section and set chart and fiber dimesion.
+ *
+ * @param domain Type of points over which to define section.
+ * @param dim Fiber dimension for section.
+ */
+ void newSection(const DomainEnum domain,
+ const int fiberDim);
+
+ /** Create section with same layout (fiber dimension and
+ * constraints) as another section. This allows the layout data
+ * structures to be reused across multiple fields, reducing memory
+ * usage.
+ *
+ * @param sec Section defining layout.
+ */
+ void newSection(const Field& src);
+
+ /// Clear variables associated with section.
+ void clear(void);
+
+ /// Allocate field.
+ void allocate(void);
+
+ /// Zero section values.
+ void zero(void);
+
+ /// Complete section by assembling across processors.
+ void complete(void);
+
+ /** Copy field values and metadata.
+ *
+ * @param field Field to copy.
+ */
+ void copy(const Field& field);
+
+ /** Add two fields, storing the result in one of the fields.
+ *
+ * @param field Field to add.
+ */
+ void operator+=(const Field& field);
+
+ /** Dimensionalize field. Throws runtime_error if field is not
+ * allowed to be dimensionalized.
+ */
+ void dimensionalize(void);
+
+ /** Print field to standard out.
+ *
+ * @param label Label for output.
+ */
+ void view(const char* label);
+
+ }; // Field
+
+ } // topology
+} // pylith
+
+
+// End of file
Added: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldBase.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldBase.i (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldBase.i 2009-02-02 02:36:40 UTC (rev 14006)
@@ -0,0 +1,107 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/FieldBase.hh
+ *
+ * @brief Python interface to C++ abstract base class FieldBase.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ class FieldBase
+ { // FieldBase
+
+ // PUBLIC ENUMS ///////////////////////////////////////////////////
+ public :
+
+ enum VectorFieldEnum {
+ SCALAR=0, ///< Scalar.
+ VECTOR=1, ///< Vector.
+ TENSOR=2, ///< Tensor.
+ OTHER=3, ///< Not a scalar, vector, or tensor.
+ MULTI_SCALAR=4, ///< Scalar at multiple points.
+ MULTI_VECTOR=5, ///< Vector at multiple points.
+ MULTI_TENSOR=6, ///< Tensor at multiple points.
+ MULTI_OTHER=7, ///< Not a scalar, vector, or tensor at multiple points.
+ }; // VectorFieldEnum
+
+ enum DomainEnum {
+ VERTICES_FIELD=0, ///< FieldBase over vertices.
+ CELLS_FIELD=1, ///< FieldBase over cells.
+ }; // omainEnum
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ FieldBase(void);
+
+ /// Destructor.
+ ~FieldBase(void);
+
+ /** Set name of field.
+ *
+ * @param value Name of field.
+ */
+ void name(const char* value);
+
+ /** Get name of field.
+ *
+ * @returns Name of field.
+ */
+ const char* name(void) const;
+
+ /** Set vector field type
+ *
+ * @param value Type of vector field.
+ */
+ void vectorFieldType(const VectorFieldEnum value);
+
+ /** Get vector field type
+ *
+ * @returns Type of vector field.
+ */
+ VectorFieldEnum vectorFieldType(void) const;
+
+ /** Set scale for dimensionalizing field.
+ *
+ * @param value Scale associated with field.
+ */
+ void scale(const double value);
+
+ /** Get scale for dimensionalizing field.
+ *
+ * @returns Scale associated with field.
+ */
+ double scale(void) const;
+
+ /** Set flag indicating whether it is okay to dimensionalize field.
+ *
+ * @param value True if it is okay to dimensionalize field.
+ */
+ void addDimensionOkay(const bool value);
+
+ /** Set flag indicating whether it is okay to dimensionalize field.
+ *
+ * @param value True if it is okay to dimensionalize field.
+ */
+ bool addDimensionOkay(void) const;
+
+ }; // FieldBase
+
+ } // topology
+} // pylith
+
+
+// End of file
Added: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldSubMesh.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldSubMesh.i (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldSubMesh.i 2009-02-02 02:36:40 UTC (rev 14006)
@@ -0,0 +1,104 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/FieldSubMesh.hh
+ *
+ * @brief Python interface to C++ FieldSubMesh object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ class FieldSubMesh : public FieldBase
+ { // FieldSubMesh
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /** Default constructor.
+ *
+ * @param mesh Lower dimension finite-element mesh.
+ */
+ FieldSubMesh(const SubMesh& mesh);
+
+ /// Destructor.
+ ~FieldSubMesh(void);
+
+ /** Get spatial dimension of domain.
+ *
+ * @returns Spatial dimension of domain.
+ */
+ int spaceDim(void) const;
+
+ /// Create sieve section.
+ void newSection(void);
+
+ /** Create sieve section and set chart and fiber dimesion.
+ *
+ * @param domain Type of points over which to define section.
+ * @param dim Fiber dimension for section.
+ */
+ void newSection(const DomainEnum domain,
+ const int fiberDim);
+
+ /** Create section with same layout (fiber dimension and
+ * constraints) as another section. This allows the layout data
+ * structures to be reused across multiple fields, reducing memory
+ * usage.
+ *
+ * @param sec Section defining layout.
+ */
+ void newSection(const FieldSubMesh& src);
+
+ /// Clear variables associated with section.
+ void clear(void);
+
+ /// Allocate field.
+ void allocate(void);
+
+ /// Zero section values.
+ void zero(void);
+
+ /// Complete section by assembling across processors.
+ void complete(void);
+
+ /** Copy field values and metadata.
+ *
+ * @param field FieldSubMesh to copy.
+ */
+ void copy(const FieldSubMesh& field);
+
+ /** Add two fields, storing the result in one of the fields.
+ *
+ * @param field FieldSubMesh to add.
+ */
+ void operator+=(const FieldSubMesh& field);
+
+ /** Dimensionalize field. Throws runtime_error if field is not
+ * allowed to be dimensionalized.
+ */
+ void dimensionalize(void);
+
+ /** Print field to standard out.
+ *
+ * @param label Label for output.
+ */
+ void view(const char* label);
+
+ }; // FieldSubMesh
+
+ } // topology
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Makefile.am 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Makefile.am 2009-02-02 02:36:40 UTC (rev 14006)
@@ -20,7 +20,11 @@
swig_sources = \
topology.i \
Mesh.i \
- MeshOps.i
+ SubMesh.i \
+ MeshOps.i \
+ FieldBase.i \
+ Field.i \
+ FieldSubMesh.i
swig_generated = \
topology_wrap.cxx \
Added: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SubMesh.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SubMesh.i (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SubMesh.i 2009-02-02 02:36:40 UTC (rev 14006)
@@ -0,0 +1,95 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/SubMesh.i
+ *
+ * @brief Python interface to C++ Mesh object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ class SubMesh
+ { // SubMesh
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ SubMesh(void);
+
+ /** Constructor with mesh and label for vertices marking boundary.
+ *
+ * @param mesh Finite-element mesh over domain.
+ * @param label Label for vertices marking boundary.
+ */
+ SubMesh(const Mesh& mesh,
+ const char* label);
+
+ /// Default destructor
+ ~SubMesh(void);
+
+ /** Create Sieve mesh.
+ *
+ * @param mesh Finite-element mesh over domain.
+ * @param label Label for vertices marking boundary.
+ */
+ void createSubMesh(const Mesh& mesh,
+ const char* label);
+
+ /** Get coordinate system.
+ *
+ * @returns Coordinate system.
+ */
+ const spatialdata::geocoords::CoordSys* coordsys(void) const;
+
+ /** Set debug flag.
+ *
+ * @param value Turn on debugging if true.
+ */
+ void debug(const bool value);
+
+ /** Get debug flag.
+ *
+ * @param Get debugging flag.
+ */
+ bool debug(void) const;
+
+ /** Get dimension of mesh.
+ *
+ * @returns Dimension of mesh.
+ */
+ int dimension(void) const;
+
+ /** Get MPI communicator associated with mesh.
+ *
+ * @returns MPI communicator.
+ */
+ const MPI_Comm comm(void) const;
+
+ /// Initialize the finite-element mesh.
+ void initialize(void);
+
+ /** Print mesh to stdout.
+ *
+ * @param label Label for mesh.
+ */
+ void view(const char* label);
+
+ }; // SubMesh
+
+ } // topology
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/topology.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/topology.i 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/topology.i 2009-02-02 02:36:40 UTC (rev 14006)
@@ -16,7 +16,11 @@
// Header files for module C++ code
%{
#include "pylith/topology/Mesh.hh"
+#include "pylith/topology/SubMesh.hh"
#include "pylith/topology/MeshOps.hh"
+#include "pylith/topology/FieldBase.hh"
+#include "pylith/topology/Field.hh"
+#include "pylith/topology/FieldSubMesh.hh"
%}
%include "exception.i"
@@ -41,7 +45,11 @@
// Interfaces
%include "Mesh.i"
+%include "SubMesh.i"
%include "MeshOps.i"
+%include "FieldBase.i"
+%include "Field.i"
+%include "FieldSubMesh.i"
// End of file
Modified: short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am 2009-02-02 02:36:40 UTC (rev 14006)
@@ -113,6 +113,7 @@
topology/Distributor.py \
topology/FieldsManager.py \
topology/Mesh.py \
+ topology/SubMesh.py \
topology/MeshGenerator.py \
topology/MeshImporter.py \
topology/MeshRefiner.py \
Modified: short/3D/PyLith/branches/pylith-swig/pylith/topology/Field.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/topology/Field.py 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/pylith/topology/Field.py 2009-02-02 02:36:40 UTC (rev 14006)
@@ -14,11 +14,11 @@
##
## @brief Python object for managing a vector field over vertices or
## cells of a finite-element mesh.
-##
-## Factory: vector_field
+from topology import Field as ModuleField
+
# Field class
-class Field(object):
+class Field(ModuleField):
"""
Python object for managing a vector field over vertices or cells of
a finite-element mesh.
@@ -30,182 +30,8 @@
"""
Constructor.
"""
- self.cppHandle = self._createCppHandle(mesh)
+ ModuleField.__init__(self, mesh)
return
-
-
- def setName(self, value):
- """
- Set name of field.
- """
- assert(None != self.cppHandle)
- self.cppHandle.name = value
- return
-
-
- def getName(self):
- """
- Get name of field.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.name
-
-
- def setVectorFieldType(self, value):
- """
- Set vector field type.
- """
- assert(None != self.cppHandle)
- self.cppHandle.vectorFieldType = value
- return
-
-
- def getVectorFieldType(self):
- """
- Get vector field type.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.VectorFieldType
- return
-
-
- def setSpaceDim(self, value):
- """
- Set spaceDim of field.
- """
- assert(None != self.cppHandle)
- self.cppHandle.spaceDim = value
- return
-
-
- def getSpaceDim(self, spaceDim):
- """
- Get spaceDim of field.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.spaceDim
-
-
- def setScale(self, value):
- """
- Set scale of field.
- """
- assert(None != self.cppHandle)
- self.cppHandle.scale = value
- return
-
-
- def getScale(self):
- """
- Get scale of field.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.scale
-
-
- def setAddDimensionOkay(self, value):
- """
- Set addDimensionOkay.
- """
- assert(None != self.cppHandle)
- self.cppHandle.addDimensionOkay = value
- return
-
-
- def getAddDimensionOkay(self):
- """
- Get addDimensionOkay.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.addDimensionOkay
-
-
- def copyLayout(self, field):
- """
- Copy layout of field.
- """
- assert(None != self.cppHandle)
- self.cppHandle.copyLayout(field.cppHandle)
- return
-
-
- def clear(self):
- """
- Clear variables associated with section.
- """
- assert(None != self.cppHandle)
- self.cppHandle.clear()
- return
-
-
- def zero(self):
- """
- Zero section values.
- """
- assert(None != self.cppHandle)
- self.cppHandle.zero()
- return
-
- def complete(self):
- """
- Complete section by assembling over processors.
- """
- assert(None != self.cppHandle)
- self.cppHandle.complete()
- return
-
-
- def copy(self, field):
- """
- Copy field values and metadata.
- """
- assert(None != self.cppHandle)
- self.cppHandle.copy(field.cppHandle)
- return
-
-
- def add(self, field):
- """
- Add two fields, storing result in field.
- """
- assert(None != self.cppHandle)
- self.cppHandle.add(field.cppHandle)
- return
-
- def dimensionalize(self):
- """
- Add dimensions to field.
- """
- okay = self.cppHandle.addDimensionOkay
- if ~okay:
- name = self.cppHandle.name
- raise RuntimeError("Field '%s' is protected. Cannot dimensionalize." % \
- name)
- assert(None != self.cppHandle)
- self.cppHandle.dimensionalize()
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _createCppHandle(self):
- """
- Create handle to corresponding C++ object.
- """
- if None == self.cppHandle:
- import pylith.topology.topology as bindings
- self.cppHandle = bindings.Field()
- return
-
-
-# FACTORIES ////////////////////////////////////////////////////////////
-
-def vector_field():
- """
- Factory associated with Mesh.
- """
- return Field()
-
-
# End of file
Modified: short/3D/PyLith/branches/pylith-swig/pylith/topology/Mesh.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/topology/Mesh.py 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/pylith/topology/Mesh.py 2009-02-02 02:36:40 UTC (rev 14006)
@@ -13,8 +13,6 @@
## @file pylith/topology/Mesh.py
##
## @brief Python Mesh for finite-element topology information.
-##
-## Factory: finite_element_mesh
from topology import Mesh as ModuleMesh
Added: short/3D/PyLith/branches/pylith-swig/pylith/topology/SubMesh.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/topology/SubMesh.py (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/pylith/topology/SubMesh.py 2009-02-02 02:36:40 UTC (rev 14006)
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/topology/SubMesh.py
+##
+## @brief Python Mesh for lower-dimension finite-element topology
+## information.
+
+from topology import SubMesh as ModuleSubMesh
+
+# SubMesh class
+class SubMesh(ModuleSubMesh):
+ """
+ Python Mesh for lower-dimension finite-element topology information.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, mesh=None, label=None):
+ """
+ Constructor.
+ """
+ if mesh is None:
+ ModuleSubMesh.__init__(self)
+ else:
+ if label is None:
+ raise ValueError("SubMesh constructor with mesh requires label.")
+ ModuleSubMesh.__init__(self, mesh, label)
+ return
+
+
+ def comm(self):
+ """
+ Get communicator.
+ """
+ # Use Communicator object to wrap C++ MPI_Comm* returned by
+ # module.
+ from pylith.mpi.Communicator import Communicator
+ return Communicator(ModuleSubMesh.comm(self))
+
+
+# End of file
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/Makefile.am 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/Makefile.am 2009-02-02 02:36:40 UTC (rev 14006)
@@ -39,9 +39,6 @@
TestDirichletBoundaryHex8.cc \
test_bc.cc
-# TestDirichletBoundaryMulti.cc \
-# TestDirichletBoundaryMultiTri3.cc \
-# TestDirichletBoundaryMultiTet4.cc
# TestAbsorbingDampers.cc \
# TestAbsorbingDampersLine2.cc \
@@ -80,9 +77,6 @@
TestDirichletBoundaryQuad4.hh \
TestDirichletBoundaryTet4.hh \
TestDirichletBoundaryHex8.hh \
- TestDirichletBoundaryMulti.hh \
- TestDirichletBoundaryMultiTri3.hh \
- TestDirichletBoundaryMultiTet4.hh \
TestDirichletBC.hh \
TestDirichletBCLine2.hh \
TestDirichletBCLine2b.hh \
Deleted: short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMulti.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMulti.cc 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMulti.cc 2009-02-02 02:36:40 UTC (rev 14006)
@@ -1,253 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletBoundaryMulti.hh" // Implementation of class methods
-
-#include "pylith/bc/DirichletBoundary.hh" // USES DirichletBoundary
-
-#include "data/DirichletDataMulti.hh" // USES DirichletData
-#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
-#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
-#include "spatialdata/spatialdb/SimpleIOAscii.hh" // USES SimpleIOAscii
-#include "spatialdata/spatialdb/UniformDB.hh" // USES UniformDB
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletBoundaryMulti::setUp(void)
-{ // setUp
- _data = 0;
-} // setUp
-
-// ----------------------------------------------------------------------
-// Tear down testing data.
-void
-pylith::bc::TestDirichletBoundaryMulti::tearDown(void)
-{ // tearDown
- delete _data; _data = 0;
-} // tearDown
-
-// ----------------------------------------------------------------------
-// Test setConstraintSizes().
-void
-pylith::bc::TestDirichletBoundaryMulti::testSetConstraintSizes(void)
-{ // testSetConstraintSizes
- ALE::Obj<Mesh> mesh;
- DirichletBoundary bcA;
- DirichletBoundary bcB;
- DirichletBoundary bcC;
- _initialize(&mesh, &bcA, &bcB, &bcC);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bcA.setConstraintSizes(field, mesh);
- bcB.setConstraintSizes(field, mesh);
- bcC.setConstraintSizes(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- CPPUNIT_ASSERT_EQUAL(_data->numDOF, field->getFiberDimension(*v_iter));
-
- CPPUNIT_ASSERT_EQUAL(_data->constraintSizes[*v_iter-offset],
- field->getConstraintDimension(*v_iter));
- } // for
-} // testSetConstraintSizes
-
-// ----------------------------------------------------------------------
-// Test setConstraints().
-void
-pylith::bc::TestDirichletBoundaryMulti::testSetConstraints(void)
-{ // testSetConstraints
- ALE::Obj<Mesh> mesh;
- DirichletBoundary bcA;
- DirichletBoundary bcB;
- DirichletBoundary bcC;
- _initialize(&mesh, &bcA, &bcB, &bcC);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bcA.setConstraintSizes(field, mesh);
- bcB.setConstraintSizes(field, mesh);
- bcC.setConstraintSizes(field, mesh);
- mesh->allocate(field);
- bcA.setConstraints(field, mesh);
- bcB.setConstraints(field, mesh);
- bcC.setConstraints(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- int index = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int numConstrainedDOF = _data->constraintSizes[*v_iter-offset];
- if (numConstrainedDOF > 0) {
- const int* fixedDOF = field->getConstraintDof(*v_iter);
- for (int iDOF=0; iDOF < numConstrainedDOF; ++iDOF)
- CPPUNIT_ASSERT_EQUAL(_data->constrainedDOF[index++], fixedDOF[iDOF]);
- } // if
- } // for
-} // testSetConstraints
-
-// ----------------------------------------------------------------------
-// Test setField().
-void
-pylith::bc::TestDirichletBoundaryMulti::testSetField(void)
-{ // testSetField
- ALE::Obj<Mesh> mesh;
- DirichletBoundary bcA;
- DirichletBoundary bcB;
- DirichletBoundary bcC;
- _initialize(&mesh, &bcA, &bcB, &bcC);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bcA.setConstraintSizes(field, mesh);
- bcB.setConstraintSizes(field, mesh);
- bcC.setConstraintSizes(field, mesh);
- mesh->allocate(field);
- bcA.setConstraints(field, mesh);
- bcB.setConstraints(field, mesh);
- bcC.setConstraints(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
- const double tolerance = 1.0e-06;
-
- // All values should be zero.
- field->zero();
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int fiberDim = field->getFiberDimension(*v_iter);
- const real_section_type::value_type* values =
- mesh->restrictClosure(field, *v_iter);
- for (int i=0; i < fiberDim; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[i], tolerance);
- } // for
-
- // Only unconstrained values should be zero.
- // Expected values set in _data->field
- const double t = 10.0;
- bcA.setField(t, field, mesh);
- bcB.setField(t, field, mesh);
- bcC.setField(t, field, mesh);
-
- int i = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int fiberDim = field->getFiberDimension(*v_iter);
- const real_section_type::value_type* values =
- mesh->restrictClosure(field, *v_iter);
- for (int iDOF=0; iDOF < fiberDim; ++iDOF)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->field[i++], values[iDOF], tolerance);
- } // for
-} // testSetField
-
-// ----------------------------------------------------------------------
-void
-pylith::bc::TestDirichletBoundaryMulti::_initialize(ALE::Obj<Mesh>* mesh,
- DirichletBoundary* const bcA,
- DirichletBoundary* const bcB,
- DirichletBoundary* const bcC) const
-{ // _initialize
- CPPUNIT_ASSERT(0 != _data);
- CPPUNIT_ASSERT(0 != bcA);
- CPPUNIT_ASSERT(0 != bcB);
- CPPUNIT_ASSERT(0 != bcC);
-
- meshio::MeshIOAscii iohandler;
- iohandler.filename(_data->meshFilename);
- iohandler.read(mesh);
- CPPUNIT_ASSERT(!mesh->isNull());
-
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((*mesh)->getDimension());
- cs.initialize();
-
- // Setup boundary condition A
- spatialdata::spatialdb::SimpleDB db("TestDirichletBoundaryMulti initial");
- spatialdata::spatialdb::SimpleIOAscii dbIO;
- dbIO.filename(_data->dbFilenameA);
- db.ioHandler(&dbIO);
-
- spatialdata::spatialdb::SimpleDB dbRate("TestDirichletBoundaryMulti rate");
- spatialdata::spatialdb::SimpleIOAscii dbIORate;
- dbIORate.filename(_data->dbFilenameARate);
- dbRate.ioHandler(&dbIORate);
-
- int_array fixedDOFA(_data->fixedDOFA, _data->numFixedDOFA);
- const double upDirVals[] = { 0.0, 0.0, 1.0 };
- double_array upDir(upDirVals, 3);
-
- bcA->label(_data->labelA);
- bcA->db(&db);
- bcA->dbRate(&dbRate);
- bcA->referenceTime(_data->tRefA);
- bcA->fixedDOF(fixedDOFA);
- bcA->initialize(*mesh, &cs, upDir);
-
- // Setup boundary condition B
- dbIO.filename(_data->dbFilenameB);
- db.ioHandler(&dbIO);
-
- dbIORate.filename(_data->dbFilenameBRate);
- dbRate.ioHandler(&dbIORate);
-
- int_array fixedDOFB(_data->fixedDOFB, _data->numFixedDOFB);
-
- bcB->label(_data->labelB);
- bcB->db(&db);
- bcB->dbRate(&dbRate);
- bcB->referenceTime(_data->tRefB);
- bcB->fixedDOF(fixedDOFB);
- bcB->initialize(*mesh, &cs, upDir);
-
- // Setup boundary condition C
- if (_data->numFixedDOFC > 0) {
- dbIO.filename(_data->dbFilenameC);
- db.ioHandler(&dbIO);
-
- dbIORate.filename(_data->dbFilenameCRate);
- dbRate.ioHandler(&dbIORate);
-
- int_array fixedDOFC(_data->fixedDOFC, _data->numFixedDOFC);
-
- bcC->label(_data->labelC);
- bcC->db(&db);
- bcC->dbRate(&dbRate);
- bcC->referenceTime(_data->tRefC);
- bcC->fixedDOF(fixedDOFC);
- bcC->initialize(*mesh, &cs, upDir);
- } // if
-} // _initialize
-
-
-// End of file
Deleted: short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMulti.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMulti.hh 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMulti.hh 2009-02-02 02:36:40 UTC (rev 14006)
@@ -1,85 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletBoundaryMulti.hh
- *
- * @brief C++ TestDirichletBoundaryMulti object.
- *
- * C++ unit testing for DirichletBoundaryMulti.
- */
-
-#if !defined(pylith_bc_testdirichletboundarymulti_hh)
-#define pylith_bc_testdirichletboundarymulti_hh
-
-#include <cppunit/extensions/HelperMacros.h>
-
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletBoundaryMulti;
-
- class DirichletBoundary;
- class DirichletDataMulti;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletBoundaryMulti.
-class pylith::bc::TestDirichletBoundaryMulti : public CppUnit::TestFixture
-{ // class TestDirichletBoundaryMulti
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
- /// Tear down testing data.
- void tearDown(void);
-
- /// Test setConstraintSizes().
- void testSetConstraintSizes(void);
-
- /// Test setConstraints().
- void testSetConstraints(void);
-
- /// Test setField().
- void testSetField(void);
-
- // PROTECTED MEMBERS //////////////////////////////////////////////////
-protected :
-
- DirichletDataMulti* _data; ///< Data for testing
-
- // PRIVATE METHODS ////////////////////////////////////////////////////
-private :
-
- /** Initialize DirichletBoundaryMulti boundary condition.
- *
- * @param mesh PETSc mesh to initialize
- * @param bcA DirichletBoundary boundary condition A to initialize.
- * @param bcB DirichletBoundary boundary condition B to initialize.
- * @param bcC DirichletBoundary boundary condition C to initialize.
- */
- void _initialize(ALE::Obj<Mesh>* mesh,
- DirichletBoundary* const bcA,
- DirichletBoundary* const bcB,
- DirichletBoundary* const bcC) const;
-
-}; // class TestDirichletBoundaryMulti
-
-#endif // pylith_bc_dirichletboundarymulti_hh
-
-
-// End of file
Deleted: short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.cc 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.cc 2009-02-02 02:36:40 UTC (rev 14006)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletBoundaryMultiTet4.hh" // Implementation of class methods
-
-#include "data/DirichletDataMultiTet4.hh" // USES DirichletDataMultiTet4
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBoundaryMultiTet4 );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletBoundaryMultiTet4::setUp(void)
-{ // setUp
- _data = new DirichletDataMultiTet4();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.hh 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.hh 2009-02-02 02:36:40 UTC (rev 14006)
@@ -1,55 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletBoundaryMultiTet4.hh
- *
- * @brief C++ TestDirichletBoundary object.
- *
- * C++ unit testing for DirichletBoundary for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletboundarymultitet4_hh)
-#define pylith_bc_testdirichletboundarymultitet4_hh
-
-#include "TestDirichletBoundaryMulti.hh" // ISA TestDirichletBoundary
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletBoundaryMultiTet4;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletBoundary for mesh with 2-D tri cells.
-class pylith::bc::TestDirichletBoundaryMultiTet4 : public TestDirichletBoundaryMulti
-{ // class TestDirichletBoundary
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestDirichletBoundaryMultiTet4 );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletBoundaryMultiTet4
-
-#endif // pylith_bc_dirichletboundarymultitet4_hh
-
-
-// End of file
Deleted: short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.cc 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.cc 2009-02-02 02:36:40 UTC (rev 14006)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletBoundaryMultiTri3.hh" // Implementation of class methods
-
-#include "data/DirichletDataMultiTri3.hh" // USES DirichletDataMultiTri3
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBoundaryMultiTri3 );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletBoundaryMultiTri3::setUp(void)
-{ // setUp
- _data = new DirichletDataMultiTri3();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.hh 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.hh 2009-02-02 02:36:40 UTC (rev 14006)
@@ -1,55 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletBoundaryMultiTri3.hh
- *
- * @brief C++ TestDirichletBoundary object.
- *
- * C++ unit testing for DirichletBoundary for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletboundarymultitri3_hh)
-#define pylith_bc_testdirichletboundarymultitri3_hh
-
-#include "TestDirichletBoundaryMulti.hh" // ISA TestDirichletBoundary
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletBoundaryMultiTri3;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletBoundary for mesh with 2-D tri cells.
-class pylith::bc::TestDirichletBoundaryMultiTri3 : public TestDirichletBoundaryMulti
-{ // class TestDirichletBoundary
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestDirichletBoundaryMultiTri3 );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletBoundaryMultiTri3
-
-#endif // pylith_bc_dirichletboundarymultitri3_hh
-
-
-// End of file
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/Makefile.am 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/Makefile.am 2009-02-02 02:36:40 UTC (rev 14006)
@@ -28,6 +28,7 @@
noinst_PYTHON = \
TestMesh.py \
+ TestSubMesh.py \
TestFieldsManager.py \
TestMeshGenerator.py \
TestMeshGenSimple.py \
Added: short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestSubMesh.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestSubMesh.py (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestSubMesh.py 2009-02-02 02:36:40 UTC (rev 14006)
@@ -0,0 +1,143 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestSubMesh.py
+
+## @brief Unit testing of Mesh object.
+
+import unittest
+
+from pylith.topology.SubMesh import SubMesh
+
+# ----------------------------------------------------------------------
+class TestSubMesh(unittest.TestCase):
+ """
+ Unit testing of SubMesh object.
+ """
+
+ def test_constructorA(self):
+ """
+ Test constructor.
+ """
+ mesh = SubMesh()
+ self.assertEqual(0, mesh.dimension())
+ self.assertEqual(False, mesh.debug())
+ return
+
+
+ def test_constructorB(self):
+ """
+ Test constructor.
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+ self.assertEqual(1, submesh.dimension())
+ self.assertEqual(False, mesh.debug())
+ return
+
+
+ def test_createSubMesh(self):
+ """
+ Test createSeiveMesh().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh()
+ submesh.createSubMesh(mesh, "bc")
+ self.assertEqual(1, submesh.dimension())
+ return
+
+
+ def test_coordsys(self):
+ """
+ Test coordsys().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+ self.assertEqual(2, submesh.coordsys().spaceDim())
+ return
+
+
+ def test_debug(self):
+ """
+ Test debug().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+
+ self.assertEqual(False, submesh.debug())
+
+ submesh.debug(True)
+ self.assertEqual(True, submesh.debug())
+ return
+
+
+ def test_dimension(self):
+ """
+ Test debug().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+
+ self.assertEqual(1, submesh.dimension())
+ return
+
+
+ def test_comm(self):
+ """
+ Test comm().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+
+ comm = submesh.comm()
+ self.assertEqual(0, comm.rank)
+ self.assertEqual(1, comm.size)
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+
+ submesh.initialize()
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _getMesh(self):
+ """
+ Get mesh from file.
+ """
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs.inventory.spaceDim = 2
+ cs._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ importer = MeshIOAscii()
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
+ mesh = importer.read(normalizer, debug=False, interpolate=False)
+
+ return mesh
+
+
+# End of file
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/testdriver.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/testdriver.py 2009-02-02 01:42:34 UTC (rev 14005)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/testdriver.py 2009-02-02 02:36:40 UTC (rev 14006)
@@ -57,6 +57,9 @@
from TestMesh import TestMesh
suite.addTest(unittest.makeSuite(TestMesh))
+ from TestSubMesh import TestSubMesh
+ suite.addTest(unittest.makeSuite(TestSubMesh))
+
from TestMeshGenerator import TestMeshGenerator
suite.addTest(unittest.makeSuite(TestMeshGenerator))
More information about the CIG-COMMITS
mailing list