[cig-commits] r6962 - in short/3D/PyLith/trunk: libsrc libsrc/feassemble modulesrc/feassemble

brad at geodynamics.org brad at geodynamics.org
Thu May 24 19:56:48 PDT 2007


Author: brad
Date: 2007-05-24 19:56:48 -0700 (Thu, 24 May 2007)
New Revision: 6962

Added:
   short/3D/PyLith/trunk/libsrc/feassemble/Constraint.cc
   short/3D/PyLith/trunk/libsrc/feassemble/Constraint.hh
Modified:
   short/3D/PyLith/trunk/libsrc/Makefile.am
   short/3D/PyLith/trunk/libsrc/feassemble/Makefile.am
   short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src
Log:
Added Constraint.

Modified: short/3D/PyLith/trunk/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/Makefile.am	2007-05-25 01:41:58 UTC (rev 6961)
+++ short/3D/PyLith/trunk/libsrc/Makefile.am	2007-05-25 02:56:48 UTC (rev 6962)
@@ -32,6 +32,7 @@
 	faults/FaultCohesiveKin.cc \
 	faults/FaultCohesiveDyn.cc \
 	faults/SlipTimeFn.cc \
+	feassemble/Constraint.cc \
 	feassemble/ExplicitElasticity.cc \
 	feassemble/ImplicitElasticity.cc \
 	feassemble/Integrator.cc \

Added: short/3D/PyLith/trunk/libsrc/feassemble/Constraint.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Constraint.cc	2007-05-25 01:41:58 UTC (rev 6961)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Constraint.cc	2007-05-25 02:56:48 UTC (rev 6962)
@@ -0,0 +1,30 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "Constraint.hh" // implementation of object methods
+
+// ----------------------------------------------------------------------
+// Default constructor.
+pylith::feassemble::Constraint::Constraint(void)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+pylith::feassemble::Constraint::~Constraint(void)
+{ // destructor
+} // destructor
+
+
+// End of file 

Added: short/3D/PyLith/trunk/libsrc/feassemble/Constraint.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Constraint.hh	2007-05-25 01:41:58 UTC (rev 6961)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Constraint.hh	2007-05-25 02:56:48 UTC (rev 6962)
@@ -0,0 +1,92 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file libsrc/feassemble/Constraint.hh
+ *
+ * @brief C++ abstract base class defining interface for constraints
+ * applied to finite-elements.
+ */
+
+#if !defined(pylith_feassemble_constraint_hh)
+#define pylith_feassemble_constraint_hh
+
+#include "pylith/utils/sievetypes.hh" // USES real_section_type
+
+/// Namespace for pylith package
+namespace pylith {
+  namespace feassemble {
+    class Constraint;
+    class TestConstraint; // unit testing
+  } // feassemble
+} // pylith
+
+
+/// C++ abstract base class defining interface for constraints applied
+/// to finite-elements.
+class pylith::feassemble::Constraint
+{ // class Constraint
+  friend class TestConstraint; // unit testing
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Default constructor.
+  Constraint(void);
+
+  /// Destructor.
+  virtual
+  ~Constraint(void);
+
+  /** Set number of degrees of freedom that are constrained at points in field.
+   *
+   * @param field Solution field
+   * @param mesh PETSc mesh
+   */
+  virtual
+  void setConstraintSizes(const ALE::Obj<real_section_type>& field,
+			  const ALE::Obj<ALE::Mesh>& mesh) = 0;
+
+  /** Set which degrees of freedom are constrained at points in field.
+   *
+   * @param field Solution field
+   * @param mesh PETSc mesh
+   */
+  virtual
+  void setConstraints(const ALE::Obj<real_section_type>& field,
+		      const ALE::Obj<ALE::Mesh>& mesh) = 0;
+
+  /** Set values in field.
+   *
+   * @param t Current time
+   * @param field Solution field
+   * @param mesh PETSc mesh
+   */
+  virtual
+  void setField(const double t,
+		const ALE::Obj<real_section_type>& field,
+		const ALE::Obj<ALE::Mesh>& mesh) = 0;
+
+  // NOT IMPLEMENTED ////////////////////////////////////////////////////
+private :
+
+  /// Not implemented
+  Constraint(const Constraint& m);
+
+  /// Not implemented
+  const Constraint& operator=(const Constraint& m);
+
+}; // class Constraint
+
+#endif // pylith_feassemble_constraint_hh
+
+
+// End of file 

Modified: short/3D/PyLith/trunk/libsrc/feassemble/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Makefile.am	2007-05-25 01:41:58 UTC (rev 6961)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Makefile.am	2007-05-25 02:56:48 UTC (rev 6962)
@@ -14,6 +14,7 @@
 include $(top_srcdir)/subpackage.am
 
 subpkginclude_HEADERS = \
+	Constraint.hh \
 	ExplicitElasticity.hh \
 	ExplicitElasticity.icc \
 	ImplicitElasticity.hh \

Modified: short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src	2007-05-25 01:41:58 UTC (rev 6961)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src	2007-05-25 02:56:48 UTC (rev 6962)
@@ -25,6 +25,8 @@
 #include "pylith/feassemble/ExplicitElasticity.hh"
 #include "pylith/feassemble/ImplicitElasticity.hh"
 
+#include "pylith/feassemble/Constraint.hh"
+
 #include "pylith/utils/petscfwd.h"
 
 #include <assert.h>
@@ -73,6 +75,20 @@
   return
 
 
+cdef void Constraint_destructor(void* obj):
+  """
+  Destroy Constraint object.
+  """
+  # create shim for destructor
+  #embed{ void Constraint_destructor_cpp(void* objVptr)
+  pylith::feassemble::Constraint* pQ =
+    (pylith::feassemble::Constraint*) objVptr;
+  delete pQ;
+  #}embed
+  Constraint_destructor_cpp(obj)
+  return
+
+
 # ----------------------------------------------------------------------
 cdef class Quadrature:
 
@@ -797,4 +813,120 @@
       ImplicitElasticity_material_set(self.thisptr, ptrFromHandle(m))
 
 
+# ----------------------------------------------------------------------
+cdef class Constraint:
+
+  cdef void* thisptr # Pointer to C++ object
+  cdef readonly object handle # PyCObject holding pointer to C++ object
+  cdef readonly object name # Identifier for object base type
+
+  def __init__(self):
+    """
+    Constructor.
+    """
+    self.handle = None
+    self.thisptr = NULL
+    self.name = "pylith_feassemble_constraint"
+    return
+
+
+  def setConstraintSizes(self, field, mesh):
+    """
+    Set number of degrees of freedom that are constrained at points in field.
+    """
+    # create shim for method 'setConstraintSizes'
+    #embed{ void Constraint_setConstraintSizes(void* objVptr, void* fieldVptr, void* meshVptr)
+    try {
+      assert(0 != objVptr);
+      assert(0 != fieldVptr);
+      assert(0 != meshVptr);
+      ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
+      ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      ((pylith::feassemble::Constraint*) objVptr)->setConstraintSizes(*field, *mesh);
+      } catch (const std::exception& err) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      const_cast<char*>(err.what()));
+    } catch (...) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      "Caught unknown C++ exception.");
+    } // try/catch      
+    #}embed
+
+    if not mesh.name == "pylith_topology_Mesh":
+      raise TypeError, \
+            "Argument must be extension module type " \
+            "'pylith::topology::Mesh'."
+    Constraint_setConstraintSizes(self.thisptr, PyCObject_AsVoidPtr(field),
+                                  ptrFromHandle(mesh))
+    return
+
+
+  def setConstraints(self, field, mesh):
+    """
+    Set which degrees of freedom that are constrained at points in field.
+    """
+    # create shim for method 'setConstraints'
+    #embed{ void Constraint_setConstraints(void* objVptr, void* fieldVptr, void* meshVptr)
+    try {
+      assert(0 != objVptr);
+      assert(0 != fieldVptr);
+      assert(0 != meshVptr);
+      ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
+      ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      ((pylith::feassemble::Constraint*) objVptr)->setConstraints(*field, *mesh);
+      } catch (const std::exception& err) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      const_cast<char*>(err.what()));
+    } catch (...) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      "Caught unknown C++ exception.");
+    } // try/catch      
+    #}embed
+
+    if not mesh.name == "pylith_topology_Mesh":
+      raise TypeError, \
+            "Argument must be extension module type " \
+            "'pylith::topology::Mesh'."
+    Constraint_setConstraints(self.thisptr, PyCObject_AsVoidPtr(field), ptrFromHandle(mesh))
+    return
+
+
+  def setField(self, t, field, mesh):
+    """
+    Set values in field.
+    """
+    # create shim for method 'setField'
+    #embed{ void Constraint_setField(void* objVptr, double t, void* fieldVptr, void* meshVptr)
+    try {
+      assert(0 != objVptr);
+      assert(0 != fieldVptr);
+      assert(0 != meshVptr);
+      ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
+      ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) meshVptr;
+      ((pylith::feassemble::Constraint*) objVptr)->setField(t, *field, *mesh);
+      } catch (const std::exception& err) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      const_cast<char*>(err.what()));
+    } catch (...) {
+      PyErr_SetString(PyExc_RuntimeError,
+                      "Caught unknown C++ exception.");
+    } // try/catch      
+    #}embed
+
+    if not mesh.name == "pylith_topology_Mesh":
+      raise TypeError, \
+            "Argument must be extension module type " \
+            "'pylith::topology::Mesh'."
+    Constraint_setField(self.thisptr, t, PyCObject_AsVoidPtr(field),
+                        ptrFromHandle(mesh))
+    return
+
+
+  def _createHandle(self):
+    """
+    Wrap pointer to C++ object in PyCObject.
+    """
+    return PyCObject_FromVoidPtr(self.thisptr, Constraint_destructor)
+
+
 # End of file 



More information about the cig-commits mailing list