[cig-commits] r8185 - in short/3D/PyLith/trunk/pylith: . solver

knepley at geodynamics.org knepley at geodynamics.org
Sat Oct 27 11:11:11 PDT 2007


Author: knepley
Date: 2007-10-27 11:11:11 -0700 (Sat, 27 Oct 2007)
New Revision: 8185

Added:
   short/3D/PyLith/trunk/pylith/solver/SolverNonlinear.py
Modified:
   short/3D/PyLith/trunk/pylith/Makefile.am
Log:
Added nonlinear solver python code


Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am	2007-10-27 17:14:48 UTC (rev 8184)
+++ short/3D/PyLith/trunk/pylith/Makefile.am	2007-10-27 18:11:11 UTC (rev 8185)
@@ -90,6 +90,7 @@
 	solver/__init__.py \
 	solver/Solver.py \
 	solver/SolverLinear.py \
+	solver/SolverNonlinear.py \
 	topology/__init__.py \
 	topology/Distributor.py \
 	topology/FieldsManager.py \

Added: short/3D/PyLith/trunk/pylith/solver/SolverNonlinear.py
===================================================================
--- short/3D/PyLith/trunk/pylith/solver/SolverNonlinear.py	2007-10-27 17:14:48 UTC (rev 8184)
+++ short/3D/PyLith/trunk/pylith/solver/SolverNonlinear.py	2007-10-27 18:11:11 UTC (rev 8185)
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/solver/SolverNonlinear.py
+
+## @brief Python PyLith nonlinear algebraic solver.
+
+from Solver import Solver
+
+# SolverNonlinear class
+class SolverNonlinear(Solver):
+  """
+  Python PyLith nonlinear algebraic solver.
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(Solver.Inventory):
+    """
+    Python object for managing SolverNonlinear facilities and properties.
+    """
+
+    ## @class Inventory
+    ## Python object for managing SolverNonlinear facilities and properties.
+    ##
+    ## \b Properties
+    ## @li None
+    ##
+    ## \b Facilities
+    ## @li None
+
+    import pyre.inventory
+
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="solvernonlinear"):
+    """
+    Constructor.
+    """
+    Solver.__init__(self, name)
+    return
+
+
+  def initialize(self, mesh, field):
+    """
+    Initialize solver.
+    """
+    self._createCppHandle()
+    self.cppHandle.initialize(mesh.cppHandle, field)
+    return
+
+
+  def solve(self, fieldOut, jacobian, fieldIn):
+    """
+    Solve nonlinear system.
+    """
+    self._info.log("Solving nonlinear equations.")
+    assert(None != self.cppHandle)
+    self.cppHandle.solve(fieldOut, jacobian, fieldIn)
+    return
+  
+
+  # PRIVATE METHODS /////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Set members based using inventory.
+    """
+    Solver._configure(self)
+    return
+
+
+  def _createCppHandle(self):
+    """
+    Create handle to corresponding C++ object.
+    """
+    if None == self.cppHandle:
+      import pylith.solver.solver as bindings
+      self.cppHandle = bindings.SolverNonlinear()
+    return
+  
+
+# End of file 



More information about the cig-commits mailing list