[cig-commits] r14364 - in short/3D/PyLith/branches/pylith-swig: . libsrc/problems libsrc/topology libsrc/utils

brad at geodynamics.org brad at geodynamics.org
Mon Mar 16 21:06:27 PDT 2009


Author: brad
Date: 2009-03-16 21:06:26 -0700 (Mon, 16 Mar 2009)
New Revision: 14364

Modified:
   short/3D/PyLith/branches/pylith-swig/TODO
   short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.hh
   short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/utils/petscfwd.h
Log:
More work setting up linear solver.

Modified: short/3D/PyLith/branches/pylith-swig/TODO
===================================================================
--- short/3D/PyLith/branches/pylith-swig/TODO	2009-03-17 03:02:17 UTC (rev 14363)
+++ short/3D/PyLith/branches/pylith-swig/TODO	2009-03-17 04:06:26 UTC (rev 14364)
@@ -4,10 +4,6 @@
 
 0. SWIG conversion
 
-  SolutionFields
-    createScatter()
-    scatter()
-
   libtests/topology/Field
     createVector()
     vector()

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.cc	2009-03-17 03:02:17 UTC (rev 14363)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.cc	2009-03-17 04:06:26 UTC (rev 14364)
@@ -16,10 +16,12 @@
 
 #include "pylith/topology/SolutionFields.hh" // USES SolutionFields
 
+#include <petscksp.h> // USES PetscKSP
 
 // ----------------------------------------------------------------------
 // Constructor
-pylith::problems::Solver::Solver(void)
+pylith::problems::Solver::Solver(void) :
+  _ksp(0)
 { // constructor
 } // constructor
 
@@ -27,6 +29,10 @@
 // Destructor
 pylith::problems::Solver::~Solver(void)
 { // destructor
+  if (0 != _ksp) {
+    PetscErrorCode err = KSPDestroy(_ksp); _ksp = 0;
+    CHECK_PETSC_ERROR(err);
+  } // if
 } // destructor
 
 // ----------------------------------------------------------------------
@@ -43,6 +49,16 @@
 
   topology::Field<topology::Mesh>& residual = fields->get("residual");
   residual.createVector();
+
+  PetscErrorCode err = 0;
+
+  if (0 != _ksp) {
+    err = KSPDestroy(_ksp); _ksp = 0;
+    CHECK_PETSC_ERROR(err);
+  } // if    
+  err = KSPCreate(fields->mesh().comm(), &_ksp); CHECK_PETSC_ERROR(err);
+
+  err = KSPSetFromOptions(_ksp); CHECK_PETSC_ERROR(err);
 } // initialize
 
 

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.hh	2009-03-17 03:02:17 UTC (rev 14363)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.hh	2009-03-17 04:06:26 UTC (rev 14364)
@@ -52,6 +52,7 @@
 // PRIVATE MEMBERS //////////////////////////////////////////////////////
 private :
 
+  PetscKSP _ksp; ///< PETSc KSP linear solver.
 
 // NOT IMPLEMENTED //////////////////////////////////////////////////////
 private :

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.cc	2009-03-17 03:02:17 UTC (rev 14363)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.cc	2009-03-17 04:06:26 UTC (rev 14364)
@@ -14,6 +14,8 @@
 
 #include "SolutionFields.hh" // implementation of class methods
 
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
+
 // ----------------------------------------------------------------------
 // Default constructor.
 pylith::topology::SolutionFields::SolutionFields(const Mesh& mesh) :
@@ -104,6 +106,15 @@
 void
 pylith::topology::SolutionFields::createScatter(void)
 { // createScatter
+  PetscErrorCode err = 0;
+  if (0 != _scatter) {
+    err = VecScatterDestroy(_scatter); _scatter = 0;
+    CHECK_PETSC_ERROR(err);
+  } // if
+  
+  err = MeshCreateGlobalScatter(_mesh.sieveMesh(), 
+				solution().section(), &_scatter);
+  CHECK_PETSC_ERROR(err);
 } // createScatter
 
 // ----------------------------------------------------------------------
@@ -111,6 +122,7 @@
 const PetscVecScatter
 pylith::topology::SolutionFields::scatter(void) const
 { // scatter
+  return _scatter;
 } // scatter
 
 // ----------------------------------------------------------------------
@@ -118,6 +130,7 @@
 PetscVecScatter
 pylith::topology::SolutionFields::scatter(void)
 { // scatter
+  return _scatter;
 } // scatter
 
 

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/utils/petscfwd.h
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/utils/petscfwd.h	2009-03-17 03:02:17 UTC (rev 14363)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/utils/petscfwd.h	2009-03-17 04:06:26 UTC (rev 14364)
@@ -32,6 +32,9 @@
 /// forward declaration for PETSc ISLocalToGlobalMapping
 typedef struct _p_ISLocalToGlobalMapping* PetscISLocalToGlobalMapping;
 
+/// forward declaration for PETSc KSP
+typedef struct _p_KSP* PetscKSP;
+
 /// forward declaration for PETSc SNES
 typedef struct _p_SNES* PetscSNES;
 



More information about the CIG-COMMITS mailing list