[cig-commits] r13957 - in short/3D/PyLith/branches/pylith-swig: libsrc/topology pylith pylith/bc unittests/libtests/topology unittests/pytests/bc

brad at geodynamics.org brad at geodynamics.org
Mon Jan 26 11:43:50 PST 2009


Author: brad
Date: 2009-01-26 11:43:49 -0800 (Mon, 26 Jan 2009)
New Revision: 13957

Added:
   short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletBC.py
Removed:
   short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletPoints.py
Modified:
   short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh
   short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.hh
   short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am
   short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletBoundary.py
   short/3D/PyLith/branches/pylith-swig/pylith/bc/__init__.py
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.hh
   short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py
Log:
Worked on Field, Mesh, and DirichletBC.

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc	2009-01-26 05:47:02 UTC (rev 13956)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc	2009-01-26 19:43:49 UTC (rev 13957)
@@ -63,8 +63,8 @@
 // Create sieve section and set chart and fiber dimesion.
 void
 pylith::topology::Field::newSection(
-			    const ALE::Obj<SieveMesh::label_sequence>& points,
-			    const int fiberDim)
+			  const ALE::Obj<SieveMesh::label_sequence>& points,
+			  const int fiberDim)
 { // newSection
   if (fiberDim < 0) {
     std::ostringstream msg;
@@ -86,6 +86,25 @@
 } // newSection
 
 // ----------------------------------------------------------------------
+// Create sieve section and set chart and fiber dimesion.
+void
+pylith::topology::Field::newSection(const DomainEnum domain,
+				    const int fiberDim)
+{ // newSection
+  ALE::Obj<SieveMesh::label_sequence> points;
+  if (VERTICES_FIELD == domain)
+    points = _mesh->depthStratum(0);
+  else if (CELLS_FIELD == domain)
+    points = _mesh->heightStratum(1);
+  else {
+    std::cerr << "Unknown value for DomainEnum: " << domain << std::endl;
+    assert(0);
+  } // else
+
+  newSection(points, fiberDim);
+} // newSection
+
+// ----------------------------------------------------------------------
 // Create section given atlas.
 void
 pylith::topology::Field::copyLayout(const Field& src)
@@ -117,6 +136,16 @@
 } // clear
 
 // ----------------------------------------------------------------------
+// Allocate Sieve section.
+void
+pylith::topology::Field::allocate(void)
+{ // allocate
+  assert(!_section.isNull());
+
+  _mesh->allocate(_section);
+} // allocate
+
+// ----------------------------------------------------------------------
 // Zero section values.
 void
 pylith::topology::Field::zero(void)

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh	2009-01-26 05:47:02 UTC (rev 13956)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh	2009-01-26 19:43:49 UTC (rev 13957)
@@ -55,6 +55,11 @@
     MULTI_OTHER=7, ///< Not a scalar, vector, or tensor at multiple points.
   }; // VectorFieldEnum
 
+  enum DomainEnum {
+    VERTICES_FIELD=0, ///< Field over vertices.
+    CELLS_FIELD=1, ///< Field over cells.
+  }; // omainEnum
+
 // PUBLIC MEMBERS ///////////////////////////////////////////////////////
 public :
 
@@ -133,12 +138,21 @@
   /** Create sieve section and set chart and fiber dimesion.
 
    *
-   * @param points Mesh points over which to define section.
+   * @param points Points over which to define section.
    * @param dim Fiber dimension for section.
    */
   void newSection(const ALE::Obj<SieveMesh::label_sequence>& points,
 		  const int fiberDim);
 
+  /** 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
@@ -151,6 +165,9 @@
   /// Clear variables associated with section.
   void clear(void);
 
+  /// Allocate field.
+  void allocate(void);
+
   /// Zero section values.
   void zero(void);
 

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.cc	2009-01-26 05:47:02 UTC (rev 13956)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.cc	2009-01-26 19:43:49 UTC (rev 13957)
@@ -70,5 +70,51 @@
     _coordsys->initialize();
 } // initialize
 
+// ----------------------------------------------------------------------
+// Create boundary mesh from mesh and label.
+void
+pylith::topology::Mesh::boundaryMeshFromMesh(const char* label)
+{ // boundaryMeshFromMesh
+#if 0
+  assert(!_mesh.isNull());
 
+  const ALE::Obj<SieveMesh::int_section_type>& groupField = 
+    _mesh->getIntSection(_label);
+  if (groupField.isNull()) {
+    std::ostringstream msg;
+    msg << "Could not find group of points '" << label << "' in mesh.";
+    throw std::runtime_error(msg.str());
+  } // if
+  ALE::Obj<SubSieveMesh> boundarySieveMesh = 
+    ALE::Selection<SieveMesh>::submeshV<SieveSubMesh>(_mesh, groupField);
+  if (boundarySieveMesh.isNull()) {
+    std::ostringstream msg;
+    msg << "Could not construct boundary mesh for boundary '"
+	<< label << "'.";
+    throw std::runtime_error(msg.str());
+  } // if
+  boundarySieveMesh->setRealSection("coordinates", 
+				    _mesh->getRealSection("coordinates"));
+
+  // Create the parallel overlap
+  ALE::Obj<SieveSubMesh::send_overlap_type> sendParallelMeshOverlap =
+    boundarySieveMesh->getSendOverlap();
+  ALE::Obj<SieveSubMesh::recv_overlap_type> recvParallelMeshOverlap =
+    boundarySieveMesh->getRecvOverlap();
+  SieveMesh::renumbering_type& renumbering = _mesh->getRenumbering();
+  //   Can I figure this out in a nicer way?
+  ALE::SetFromMap<std::map<SieveMesh::point_type,SieveMesh::point_type> > globalPoints(renumbering);
+
+  ALE::OverlapBuilder<>::constructOverlap(globalPoints, renumbering,
+					  sendParallelMeshOverlap,
+					  recvParallelMeshOverlap);
+  boundarySieveMesh->setCalculatedOverlap(true);
+
+  Mesh boundaryMesh;
+
+  return boundaryMesh
+#endif
+} // createBoundaryMesh
+
+
 // End of file 

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.hh	2009-01-26 05:47:02 UTC (rev 13956)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Mesh.hh	2009-01-26 19:43:49 UTC (rev 13957)
@@ -131,6 +131,12 @@
    */
   void view(const char* label);
 
+  /** Create boundary mesh from mesh and label.
+   *
+   * @param label Label for group of vertices forming boundary.
+   */
+  Mesh createBoundaryMesh(const char* label);
+
 // PRIVATE MEMBERS //////////////////////////////////////////////////////
 private :
 

Modified: short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am	2009-01-26 05:47:02 UTC (rev 13956)
+++ short/3D/PyLith/branches/pylith-swig/pylith/Makefile.am	2009-01-26 19:43:49 UTC (rev 13957)
@@ -16,7 +16,7 @@
 	bc/__init__.py \
 	bc/AbsorbingDampers.py \
 	bc/BoundaryCondition.py \
-	bc/DirichletPoints.py \
+	bc/DirichletBC.py \
 	bc/DirichletBoundary.py \
 	bc/FixedDOFDB.py \
 	bc/Neumann.py \

Copied: short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletBC.py (from rev 13956, short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletPoints.py)
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletBC.py	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletBC.py	2009-01-26 19:43:49 UTC (rev 13957)
@@ -0,0 +1,172 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/bc/DirichletBC.py
+##
+## @brief Python object for managing a Dirichlet (prescribed
+## displacements) boundary condition with a set of points.
+##
+## Factory: boundary_condition
+
+from BoundaryCondition import BoundaryCondition
+from pylith.feassemble.Constraint import Constraint
+from bc import DirichletBC as ModuleDirichletBC
+
+def validateDOF(value):
+  """
+  Validate list of fixed degrees of freedom.
+  """
+  try:
+    size = len(value)
+    num = map(int, value)
+    for v in num:
+      if v < 0:
+        raise ValueError
+  except:
+    raise ValueError, \
+          "'fixed_dof' must be a zero based list of indices of fixed " \
+          "degrees of freedom."
+  return num
+  
+
+# DirichletBC class
+class DirichletBC(BoundaryCondition, Constraint, ModuleDirichletBC):
+  """
+  Python object for managing a DirichletBC (prescribed displacements)
+  boundary condition.
+
+  Factory: boundary_condition
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(BoundaryCondition.Inventory):
+    """
+    Python object for managing BoundaryCondition facilities and properties.
+    """
+    
+    ## @class Inventory
+    ## Python object for managing BoundaryCondition facilities and properties.
+    ##
+    ## \b Properties
+    ## @li \b fixed_dof Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc).
+    ## @li \b reference_t Reference time for rate of change of values.
+    ##
+    ## \b Facilities
+    ## @li \b initial_db Database of parameters for initial values.
+    ## @li \b rate_db Database of parameters for rate of change of values.
+
+    import pyre.inventory
+
+    fixedDOF = pyre.inventory.list("fixed_dof", default=[],
+                                   validator=validateDOF)
+    fixedDOF.meta['tip'] = "Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc)."
+
+    from pyre.units.time import s
+    tRef = pyre.inventory.dimensional("reference_t", default=0.0*s)
+    tRef.meta['tip'] = "Reference time for rate of change of values."
+
+    from FixedDOFDB import FixedDOFDB
+    db = pyre.inventory.facility("db", factory=FixedDOFDB,
+                                 family="spatial_database")
+    db.meta['tip'] = "Database of parameters for initial values."
+
+    dbRate = pyre.inventory.facility("rate_db", factory=FixedDOFDB,
+                                 family="spatial_database")
+    dbRate.meta['tip'] = "Database of parameters for rate of change of values."
+    
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="dirichletpoints"):
+    """
+    Constructor.
+    """
+    BoundaryCondition.__init__(self, name)
+    Constraint.__init__(self)
+    self._loggingPrefix = "DiBC "
+    return
+
+
+  def preinitialize(self, mesh):
+    """
+    Do pre-initialization setup.
+    """
+    BoundaryCondition.preinitialize(self, mesh)
+    Constraint.preinitialize(self, mesh)
+    self.dbRate(self.inventory.dbRate)
+    self.fixedDOF(self.inventory.fixedDOF)
+    return
+
+
+  def verifyConfiguration(self):
+    """
+    Verify compatibility of configuration.
+    """
+    logEvent = "%sverify" % self._loggingPrefix
+    self._logger.eventBegin(logEvent)
+
+    BoundaryCondition.verifyConfiguration(self)
+    Constraint.verifyConfiguration(self)
+
+    self._logger.eventEnd(logEvent)
+    return
+
+
+  def initialize(self, totalTime, numTimeSteps, normalizer):
+    """
+    Initialize DirichletBC boundary condition.
+    """
+    logEvent = "%sinit" % self._loggingPrefix
+    self._logger.eventBegin(logEvent)
+
+    timeScale = normalizer.timeScale()
+    tRef = normalizer.nondimensionalize(self.inventory.tRef, timeScale)
+    self.referenceTime(tRef)
+    
+    self.normalizer(normalizer)
+
+    BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
+
+    self._logger.eventEnd(logEvent)    
+    return
+  
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Setup members using inventory.
+    """
+    BoundaryCondition._configure(self)
+    return
+
+
+  def _createModuleObj(self):
+    """
+    Create handle to corresponding C++ object.
+    """
+    if None == self.this:
+      ModuleDirichletBC.__init__(self)
+    return
+  
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def boundary_condition():
+  """
+  Factory associated with DirichletBC.
+  """
+  return DirichletBC()
+
+  
+# End of file 

Modified: short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletBoundary.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletBoundary.py	2009-01-26 05:47:02 UTC (rev 13956)
+++ short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletBoundary.py	2009-01-26 19:43:49 UTC (rev 13957)
@@ -17,28 +17,12 @@
 ##
 ## Factory: boundary_condition
 
-from BoundaryCondition import BoundaryCondition
-from pylith.feassemble.Constraint import Constraint
+from DirichletBC import DirichletBC
+from DicihletBC import validateDOF
+from bc import DirichletBoundary as ModuleDirichletBoundary
 
-def validateDOF(value):
-  """
-  Validate list of fixed degrees of freedom.
-  """
-  try:
-    size = len(value)
-    num = map(int, value)
-    for v in num:
-      if v < 0:
-        raise ValueError
-  except:
-    raise ValueError, \
-          "'fixed_dof' must be a zero based list of indices of fixed " \
-          "degrees of freedom."
-  return num
-  
-
 # DirichletBoundary class
-class DirichletBoundary(BoundaryCondition, Constraint):
+class DirichletBoundary(DirichletBC, ModuleDirichletBoundary):
   """
   Python object for managing a DirichletBoundary (prescribed displacements)
   boundary condition with points on a surface.
@@ -57,33 +41,13 @@
     ## Python object for managing BoundaryCondition facilities and properties.
     ##
     ## \b Properties
-    ## @li \b fixed_dof Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc).
-    ## @li \b reference_t Reference time for rate of change of values.
+    ## @li None
     ##
     ## \b Facilities
-    ## @li \b initial_db Database of parameters for initial values.
-    ## @li \b rate_db Database of parameters for rate of change of values.
     ## @li \b output Output manager associated with diagnostic output.
 
     import pyre.inventory
 
-    fixedDOF = pyre.inventory.list("fixed_dof", default=[],
-                                   validator=validateDOF)
-    fixedDOF.meta['tip'] = "Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc)."
-
-    from pyre.units.time import s
-    tRef = pyre.inventory.dimensional("reference_t", default=0.0*s)
-    tRef.meta['tip'] = "Reference time for rate of change of values."
-
-    from FixedDOFDB import FixedDOFDB
-    db = pyre.inventory.facility("db", factory=FixedDOFDB,
-                                 family="spatial_database")
-    db.meta['tip'] = "Database of parameters for initial values."
-
-    dbRate = pyre.inventory.facility("rate_db", factory=FixedDOFDB,
-                                 family="spatial_database")
-    dbRate.meta['tip'] = "Database of parameters for rate of change of values."
-
     from pylith.meshio.OutputDirichlet import OutputDirichlet
     output = pyre.inventory.facility("output", family="output_manager",
                                      factory=OutputDirichlet)
@@ -96,10 +60,8 @@
     """
     Constructor.
     """
-    BoundaryCondition.__init__(self, name)
-    Constraint.__init__(self)
+    DirichletBC.__init__(self, name)
     self._loggingPrefix = "DiBC "
-    self.fixedDOF = []
     self.availableFields = \
         {'vertex': \
            {'info': ["initial", "rate-of-change"],
@@ -114,9 +76,7 @@
     """
     Do pre-initialization setup.
     """
-    BoundaryCondition.preinitialize(self, mesh)
-    Constraint.preinitialize(self, mesh)
-    self.cppHandle.fixedDOF = self.fixedDOF
+    DirichletBC.preinitialize(self, mesh)
     self.output.preinitialize(self)
     return
 
@@ -128,8 +88,7 @@
     logEvent = "%sverify" % self._loggingPrefix
     self._logger.eventBegin(logEvent)
 
-    BoundaryCondition.verifyConfiguration(self)
-    Constraint.verifyConfiguration(self)
+    DichletBC.verifyConfiguration(self)
     self.output.verifyConfiguration(self.mesh)
 
     self._logger.eventEnd(logEvent)
@@ -142,23 +101,9 @@
     """
     logEvent = "%sinit" % self._loggingPrefix
     self._logger.eventBegin(logEvent)
-    
-    timeScale = normalizer.timeScale()
-    self.tRef = normalizer.nondimensionalize(self.tRef, timeScale)
-    
-    assert(None != self.cppHandle)
-    self.cppHandle.referenceTime = self.tRef
-    self.dbRate.initialize()
-    self.cppHandle.dbRate = self.dbRate.cppHandle
-    self.cppHandle.normalizer = normalizer.cppHandle
 
-    BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
+    DirichletBC.initialize(self, totalTime, numTimeSteps, normalizer)
 
-    from pylith.topology.Mesh import Mesh
-    self.boundaryMesh = Mesh()
-    self.boundaryMesh.initialize(self.mesh.coordsys)
-    self.cppHandle.boundaryMesh(self.boundaryMesh.cppHandle)
-
     self.output.initialize(normalizer)
     self.output.writeInfo()
 
@@ -170,7 +115,9 @@
     """
     Get mesh associated with data fields.
     """
-    return (self.boundaryMesh, None, None)
+    label = ""
+    labelId = 0
+    return (self.boundaryMesh(), label, labelId)
 
 
   def getVertexField(self, name, fields=None):
@@ -178,13 +125,10 @@
     Get vertex field.
     """
     if None == fields:
-      (field, fieldType) = self.cppHandle.vertexField(name,
-                                                      self.mesh.cppHandle)
+      field = self.vertexField(name, self.mesh)
     else:
-      (field, fieldType) = self.cppHandle.vertexField(name,
-                                                     self.mesh.cppHandle,
-                                                     fields.cppHandle)
-    return (field, fieldType)
+      field = self.vertexField(name, self.mesh, fields)
+    return field
 
 
   # PRIVATE METHODS ////////////////////////////////////////////////////
@@ -194,20 +138,16 @@
     Setup members using inventory.
     """
     BoundaryCondition._configure(self)
-    self.tRef = self.inventory.tRef
-    self.fixedDOF = self.inventory.fixedDOF
-    self.dbRate = self.inventory.dbRate
     self.output = self.inventory.output
     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.DirichletBoundary()    
+    if None == self.this:
+      ModuleDirichletBoundary.__init__(self)
     return
   
 

Deleted: short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletPoints.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletPoints.py	2009-01-26 05:47:02 UTC (rev 13956)
+++ short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletPoints.py	2009-01-26 19:43:49 UTC (rev 13957)
@@ -1,178 +0,0 @@
-#!/usr/bin/env python
-#
-# ----------------------------------------------------------------------
-#
-#                           Brad T. Aagaard
-#                        U.S. Geological Survey
-#
-# <LicenseText>
-#
-# ----------------------------------------------------------------------
-#
-
-## @file pylith/bc/DirichletPoints.py
-##
-## @brief Python object for managing a Dirichlet (prescribed
-## displacements) boundary condition with a set of points.
-##
-## Factory: boundary_condition
-
-from BoundaryCondition import BoundaryCondition
-from pylith.feassemble.Constraint import Constraint
-
-def validateDOF(value):
-  """
-  Validate list of fixed degrees of freedom.
-  """
-  try:
-    size = len(value)
-    num = map(int, value)
-    for v in num:
-      if v < 0:
-        raise ValueError
-  except:
-    raise ValueError, \
-          "'fixed_dof' must be a zero based list of indices of fixed " \
-          "degrees of freedom."
-  return num
-  
-
-# DirichletPoints class
-class DirichletPoints(BoundaryCondition, Constraint):
-  """
-  Python object for managing a DirichletPoints (prescribed displacements)
-  boundary condition.
-
-  Factory: boundary_condition
-  """
-
-  # INVENTORY //////////////////////////////////////////////////////////
-
-  class Inventory(BoundaryCondition.Inventory):
-    """
-    Python object for managing BoundaryCondition facilities and properties.
-    """
-    
-    ## @class Inventory
-    ## Python object for managing BoundaryCondition facilities and properties.
-    ##
-    ## \b Properties
-    ## @li \b fixed_dof Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc).
-    ## @li \b reference_t Reference time for rate of change of values.
-    ##
-    ## \b Facilities
-    ## @li \b initial_db Database of parameters for initial values.
-    ## @li \b rate_db Database of parameters for rate of change of values.
-
-    import pyre.inventory
-
-    fixedDOF = pyre.inventory.list("fixed_dof", default=[],
-                                   validator=validateDOF)
-    fixedDOF.meta['tip'] = "Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc)."
-
-    from pyre.units.time import s
-    tRef = pyre.inventory.dimensional("reference_t", default=0.0*s)
-    tRef.meta['tip'] = "Reference time for rate of change of values."
-
-    from FixedDOFDB import FixedDOFDB
-    db = pyre.inventory.facility("db", factory=FixedDOFDB,
-                                 family="spatial_database")
-    db.meta['tip'] = "Database of parameters for initial values."
-
-    dbRate = pyre.inventory.facility("rate_db", factory=FixedDOFDB,
-                                 family="spatial_database")
-    dbRate.meta['tip'] = "Database of parameters for rate of change of values."
-    
-
-  # PUBLIC METHODS /////////////////////////////////////////////////////
-
-  def __init__(self, name="dirichletpoints"):
-    """
-    Constructor.
-    """
-    BoundaryCondition.__init__(self, name)
-    Constraint.__init__(self)
-    self._loggingPrefix = "DiBC "
-    self.fixedDOF = []
-    return
-
-
-  def preinitialize(self, mesh):
-    """
-    Do pre-initialization setup.
-    """
-    BoundaryCondition.preinitialize(self, mesh)
-    Constraint.preinitialize(self, mesh)
-    self.cppHandle.fixedDOF = self.fixedDOF    
-    return
-
-
-  def verifyConfiguration(self):
-    """
-    Verify compatibility of configuration.
-    """
-    logEvent = "%sverify" % self._loggingPrefix
-    self._logger.eventBegin(logEvent)
-
-    BoundaryCondition.verifyConfiguration(self)
-    Constraint.verifyConfiguration(self)
-
-    self._logger.eventEnd(logEvent)
-    return
-
-
-  def initialize(self, totalTime, numTimeSteps, normalizer):
-    """
-    Initialize DirichletPoints boundary condition.
-    """
-    logEvent = "%sinit" % self._loggingPrefix
-    self._logger.eventBegin(logEvent)
-
-    timeScale = normalizer.timeScale()
-    self.tRef = normalizer.nondimensionalize(self.tRef, timeScale)
-    
-    assert(None != self.cppHandle)
-    self.cppHandle.referenceTime = self.tRef
-    self.dbRate.initialize()
-    self.cppHandle.dbRate = self.dbRate.cppHandle
-    self.cppHandle.normalizer = normalizer.cppHandle
-
-    BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
-
-    self._logger.eventEnd(logEvent)    
-    return
-  
-
-  # PRIVATE METHODS ////////////////////////////////////////////////////
-
-  def _configure(self):
-    """
-    Setup members using inventory.
-    """
-    BoundaryCondition._configure(self)
-    self.tRef = self.inventory.tRef
-    self.fixedDOF = self.inventory.fixedDOF
-    self.dbRate = self.inventory.dbRate
-    return
-
-
-  def _createCppHandle(self):
-    """
-    Create handle to corresponding C++ object.
-    """
-    if None == self.cppHandle:
-      import pylith.bc.bc as bindings
-      self.cppHandle = bindings.DirichletPoints()    
-    return
-  
-
-# FACTORIES ////////////////////////////////////////////////////////////
-
-def boundary_condition():
-  """
-  Factory associated with DirichletPoints.
-  """
-  return DirichletPoints()
-
-  
-# End of file 

Modified: short/3D/PyLith/branches/pylith-swig/pylith/bc/__init__.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/bc/__init__.py	2009-01-26 05:47:02 UTC (rev 13956)
+++ short/3D/PyLith/branches/pylith-swig/pylith/bc/__init__.py	2009-01-26 19:43:49 UTC (rev 13957)
@@ -16,8 +16,8 @@
 
 __all__ = ['AbsorbingDampers',
            'BoundaryCondition',
+           'DirichletBC',
            'DirichletBoundary',
-           'DirichletPoints',
            'FixedDOFDB',
            'Neumann',
            ]

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc	2009-01-26 05:47:02 UTC (rev 13956)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc	2009-01-26 19:43:49 UTC (rev 13957)
@@ -75,19 +75,23 @@
 void
 pylith::topology::TestField::testSectionPoints(void)
 { // testSectionPoints
+  const int fiberDim = 2;
+
   Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
 
-  Field field(sieveMesh);
-
-  const ALE::Obj<SieveMesh::real_section_type>& section = field.section();
-  CPPUNIT_ASSERT(section.isNull());
-
+  Field fieldA(sieveMesh);
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
-  field.newSection();
-  CPPUNIT_ASSERT(!section.isNull());
+  fieldA.newSection(vertices, fiberDim);
+  const ALE::Obj<SieveMesh::real_section_type>& sectionA = fieldA.section();
+  CPPUNIT_ASSERT(!sectionA.isNull());
+
+  Field fieldB(sieveMesh);
+  fieldB.newSection(Field::VERTICES_FIELD, fiberDim);
+  const ALE::Obj<SieveMesh::real_section_type>& sectionB = fieldB.section();
+  CPPUNIT_ASSERT(!sectionB.isNull());
 } // testSectionPoints
 
 // ----------------------------------------------------------------------
@@ -183,6 +187,8 @@
     
   Mesh mesh;
   _buildMesh(&mesh);
+  
+
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
@@ -190,19 +196,14 @@
   // Create field with atlas to use to create new field
   Field fieldSrc(sieveMesh);
   { // Setup source field
-    fieldSrc.newSection();
+    fieldSrc.newSection(Field::VERTICES_FIELD, fiberDim);
     const ALE::Obj<SieveRealSection>& section = fieldSrc.section();
-    const int spaceDim = _TestField::cellDim;
-    section->setChart(SieveMesh::real_section_type::chart_type(
-		  *std::min_element(vertices->begin(), vertices->end()),
-		  *std::max_element(vertices->begin(), vertices->end())+1));
-    section->setFiberDimension(vertices, fiberDim);
     int iV=0;
     for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
 	 v_iter != vertices->end();
 	 ++v_iter)
       section->addConstraintDimension(*v_iter, nconstraints[iV++]);
-    sieveMesh->allocate(section);
+    fieldSrc.allocate();
   } // Setup source field
 
   Field field(sieveMesh);
@@ -239,6 +240,53 @@
 } // testClear
 
 // ----------------------------------------------------------------------
+// Test allocate().
+void
+pylith::topology::TestField::testAllocate(void)
+{ // testZero
+  const int fiberDim = 3;
+  const double scale = 2.0;
+  const double valuesNondim[] = {
+    1.1, 2.2, 3.3,
+    1.2, 2.3, 3.4,
+    1.3, 2.4, 3.5,
+    1.4, 2.5, 3.6,
+  };
+
+  Mesh mesh;
+  _buildMesh(&mesh);
+  const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+  const ALE::Obj<SieveMesh::label_sequence>& vertices = 
+    sieveMesh->depthStratum(0);
+
+  Field field(sieveMesh);
+  field.newSection(Field::VERTICES_FIELD, fiberDim);
+  field.allocate();
+  const ALE::Obj<SieveRealSection>& section = field.section();
+
+  double_array values(fiberDim);
+  int i = 0;
+  for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != vertices->end();
+       ++v_iter) {
+    for (int iDim=0; iDim < fiberDim; ++iDim)
+      values[iDim] = valuesNondim[i++];
+    section->updatePoint(*v_iter, &values[0]);
+  } // for
+
+  const double tolerance = 1.0e-6;
+  i = 0;
+  for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != vertices->end();
+       ++v_iter) {
+    section->restrictPoint(*v_iter, &values[0], values.size());
+    for (int iDim=0; iDim < fiberDim; ++iDim) {
+      CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesNondim[i++], values[iDim], tolerance);
+    } // for
+  } // for
+} // testZero
+
+// ----------------------------------------------------------------------
 // Test zero().
 void
 pylith::topology::TestField::testZero(void)
@@ -259,15 +307,9 @@
     sieveMesh->depthStratum(0);
 
   Field field(sieveMesh);
-  field.newSection();
+  field.newSection(Field::VERTICES_FIELD, fiberDim);
+  field.allocate();
   const ALE::Obj<SieveRealSection>& section = field.section();
-  const int spaceDim = _TestField::cellDim;
-    
-  section->setChart(SieveMesh::real_section_type::chart_type(
-		  *std::min_element(vertices->begin(), vertices->end()),
-		  *std::max_element(vertices->begin(), vertices->end())+1));
-  section->setFiberDimension(vertices, fiberDim);
-  sieveMesh->allocate(section);
 
   double_array values(fiberDim);
   int i = 0;
@@ -313,15 +355,9 @@
     sieveMesh->depthStratum(0);
 
   Field field(sieveMesh);
-  field.newSection();
+  field.newSection(Field::VERTICES_FIELD, fiberDim);
+  field.allocate();
   const ALE::Obj<SieveRealSection>& section = field.section();
-  const int spaceDim = _TestField::cellDim;
-    
-  section->setChart(SieveMesh::real_section_type::chart_type(
-		  *std::min_element(vertices->begin(), vertices->end()),
-		  *std::max_element(vertices->begin(), vertices->end())+1));
-  section->setFiberDimension(vertices, fiberDim);
-  sieveMesh->allocate(section);
 
   double_array values(fiberDim);
   int i = 0;
@@ -370,16 +406,10 @@
 
   Field fieldSrc(sieveMesh);
   { // Setup source field
-    fieldSrc.newSection();
+    fieldSrc.newSection(Field::VERTICES_FIELD, fiberDim);
+    fieldSrc.allocate();
     const ALE::Obj<SieveRealSection>& section = fieldSrc.section();
-    const int spaceDim = _TestField::cellDim;
     
-    section->setChart(SieveMesh::real_section_type::chart_type(
-		  *std::min_element(vertices->begin(), vertices->end()),
-		  *std::max_element(vertices->begin(), vertices->end())+1));
-    section->setFiberDimension(vertices, fiberDim);
-    sieveMesh->allocate(section);
-
     double_array values(fiberDim);
     int i = 0;
     for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
@@ -392,17 +422,9 @@
   } // Setup source field
 
   Field field(sieveMesh);
-  field.newSection();
+  field.newSection(Field::VERTICES_FIELD, fiberDim);
+  field.allocate();
   const ALE::Obj<SieveRealSection>& section = field.section();
-  { // Setup destination field
-    const int spaceDim = _TestField::cellDim;
-    
-    section->setChart(SieveMesh::real_section_type::chart_type(
-		  *std::min_element(vertices->begin(), vertices->end()),
-		  *std::max_element(vertices->begin(), vertices->end())+1));
-    section->setFiberDimension(vertices, fiberDim);
-    sieveMesh->allocate(section);
-  } // Setup destination field
 
   field.copy(fieldSrc);
 
@@ -447,16 +469,10 @@
 
   Field fieldSrc(sieveMesh);
   { // Setup source field
-    fieldSrc.newSection();
+    fieldSrc.newSection(Field::VERTICES_FIELD, fiberDim);
+    fieldSrc.allocate();
     const ALE::Obj<SieveRealSection>& section = fieldSrc.section();
-    const int spaceDim = _TestField::cellDim;
     
-    section->setChart(SieveMesh::real_section_type::chart_type(
-		  *std::min_element(vertices->begin(), vertices->end()),
-		  *std::max_element(vertices->begin(), vertices->end())+1));
-    section->setFiberDimension(vertices, fiberDim);
-    sieveMesh->allocate(section);
-
     double_array values(fiberDim);
     int i = 0;
     for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
@@ -469,16 +485,10 @@
   } // Setup source field
 
   Field field(sieveMesh);
-  field.newSection();
+  field.newSection(Field::VERTICES_FIELD, fiberDim);
+  field.allocate();
   const ALE::Obj<SieveRealSection>& section = field.section();
   { // Setup destination field
-    const int spaceDim = _TestField::cellDim;
-    
-    section->setChart(SieveMesh::real_section_type::chart_type(
-		  *std::min_element(vertices->begin(), vertices->end()),
-		  *std::max_element(vertices->begin(), vertices->end())+1));
-    section->setFiberDimension(vertices, fiberDim);
-    sieveMesh->allocate(section);
 
     double_array values(fiberDim);
     int i = 0;
@@ -526,17 +536,11 @@
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   Field field(sieveMesh);
-  field.newSection();
+  field.newSection(Field::VERTICES_FIELD, fiberDim);
+  field.allocate();
   const ALE::Obj<SieveRealSection>& section = field.section();
-  const int spaceDim = _TestField::cellDim;
-
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
-  section->setChart(SieveMesh::real_section_type::chart_type(
-		  *std::min_element(vertices->begin(), vertices->end()),
-		  *std::max_element(vertices->begin(), vertices->end())+1));
-  section->setFiberDimension(vertices, fiberDim);
-  sieveMesh->allocate(section);
 
   double_array values(fiberDim);
   int i = 0;
@@ -583,20 +587,13 @@
   Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+  Field field(sieveMesh);
+  field.newSection(Field::VERTICES_FIELD, fiberDim);
+  field.allocate();
+  const ALE::Obj<SieveRealSection>& section = field.section();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
 
-  Field field(sieveMesh);
-  field.newSection();
-  const ALE::Obj<SieveRealSection>& section = field.section();
-  const int spaceDim = _TestField::cellDim;
-    
-  section->setChart(SieveMesh::real_section_type::chart_type(
-		  *std::min_element(vertices->begin(), vertices->end()),
-		  *std::max_element(vertices->begin(), vertices->end())+1));
-  section->setFiberDimension(vertices, fiberDim);
-  sieveMesh->allocate(section);
-
   double_array values(fiberDim);
   int i = 0;
   for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.hh	2009-01-26 05:47:02 UTC (rev 13956)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.hh	2009-01-26 19:43:49 UTC (rev 13957)
@@ -51,6 +51,7 @@
   CPPUNIT_TEST( testAddDimensionOkay );
   CPPUNIT_TEST( testCopyLayout );
   CPPUNIT_TEST( testClear );
+  CPPUNIT_TEST( testAllocate );
   CPPUNIT_TEST( testZero );
   CPPUNIT_TEST( testComplete );
   CPPUNIT_TEST( testCopy );
@@ -93,6 +94,9 @@
   /// Test clear().
   void testClear(void);
 
+  /// Test allocate().
+  void testAllocate(void);
+
   /// Test zero().
   void testZero(void);
 

Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py	2009-01-26 05:47:02 UTC (rev 13956)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py	2009-01-26 19:43:49 UTC (rev 13957)
@@ -24,16 +24,6 @@
   Unit testing of DirichletBC object.
   """
 
-  def test_implementsConstraint(self):
-    """
-    Test to make sure DirichletBC satisfies constraint requirements.
-    """
-    bc = DirichletBC()
-    from pylith.feassemble.Constraint import implementsConstraint
-    self.failUnless(implementsConstraint(bc))
-    return
-    
-
   def test_constructor(self):
     """
     Test constructor.
@@ -51,10 +41,8 @@
     don't verify the results.
     """
 
-    (mesh, bc, fields) = self._initialize()
+    (mesh, bc, field) = self._initialize()
 
-    self.assertNotEqual(None, bc.cppHandle)
-
     # We should really add something here to check to make sure things
     # actually initialized correctly    
     return
@@ -68,8 +56,8 @@
     don't verify the results.
     """
 
-    (mesh, bc, fields) = self._initialize()
-    field = fields.getReal("field")
+    (mesh, bc, field) = self._initialize()
+
     bc.setConstraintSizes(field)
 
     # We should really add something here to check to make sure things
@@ -85,8 +73,7 @@
     don't verify the results.
     """
 
-    (mesh, bc, fields) = self._initialize()
-    field = fields.getReal("field")
+    (mesh, bc, field) = self._initialize()
     bc.setConstraintSizes(field)
     mesh.allocateRealSection(field)
     bc.setConstraints(field)
@@ -100,7 +87,7 @@
     """
     Test useSolnIncr().
     """
-    (mesh, bc, fields) = self._initialize()
+    (mesh, bc, field) = self._initialize()
     bc.useSolnIncr(True)
     return
 
@@ -113,8 +100,7 @@
     don't verify the results.
     """
 
-    (mesh, bc, fields) = self._initialize()
-    field = fields.getReal("field")
+    (mesh, bc, field) = self._initialize()
     bc.setConstraintSizes(field)
     mesh.allocateRealSection(field)
     bc.setConstraints(field)
@@ -133,7 +119,7 @@
     WARNING: This is not a rigorous test of finalize() because we
     neither set the input fields or verify the results.
     """
-    (mesh, bc, fields) = self._initialize()
+    (mesh, bc, field) = self._initialize()
     bc.finalize()
 
     # We should really add something here to check to make sure things
@@ -147,34 +133,33 @@
     """
     Initialize DirichletBC boundary condition.
     """
-    from pylith.bc.DirichletBC import DirichletBC
-    bc = DirichletBC()
-    bc._configure()
-    bc.id = 0
-    bc.label = "bc"
-    bc.fixedDOF = [1]
-
-    from pyre.units.time import second
-    bc.tRef = -1.0*second
-
     from spatialdata.spatialdb.SimpleDB import SimpleDB
     db = SimpleDB()
     db._configure()
-    db.label = "TestDirichletBC tri3"
-    db.iohandler.filename = "data/tri3.spatialdb"
-    db.initialize()
-    bc.db = db
+    db.inventory.label = "TestDirichletBC tri3"
+    db.inventory.iohandler.inventory.filename = "data/tri3.spatialdb"
+    db.inventory.iohandler._configure()
+    db._configure()
 
     from pylith.bc.FixedDOFDB import FixedDOFDB
     dbRate = FixedDOFDB()
+    dbRate.inventory.label = "TestDirichletBC rate tri3"
     dbRate._configure()
-    dbRate.label = "TestDirichletBC rate tri3"
-    dbRate.initialize()
-    bc.dbRate = dbRate
 
+    from pylith.bc.DirichletBC import DirichletBC
+    bc = DirichletBC()
+    bc.inventory.label = "bc"
+    bc.inventory.fixedDOF = [1]
+    from pyre.units.time import second
+    bc.inventory.tRef = -1.0*second
+    bc.inventory.db = db
+    bc.inventory.dbRate = dbRate
+    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()
@@ -182,24 +167,23 @@
 
     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)
     bc.initialize(totalTime=0.0, numTimeSteps=1, normalizer=normalizer)
 
-    # Setup fields
-    from pylith.topology.FieldsManager import FieldsManager
-    fields = FieldsManager(mesh)
-    fields.addReal("field")
-    fields.setFiberDimension("field", cs.spaceDim)
-    fields.allocate("field")
+    # Setup field
+    from pylith.topology.Field import Field
+    field = Field()
+    field.fiberDimension(cs.spaceDim())
+    field.newSection()
 
-    import pylith.topology.topology as bindings
-    bindings.zeroRealSection(fields.getReal("field"))
+    field.zero()
     
-    return (mesh, bc, fields)
+    return (mesh, bc, field)
 
 
 # End of file 



More information about the CIG-COMMITS mailing list