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
This commit is contained in:
akva 2011-02-25 10:37:32 +00:00 committed by Knut Morten Okstad
parent 16eada7028
commit cb062d0f44
2 changed files with 30 additions and 21 deletions

View File

@ -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<PETScMatrix*>(A)->beginAssembly()) return false;
if (!static_cast<PETScMatrix*>(A)->endAssembly()) return false;
if (!static_cast<PETScVector*>(b)->beginAssembly()) return false;
if (!static_cast<PETScVector*>(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<PETScMatrix*>(A)->beginAssembly()) return false;
if (!static_cast<PETScMatrix*>(A)->endAssembly()) return false;
if (!static_cast<PETScVector*>(b)->beginAssembly()) return false;
if (!static_cast<PETScVector*>(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;
}

View File

@ -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
//!