Added argument newLHSmatrix for method finalizeAssembly, and argument pindex (optional) for method setProperty

git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@861 e10b68d5-8a6e-419e-a041-bce267b0401d
This commit is contained in:
kmo 2011-03-08 09:51:35 +00:00 committed by Knut Morten Okstad
parent 3a4e4215e8
commit c33e4b73fe
2 changed files with 28 additions and 12 deletions

View File

@ -280,15 +280,24 @@ bool SIMbase::preprocess (const std::vector<int>& ignoredPatches, bool fixDup)
}
void SIMbase::setPropertyType (int code, Property::Type ptype)
bool SIMbase::setPropertyType (int code, Property::Type ptype, int pindex)
{
if (code < 0)
{
std::cerr <<" ** SIMbase::setPropertyType: Negative property code "
<< code <<" (ignored)"<< std::endl;
else for (size_t j = 0; j < myProps.size(); j++)
return false;
}
for (size_t j = 0; j < myProps.size(); j++)
if (myProps[j].pindx == (size_t)code &&
myProps[j].pcode == Property::UNDEFINED)
{
myProps[j].pcode = ptype;
if (pindex >= 0) myProps[j].pindx = pindex;
}
return true;
}
@ -479,7 +488,7 @@ bool SIMbase::assembleSystem (const TimeDomain& time, const Vectors& prevSol,
else
ok = false;
return ok && finalizeAssembly();
return ok && this->finalizeAssembly(newLHSmatrix);
}
@ -1238,22 +1247,27 @@ bool SIMbase::dumpSolution (const Vector& psol, std::ostream& os) const
return true;
}
void SIMbase::readLinSolParams(std::istream& is, int npar)
void SIMbase::readLinSolParams (std::istream& is, int npar)
{
if (!mySolParams) mySolParams = new LinSolParams();
mySolParams->read(is,npar);
}
bool SIMbase::finalizeAssembly()
bool SIMbase::finalizeAssembly (bool newLHSmatrix)
{
SystemMatrix* A = myEqSys->getMatrix();
SystemVector* b = myEqSys->getVector();
if (A && b && A->getType() == SystemMatrix::PETSC)
{
//Communication of matrix and vector assembly (for PETSC only)
// 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 (newLHSmatrix)
{
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

View File

@ -140,7 +140,7 @@ public:
// TODO: This HAS to be called from subclasses if assembleSystem
// is overridden. This need to be fixed, probably through
// a wrapper function
bool finalizeAssembly();
bool finalizeAssembly(bool newLHSmatrix);
//! \brief Administers assembly of the linear equation system.
//! \param[in] pSol Previous primary solution vectors in DOF-order
@ -303,7 +303,8 @@ protected:
//! \brief Defines the type of a property set.
//! \param[in] code The property code to be associated with the property type
//! \param[in] ptype The property type to be associated with the given code
void setPropertyType(int code, Property::Type ptype);
//! \param[in] pindex 0-based index into problem-dependent property container
bool setPropertyType(int code, Property::Type ptype, int pindex = -1);
//! \brief Preprocesses a user-defined Dirichlet boundary property.
//! \param[in] patch 1-based index of the patch to receive the property
@ -335,9 +336,10 @@ protected:
//! \param[in] sol Global primary solution vectors in DOF-order
void extractPatchSolution(const ASMbase* patch, const Vectors& sol);
//! \brief Read a LinSolParams from the given stream.
//! This method helps with encapsulating PETSc in libIFEM
//! \brief Read a LinSolParams object from the given stream.
//! \details This method helps with encapsulating PETSc in libIFEM.
void readLinSolParams(std::istream& is, int npar);
public:
//! \brief Enum defining the available discretization methods.
enum Discretization { Spline, Lagrange, Spectral };