[cig-commits] r9333 - in short/3D/PyLith/trunk: libsrc libsrc/bc pylith/bc

brad at geodynamics.org brad at geodynamics.org
Wed Feb 13 21:59:37 PST 2008


Author: brad
Date: 2008-02-13 21:59:37 -0800 (Wed, 13 Feb 2008)
New Revision: 9333

Added:
   short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.cc
   short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.hh
   short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.icc
   short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py
Modified:
   short/3D/PyLith/trunk/libsrc/Makefile.am
   short/3D/PyLith/trunk/libsrc/bc/Makefile.am
Log:
Added DirichletBoundary for Dirichlet BC with boundary topology.

Modified: short/3D/PyLith/trunk/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/Makefile.am	2008-02-14 05:58:57 UTC (rev 9332)
+++ short/3D/PyLith/trunk/libsrc/Makefile.am	2008-02-14 05:59:37 UTC (rev 9333)
@@ -24,6 +24,7 @@
 libpylith_la_SOURCES = \
 	bc/AbsorbingDampers.cc \
 	bc/BoundaryCondition.cc \
+	bc/DirichletBoundary.cc \
 	bc/DirichletPoints.cc \
 	bc/Neumann.cc \
 	faults/BruneSlipFn.cc \

Added: short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.cc	                        (rev 0)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.cc	2008-02-14 05:59:37 UTC (rev 9333)
@@ -0,0 +1,293 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "DirichletBoundary.hh" // implementation of object methods
+
+#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
+#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
+
+#include <Selection.hh> // USES submesh algorithms
+
+#include <assert.h> // USES assert()
+#include <stdexcept> // USES std::runtime_error
+#include <sstream> // USES std::ostringstream
+
+// ----------------------------------------------------------------------
+// Default constructor.
+pylith::bc::DirichletBoundary::DirichletBoundary(void) :
+  _tRef(0.0),
+  _dbRate(0)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+pylith::bc::DirichletBoundary::~DirichletBoundary(void)
+{ // destructor
+  _dbRate = 0;
+} // destructor
+
+// ----------------------------------------------------------------------
+// Initialize boundary condition.
+void
+pylith::bc::DirichletBoundary::initialize(
+				   const ALE::Obj<ALE::Mesh>& mesh,
+				   const spatialdata::geocoords::CoordSys* cs,
+				   const double_array& upDir)
+{ // initialize
+  assert(0 != _db);
+  assert(0 != _dbRate);
+  assert(!mesh.isNull());
+  assert(0 != cs);
+
+  const int numFixedDOF = _fixedDOF.size();
+  if (0 == numFixedDOF)
+    return;
+
+  // Extract submesh associated with boundary
+  _boundaryMesh = 
+    ALE::Selection<ALE::Mesh>::submesh(mesh, mesh->getIntSection(_label));
+  if (_boundaryMesh.isNull()) {
+    std::ostringstream msg;
+    msg << "Could not construct boundary mesh for Dirichlet boundary "
+	<< "condition '" << _label << "'.";
+    throw std::runtime_error(msg.str());
+  } // if
+
+  // Get values for degrees of freedom
+  char** valueNames = (numFixedDOF > 0) ? new char*[numFixedDOF] : 0;
+  for (int i=0; i < numFixedDOF; ++i) {
+    std::ostringstream name;
+    name << "dof-" << _fixedDOF[i];
+    const int size = 1 + name.str().length();
+    valueNames[i] = new char[size];
+    strcpy(valueNames[i], name.str().c_str());
+  } // for
+  _db->open();
+  _db->queryVals((const char**) valueNames, numFixedDOF);
+  _dbRate->open();
+  _dbRate->queryVals((const char**) valueNames, numFixedDOF);
+  for (int i=0; i < numFixedDOF; ++i) {
+    delete[] valueNames[i]; valueNames[i] = 0;
+  } // for
+  delete[] valueNames; valueNames = 0;
+
+  const ALE::Obj<Mesh::label_sequence>& vertices = 
+    _boundaryMesh->depthStratum(0);
+  const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+
+  const ALE::Obj<real_section_type>& coordinates = 
+    mesh->getRealSection("coordinates");
+  assert(!coordinates.isNull());
+  const int spaceDim = cs->spaceDim();
+
+  _values = new real_section_type(_boundaryMesh->comm(), 
+				  _boundaryMesh->debug());
+  _values->addSpace(); // initial values
+  _values->addSpace(); // rate of change of values
+  _values->setFiberDimension(vertices, 2*numFixedDOF);
+  _values->setFiberDimension(vertices, numFixedDOF, 0); // initial values
+  _values->setFiberDimension(vertices, numFixedDOF, 1); // rate of change
+  _boundaryMesh->allocate(_values);
+
+  double_array queryValues(2*numFixedDOF);
+
+  for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != verticesEnd;
+       ++v_iter) {
+    // Get coordinates of vertex
+    const real_section_type::value_type* vCoords = 
+      coordinates->restrictPoint(*v_iter);
+    int err = _db->query(&queryValues[0], numFixedDOF, vCoords, 
+				spaceDim, cs);
+    if (err) {
+      std::ostringstream msg;
+      msg << "Could not find values at (";
+      for (int i=0; i < spaceDim; ++i)
+	msg << "  " << vCoords[i];
+      msg << ") using spatial database " << _db->label() << ".";
+      throw std::runtime_error(msg.str());
+    } // if
+
+    err = _dbRate->query(&queryValues[numFixedDOF], numFixedDOF, vCoords, 
+			 spaceDim, cs);
+    if (err) {
+      std::ostringstream msg;
+      msg << "Could not find values at (";
+      for (int i=0; i < spaceDim; ++i)
+	msg << "  " << vCoords[i];
+      msg << ") using spatial database " << _dbRate->label() << ".";
+      throw std::runtime_error(msg.str());
+    } // if
+
+    _values->updatePoint(*v_iter, &queryValues[0]);
+  } // for
+  _db->close();
+  _dbRate->close();
+} // initialize
+
+// ----------------------------------------------------------------------
+// Set number of degrees of freedom that are constrained at points in field.
+void
+pylith::bc::DirichletBoundary::setConstraintSizes(
+				     const ALE::Obj<real_section_type>& field,
+				     const ALE::Obj<ALE::Mesh>& mesh)
+{ // setConstraintSizes
+  assert(!field.isNull());
+  assert(!mesh.isNull());
+
+  const int numFixedDOF = _fixedDOF.size();
+  if (0 == numFixedDOF)
+    return;
+
+  const ALE::Obj<Mesh::label_sequence>& vertices = 
+    _boundaryMesh->depthStratum(0);
+  const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+
+  _offsetLocal = new int_section_type(_boundaryMesh->comm(), 
+				      _boundaryMesh->debug());
+  _offsetLocal->setFiberDimension(vertices, 1);
+  _boundaryMesh->allocate(_offsetLocal);
+
+  for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != verticesEnd;
+       ++v_iter) {
+    const int fiberDim = field->getFiberDimension(*v_iter);
+    const int curNumConstraints = field->getConstraintDimension(*v_iter);
+    if (curNumConstraints + numFixedDOF > fiberDim) {
+      std::ostringstream msg;
+      msg << "Found overly constrained point while setting up constraints "
+	  << "for DirichletBoundary boundary condition '" << _label << "'.\n"
+	  << "Number of DOF at point " << *v_iter << " is " << fiberDim
+	  << " and number of attempted constraints is "
+	  << curNumConstraints+numFixedDOF << ".";
+      throw std::runtime_error(msg.str());
+    } // if
+    _offsetLocal->updatePoint(*v_iter, &curNumConstraints);
+    field->addConstraintDimension(*v_iter, numFixedDOF);
+  } // for
+} // setConstraintSizes
+
+// ----------------------------------------------------------------------
+// Set which degrees of freedom are constrained at points in field.
+void
+pylith::bc::DirichletBoundary::setConstraints(
+				    const ALE::Obj<real_section_type>& field,
+				    const ALE::Obj<ALE::Mesh>& mesh)
+{ // setConstraints
+  assert(!field.isNull());
+  assert(!mesh.isNull());
+
+  const int numFixedDOF = _fixedDOF.size();
+  if (0 == numFixedDOF)
+    return;
+
+  const ALE::Obj<Mesh::label_sequence>& vertices = 
+    _boundaryMesh->depthStratum(0);
+  const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+
+  for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != verticesEnd;
+       ++v_iter) {
+    // Get list of currently constrained DOF
+    const int* curFixedDOF = field->getConstraintDof(*v_iter);
+    const int numTotalConstrained = field->getConstraintDimension(*v_iter);
+
+    // Create array holding all constrained DOF
+    int_array allFixedDOF(curFixedDOF, numTotalConstrained);
+
+    const int_section_type::value_type* offset = 
+      _offsetLocal->restrictPoint(*v_iter);
+
+    // Add in the ones for this DirichletBoundary BC
+    for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
+      allFixedDOF[offset[0]+iDOF] = _fixedDOF[iDOF];
+
+    // Fill in rest of values not yet set
+    // (will be set by another DirichletBoundary BC)
+    for (int iDOF=offset[0]+numFixedDOF; iDOF < numTotalConstrained; ++iDOF)
+      allFixedDOF[offset[0]+iDOF] = 999;
+
+    // Sort list of constrained DOF
+    // I need these sorted for my update algorithms to work properly
+    std::sort(&allFixedDOF[0], &allFixedDOF[numTotalConstrained]);
+
+    // Update list of constrained DOF
+    field->setConstraintDof(*v_iter, &allFixedDOF[0]);
+  } // for
+} // setConstraints
+
+// ----------------------------------------------------------------------
+// Set values in field.
+void
+pylith::bc::DirichletBoundary::setField(const double t,
+				      const ALE::Obj<real_section_type>& field,
+				      const ALE::Obj<ALE::Mesh>& mesh)
+{ // setField
+  assert(!field.isNull());
+  assert(!mesh.isNull());
+
+  const int numFixedDOF = _fixedDOF.size();
+  if (0 == numFixedDOF)
+    return;
+
+  const ALE::Obj<Mesh::label_sequence>& vertices = 
+    _boundaryMesh->depthStratum(0);
+  const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+
+  const int fiberDimension = 
+    (vertices->size() > 0) ? field->getFiberDimension(*vertices->begin()) : 0;
+
+  double_array fieldValues(fiberDimension);
+
+  for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+       v_iter != verticesEnd;
+       ++v_iter) {
+    assert(fiberDimension == field->getFiberDimension(*v_iter));
+    mesh->restrict(field, *v_iter, &fieldValues[0], fiberDimension);
+
+    const real_section_type::value_type* values = 
+      _values->restrictPoint(*v_iter);
+
+    for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
+      fieldValues[_fixedDOF[iDOF]] = values[iDOF];
+    if (t > _tRef)
+      for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
+	fieldValues[_fixedDOF[iDOF]] += (t-_tRef) * values[numFixedDOF+iDOF];
+    field->updatePointAll(*v_iter, &fieldValues[0]);
+  } // for
+} // setField
+
+// ----------------------------------------------------------------------
+// Get vertex field of BC initial or rate of change of values.
+const ALE::Obj<pylith::real_section_type>&
+pylith::bc::DirichletBoundary::getVertexField(const char* name)
+{ // getVertexField
+  
+  if (0 == strcasecmp(name, "initial"))
+    _buffer = _values->getFibration(0);
+  else if (0 == strcasecmp(name, "rate-of-change"))
+    _buffer = _values->getFibration(1);
+  else {
+    std::ostringstream msg;
+    msg << "Unknown field '" << name << "' requested for Dirichlet BC '" 
+	<< _label << "'.";
+    throw std::runtime_error(msg.str());
+  } // else
+
+  return _buffer;
+} // getVertexField
+
+
+// End of file 

Added: short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.hh	                        (rev 0)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.hh	2008-02-14 05:59:37 UTC (rev 9333)
@@ -0,0 +1,158 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file libsrc/bc/DirichletBoundary.hh
+ *
+ * @brief C++ implementation of Dirichlet (prescribed values at
+ * degrees of freedom) boundary conditions with points on a boundary.
+ */
+
+#if !defined(pylith_bc_dirichletboundary_hh)
+#define pylith_bc_dirichletboundary_hh
+
+#include "BoundaryCondition.hh" // ISA BoundaryCondition
+#include "pylith/feassemble/Constraint.hh" // ISA Constraint
+
+#include "pylith/utils/array.hh" // USES std::vector, double_array, int_array
+
+/// Namespace for pylith package
+namespace pylith {
+  namespace bc {
+    class DirichletBoundary;
+    class TestDirichletBoundary; // unit testing
+  } // bc
+} // pylith
+
+
+/// C++ implementation of DirichletBoundary boundary conditions.
+class pylith::bc::DirichletBoundary : public BoundaryCondition, 
+				    public feassemble::Constraint
+{ // class DirichletBoundary
+  friend class TestDirichletBoundary; // unit testing
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Default constructor.
+  DirichletBoundary(void);
+
+  /// Destructor.
+  ~DirichletBoundary(void);
+
+  /** Set database for rate of change of values.
+   *
+   * @param db Spatial database
+   */
+  void dbRate(spatialdata::spatialdb::SpatialDB* const db);
+
+  /** Set indices of fixed degrees of freedom. 
+   *
+   * Note: all points associated with boundary condition has same
+   * degrees of freedom fixed.
+   *
+   * Example: [0, 1] to fix x and y degrees of freedom in Cartesian system.
+   *
+   * @param flags Indices of fixed degrees of freedom.
+   */
+  void fixedDOF(const int_array& flags);
+
+  /** Set time at which rate of change begins.
+   *
+   * @param t Reference time.
+   */
+  void referenceTime(const double t);
+
+  /** Initialize boundary condition.
+   *
+   * @param mesh PETSc mesh
+   * @param cs Coordinate system for mesh
+   */
+  void initialize(const ALE::Obj<ALE::Mesh>& mesh,
+		  const spatialdata::geocoords::CoordSys* cs,
+		  const double_array& upDir);
+
+  /** Set number of degrees of freedom that are constrained at points in field.
+   *
+   * @param field Solution field
+   * @param mesh PETSc mesh
+   */
+  void setConstraintSizes(const ALE::Obj<real_section_type>& field,
+			  const ALE::Obj<ALE::Mesh>& mesh);
+
+  /** Set which degrees of freedom are constrained at points in field.
+   *
+   * @param field Solution field
+   * @param mesh PETSc mesh
+   */
+  void setConstraints(const ALE::Obj<real_section_type>& field,
+		      const ALE::Obj<ALE::Mesh>& mesh);
+
+  /** Set values in field.
+   *
+   * @param t Current time
+   * @param field Solution field
+   * @param mesh PETSc mesh
+   */
+  void setField(const double t,
+		const ALE::Obj<real_section_type>& field,
+		const ALE::Obj<ALE::Mesh>& mesh);
+
+  /** Get data mesh.
+   *
+   * @return Boundary mesh.
+   */
+  const ALE::Obj<Mesh>& dataMesh(void) const;
+
+  /** Get vertex field of BC initial or rate of change of values.
+   *
+   * @param name Name of field {'initial', 'rate-of-change'}
+   */
+  const ALE::Obj<real_section_type>&
+  getVertexField(const char* name);
+
+  // NOT IMPLEMENTED ////////////////////////////////////////////////////
+private :
+
+  /// Not implemented
+  DirichletBoundary(const DirichletBoundary& m);
+
+  /// Not implemented
+  const DirichletBoundary& operator=(const DirichletBoundary& m);
+
+  // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+  double _tRef; /// Time when rate of change for values begins
+
+  /// Initial values and rate of change of values at DOF.
+  ALE::Obj<real_section_type> _values;
+  ALE::Obj<real_section_type> _buffer; ///< Buffer for values.
+
+  ALE::Obj<Mesh> _boundaryMesh; ///< Boundary mesh.
+  int_array _fixedDOF; ///< Indices of fixed degrees of freedom
+
+  /// Offset in list of fixed DOF at point to get to fixed DOF
+  /// associated with this DirichletBoundary boundary condition.
+  ALE::Obj<int_section_type> _offsetLocal;
+
+  /// Spatial database with parameters for rate of change values.
+  spatialdata::spatialdb::SpatialDB* _dbRate;
+
+
+}; // class DirichletBoundary
+
+#include "DirichletBoundary.icc" // inline methods
+
+#endif // pylith_bc_dirichletboundary_hh
+
+
+// End of file 

Added: short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.icc	                        (rev 0)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.icc	2008-02-14 05:59:37 UTC (rev 9333)
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#if !defined(pylith_bc_dirichletboundary_hh)
+#error "DirichletBoundary.icc can only be included from DirichletBoundary.hh"
+#endif
+
+// Set database for boundary condition parameters.
+inline
+void
+pylith::bc::DirichletBoundary::dbRate(
+			      spatialdata::spatialdb::SpatialDB* const db) {
+  _dbRate = db;
+}
+
+// Set indices of fixed degrees of freedom. 
+inline
+void
+pylith::bc::DirichletBoundary::fixedDOF(const int_array& flags) {
+  const size_t size = flags.size();
+  _fixedDOF.resize(size);
+  _fixedDOF = flags;
+} // fixedDOF
+
+// Set time at which rate of change begins.
+inline
+void 
+pylith::bc::DirichletBoundary::referenceTime(const double t) {
+  _tRef = t;
+} // referenceTime
+
+  /** Get data mesh.
+   *
+   * @return Boundary mesh.
+   */
+inline
+const ALE::Obj<pylith::Mesh>&
+pylith::bc::DirichletBoundary::dataMesh(void) const {
+  return _boundaryMesh;
+} // dataMesh
+
+
+// End of file 

Modified: short/3D/PyLith/trunk/libsrc/bc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/Makefile.am	2008-02-14 05:58:57 UTC (rev 9332)
+++ short/3D/PyLith/trunk/libsrc/bc/Makefile.am	2008-02-14 05:59:37 UTC (rev 9333)
@@ -17,6 +17,8 @@
 	AbsorbingDampers.hh \
 	BoundaryCondition.hh \
 	BoundaryCondition.icc \
+	DirichletBoundary.hh \
+	DirichletBoundary.icc \
 	DirichletPoints.hh \
 	DirichletPoints.icc \
 	Neumann.hh

Added: short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py	                        (rev 0)
+++ short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py	2008-02-14 05:59:37 UTC (rev 9333)
@@ -0,0 +1,208 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/bc/DirichletBoundary.py
+##
+## @brief Python object for managing a Dirichlet (prescribed
+## displacements) boundary condition with points on a surface.
+##
+## 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
+  
+
+# DirichletBoundary class
+class DirichletBoundary(BoundaryCondition, Constraint):
+  """
+  Python object for managing a DirichletBoundary (prescribed displacements)
+  boundary condition with points on a surface.
+
+  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.
+    ## @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)
+    #output.meta['tip'] = "Output manager associated with diagnostic output."
+    
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="dirichletpoints"):
+    """
+    Constructor.
+    """
+    BoundaryCondition.__init__(self, name)
+    Constraint.__init__(self)
+    self._loggingPrefix = "DiBC "
+    self.fixedDOF = []
+    self.availableFields = \
+        {'vertex': \
+           {'info': ["initial", "rate-of-change"],
+            'data': []},
+         'cell': \
+           {'info': [],
+            'data': []}}
+    return
+
+
+  def preinitialize(self, mesh):
+    """
+    Do pre-initialization setup.
+    """
+    BoundaryCondition.preinitialize(self, mesh)
+    Constraint.preinitialize(self, mesh)
+    self.cppHandle.fixedDOF = self.fixedDOF
+    self.output.preinitialize(self)
+    return
+
+
+  def verifyConfiguration(self):
+    """
+    Verify compatibility of configuration.
+    """
+    BoundaryCondition.verifyConfiguration(self)
+    Constraint.verifyConfiguration(self)
+    self.output.verifyConfiguration()
+    return
+
+
+  def initialize(self, totalTime, numTimeSteps):
+    """
+    Initialize DirichletBoundary boundary condition.
+    """
+    logEvent = "%sinit" % self._loggingPrefix
+    self._logger.eventBegin(logEvent)
+    
+    assert(None != self.cppHandle)
+    self.dbRate.initialize()
+    self.cppHandle.dbRate = self.dbRate.cppHandle
+
+    BoundaryCondition.initialize(self, totalTime, numTimeSteps)
+
+    #from pylith.topology.Mesh import Mesh
+    #self.boundaryMesh = Mesh()
+    #self.boundaryMesh.initialize(self.mesh.coordsys)
+    #self.cppHandle.boundaryMesh(self.boundaryMesh.cppHandle)
+
+    #if None != self.output:
+    #  self.output.initialize()
+    #  self.output.writeInfo()
+
+    self._logger.eventEnd(logEvent)    
+    return
+  
+
+  def getDataMesh(self):
+    """
+    Get mesh associated with data fields.
+    """
+    return (self.boundaryMesh, None, None)
+
+
+  def getVertexField(self, name, fields=None):
+    """
+    Get vertex field.
+    """
+    (field, fieldType) = self.cppHandle.vertexField(name,
+                                                    self.mesh.cppHandle)
+    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.DirichletBoundary()    
+    return
+  
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def boundary_condition():
+  """
+  Factory associated with DirichletBoundary.
+  """
+  return DirichletBoundary()
+
+  
+# End of file 



More information about the cig-commits mailing list