[cig-commits] r19284 - short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/problems

brad at geodynamics.org brad at geodynamics.org
Fri Dec 9 11:36:13 PST 2011


Author: brad
Date: 2011-12-09 11:36:13 -0800 (Fri, 09 Dec 2011)
New Revision: 19284

Modified:
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/problems/SolverNonlinear.cc
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/problems/SolverNonlinear.hh
Log:
Added setting initial guess for nonlinear solver to zero (important for friction which assumes fault is locked at first iteration).

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/problems/SolverNonlinear.cc
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/problems/SolverNonlinear.cc	2011-12-09 09:54:48 UTC (rev 19283)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/problems/SolverNonlinear.cc	2011-12-09 19:36:13 UTC (rev 19284)
@@ -98,6 +98,7 @@
 
   err = SNESSetFromOptions(_snes); CHECK_PETSC_ERROR(err);
   err = SNESLineSearchSet(_snes, lineSearch, (void*) formulation); CHECK_PETSC_ERROR(err);
+  err = SNESSetComputeInitialGuess(_snes, initialGuess, (void*) formulation); CHECK_PETSC_ERROR(err);
 
   if (formulation->splitFields()) {
     PetscKSP ksp = 0;
@@ -425,6 +426,18 @@
 } // lineSearch
 
 // ----------------------------------------------------------------------
+// Generic C interface for customized PETSc initial guess.
+#undef __FUNCT__
+#define __FUNCT__ "initialGuess"
+PetscErrorCode
+pylith::problems::SolverNonlinear::initialGuess(PetscSNES snes,
+						PetscVec initialGuessVec,
+						void *lsctx)
+{ // initialGuess
+  VecSet(initialGuessVec, 0.0);
+} // initialGuess
+
+// ----------------------------------------------------------------------
 // Initialize logger.
 void
 pylith::problems::SolverNonlinear::_initializeLogger(void)

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/problems/SolverNonlinear.hh
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/problems/SolverNonlinear.hh	2011-12-09 09:54:48 UTC (rev 19283)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/problems/SolverNonlinear.hh	2011-12-09 19:36:13 UTC (rev 19284)
@@ -141,6 +141,18 @@
 			    PetscReal *gnorm,
 			    PetscBool *flag);
 
+  /** Generic C interface for customized PETSc initial guess.
+   *
+   * @param snes PETSc SNES solver.
+   * @param initialGuessVec PETSc vector for initial guess.
+   * @param lsctx Optional context for line search (not used here).
+   * @returns PETSc error code.
+   */
+  static
+  PetscErrorCode initialGuess(PetscSNES snes,
+			      PetscVec initialGuessVec,
+			      void *lsctx);
+
 // PRIVATE METHODS //////////////////////////////////////////////////////
 private :
 



More information about the CIG-COMMITS mailing list