[cig-commits] r6959 - short/3D/PyLith/trunk/pylith/feassemble
brad at geodynamics.org
brad at geodynamics.org
Thu May 24 17:03:40 PDT 2007
Author: brad
Date: 2007-05-24 17:03:40 -0700 (Thu, 24 May 2007)
New Revision: 6959
Added:
short/3D/PyLith/trunk/pylith/feassemble/Constraint.py
Log:
Updated boundary condition interfaces to use Constraint and Integrator.
Added: short/3D/PyLith/trunk/pylith/feassemble/Constraint.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/Constraint.py 2007-05-25 00:03:09 UTC (rev 6958)
+++ short/3D/PyLith/trunk/pylith/feassemble/Constraint.py 2007-05-25 00:03:40 UTC (rev 6959)
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/feassemble/Constraint.py
+##
+## @brief Python abstract base class for constraints on operator
+## actions with finite-elements.
+##
+## Factory: fe_constraint.
+
+def implementsConstraint(obj):
+ """
+ Check whether object implements a constraint.
+ """
+ result = True
+ attrs = dir(obj)
+ if not "timeStep" in attrs or \
+ not "setConstraintSizes" in attrs or \
+ not "setConstraints" in attrs or \
+ not "setField" in attrs:
+ result = False
+ return result
+
+
+# Constraint class
+class Constraint(object):
+ """
+ Python abstract base class for constraints on operator
+ actions with finite-elements.
+
+ Factory: constraint.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ self.mesh = None
+ return
+
+
+ def timeStep(self, dt):
+ """
+ Set time step for advancing from time t to time t+dt.
+ """
+ assert(None != self.cppHandle)
+ self.cppHandle.timeStep = dt.value
+ return
+
+
+ def setConstraintSizes(self, field):
+ """
+ Set constraint sizes in field.
+ """
+ assert(None != self.cppHandle)
+ self.cppHandle.setConstraintSizes(field, self.mesh.cppHandle)
+ return
+
+
+ def setConstraints(self, field):
+ """
+ Set constraints for field.
+ """
+ assert(None != self.cppHandle)
+ self.cppHandle.setConstraints(field, self.mesh.cppHandle)
+ return
+
+
+ def setField(self, t, field):
+ """
+ Set constrained values in field at time t.
+ """
+ assert(None != self.cppHandle)
+ self.cppHandle.setField(t, field, self.mesh.cppHandle)
+ return
+
+
+# End of file
More information about the cig-commits
mailing list