[cig-commits] r14361 - in short/3D/PyLith/branches/pylith-swig: . libsrc libsrc/bc libsrc/feassemble libsrc/problems libsrc/topology libsrc/utils unittests/libtests/bc unittests/libtests/feassemble unittests/libtests/topology
brad at geodynamics.org
brad at geodynamics.org
Mon Mar 16 17:57:16 PDT 2009
Author: brad
Date: 2009-03-16 17:57:16 -0700 (Mon, 16 Mar 2009)
New Revision: 14361
Added:
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/problems/SolverLinear.hh
short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverNonlinear.hh
Modified:
short/3D/PyLith/branches/pylith-swig/TODO
short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am
short/3D/PyLith/branches/pylith-swig/libsrc/bc/AbsorbingDampers.cc
short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityExplicit.cc
short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityImplicit.cc
short/3D/PyLith/branches/pylith-swig/libsrc/problems/Makefile.am
short/3D/PyLith/branches/pylith-swig/libsrc/problems/problemsfwd.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/libsrc/topology/Field.icc
short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.cc
short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.hh
short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.cc
short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.hh
short/3D/PyLith/branches/pylith-swig/libsrc/utils/petscfwd.h
short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestAbsorbingDampers.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityImplicit.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestJacobian.cc
Log:
Started working on C++ solver objects (moving stuff from old Pyrex module into C++ code).
Modified: short/3D/PyLith/branches/pylith-swig/TODO
===================================================================
--- short/3D/PyLith/branches/pylith-swig/TODO 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/TODO 2009-03-17 00:57:16 UTC (rev 14361)
@@ -4,6 +4,17 @@
0. SWIG conversion
+ SolutionFields
+ createScatter()
+ scatter()
+
+ libtests/topology/Field
+ createVector()
+ vector()
+ libtests/topology/SolutionFields
+ createScatter()
+ scatter()
+
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-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am 2009-03-17 00:57:16 UTC (rev 14361)
@@ -76,6 +76,7 @@
meshio/PsetFileAscii.cc \
meshio/PsetFileBinary.cc \
problems/Formulation.cc \
+ problems/Solver.cc \
topology/FieldBase.cc \
topology/Jacobian.cc \
topology/Mesh.cc \
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/bc/AbsorbingDampers.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/bc/AbsorbingDampers.cc 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/bc/AbsorbingDampers.cc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -395,7 +395,7 @@
sieveMesh->depth())*spaceDim);
// Get sparse matrix
- const PetscMat* jacobianMat = jacobian->matrix();
+ const PetscMat jacobianMat = jacobian->matrix();
assert(0 != jacobianMat);
// Get parameters used in integration.
@@ -441,7 +441,7 @@
PetscLogFlops(numQuadPts*(3+numBasis*(1+numBasis*(1+2*spaceDim))));
// Assemble cell contribution into PETSc Matrix
- PetscErrorCode err = updateOperator(*jacobianMat, *submesh->getSieve(),
+ PetscErrorCode err = updateOperator(jacobianMat, *submesh->getSieve(),
iV, *c_iter, &_cellMatrix[0],
ADD_VALUES);
CHECK_PETSC_ERROR_MSG(err, "Update to PETSc Mat failed.");
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityExplicit.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityExplicit.cc 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityExplicit.cc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -314,7 +314,7 @@
assert(!dispTSection.isNull());
// Get sparse matrix
- const PetscMat* jacobianMat = jacobian->matrix();
+ const PetscMat jacobianMat = jacobian->matrix();
assert(0 != jacobianMat);
// Get parameters used in integration.
@@ -379,7 +379,7 @@
// Assemble cell contribution into PETSc matrix.
_logger->eventBegin(updateEvent);
jacobianVisitor.clear();
- PetscErrorCode err = updateOperator(*jacobianMat, *sieveMesh->getSieve(),
+ PetscErrorCode err = updateOperator(jacobianMat, *sieveMesh->getSieve(),
jacobianVisitor, *c_iter,
&_cellMatrix[0], ADD_VALUES);
CHECK_PETSC_ERROR_MSG(err, "Update to PETSc Mat failed.");
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityImplicit.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityImplicit.cc 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/ElasticityImplicit.cc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -355,7 +355,7 @@
&dispTBctpdtCell[0]);
// Get sparse matrix
- const PetscMat* jacobianMat = jacobian->matrix();
+ const PetscMat jacobianMat = jacobian->matrix();
assert(0 != jacobianMat);
// Get parameters used in integration.
@@ -448,7 +448,7 @@
// Assemble cell contribution into PETSc matrix.
_logger->eventBegin(updateEvent);
jacobianVisitor.clear();
- PetscErrorCode err = updateOperator(*jacobianMat, *sieveMesh->getSieve(),
+ PetscErrorCode err = updateOperator(jacobianMat, *sieveMesh->getSieve(),
jacobianVisitor, *c_iter,
&_cellMatrix[0], ADD_VALUES);
CHECK_PETSC_ERROR_MSG(err, "Update to PETSc Mat failed.");
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/problems/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/Makefile.am 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/Makefile.am 2009-03-17 00:57:16 UTC (rev 14361)
@@ -15,6 +15,9 @@
subpkginclude_HEADERS = \
Formulation.hh \
+ Solver.hh \
+ SolverLinear.hh \
+ SolverNonlinear.hh \
problemsfwd.hh
noinst_HEADERS =
Added: short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.cc (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.cc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "Solver.hh" // implementation of class methods
+
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+
+
+// ----------------------------------------------------------------------
+// Constructor
+pylith::problems::Solver::Solver(void)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::problems::Solver::~Solver(void)
+{ // destructor
+} // destructor
+
+// ----------------------------------------------------------------------
+// Initialize solver.
+void
+pylith::problems::Solver::initialize(topology::SolutionFields* fields)
+{ // initialize
+ assert(0 != fields);
+
+ fields->createScatter();
+
+ topology::Field<topology::Mesh>& solution = fields->solution();
+ solution.createVector();
+
+ topology::Field<topology::Mesh>& residual = fields->get("residual");
+ residual.createVector();
+} // initialize
+
+
+// End of file
Added: short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.hh (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/Solver.hh 2009-03-17 00:57:16 UTC (rev 14361)
@@ -0,0 +1,67 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file pylith/problems/Solver.hh
+ *
+ * @brief Abstract C++ base class for using PETSc linear and nonlinear
+ * solvers.
+ */
+
+#if !defined(pylith_problems_solver_hh)
+#define pylith_problems_solver_hh
+
+// Include directives ---------------------------------------------------
+#include "problemsfwd.hh" // forward declarations
+
+#include "pylith/topology/topologyfwd.hh" // USES SolutionFields
+#include "pylith/utils/petscfwd.h" // USES PetscVec
+
+
+// Solver ---------------------------------------------------------
+class pylith::problems::Solver
+{ // Integrator
+ friend class TestSolver; // unit testing
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /// Constructor
+ Solver(void);
+
+ /// Destructor
+ ~Solver(void);
+
+ /** Initialize solver.
+ *
+ * @param fields Solution fields.
+ */
+ virtual
+ void
+ initialize(topology::SolutionFields* fields);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ Solver(const Solver&); ///< Not implemented
+ const Solver& operator=(const Solver&); ///< Not implemented
+
+}; // Solver
+
+#endif // pylith_problems_solver_hh
+
+
+// End of file
Added: short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverLinear.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverLinear.hh (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverLinear.hh 2009-03-17 00:57:16 UTC (rev 14361)
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file pylith/problems/SolverLinear.hh
+ *
+ * @brief Object for using PETSc scalable linear equation solvers (KSP).
+ *
+ * The PETSc linear KSP solvers provide an interface to Krylov subspace
+ * (KS) iterative methods and preconditioners (P).
+ */
+
+#if !defined(pylith_problems_solverlinear_hh)
+#define pylith_problems_solverlinear_hh
+
+// Include directives ---------------------------------------------------
+#include "problemsfwd.hh" // forward declarations
+
+#include "pylith/feassemble/feassemblefwd.hh" // USES Integrator
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, Field, SolutionFields
+
+// SolverLinear ---------------------------------------------------------
+class pylith::problems::SolverLinear
+{ // Integrator
+ friend class TestSolverLinear; // unit testing
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /// Constructor
+ SolverLinear(void);
+
+ /// Destructor
+ ~SolverLinear(void);
+
+ /** Set initial guess nonzero flag.
+ *
+ * True = use previous solution as initial guess, False = use zero
+ * as initial guess.
+ */
+ void initialGuessNonzero(bool flag);
+
+ /** Solve the system.
+ *
+ * @param solution Solution field.
+ * @param jacobian Jacobian of the system.
+ * @param residual Residual field.
+ */
+ void solve(topology::Field<topology::Mesh>* solution,
+ const topology::Jacobian& jacobian,
+ const topology::Field<topology::Mesh>& residual);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ SolverLinear(const SolverLinear&); ///< Not implemented
+ const SolverLinear& operator=(const SolverLinear&); ///< Not implemented
+
+}; // SolverLinear
+
+#endif // pylith_problems_solverlinear_hh
+
+
+// End of file
Added: short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverNonlinear.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverNonlinear.hh (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/SolverNonlinear.hh 2009-03-17 00:57:16 UTC (rev 14361)
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file pylith/problems/SolverNonlinear.hh
+ *
+ * @brief Object for using PETSc scalable nonlinear equation solvers (SNES).
+ *
+ * The PETSc nonlinear solvers provide an interface to Newton-based
+ * methods for solving nonlinear equations.
+ */
+
+#if !defined(pylith_problems_solvernonlinear_hh)
+#define pylith_problems_solvernonlinear_hh
+
+// Include directives ---------------------------------------------------
+#include "problemsfwd.hh" // forward declarations
+
+#include "pylith/feassemble/feassemblefwd.hh" // USES Integrator
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, Field, SolutionFields
+
+// SolverNonlinear ---------------------------------------------------------
+class pylith::problems::SolverNonlinear
+{ // Integrator
+ friend class TestSolverNonlinear; // unit testing
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /// Constructor
+ SolverNonlinear(void);
+
+ /// Destructor
+ ~SolverNonlinear(void);
+
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ SolverNonlinear(const SolverNonlinear&); ///< Not implemented
+ const SolverNonlinear& operator=(const SolverNonlinear&); ///< Not implemented
+
+}; // SolverNonlinear
+
+#endif // pylith_problems_solvernonlinear_hh
+
+
+// End of file
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/problems/problemsfwd.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/problems/problemsfwd.hh 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/problems/problemsfwd.hh 2009-03-17 00:57:16 UTC (rev 14361)
@@ -26,6 +26,10 @@
class Formulation;
+ class Solver;
+ class SolverLinear;
+ class SolverNonlinear;
+
} // problems
} // pylith
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -19,6 +19,7 @@
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
#include <stdexcept> // USES std::runtime_error
#include <sstream> // USES std::ostringstream
#include <cassert> // USES assert()
@@ -30,6 +31,7 @@
_scale(1.0),
_name("unknown"),
_mesh(mesh),
+ _vector(0),
_vecFieldType(OTHER),
_dimensionsOkay(false)
{ // constructor
@@ -40,6 +42,10 @@
template<typename mesh_type>
pylith::topology::Field<mesh_type>::~Field(void)
{ // destructor
+ if (0 != _vector) {
+ PetscErrorCode err = VecDestroy(_vector); _vector = 0;
+ CHECK_PETSC_ERROR(err);
+ } // if
} // destructor
// ----------------------------------------------------------------------
@@ -384,5 +390,34 @@
_section->view(label);
} // view
+// ----------------------------------------------------------------------
+// Create PETSc vector for field.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::createVector(void)
+{ // createVector
+ PetscErrorCode err = 0;
+ if (0 != _vector) {
+ err = VecDestroy(_vector); _vector = 0;
+ CHECK_PETSC_ERROR(err);
+ } // if
+
+ const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = _mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<typename mesh_type::SieveMesh::order_type>& order =
+ sieveMesh->getFactory()->getGlobalOrder(sieveMesh,
+ _section->getName(), _section);
+ assert(!order.isNull());
+
+ err = VecCreate(_mesh.comm(), &_vector);
+ CHECK_PETSC_ERROR(err);
+
+ err = VecSetSizes(_vector, order->getLocalSize(), order->getGlobalSize());
+ CHECK_PETSC_ERROR(err);
+
+ err = VecSetFromOptions(_vector); CHECK_PETSC_ERROR(err);
+} // createVector
+
+
// End of file
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh 2009-03-17 00:57:16 UTC (rev 14361)
@@ -25,6 +25,8 @@
// Include directives ---------------------------------------------------
#include "FieldBase.hh" // ISA FieldBase
+#include "pylith/utils/petscfwd.h" // HASA PetscVec
+
#include <petscmesh.hh>
// Field ----------------------------------------------------------------
@@ -199,6 +201,21 @@
*/
void view(const char* label);
+ /// Create PETSc vector for field.
+ void createVector(void);
+
+ /** Get PETSc vector associated with field.
+ *
+ * @returns PETSc vector.
+ */
+ PetscVec vector(void);
+
+ /** Get PETSc vector associated with field.
+ *
+ * @returns PETSc vector.
+ */
+ const PetscVec vector(void) const;
+
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
@@ -206,6 +223,7 @@
std::string _name; ///< Name of field
const mesh_type& _mesh; ///< Mesh associated with section
ALE::Obj<RealSection> _section; ///< Real section with data
+ PetscVec _vector;
VectorFieldEnum _vecFieldType; ///< Type of vector field
bool _dimensionsOkay; ///< Flag indicating it is okay to dimensionalize
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.icc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.icc 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.icc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -95,6 +95,22 @@
return _dimensionsOkay;
}
+// Get PETSc vector associated with field.
+template<typename mesh_type>
+inline
+PetscVec
+pylith::topology::Field<mesh_type>::vector(void) {
+ return _vector;
+}
+
+// Get PETSc vector associated with field.
+template<typename mesh_type>
+inline
+const PetscVec
+pylith::topology::Field<mesh_type>::vector(void) const {
+ return _vector;
+}
+
#endif
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.cc 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.cc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -29,10 +29,8 @@
const ALE::Obj<Mesh::SieveMesh>& sieveMesh = fields.mesh().sieveMesh();
const ALE::Obj<Mesh::RealSection>& solnSection = fields.solution().section();
- _matrix = new PetscMat;
- assert(0 != _matrix);
PetscErrorCode err = MeshCreateMatrix(sieveMesh, solnSection,
- MATAIJ, _matrix);
+ MATAIJ, &_matrix);
CHECK_PETSC_ERROR_MSG(err, "Could not create PETSc sparse matrix "
"associated with system Jacobian.");
} // constructor
@@ -41,13 +39,12 @@
// Destructor.
pylith::topology::Jacobian::~Jacobian(void)
{ // destructor
- MatDestroy(*_matrix);
- delete _matrix; _matrix = 0;
+ MatDestroy(_matrix); _matrix = 0;
} // destructor
// ----------------------------------------------------------------------
// Get PETSc matrix.
-const PetscMat*
+const PetscMat
pylith::topology::Jacobian::matrix(void) const
{ // matrix
return _matrix;
@@ -55,7 +52,7 @@
// ----------------------------------------------------------------------
// Get PETSc matrix.
-PetscMat*
+PetscMat
pylith::topology::Jacobian::matrix(void)
{ // matrix
return _matrix;
@@ -68,14 +65,14 @@
{ // assemble
PetscErrorCode err = 0;
if (0 == strcmp(mode, "final_assembly")) {
- err = MatAssemblyBegin(*_matrix, MAT_FINAL_ASSEMBLY);
+ err = MatAssemblyBegin(_matrix, MAT_FINAL_ASSEMBLY);
CHECK_PETSC_ERROR(err);
- err = MatAssemblyEnd(*_matrix, MAT_FINAL_ASSEMBLY);
+ err = MatAssemblyEnd(_matrix, MAT_FINAL_ASSEMBLY);
CHECK_PETSC_ERROR(err);
} else if (0 == strcmp(mode, "flush_assembly")) {
- err = MatAssemblyBegin(*_matrix, MAT_FLUSH_ASSEMBLY);
+ err = MatAssemblyBegin(_matrix, MAT_FLUSH_ASSEMBLY);
CHECK_PETSC_ERROR(err);
- err = MatAssemblyEnd(*_matrix, MAT_FLUSH_ASSEMBLY);
+ err = MatAssemblyEnd(_matrix, MAT_FLUSH_ASSEMBLY);
CHECK_PETSC_ERROR(err);
} else
throw std::runtime_error("Unknown mode for assembly of sparse matrix "
@@ -87,7 +84,7 @@
void
pylith::topology::Jacobian::zero(void)
{ // zero
- PetscErrorCode err = MatZeroEntries(*_matrix);
+ PetscErrorCode err = MatZeroEntries(_matrix);
CHECK_PETSC_ERROR(err);
} // zero
@@ -96,7 +93,7 @@
void
pylith::topology::Jacobian::view(void)
{ // view
- PetscErrorCode err = MatView(*_matrix, PETSC_VIEWER_STDOUT_WORLD);
+ PetscErrorCode err = MatView(_matrix, PETSC_VIEWER_STDOUT_WORLD);
CHECK_PETSC_ERROR(err);
} // view
@@ -113,7 +110,7 @@
PetscViewerBinaryOpen(comm, filename, FILE_MODE_WRITE, &viewer);
CHECK_PETSC_ERROR(err);
- err = MatView(*_matrix, viewer); CHECK_PETSC_ERROR(err);
+ err = MatView(_matrix, viewer); CHECK_PETSC_ERROR(err);
err = PetscViewerDestroy(viewer); CHECK_PETSC_ERROR(err);
} // write
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.hh 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.hh 2009-03-17 00:57:16 UTC (rev 14361)
@@ -45,13 +45,13 @@
*
* @returns PETSc sparse matrix.
*/
- const PetscMat* matrix(void) const;
+ const PetscMat matrix(void) const;
/** Get PETSc matrix.
*
* @returns PETSc sparse matrix.
*/
- PetscMat* matrix(void);
+ PetscMat matrix(void);
/** Assemble matrix.
*
@@ -75,7 +75,7 @@
private :
const SolutionFields& _fields; ///< Solution fields associated with problem.
- PetscMat* _matrix; ///< Sparse matrix for Jacobian of problem.
+ PetscMat _matrix; ///< Sparse matrix for Jacobian of problem.
// 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 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.cc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -99,5 +99,26 @@
_fields[_history[0]] = tmp;
} // shiftHistory
+// ----------------------------------------------------------------------
+// Create vector scatter associated with solution fields.
+void
+pylith::topology::SolutionFields::createScatter(void)
+{ // createScatter
+} // createScatter
+// ----------------------------------------------------------------------
+// Get vector scatter associated with solution fields.
+const PetscVecScatter
+pylith::topology::SolutionFields::scatter(void) const
+{ // scatter
+} // scatter
+
+// ----------------------------------------------------------------------
+// Get vector scatter associated with solution fields.
+PetscVecScatter
+pylith::topology::SolutionFields::scatter(void)
+{ // scatter
+} // scatter
+
+
// End of file
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.hh 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.hh 2009-03-17 00:57:16 UTC (rev 14361)
@@ -78,9 +78,26 @@
*/
void shiftHistory(void);
+ /// Create vector scatter associated with solution fields.
+ void createScatter(void);
+
+ /** Get vector scatter associated with solution fields.
+ *
+ * @returns PETSc vector scatter.
+ */
+ const PetscVecScatter scatter(void) const;
+
+ /** Get vector scatter associated with solution fields.
+ *
+ * @returns PETSc vector scatter.
+ */
+ PetscVecScatter scatter(void);
+
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
+ PetscVecScatter _scatter; /// Petsc vector scatter.
+
/// Name of field that corresponds to the solution.
std::string _solutionName;
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/utils/petscfwd.h
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/utils/petscfwd.h 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/utils/petscfwd.h 2009-03-17 00:57:16 UTC (rev 14361)
@@ -26,6 +26,9 @@
/// forward declaration for PETSc Vec
typedef struct _p_Vec* PetscVec;
+/// forward declaration for PETSc VecScatter
+typedef struct _p_VecScatter* PetscVecScatter;
+
/// forward declaration for PETSc ISLocalToGlobalMapping
typedef struct _p_ISLocalToGlobalMapping* PetscISLocalToGlobalMapping;
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestAbsorbingDampers.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestAbsorbingDampers.cc 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestAbsorbingDampers.cc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -219,16 +219,16 @@
const int nrowsE = totalNumVertices * _data->spaceDim;
const int ncolsE = totalNumVertices * _data->spaceDim;
- const PetscMat* jacobianMat = jacobian.matrix();
+ const PetscMat jacobianMat = jacobian.matrix();
int nrows = 0;
int ncols = 0;
- MatGetSize(*jacobianMat, &nrows, &ncols);
+ MatGetSize(jacobianMat, &nrows, &ncols);
CPPUNIT_ASSERT_EQUAL(nrowsE, nrows);
CPPUNIT_ASSERT_EQUAL(ncolsE, ncols);
PetscMat jDense;
PetscMat jSparseAIJ;
- MatConvert(*jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
+ MatConvert(jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
MatConvert(jSparseAIJ, MATSEQDENSE, MAT_INITIAL_MATRIX, &jDense);
double_array vals(nrows*ncols);
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.cc 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.cc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -224,17 +224,17 @@
const int nrowsE = _data->numVertices * _data->spaceDim;
const int ncolsE = _data->numVertices * _data->spaceDim;
- const PetscMat* jacobianMat = jacobian.matrix();
+ const PetscMat jacobianMat = jacobian.matrix();
int nrows = 0;
int ncols = 0;
- MatGetSize(*jacobianMat, &nrows, &ncols);
+ MatGetSize(jacobianMat, &nrows, &ncols);
CPPUNIT_ASSERT_EQUAL(nrowsE, nrows);
CPPUNIT_ASSERT_EQUAL(ncolsE, ncols);
PetscMat jDense;
PetscMat jSparseAIJ;
- MatConvert(*jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
+ MatConvert(jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
MatConvert(jSparseAIJ, MATSEQDENSE, MAT_INITIAL_MATRIX, &jDense);
double_array vals(nrows*ncols);
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityImplicit.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityImplicit.cc 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityImplicit.cc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -224,17 +224,17 @@
const int nrowsE = _data->numVertices * _data->spaceDim;
const int ncolsE = _data->numVertices * _data->spaceDim;
- const PetscMat* jacobianMat = jacobian.matrix();
+ const PetscMat jacobianMat = jacobian.matrix();
int nrows = 0;
int ncols = 0;
- MatGetSize(*jacobianMat, &nrows, &ncols);
+ MatGetSize(jacobianMat, &nrows, &ncols);
CPPUNIT_ASSERT_EQUAL(nrowsE, nrows);
CPPUNIT_ASSERT_EQUAL(ncolsE, ncols);
PetscMat jDense;
PetscMat jSparseAIJ;
- MatConvert(*jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
+ MatConvert(jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
MatConvert(jSparseAIJ, MATSEQDENSE, MAT_INITIAL_MATRIX, &jDense);
double_array vals(nrows*ncols);
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestJacobian.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestJacobian.cc 2009-03-17 00:18:09 UTC (rev 14360)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestJacobian.cc 2009-03-17 00:57:16 UTC (rev 14361)
@@ -46,7 +46,7 @@
_initialize(&mesh, &fields);
Jacobian jacobian(fields);
- const PetscMat* matrix = jacobian.matrix();
+ const PetscMat matrix = jacobian.matrix();
CPPUNIT_ASSERT(0 != matrix);
} // testMatrix
More information about the CIG-COMMITS
mailing list