[cig-commits] r6520 - in short/3D/PyLith/trunk: modulesrc/solver pylith/problems pylith/solver

brad at geodynamics.org brad at geodynamics.org
Sat Apr 7 15:16:54 PDT 2007


Author: brad
Date: 2007-04-07 15:16:54 -0700 (Sat, 07 Apr 2007)
New Revision: 6520

Modified:
   short/3D/PyLith/trunk/modulesrc/solver/solver.pyxe.src
   short/3D/PyLith/trunk/pylith/problems/Explicit.py
   short/3D/PyLith/trunk/pylith/problems/Formulation.py
   short/3D/PyLith/trunk/pylith/solver/SolverLinear.py
Log:
Fixed solver initialization. Moved from constructor to initialize (need to wait for PETSc to be initialized. Fixed setup of KSP in solver module.

Modified: short/3D/PyLith/trunk/modulesrc/solver/solver.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/solver/solver.pyxe.src	2007-04-07 20:35:40 UTC (rev 6519)
+++ short/3D/PyLith/trunk/modulesrc/solver/solver.pyxe.src	2007-04-07 22:16:54 UTC (rev 6520)
@@ -86,7 +86,7 @@
         PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
         throw std::runtime_error("Could not create KSP object.");
       } // if
-      err = KSPSetFromOptions(*ksp);
+      //err = KSPSetFromOptions(*ksp);
       if (err) {
         PetscError(__LINE__,__FUNCT__,__FILE__,__SDIR__,err,0," ");
         throw std::runtime_error("Could not set KSP options.");
@@ -208,6 +208,7 @@
       
       err = VecCreateSeqWithArray(PETSC_COMM_SELF, (*fieldIn)->size(),
                                   (*fieldIn)->restrict(), &localVec);CHKERRQ(err);
+      err = VecDuplicate(localVec, &vecIn); CHKERRQ(err);
       err = VecScatterBegin(localVec, vecIn, INSERT_VALUES, SCATTER_FORWARD,
                             scatter);CHKERRQ(err);
       err = VecScatterEnd(localVec, vecIn, INSERT_VALUES, SCATTER_FORWARD,
@@ -215,6 +216,7 @@
       err = VecDestroy(localVec); CHKERRQ(err);
       err = KSPSetOperators(*ksp, *jacobian, *jacobian,
                             DIFFERENT_NONZERO_PATTERN); CHKERRQ(err);
+      err = VecDuplicate(vecIn, &vecOut); CHKERRQ(err);
       err = KSPSolve(*ksp, vecIn, vecOut); CHKERRQ(err);
       err = VecCreateSeqWithArray(PETSC_COMM_SELF, (*fieldOut)->size(),
                                 (*fieldOut)->restrict(), &localVec);CHKERRQ(err);
@@ -232,10 +234,6 @@
     } // try/catch      
     #}embed
 
-    if not mesh.name == "pylith_topology_Mesh":
-      raise TypeError, \
-            "Argument must be extension module type " \
-            "'pylith::topology::Mesh'."
     cdef void* fieldOutVptr
     cdef void* jacobianVptr
     cdef void* fieldInVptr

Modified: short/3D/PyLith/trunk/pylith/problems/Explicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Explicit.py	2007-04-07 20:35:40 UTC (rev 6519)
+++ short/3D/PyLith/trunk/pylith/problems/Explicit.py	2007-04-07 22:16:54 UTC (rev 6520)
@@ -160,22 +160,6 @@
     return
 
 
-  def _calcConstant(self):
-    """
-    Compute residual, {b(t)}.
-    """
-    self._info.log("WARNING: Explicit::calcConstant() not implemented.")
-    return
-
-
-  def _calcJacobian(self):
-    """
-    Compute Jacobian, [A(t)].
-    """
-    self._info.log("WARNING: Explicit::calcJacobian() not implemented.")
-    return
-
-
 # FACTORIES ////////////////////////////////////////////////////////////
 
 def pde_formulation():

Modified: short/3D/PyLith/trunk/pylith/problems/Formulation.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Formulation.py	2007-04-07 20:35:40 UTC (rev 6519)
+++ short/3D/PyLith/trunk/pylith/problems/Formulation.py	2007-04-07 22:16:54 UTC (rev 6520)
@@ -83,22 +83,6 @@
     return
 
 
-  def _calcResidual(self):
-    """
-    Compute residual, {b(t)}.
-    """
-    raise NotImplementedError("Please implement calcResidual().")
-    return
-
-
-  def _calcJacobian(self):
-    """
-    Compute Jacobian, [A(t)].
-    """
-    raise NotImplementedError("Please implement calcJacobian().")
-    return
-
-
 # FACTORIES ////////////////////////////////////////////////////////////
 
 def pde_formulation():

Modified: short/3D/PyLith/trunk/pylith/solver/SolverLinear.py
===================================================================
--- short/3D/PyLith/trunk/pylith/solver/SolverLinear.py	2007-04-07 20:35:40 UTC (rev 6519)
+++ short/3D/PyLith/trunk/pylith/solver/SolverLinear.py	2007-04-07 22:16:54 UTC (rev 6520)
@@ -48,8 +48,7 @@
     Constructor.
     """
     Solver.__init__(self, name)
-    import pylith.solver.solver as bindings
-    self.cppHandle = bindings.SolverLinear()
+    self.cppHandle = None
     return
 
 
@@ -57,6 +56,8 @@
     """
     Initialize solver.
     """
+    import pylith.solver.solver as bindings
+    self.cppHandle = bindings.SolverLinear()
     self.cppHandle.initialize(mesh.cppHandle, field)
     return
 



More information about the cig-commits mailing list