[cig-commits] r14263 - in short/3D/PyLith/branches/pylith-swig: libsrc/topology modulesrc/include modulesrc/materials modulesrc/topology pylith pylith/bc pylith/materials pylith/topology unittests/pytests/bc unittests/pytests/topology

brad at geodynamics.org brad at geodynamics.org
Sun Mar 8 19:11:03 PDT 2009


Author: brad
Date: 2009-03-08 19:11:03 -0700 (Sun, 08 Mar 2009)
New Revision: 14263

Added:
   short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Fields.i
   short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SolutionFields.i
   short/3D/PyLith/branches/pylith-swig/pylith/topology/Fields.py
   short/3D/PyLith/branches/pylith-swig/pylith/topology/SolutionFields.py
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestFieldBase.py
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestMeshFields.py
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestSolutionFields.py
Removed:
   short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldSubMesh.i
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestFieldsManager.py
Modified:
   short/3D/PyLith/branches/pylith-swig/libsrc/topology/Fields.hh
   short/3D/PyLith/branches/pylith-swig/libsrc/topology/Fields.icc
   short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.hh
   short/3D/PyLith/branches/pylith-swig/modulesrc/include/chararray.i
   short/3D/PyLith/branches/pylith-swig/modulesrc/materials/Makefile.am
   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/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/bc/AbsorbingDampers.py
   short/3D/PyLith/branches/pylith-swig/pylith/materials/Material.py
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestAbsorbingDampers.py
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/testdriver.py
Log:
Worked on updating Python/C++ intefaces.

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Fields.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Fields.hh	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Fields.hh	2009-03-09 02:11:03 UTC (rev 14263)
@@ -56,7 +56,7 @@
    * @param fiberDim Fiber dimension for field.
    */
   void add(const char* name,
-	   const typename field_type::DomainEnum domain,
+	   const pylith::topology::FieldBase::DomainEnum domain,
 	   const int fiberDim);
 
   /** Delete field.
@@ -65,6 +65,12 @@
    */
   void del(const char* name);
 
+  /** Delete field (without conflict with Python del).
+   *
+   * @param name Name of field.
+   */
+  void delField(const char* name);
+
   /** Get field.
    *
    * @param name Name of field.

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Fields.icc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Fields.icc	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Fields.icc	2009-03-09 02:11:03 UTC (rev 14263)
@@ -54,9 +54,9 @@
 template<typename field_type>
 void 
 pylith::topology::Fields<field_type>::add(
-			       const char* name,
-			       const typename field_type::DomainEnum domain,
-			       const int fiberDim)
+			const char* name,
+			const pylith::topology::FieldBase::DomainEnum domain,
+			const int fiberDim)
 { // add
   typename map_type::iterator iter = _fields.find(name);
   if (iter != _fields.end()) {
@@ -88,6 +88,16 @@
 } // del
 
 // ----------------------------------------------------------------------
+// Delete field.
+template<typename field_type>
+inline
+void
+pylith::topology::Fields<field_type>::delField(const char* name)
+{ // delField
+  del(name);
+} // delField
+
+// ----------------------------------------------------------------------
 // Get field.
 template<typename field_type>
 const field_type&

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.cc	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.cc	2009-03-09 02:11:03 UTC (rev 14263)
@@ -68,7 +68,7 @@
 // ----------------------------------------------------------------------
 // Create history manager for a subset of the managed fields.
 void
-pylith::topology::SolutionFields::createHistory(const char** fields,
+pylith::topology::SolutionFields::createHistory(const char* const* fields,
 						const int size)
 { // createHistory
   if (size > 0 && 0 != fields) {

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.hh	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.hh	2009-03-09 02:11:03 UTC (rev 14263)
@@ -69,7 +69,7 @@
    * @param fields Fields in history (first is most recent).
    * @param size Number of fields in history.
    */
-  void createHistory(const char** fields,
+  void createHistory(const char* const* fields,
 		     const int size);
 
   /** Shift fields in history. Handles to fields are shifted so that

Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/include/chararray.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/include/chararray.i	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/include/chararray.i	2009-03-09 02:11:03 UTC (rev 14263)
@@ -10,8 +10,8 @@
 // ======================================================================
 //
 
-// Treat const char** as a special case.
-%typemap(in) (const char** string_list) {
+// Treat const char* const* as a special case.
+%typemap(in) (const char* const* string_list) {
   // Check to make sure input is a list.
   if (PyList_Check($input)) {
     const int size = PyList_Size($input);
@@ -38,8 +38,8 @@
 }
 
 
-// Treat const char** as a special case.
-%typemap(in) (const char** string_list, const int list_len) {
+// Treat const char* const* as a special case.
+%typemap(in) (const char* const* string_list, const int list_len) {
   // Check to make sure input is a list.
   if (PyList_Check($input)) {
     const int size = PyList_Size($input);

Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/materials/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/materials/Makefile.am	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/materials/Makefile.am	2009-03-09 02:11:03 UTC (rev 14263)
@@ -13,40 +13,46 @@
 subpackage = materials
 include $(top_srcdir)/subpackage.am
 
-subpkgpyexec_LTLIBRARIES = materialsmodule.la
+subpkgpyexec_LTLIBRARIES = _materialsmodule.la
 
-materialsmodule_la_LDFLAGS = -module -avoid-version \
+subpkgpyexec_PYTHON = materials.py
+
+swig_sources = \
+	materials.i \
+	Material.i \
+	ElasticMaterial.i \
+	ElasticStrain1D.i
+
+swig_generated = \
+	materials_wrap.cxx \
+	materials.py
+
+_materialsmodule_la_LDFLAGS = -module -avoid-version \
 	$(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
 
-dist_materialsmodule_la_SOURCES = materials.pyxe.src
-nodist_materialsmodule_la_SOURCES = \
-	materials.pyxe \
-	materials.c materials_embed.cpp materials_embed.h
+dist__materialsmodule_la_SOURCES = $(swig_sources) $(swig_generated)
 
-materialsmodule_la_LIBADD = \
+_materialsmodule_la_LIBADD = \
 	$(top_builddir)/libsrc/libpylith.la \
 	-lspatialdata \
-	$(PETSC_LIB)
-
+	$(PETSC_LIBS)
 if ENABLE_CUBIT
-  materialsmodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
+  _materialsmodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
 endif
 if NO_UNDEFINED
-  materialsmodule_la_LIBADD += $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+_materialsmodule_la_LIBADD += \
+	$(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
 endif
 
-INCLUDES += -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
+INCLUDES += $(PYTHON_EGG_CPPFLAGS) -I$(NUMPY_INCDIR) -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
 
-materials.pyx materials_embed.cpp  materials_embed.h: materials.pyxe
-	pyrexembed materials.pyxe
-materials.pyxe: $(srcdir)/materials.pyxe.src
-	cp $(srcdir)/materials.pyxe.src $@
-materials_embed.cpp: materials_embed.h
-materials_embed.h: materials.pyx
+$(srcdir)/materials_wrap.cxx $(srcdir)/materials.py: $(swig_sources)
+	$(SWIG) -Wall -c++ -python $<
 
-.pyx.c:
-	pyrexc $<
 
-CLEANFILES = materials.pyxe materials.pyx materials.c *_embed.*
+MAINTAINERCLEANFILES = \
+	$(srcdir)/materials_wrap.cxx \
+	$(srcdir)/materials.py
 
+
 # End of file 

Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Field.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Field.i	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Field.i	2009-03-09 02:11:03 UTC (rev 14263)
@@ -20,28 +20,9 @@
   namespace topology {
 
     template<typename mesh_type>
-    class Field
+    class Field : public FieldBase
     { // Field
 
-      // 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
-
       // PRIVATE TYPEDEFS ///////////////////////////////////////////////
     private:
 
@@ -85,13 +66,13 @@
        *
        * @param value Type of vector field.
        */
-      void vectorFieldType(const VectorFieldEnum value);
+      void vectorFieldType(const pylith::topology::FieldBase::VectorFieldEnum value);
 
       /** Get vector field type
        *
        * @returns Type of vector field.
        */
-      VectorFieldEnum vectorFieldType(void) const;
+      pylith::topology::FieldBase::VectorFieldEnum vectorFieldType(void) const;
 
       /** Set scale for dimensionalizing field.
        *
@@ -131,7 +112,7 @@
        * @param domain Type of points over which to define section.
        * @param dim Fiber dimension for section.
        */
-      void newSection(const DomainEnum domain,
+      void newSection(const pylith::topology::FieldBase::DomainEnum domain,
 		      const int fiberDim);
 
       /** Create section with same layout (fiber dimension and

Modified: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldBase.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldBase.i	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldBase.i	2009-03-09 02:11:03 UTC (rev 14263)
@@ -11,9 +11,9 @@
 //
 
 /**
- * @file modulesrc/topology/FieldBase.hh
+ * @file modulesrc/topology/Field.hh
  *
- * @brief Python interface to C++ abstract base class FieldBase.
+ * @brief Python interface to C++ FieldBase object.
  */
 
 namespace pylith {
@@ -39,69 +39,18 @@
       enum DomainEnum {
 	VERTICES_FIELD=0, ///< FieldBase over vertices.
 	CELLS_FIELD=1, ///< FieldBase over cells.
-      }; // omainEnum
-      
+      }; // DomainEnum
+
       // PUBLIC MEMBERS /////////////////////////////////////////////////
     public :
 
-      /// Default constructor.
-      FieldBase(void);
+      FieldBase(void); ///< Default constructor.
+      ~FieldBase(void); ///< Default destructor.
 
-      /// 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 
+// End of file

Deleted: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldSubMesh.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldSubMesh.i	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldSubMesh.i	2009-03-09 02:11:03 UTC (rev 14263)
@@ -1,110 +0,0 @@
-// -*- 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 mesh associated with field.
-       *
-       * @returns Lower-dimension finite-element mesh.
-       */
-      const SubMesh& mesh(void) const;
-
-      /** 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 

Added: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Fields.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Fields.i	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Fields.i	2009-03-09 02:11:03 UTC (rev 14263)
@@ -0,0 +1,90 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/Fields.i
+ *
+ * @brief Python interface to C++ Fields object.
+ */
+
+namespace pylith {
+  namespace topology {
+
+    template<typename field_type>
+    class Fields
+    { // Fields
+
+      // PUBLIC MEMBERS /////////////////////////////////////////////////
+    public :
+
+      /** Default constructor.
+       *
+       * @param mesh Finite-element mesh.
+       */
+      Fields(const typename field_type::Mesh& mesh);
+
+      /// Destructor.
+      ~Fields(void);
+
+      /** Add field.
+       *
+       * @param name Name of field.
+       */
+      void add(const char* name);
+
+      /** Add field.
+       *
+       * @param name Name of field.
+       * @param domain Type of points over which to define field.
+       * @param fiberDim Fiber dimension for field.
+       */
+      void add(const char* name,
+	       const pylith::topology::FieldBase::DomainEnum domain,
+	       const int fiberDim);
+
+      /** Delete field.
+       *
+       * @param name Name of field.
+       */
+      void delField(const char* name);
+
+      /** Get field.
+       *
+       * @param name Name of field.
+       */
+      const field_type& get(const char* name) const;
+	   
+      /** Get field.
+       *
+       * @param name Name of field.
+       */
+      field_type& get(const char* name);
+	   
+      /** Copy layout to other fields.
+       *
+       * @param name Name of field to use as template for layout.
+       */
+      void copyLayout(const char* name);
+      
+      /** Get mesh associated with fields.
+       *
+       * @returns Finite-element mesh.
+       */
+      const typename field_type::Mesh& mesh(void) const;
+
+    }; // Fields
+
+  } // 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-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Makefile.am	2009-03-09 02:11:03 UTC (rev 14263)
@@ -24,7 +24,8 @@
 	MeshOps.i \
 	FieldBase.i \
 	Field.i \
-	FieldSubMesh.i
+	Fields.i \
+	SolutionFields.i
 
 swig_generated = \
 	topology_wrap.cxx \

Added: short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SolutionFields.i
===================================================================
--- short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SolutionFields.i	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SolutionFields.i	2009-03-09 02:11:03 UTC (rev 14263)
@@ -0,0 +1,81 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/SolutionFields.i
+ *
+ * @brief Python interface to C++ SolutionFields object.
+ */
+
+%template(SolutionFieldsBase) pylith::topology::Fields<pylith::topology::Field<pylith::topology::Mesh> >;
+
+namespace pylith {
+  namespace topology {
+
+    class SolutionFields : public Fields <Field <Mesh> >
+    { // SolutionFields
+
+      // PUBLIC MEMBERS /////////////////////////////////////////////////
+    public :
+
+      /** Default constructor.
+       *
+       * @param mesh Finite-element mesh.
+       */
+      SolutionFields(const Mesh& mesh);
+      
+      /// Destructor.
+      ~SolutionFields(void);
+      
+      /** Set name of solution field.
+       *
+       * @param name Name of field that is the solution.
+       */
+      void solutionName(const char* name);
+      
+      /** Get solution field.
+       *
+       * @returns Solution field.
+       */
+      const Field<Mesh>& solution(void) const;
+      
+      /** Get solution field.
+       *
+       * @returns Solution field.
+       */
+      Field<Mesh>& solution(void);
+      
+      /** Create history manager for a subset of the managed fields.
+       *
+       * @param fields Fields in history (first is most recent).
+       * @param size Number of fields in history.
+       */
+      %apply(const char* const* string_list, const int list_len){
+	(const char* const* fields,
+	 const int size)
+	  };
+      void createHistory(const char* const* fields,
+			 const int size);
+      %clear(const char* const* fields, const int size);
+      
+      /** Shift fields in history. Handles to fields are shifted so that
+       *  the most recent values become associated with the second most
+       *  recent item in the history, etc.
+       */
+      void shiftHistory(void);
+      
+    }; // SolutionFields
+
+  } // 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-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/modulesrc/topology/topology.i	2009-03-09 02:11:03 UTC (rev 14263)
@@ -17,10 +17,11 @@
 %{
 #include "pylith/topology/Mesh.hh"
 #include "pylith/topology/SubMesh.hh"
-// #include "pylith/topology/MeshOps.hh"
-// #include "pylith/topology/FieldBase.hh"
+#include "pylith/topology/MeshOps.hh"
+#include "pylith/topology/FieldBase.hh"
 #include "pylith/topology/Field.hh"
-// #include "pylith/topology/FieldSubMesh.hh"
+#include "pylith/topology/Fields.hh"
+#include "pylith/topology/SolutionFields.hh"
 %}
 
 %include "exception.i"
@@ -33,6 +34,7 @@
  } // exception
 
 %include "typemaps.i"
+%include "../include/chararray.i"
 
 // Numpy interface stuff
 %{
@@ -46,15 +48,17 @@
 // Interfaces
 %include "Mesh.i"
 %include "SubMesh.i"
-// %include "MeshOps.i"
-// %include "FieldBase.i"
+%include "MeshOps.i"
+%include "FieldBase.i"
 %include "Field.i"
-// %include "FieldSubMesh.i"
+%include "Fields.i"
+%include "SolutionFields.i"
 
-
 // Template instatiation
 %template(MeshField) pylith::topology::Field<pylith::topology::Mesh>;
 %template(SubMeshField) pylith::topology::Field<pylith::topology::SubMesh>;
+%template(MeshFields) pylith::topology::Fields<pylith::topology::Field<pylith::topology::Mesh> >;
+%template(SubMeshFields) pylith::topology::Fields<pylith::topology::Field<pylith::topology::SubMesh> >;
 
 // End of file
 

Modified: short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am	2009-03-09 02:11:03 UTC (rev 14263)
@@ -111,10 +111,11 @@
 	solver/SolverNonlinear.py \
 	topology/__init__.py \
 	topology/Distributor.py \
-	topology/FieldsManager.py \
 	topology/Mesh.py \
 	topology/SubMesh.py \
 	topology/Field.py \
+	topology/Fields.py \
+	topology/SolutionFields.py \
 	topology/MeshGenerator.py \
 	topology/MeshImporter.py \
 	topology/MeshRefiner.py \

Modified: short/3D/PyLith/branches/pylith-swig/pylith/bc/AbsorbingDampers.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/bc/AbsorbingDampers.py	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/pylith/bc/AbsorbingDampers.py	2009-03-09 02:11:03 UTC (rev 14263)
@@ -19,9 +19,10 @@
 
 from BoundaryCondition import BoundaryCondition
 from pylith.feassemble.Integrator import Integrator
+from bc import AbsorbingDampers as ModuleAbsorbingDampers
 
 # AbsorbingDampers class
-class AbsorbingDampers(BoundaryCondition, Integrator):
+class AbsorbingDampers(BoundaryCondition, Integrator, ModuleAbsorbingDampers):
   """
   Python object for managing absorbing boundary condition using simple
   dashpots.
@@ -102,9 +103,8 @@
     logEvent = "%sinit" % self._loggingPrefix
     self._logger.eventBegin(logEvent)
 
-    Integrator.initialize(self, totalTime, numTimeSteps, normalizer)
-    
-    self.cppHandle.quadrature = self.quadrature.cppHandle
+    ModuleAbsorbingDampers.quadrature(self.quadrature)
+    Integrator.initialize(self, totalTime, numTimeSteps, normalizer)    
     BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
 
     self._logger.eventEnd(logEvent)
@@ -122,13 +122,12 @@
     return
 
 
-  def _createCppHandle(self):
+  def _createModuleObj(self):
     """
     Create handle to corresponding C++ object.
     """
     if None == self.cppHandle:
-      import pylith.bc.bc as bindings
-      self.cppHandle = bindings.AbsorbingDampers()    
+      ModuleAbsorbingDampers.__init__(self)
     return
   
 

Modified: short/3D/PyLith/branches/pylith-swig/pylith/materials/Material.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/materials/Material.py	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/pylith/materials/Material.py	2009-03-09 02:11:03 UTC (rev 14263)
@@ -14,7 +14,7 @@
 ##
 
 ## @brief Python abstract base class for managing physical properties
-## of a material.
+## and state variables of a material.
 ##
 ## This implementation of a material associates both physical
 ## properties and a quadrature scheme with the material. Thus,
@@ -24,10 +24,11 @@
 ##
 ## Factory: material
 
+from materials import ModuleMaterial
 from pyre.components.Component import Component
 
 # Material class
-class Material(Component):
+class Material(Component, ModuleMaterial):
   """
   Python material property manager.
 
@@ -56,7 +57,7 @@
     ## \b Facilities
     ## @li \b db Database of material property parameters
     ## @li \b quadrature Quadrature object for numerical integration
-    ## @li \b initialStateDB Database for initial state.
+    ## @li \b dbInitialState Database for initial state.
 
     import pyre.inventory
 
@@ -70,15 +71,16 @@
     label.meta['tip'] = "Name of material."
 
     from spatialdata.spatialdb.SimpleDB import SimpleDB
-    db = pyre.inventory.facility("db", family="spatial_database",
-                                 factory=SimpleDB)
-    db.meta['tip'] = "Database of material property parameters."
+    dbProperties = pyre.inventory.facility("properties_db",
+                                           family="spatial_database",
+                                           factory=SimpleDB)
+    dbProperties.meta['tip'] = "Database for physical property parameters."
 
-    initialStateDB = pyre.inventory.facility("initial_state_db",
-                                              family="spatial_database",
-                                              factory=SimpleDB)
-    initialStateDB.meta['tip'] = "Database used for initial state."
-    
+    dbInitialState = pyre.inventory.facility("initial_state_db",
+                                           family="spatial_database",
+                                           factory=SimpleDB)
+    dbInitialState.meta['tip'] = "Database for initial state variables."
+
     from pylith.feassemble.quadrature.Quadrature import Quadrature
     quadrature = pyre.inventory.facility("quadrature", factory=Quadrature)
     quadrature.meta['tip'] = "Quadrature object for numerical integration."
@@ -91,8 +93,7 @@
     Constructor.
     """
     Component.__init__(self, name, facility="material")
-    self.cppHandle = None
-    self.dimension = None
+    ModuleMaterial.__init__(self)
     self.output = None
     return
 
@@ -101,9 +102,6 @@
     """
     Do pre-initialization setup.
     """
-    self._createCppHandle()
-    self.cppHandle.id = self.id
-    self.cppHandle.label = self.label
     self.quadrature.preinitialize()
     self._setupLogging()
     return
@@ -127,35 +125,11 @@
     return
   
 
-  def initialize(self, mesh, totalTime, numTimeSteps, normalizer):
-    """
-    Initialize material property manager.
-    """
-    logEvent = "%sinit" % self._loggingPrefix
-    self._logger.eventBegin(logEvent)
-
-    self._info.log("Initializing material '%s'." % self.label)
-    self.mesh = mesh
-    assert(None != self.cppHandle)
-    self.db.initialize()
-    self.cppHandle.db = self.db.cppHandle
-    self.cppHandle.normalizer = normalizer.cppHandle
-    if self.initialStateDB != None:
-      self._info.log("Initializing initial state database.")
-      self.initialStateDB.initialize()
-      self.cppHandle.initialStateDB = self.initialStateDB.cppHandle
-    self.cppHandle.initialize(mesh.cppHandle, mesh.coordsys.cppHandle,
-                              self.quadrature.cppHandle)
-
-    self._logger.eventEnd(logEvent)
-    return
-
-
   def getDataMesh(self):
     """
     Get mesh associated with data fields.
     """
-    return (self.mesh, "material-id", self.id)
+    return (self.mesh, "material-id", self.id())
 
 
   # PRIVATE METHODS ////////////////////////////////////////////////////
@@ -165,14 +139,13 @@
     Setup members using inventory.
     """
     Component._configure(self)
-    self.id = self.inventory.id
-    self.label = self.inventory.label
-    self.db = self.inventory.db
-    self.quadrature = self.inventory.quadrature
+    self.id(self.inventory.id)
+    self.label(self.inventory.label)
+    self.dbProperties(self.inventory.dbProperties)
     if self.inventory.useInitialState:
-      self.initialStateDB = self.inventory.initialStateDB
-    else:
-      self.initialStateDB = None
+      self.dbInitialState(self.inventory.dbInitialState)
+
+    self.quadrature = self.inventory.quadrature
     return
 
   

Added: short/3D/PyLith/branches/pylith-swig/pylith/topology/Fields.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/topology/Fields.py	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/pylith/topology/Fields.py	2009-03-09 02:11:03 UTC (rev 14263)
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/topology/Fields.py
+##
+## @brief Python object for managing vector fields over vertices or
+## cells of a finite-element mesh.
+
+from topology import MeshFields as ModuleMeshFields
+from topology import SubMeshFields as ModuleSubMeshFields
+
+# ----------------------------------------------------------------------
+# MeshFields class
+class MeshFields(ModuleMeshFields):
+  """
+  Python object for managing vector fields over vertices or cells of a
+  finite-element mesh.
+  """
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, mesh):
+    """
+    Constructor.
+    """
+    ModuleMeshFields.__init__(self, mesh)
+    return
+    
+
+# ----------------------------------------------------------------------
+# SubMeshFields class
+class SubMeshFields(ModuleSubMeshFields):
+  """
+  Python object for managing vector fields over vertices or cells of
+  a lower-dimension finite-element mesh.
+  """
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, mesh):
+    """
+    Constructor.
+    """
+    ModuleSubMeshFields.__init__(self, mesh)
+    return
+    
+
+# End of file

Added: short/3D/PyLith/branches/pylith-swig/pylith/topology/SolutionFields.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/topology/SolutionFields.py	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/pylith/topology/SolutionFields.py	2009-03-09 02:11:03 UTC (rev 14263)
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/topology/SolutionFields.py
+##
+## @brief Python object for managing fields associated with problem
+## solution.
+
+from topology import SolutionFields as ModuleSolutionFields
+
+# ----------------------------------------------------------------------
+# SolutionFields class
+class SolutionFields(ModuleSolutionFields):
+  """
+  Python object for managing fields associated with problem solution.
+  """
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, mesh):
+    """
+    Constructor.
+    """
+    ModuleSolutionFields.__init__(self, mesh)
+    return
+    
+
+# End of file

Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestAbsorbingDampers.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestAbsorbingDampers.py	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestAbsorbingDampers.py	2009-03-09 02:11:03 UTC (rev 14263)
@@ -24,6 +24,15 @@
   Unit testing of AbsorbingDampers object.
   """
 
+  def test_constructor(self):
+    """
+    Test constructor.
+    """
+    from pylith.bc.AbsorbingDampers import AbsorbingDampers
+    bc = AbsorbingDampers()
+    return
+
+
   def test_implementsIntegrator(self):
     """
     Test to make sure AbsorbingDampers satisfies constraint requirements.
@@ -34,15 +43,6 @@
     return
     
 
-  def test_constructor(self):
-    """
-    Test constructor.
-    """
-    from pylith.bc.AbsorbingDampers import AbsorbingDampers
-    bc = AbsorbingDampers()
-    return
-
-
   def test_initialize(self):
     """
     Test initialize().
@@ -53,8 +53,6 @@
 
     (mesh, bc, fields) = self._initialize()
 
-    self.assertNotEqual(None, bc.cppHandle)
-
     # We should really add something here to check to make sure things
     # actually initialized correctly    
     return
@@ -108,7 +106,7 @@
     """
     (mesh, bc, fields) = self._initialize()
 
-    residual = fields.getReal("residual")
+    residual = fields.get("residual")
     t = 0.02
     bc.integrateResidual(residual, t, fields)
 
@@ -127,7 +125,7 @@
 
     (mesh, bc, fields) = self._initialize()
 
-    jacobian = mesh.createMatrix(fields.getReal("residual"))
+    jacobian = mesh.createMatrix(fields.get("residual"))
     import pylith.utils.petsc as petsc
     petsc.mat_setzero(jacobian)
     t = 0.24
@@ -179,43 +177,47 @@
     """
     Initialize AbsorbingDampers boundary condition.
     """
-    from pylith.bc.AbsorbingDampers import AbsorbingDampers
-    bc = AbsorbingDampers()
-    bc._configure()
-    bc.id = 0
-    bc.label = "bc"
+    from spatialdata.spatialdb.SimpleDB import SimpleDB
+    db = SimpleDB()
+    db.inventory.label = "TestAbsorbingDampers tri3"
+    db.inventory.iohandler.inventory.filename = \
+        "data/elasticplanestrain.spatialdb"
+    db.inventory.iohandler._configure()
+    db._configure()
 
     from pylith.feassemble.FIATSimplex import FIATSimplex
     cell = FIATSimplex()
-    cell.shape = "line"
-    cell.degree = 1
-    cell.order = 1
-    from pylith.feassemble.quadrature.Quadrature1Din2D import Quadrature1Din2D
-    quadrature = Quadrature1Din2D()
+    cell.inventory.shape = "line"
+    cell.inventory.degree = 1
+    cell.inventory.order = 1
+    cell._configure()
+    from pylith.feassemble.quadrature.Quadrature import Quadrature
+    quadrature = Quadrature()
+    quadrature.inventory.cell = cell
     quadrature._configure()
-    quadrature.cell = cell
-    bc.quadrature = quadrature
 
-    from spatialdata.spatialdb.SimpleDB import SimpleDB
-    db = SimpleDB()
-    db._configure()
-    db.label = "TestAbsorbingDampers tri3"
-    db.iohandler.filename = "data/elasticplanestrain.spatialdb"
-    db.initialize()
-    bc.db = db
+    from pylith.bc.AbsorbingDampers import AbsorbingDampers
+    bc = AbsorbingDampers()
+    bc.inventory.quadrature = quadrature
+    bc.inventory.db = db
+    bc.inventory.id = 0
+    bc.inventory.label = "bc"
+    bc._configure()
 
     from spatialdata.geocoords.CSCart import CSCart
     cs = CSCart()
-    cs.spaceDim = 2
+    cs.inventory.spaceDim = 2
+    cs._configure()
 
     from spatialdata.units.Nondimensional import Nondimensional
     normalizer = Nondimensional()
-    normalizer.initialize()
+    normalizer._configure()
 
     from pylith.meshio.MeshIOAscii import MeshIOAscii
     importer = MeshIOAscii()
-    importer.filename = "data/tri3.mesh"
-    importer.coordsys = cs
+    importer.inventory.filename = "data/tri3.mesh"
+    importer.inventory.coordsys = cs
+    importer._configure()
     mesh = importer.read(normalizer, debug=False, interpolate=False)
     
     bc.preinitialize(mesh)
@@ -223,14 +225,14 @@
     bc.timeStep(0.01)
 
     # Setup fields
-    from pylith.topology.FieldsManager import FieldsManager
-    fields = FieldsManager(mesh)
-    fields.addReal("residual")
-    fields.addReal("solution")
-    fields.addReal("dispT")
-    fields.addReal("dispTmdt")
-    fields.solutionField("solution")
-    fields.createHistory(["solution", "dispT", "dispTmdt"])
+    from pylith.topology.SolutionFields import SolutionFields
+    fields = SolutionFields(mesh)
+    fields.add("residual")
+    fields.add("solution")
+    fields.add("disp t")
+    fields.add("disp t-dt")
+    fields.solutionName("solution")
+    fields.createHistory(["solution", "disp t", "disp t-dt"])
     fields.setFiberDimension("residual", cs.spaceDim)
     fields.allocate("residual")
     fields.copyLayout("residual")

Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py	2009-03-09 02:11:03 UTC (rev 14263)
@@ -135,7 +135,6 @@
     """
     from spatialdata.spatialdb.SimpleDB import SimpleDB
     db = SimpleDB()
-    db._configure()
     db.inventory.label = "TestDirichletBC tri3"
     db.inventory.iohandler.inventory.filename = "data/tri3.spatialdb"
     db.inventory.iohandler._configure()

Added: short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestFieldBase.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestFieldBase.py	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestFieldBase.py	2009-03-09 02:11:03 UTC (rev 14263)
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestFieldBase.py
+
+## @brief Unit testing of FieldBase object.
+
+import unittest
+
+from pylith.topology.topology import FieldBase
+
+# ----------------------------------------------------------------------
+class TestFieldBase(unittest.TestCase):
+  """
+  Unit testing of FieldBase object.
+  """
+
+  def test_vectorfield(self):
+    self.assertEqual(0, FieldBase.SCALAR)
+    self.assertEqual(1, FieldBase.VECTOR)
+    self.assertEqual(2, FieldBase.TENSOR)
+    self.assertEqual(3, FieldBase.OTHER)
+    self.assertEqual(4, FieldBase.MULTI_SCALAR)
+    self.assertEqual(5, FieldBase.MULTI_VECTOR)
+    self.assertEqual(6, FieldBase.MULTI_TENSOR)
+    self.assertEqual(7, FieldBase.MULTI_OTHER)
+    return
+
+
+  def test_domain(self):
+    self.assertEqual(0, FieldBase.VERTICES_FIELD)
+    self.assertEqual(1, FieldBase.CELLS_FIELD)    
+    return
+
+
+# End of file 

Deleted: short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestFieldsManager.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestFieldsManager.py	2009-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestFieldsManager.py	2009-03-09 02:11:03 UTC (rev 14263)
@@ -1,320 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-#                           Brad T. Aagaard
-#                        U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/pytests/topology/TestFieldsManager.py
-##
-## @brief Unit testing of FieldsManager object.
-
-import unittest
-
-from pylith.topology.FieldsManager import FieldsManager
-
-# ----------------------------------------------------------------------
-class TestFieldsManager(unittest.TestCase):
-  """
-  Unit testing of FieldsManager object.
-  """
-
-  def test_constructor(self):
-    """
-    Test constructor.
-    """
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-
-    self.assertNotEqual(None, manager.cppHandle)
-    return
-
-
-  def test_addReal(self):
-    """
-    Test addReal().
-
-    WARNING: This is not a rigorous test of addReal() because we
-    don't verify the results.
-    """
-
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-    manager.addReal("field")
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  def test_getReal(self):
-    """
-    Test getReal().
-
-    WARNING: This is not a rigorous test of getReal() because we
-    don't verify the results.
-    """
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-    manager.addReal("field")
-
-    field = manager.getReal("field")
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  def test_delReal(self):
-    """
-    Test delReal().
-
-    WARNING: This is not a rigorous test of delReal() because we
-    don't verify the results.
-    """
-
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-    manager.addReal("field")
-
-    manager.delReal("field")
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  def test_setFiberDimension(self):
-    """
-    Test setFiberDimension().
-
-    WARNING: This is not a rigorous test of setFiberDimension() because we
-    don't verify the results.
-    """
-
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-
-    manager.addReal("field A")
-    manager.setFiberDimension("field A", 3, "vertices")
-
-    manager.addReal("field B")
-    manager.setFiberDimension("field B", 2, "cells")
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  def test_allocate(self):
-    """
-    Test allocate().
-
-    WARNING: This is not a rigorous test of allocate() because we
-    don't verify the results.
-    """
-
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-
-    manager.addReal("field")
-    manager.setFiberDimension("field", 3, "vertices")
-    manager.allocate("field")
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  def test_copyLayout(self):
-    """
-    Test copyLayout().
-
-    WARNING: This is not a rigorous test of copyLayout() because we
-    don't verify the results.
-    """
-
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-    manager.addReal("field")
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  def test_copyLayoutFromSrc(self):
-    """
-    Test copyLayoutFromSrc().
-
-    WARNING: This is not a rigorous test of copyLayoutFromSrc() because we
-    don't verify the results.
-    """
-
-    mesh = self._initialize()
-    field = mesh.createRealSection("field", fiberDim=3)
-    mesh.allocateRealSection(field)
-
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-    manager.addReal("fieldA")
-    manager.addReal("fieldB")
-
-    manager.copyLayoutFromSrc(field)
-    
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  def test_solutionField(self):
-    """
-    Test solutionField().
-
-    WARNING: This is not a rigorous test of solutionField() because we
-    don't verify the results.
-    """
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-    
-    fields = ["field A", "field B", "field C"]
-    for field in fields:
-      manager.addReal(field)
-
-    manager.solutionField("field B")
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  def test_getSolution(self):
-    """
-    Test getSolution().
-
-    WARNING: This is not a rigorous test of getSolution() because we
-    don't verify the results.
-    """
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-    
-    fields = ["field A", "field B", "field C"]
-    for field in fields:
-      manager.addReal(field)
-
-    manager.solutionField("field B")
-    solution = manager.getSolution()
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  def test_createHistory(self):
-    """
-    Test createHistory().
-
-    WARNING: This is not a rigorous test of createHitory() because we
-    don't verify the results.
-    """
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-    
-    fields = ["field A", "field B", "field C", "field D"]
-    for field in fields:
-      manager.addReal(field)
-
-    historyFields = fields[0:2]
-    manager.createHistory(historyFields)
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  def test_shiftHistory(self):
-    """
-    Test createHistory().
-
-    WARNING: This is not a rigorous test of shitHistory() because we
-    don't verify the results.
-    """
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-    
-    fields = ["field A", "field B"]
-    for field in fields:
-      manager.addReal(field)
-
-    manager.createHistory(fields)
-    manager.shiftHistory()
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  def test_getFieldByHistory(self):
-    """
-    Test createHistory().
-
-    WARNING: This is not a rigorous test of getFieldByHistory() because we
-    don't verify the results.
-    """
-    mesh = self._initialize()
-    from pylith.topology.FieldsManager import FieldsManager
-    manager = FieldsManager(mesh)
-    
-    fields = ["field A", "field B", "field C"]
-    for field in fields:
-      manager.addReal(field)
-
-    manager.createHistory(fields)
-    for i in [0, 2, 1]:
-      field = manager.getFieldByHistory(i)
-
-    # We should really add something here to check to make sure things
-    # actually initialized correctly.
-    return
-
-
-  # PRIVATE METHODS ////////////////////////////////////////////////////
-
-  def _initialize(self):
-    """
-    Initialize mesh.
-    """
-    from spatialdata.geocoords.CSCart import CSCart
-    cs = CSCart()
-    cs.spaceDim = 2
-
-    from spatialdata.units.Nondimensional import Nondimensional
-    normalizer = Nondimensional()
-    normalizer.initialize()    
-
-    from pylith.meshio.MeshIOAscii import MeshIOAscii
-    importer = MeshIOAscii()
-    importer.filename = "data/tri3.mesh"
-    importer.coordsys = cs
-    mesh = importer.read(normalizer, debug=False, interpolate=False)
-    
-    return mesh
-
-
-# End of file 

Added: short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestMeshFields.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestMeshFields.py	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestMeshFields.py	2009-03-09 02:11:03 UTC (rev 14263)
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestMeshFields.py
+
+## @brief Unit testing of MeshFields object.
+
+import unittest
+
+from pylith.topology.Fields import MeshFields
+
+# ----------------------------------------------------------------------
+class TestMeshFields(unittest.TestCase):
+  """
+  Unit testing of MeshFields object.
+  """
+
+  def setUp(self):
+    """
+    Setup mesh and associated field.
+    """
+    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()
+    self.mesh = importer.read(normalizer, debug=False, interpolate=False)
+    
+    self.fields = MeshFields(self.mesh)
+    return
+
+
+  def test_constructorA(self):
+    """
+    Test constructor.
+    """
+    return
+
+
+  def test_mesh(self):
+    """
+    Test mesh().
+    """
+    mesh = self.fields.mesh()
+    
+    self.assertEqual(2, mesh.dimension())
+    return
+
+
+  def test_add(self):
+    self.fields.add("field")
+    field = self.fields.get("field")
+    field.newSection()
+
+    self.assertEqual(2, field.spaceDim())
+    return
+
+
+  def test_addFiberDim(self):
+    from pylith.topology.topology import FieldBase
+    self.fields.add("field", )
+    field = self.fields.get("field")
+    field.newSection(FieldBase.VERTICES_FIELD, 4)
+
+    self.assertEqual(2, field.spaceDim())
+    return
+
+
+  def test_del(self):
+    self.fields.add("field A")
+    self.fields.add("field B")
+    self.fields.delField("field A")
+    field = self.fields.get("field B")
+    return
+
+
+  def test_copyLayout(self):
+    from pylith.topology.topology import FieldBase
+    self.fields.add("field A")
+    field = self.fields.get("field A")
+    field.newSection(FieldBase.VERTICES_FIELD, 4)
+
+    self.fields.add("field B")
+    self.fields.copyLayout("field A")
+
+    # No test of result
+    return
+
+
+# End of file 

Added: short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestSolutionFields.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestSolutionFields.py	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestSolutionFields.py	2009-03-09 02:11:03 UTC (rev 14263)
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestSolutionFields.py
+
+## @brief Unit testing of SolutionFields object.
+
+import unittest
+
+from pylith.topology.SolutionFields import SolutionFields
+
+# ----------------------------------------------------------------------
+class TestSolutionFields(unittest.TestCase):
+  """
+  Unit testing of SolutionFields object.
+  """
+
+  def setUp(self):
+    """
+    Setup mesh and associated field.
+    """
+    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()
+    self.mesh = importer.read(normalizer, debug=False, interpolate=False)
+    
+    self.fields = SolutionFields(self.mesh)
+    return
+
+
+  def test_constructor(self):
+    """
+    Test constructor.
+    """
+    return
+
+
+  def test_solutionName(self):
+    """
+    Test mesh().
+    """
+    fields = self.fields
+    fields.add("field A");
+    fields.add("field B");
+    fields.add("field C");
+    
+    fields.solutionName("field B")
+    return
+
+
+  def test_solution(self):
+    """
+    Test solution().
+    """
+    fields = self.fields
+    fields.add("field A");
+    fields.add("field B");
+    fields.add("field C");
+    
+    fields.solutionName("field B")
+    solution = self.fields.solution()
+    return
+
+
+  def test_createHistory(self):
+    """
+    Test createHistory().
+    """
+    fields = self.fields
+    fields.add("field A");
+    fields.add("field B");
+    fields.add("field C");
+    
+    fields.createHistory(["field B", "field A", "field C"])
+    return
+
+
+  def test_shiftHistory(self):
+    """
+    Test shiftHistory().
+    """
+    fields = self.fields
+    fields.add("field A");
+    fields.add("field B");
+    fields.add("field C");
+    
+    fields.createHistory(["field B", "field A", "field C"])
+    fields.shiftHistory()
+    return
+
+
+# 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-03-08 22:38:48 UTC (rev 14262)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/testdriver.py	2009-03-09 02:11:03 UTC (rev 14263)
@@ -60,18 +60,24 @@
     from TestSubMesh import TestSubMesh
     suite.addTest(unittest.makeSuite(TestSubMesh))
 
+    from TestFieldBase import TestFieldBase
+    suite.addTest(unittest.makeSuite(TestFieldBase))
+
     from TestMeshField import TestMeshField
     suite.addTest(unittest.makeSuite(TestMeshField))
 
+    from TestMeshFields import TestMeshFields
+    suite.addTest(unittest.makeSuite(TestMeshFields))
+
+    from TestSolutionFields import TestSolutionFields
+    suite.addTest(unittest.makeSuite(TestSolutionFields))
+
     from TestMeshGenerator import TestMeshGenerator
     suite.addTest(unittest.makeSuite(TestMeshGenerator))
 
     from TestMeshImporter import TestMeshImporter
     suite.addTest(unittest.makeSuite(TestMeshImporter))
 
-    #from TestFieldsManager import TestFieldsManager
-    #suite.addTest(unittest.makeSuite(TestFieldsManager))
-
     return suite
 
 



More information about the CIG-COMMITS mailing list