From cb062d0f448dcb75105bdf7bb48ef6f01521f7bb Mon Sep 17 00:00:00 2001 From: akva Date: Fri, 25 Feb 2011 10:37:32 +0000 Subject: [PATCH] refactor: move PETSc assembly routine calls to SIMbase::finalizeAssembly(). git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@845 e10b68d5-8a6e-419e-a041-bce267b0401d --- src/SIM/SIMbase.C | 45 ++++++++++++++++++++++++--------------------- src/SIM/SIMbase.h | 6 ++++++ 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/SIM/SIMbase.C b/src/SIM/SIMbase.C index 61f45ed1..b78dd2ff 100644 --- a/src/SIM/SIMbase.C +++ b/src/SIM/SIMbase.C @@ -479,27 +479,7 @@ bool SIMbase::assembleSystem (const TimeDomain& time, const Vectors& prevSol, else ok = false; - SystemMatrix* A = myEqSys->getMatrix(); - SystemVector* b = myEqSys->getVector(); - if (A && b && A->getType() == SystemMatrix::PETSC) - { -#ifdef HAS_PETSC - // Communication of matrix and vector assembly (for PETSc only) - if (!static_cast(A)->beginAssembly()) return false; - if (!static_cast(A)->endAssembly()) return false; - if (!static_cast(b)->beginAssembly()) return false; - if (!static_cast(b)->endAssembly()) return false; -#else - ok = false; -#endif - } - -#if SP_DEBUG > 3 - if (A && newLHSmatrix) std::cout <<"\nSystem coefficient matrix:"<< *A; - if (b) std::cout <<"\nSystem right-hand-side vector:"<< *b; -#endif - - return ok; + return ok && finalizeAssembly(); } @@ -1263,3 +1243,26 @@ void SIMbase::readLinSolParams(std::istream& is, int npar) if (!mySolParams) mySolParams = new LinSolParams(); mySolParams->read(is,npar); } + +bool SIMbase::finalizeAssembly() +{ + SystemMatrix* A = myEqSys->getMatrix(); + SystemVector* b = myEqSys->getVector(); + if (A && b && A->getType() == SystemMatrix::PETSC) + { + //Communication of matrix and vector assembly (for PETSC only) +#ifdef HAS_PETSC + if (!static_cast(A)->beginAssembly()) return false; + if (!static_cast(A)->endAssembly()) return false; + if (!static_cast(b)->beginAssembly()) return false; + if (!static_cast(b)->endAssembly()) return false; +#endif + } + +#if SP_DEBUG > 3 + if (A && newLHSmatrix) std::cout <<"\nSystem coefficient matrix:"<< *A; + if (b) std::cout <<"\nSystem right-hand-side vector:"<< *b; +#endif + + return true; +} diff --git a/src/SIM/SIMbase.h b/src/SIM/SIMbase.h index 6a6173e3..d3f5a52d 100644 --- a/src/SIM/SIMbase.h +++ b/src/SIM/SIMbase.h @@ -136,6 +136,12 @@ public: bool assembleSystem(const TimeDomain& time, const Vectors& pSol = Vectors(), bool newLHSmatrix = true); + //! \brief Finalize system assembly. + // TODO: This HAS to be called from subclasses if assembleSystem + // is overridden. This need to be fixed, probably through + // a wrapper function + bool finalizeAssembly(); + //! \brief Administers assembly of the linear equation system. //! \param[in] pSol Previous primary solution vectors in DOF-order //!