本文整理汇总了C++中TPZAutoPointer::SolveSSOR方法的典型用法代码示例。如果您正苦于以下问题:C++ TPZAutoPointer::SolveSSOR方法的具体用法?C++ TPZAutoPointer::SolveSSOR怎么用?C++ TPZAutoPointer::SolveSSOR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPZAutoPointer
的用法示例。
在下文中一共展示了TPZAutoPointer::SolveSSOR方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: H
void TPZStepSolver<TVar>::Solve(const TPZFMatrix<TVar> &F, TPZFMatrix<TVar> &result, TPZFMatrix<TVar> *residual){
if(!this->Matrix()) {
cout << "TPZMatrixSolver::Solve called without a matrix pointer\n";
DebugStop();
}
TPZAutoPointer<TPZMatrix<TVar> > mat = this->Matrix();
// update the matrix to which the preconditioner refers
if(fPrecond)
{
fPrecond->UpdateFrom(this->Matrix());
}
if(result.Rows() != mat->Rows() || result.Cols() != F.Cols()) {
result.Redim(mat->Rows(),F.Cols());
}
if(this->fScratch.Rows() != result.Rows() || this->fScratch.Cols() != result.Cols()) {
this->fScratch.Redim(result.Rows(),result.Cols());
}
TVar tol = fTol;
int numiterations = fNumIterations;
switch(fSolver) {
case TPZStepSolver::ENoSolver:
default:
cout << "TPZMatrixSolver::Solve called without initialized solver, Jacobi used\n";
SetJacobi(1,0.,0);
case TPZStepSolver::EJacobi:
// cout << "fScratch dimension " << fScratch.Rows() << ' ' << fScratch.Cols() << endl;
mat->SolveJacobi(numiterations,F,result,residual,this->fScratch,tol,fFromCurrent);
break;
case TPZStepSolver::ESOR:
mat->SolveSOR(numiterations,F,result,residual,this->fScratch,fOverRelax,tol,fFromCurrent);
break;
case TPZStepSolver::ESSOR:
mat->SolveSSOR(numiterations,F,result,residual,this->fScratch,fOverRelax,tol,fFromCurrent);
break;
case TPZStepSolver::ECG:
mat->SolveCG(numiterations,*fPrecond,F,result,residual,tol,fFromCurrent);
#ifdef LOG4CXX
{
std::stringstream sout;
sout << "Number of equations " << mat->Rows() << std::endl;
sout << "Number of CG iterations " << numiterations << " tol = " << tol;
LOGPZ_DEBUG(logger,sout.str().c_str());
}
#endif
break;
case TPZStepSolver::EGMRES: {
TPZFMatrix<TVar> H(fNumVectors+1,fNumVectors+1,0.);
mat->SolveGMRES(numiterations,*fPrecond,H,fNumVectors,F,result,residual,tol,fFromCurrent);
if(numiterations == fNumIterations || tol >= fTol)
{
std::cout << "GMRes tolerance was not achieved : numiter " << numiterations <<
" tol " << tol << endl;
}
#ifdef LOG4CXX
{
std::stringstream sout;
sout << "Number of GMRES iterations " << numiterations << " tol = " << tol;
LOGPZ_DEBUG(logger,sout.str().c_str());
}
#endif
}
break;
case TPZStepSolver::EBICGSTAB:
mat->SolveBICGStab(numiterations, *fPrecond, F, result,residual,tol,fFromCurrent);
if(numiterations == fNumIterations || tol >= fTol)
{
std::cout << "BiCGStab tolerance was not achieved : numiter " << numiterations <<
" tol " << tol << endl;
}
#ifdef LOG4CXX
{
std::stringstream sout;
sout << "Number of BiCGStab iterations " << numiterations << " tol = " << tol;
LOGPZ_DEBUG(logger,sout.str().c_str());
}
#endif
break;
case TPZStepSolver::EDirect:
result = F;
mat->SolveDirect(result,fDecompose,fSingular);
if(residual) residual->Redim(F.Rows(),F.Cols());
break;
case TPZStepSolver::EMultiply:
mat->Multiply(F,result);
if(residual) mat->Residual(result,F,*residual);
}
}