[cig-commits] r14409 - in short/3D/PyLith/branches/pylith-swig: . libsrc libsrc/problems libsrc/topology unittests/libtests/topology
brad at geodynamics.org
brad at geodynamics.org
Fri Mar 20 17:36:40 PDT 2009
Author: brad
Date: 2009-03-20 17:36:39 -0700 (Fri, 20 Mar 2009)
New Revision: 14409
Modified:
short/3D/PyLith/branches/pylith-swig/TODO
short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am
short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.cc
short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverLinear.cc
short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverLinear.hh
short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc
short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldMesh.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldSubMesh.cc
Log:
Worked on C++ implementation of SolverLinear (wraps KSP).
Modified: short/3D/PyLith/branches/pylith-swig/TODO
===================================================================
--- short/3D/PyLith/branches/pylith-swig/TODO 2009-03-20 23:36:56 UTC (rev 14408)
+++ short/3D/PyLith/branches/pylith-swig/TODO 2009-03-21 00:36:39 UTC (rev 14409)
@@ -4,10 +4,6 @@
0. SWIG conversion
- libsrc/topology/Field
- createScatter()
- When copying layout, copy VecScatter. [Fields]
-
Cleanup logging. Constraints and Integrators should log at the C++
level using the C++ EventLogger. Add finer grain logging at C++
level as in ElasticityImplicit.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am 2009-03-20 23:36:56 UTC (rev 14408)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am 2009-03-21 00:36:39 UTC (rev 14409)
@@ -77,6 +77,7 @@
meshio/PsetFileBinary.cc \
problems/Formulation.cc \
problems/Solver.cc \
+ problems/SolverLinear.cc \
topology/FieldBase.cc \
topology/Jacobian.cc \
topology/Mesh.cc \
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.cc 2009-03-20 23:36:56 UTC (rev 14408)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.cc 2009-03-21 00:36:39 UTC (rev 14409)
@@ -14,8 +14,6 @@
#include "Solver.hh" // implementation of class methods
-#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
-
// ----------------------------------------------------------------------
// Constructor
pylith::problems::Solver::Solver(void)
@@ -33,15 +31,6 @@
void
pylith::problems::Solver::initialize(topology::SolutionFields* fields)
{ // initialize
- assert(0 != fields);
-
- topology::Field<topology::Mesh>& solution = fields->solution();
- solution.createVector(); // Move this to use of SolutionFields and copyLayout?
- solution.createScatter();
-
- topology::Field<topology::Mesh>& residual = fields->get("residual");
- residual.createVector();
- solution.createScatter(); // :TODO: eliminate duplication
} // initialize
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverLinear.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverLinear.cc 2009-03-20 23:36:56 UTC (rev 14408)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverLinear.cc 2009-03-21 00:36:39 UTC (rev 14409)
@@ -15,9 +15,12 @@
#include "SolverLinear.hh" // implementation of class methods
#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
#include <petscksp.h> // USES PetscKSP
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
+
// ----------------------------------------------------------------------
// Constructor
pylith::problems::SolverLinear::SolverLinear(void) :
@@ -43,7 +46,8 @@
assert(0 != _ksp);
PetscTruth flag = (value) ? PETSC_TRUE : PETSC_FALSE;
- KSPSetInitialGuessNonzero(_ksp, flag);
+ PetscErrorCode err = KSPSetInitialGuessNonzero(_ksp, flag);
+ CHECK_PETSC_ERROR(err);
} // initialGuessNonzero
// ----------------------------------------------------------------------
@@ -76,8 +80,9 @@
PetscErrorCode err = 0;
// Update PetscVector view of field.
- residual->scatterSectionToVector();
+ residual.scatterSectionToVector();
+ const PetscMat jacobianMat = jacobian.matrix();
err = KSPSetOperators(_ksp, jacobianMat, jacobianMat,
DIFFERENT_NONZERO_PATTERN); CHECK_PETSC_ERROR(err);
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverLinear.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverLinear.hh 2009-03-20 23:36:56 UTC (rev 14408)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverLinear.hh 2009-03-21 00:36:39 UTC (rev 14409)
@@ -23,13 +23,12 @@
#define pylith_problems_solverlinear_hh
// Include directives ---------------------------------------------------
-#include "problemsfwd.hh" // forward declarations
+#include "Solver.hh" // ISA Solver
-#include "pylith/feassemble/feassemblefwd.hh" // USES Integrator
-#include "pylith/topology/topologyfwd.hh" // USES Mesh, Field, SolutionFields
+#include "pylith/utils/petscfwd.h" // HASA PetscKSP
// SolverLinear ---------------------------------------------------------
-class pylith::problems::SolverLinear
+class pylith::problems::SolverLinear : Solver
{ // Integrator
friend class TestSolverLinear; // unit testing
@@ -69,6 +68,7 @@
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
+ PetscKSP _ksp; ///< PETSc KSP linear solver.
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc 2009-03-20 23:36:56 UTC (rev 14408)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc 2009-03-21 00:36:39 UTC (rev 14409)
@@ -459,15 +459,12 @@
// PETSc vector view of the field.
template<typename mesh_type>
void
-pylith::topology::Field<mesh_type>::scatterSectionToVector(void)
+pylith::topology::Field<mesh_type>::scatterSectionToVector(void) const
{ // scatterSectionToVector
assert(!_section.isNull());
+ assert(0 != _scatter);
+ assert(0 != _vector);
- if (0 == _scatter)
- createScatter();
- if (0 == _vector)
- createVector();
-
PetscErrorCode err = 0;
PetscVec localVec = 0;
err = VecCreateSeqWithArray(PETSC_COMM_SELF,
@@ -485,15 +482,12 @@
// section view of the field.
template<typename mesh_type>
void
-pylith::topology::Field<mesh_type>::scatterVectorToSection(void)
+pylith::topology::Field<mesh_type>::scatterVectorToSection(void) const
{ // scatterVectorToSection
assert(!_section.isNull());
+ assert(0 != _scatter);
+ assert(0 != _vector);
- if (0 == _scatter)
- createScatter();
- if (0 == _vector)
- createVector();
-
PetscErrorCode err = 0;
PetscVec localVec = 0;
err = VecCreateSeqWithArray(PETSC_COMM_SELF,
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh 2009-03-20 23:36:56 UTC (rev 14408)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh 2009-03-21 00:36:39 UTC (rev 14409)
@@ -223,11 +223,11 @@
/// Scatter section information across processors to update the
/// PETSc vector view of the field.
- void scatterSectionToVector(void);
+ void scatterSectionToVector(void) const;
/// Scatter PETSc vector information across processors to update the
/// Sieve section view of the field.
- void scatterVectorToSection(void);
+ void scatterVectorToSection(void) const;
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldMesh.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldMesh.cc 2009-03-20 23:36:56 UTC (rev 14408)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldMesh.cc 2009-03-21 00:36:39 UTC (rev 14409)
@@ -787,6 +787,8 @@
section->updatePoint(*v_iter, &values[0]);
} // for
+ field.createVector();
+ field.createScatter();
field.scatterSectionToVector();
CPPUNIT_ASSERT(0 != field._scatter);
const PetscVec vec = field.vector();
@@ -842,6 +844,7 @@
valuesVec[i] = valuesE[i];
VecRestoreArray(vec, &valuesVec);
+ field.createScatter();
field.scatterVectorToSection();
CPPUNIT_ASSERT(0 != field._scatter);
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldSubMesh.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldSubMesh.cc 2009-03-20 23:36:56 UTC (rev 14408)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldSubMesh.cc 2009-03-21 00:36:39 UTC (rev 14409)
@@ -808,6 +808,8 @@
section->updatePoint(*v_iter, &values[0]);
} // for
+ field.createVector();
+ field.createScatter();
field.scatterSectionToVector();
CPPUNIT_ASSERT(0 != field._scatter);
const PetscVec vec = field.vector();
@@ -866,6 +868,7 @@
valuesVec[i] = valuesE[i];
VecRestoreArray(vec, &valuesVec);
+ field.createScatter();
field.scatterVectorToSection();
CPPUNIT_ASSERT(0 != field._scatter);
More information about the CIG-COMMITS
mailing list