33 shared_ptr<MultiField> bOrig(ls.
getBPtr());
39 shared_ptr<MultiField> r(dynamic_pointer_cast<MultiField>(ls.
getResidual().
newCopy()));
40 shared_ptr<MultiField> rTilda(dynamic_pointer_cast<MultiField>(ls.
getResidual().
newCopy()));
42 shared_ptr<MultiField> p;
43 shared_ptr<MultiField> pHat(dynamic_pointer_cast<MultiField>(x->newClone()));
44 shared_ptr<MultiField> v(dynamic_pointer_cast<MultiField>(x->newClone()));
45 shared_ptr<MultiField> t(dynamic_pointer_cast<MultiField>(x->newClone()));
55 cout << 0 <<
": " << *rNorm0 << endl;
59 if (
verbosity >0 && MPI::COMM_WORLD.Get_rank() == 0)
60 cout << 0 <<
": " << *rNorm0 << endl;
67 rho = r->dotWith(*rTilda);
73 p = dynamic_pointer_cast<
MultiField>(r->newCopy());
77 MFRPtr rhoRatio = (*rho) / (*rhoPrev);
78 MFRPtr alphaByOmega = (*alpha) / (*omega);
79 MFRPtr beta = (*rhoRatio) * (*alphaByOmega);
93 MFRPtr rtv = rTilda->dotWith(*v);
96 alpha = (*rho)/(*rtv);
98 x->msaxpy(*alpha,*pHat);
101 MFRPtr rNorm = r->getOneNorm();
108 shared_ptr<MultiField> sHat = pHat;
117 MFRPtr tdotr = t->dotWith(*r);
118 MFRPtr tdott = t->dotWith(*t);
123 omega = (*tdotr) / (*tdott);
125 x->msaxpy(*omega,*sHat);
126 r->msaxpy(*omega,*t);
128 rNorm = r->getOneNorm();
130 MFRPtr normRatio(rNorm->normalize(*rNorm0));
134 cout << i+1 <<
": " << *rNorm << endl;
138 if (
verbosity >0 && MPI::COMM_WORLD.Get_rank() == 0)
139 cout << i+1 <<
": " << *rNorm << endl;
158 cout <<
"n" <<
": " << *rNormn << endl;
163 if (
verbosity >0 && MPI::COMM_WORLD.Get_rank() == 0)
164 cout <<
"n" <<
": " << *rNormn << endl;
175 throw CException(
"cannot use BCGStab as preconditioner");
virtual shared_ptr< IContainer > newCopy() const
MultiField & getResidual()
LinearSolver * preconditioner
void replaceB(shared_ptr< MultiField > newB)
MultiField & msaxpy(const MultiFieldReduction &alphaMF, const MultiField &xMF)
shared_ptr< MultiField > getDeltaPtr()
shared_ptr< MultiFieldReduction > getOneNorm() const
virtual void computeResidual(const IContainer &xB, const IContainer &bB, IContainer &rB) const
virtual MFRPtr solve(LinearSystem &ls)
virtual void smooth(LinearSystem &ls)
shared_ptr< MultiFieldReduction > MFRPtr
virtual void multiply(IContainer &yB, const IContainer &xB) const
virtual void smooth(LinearSystem &ls)=0
void replaceDelta(shared_ptr< MultiField > newDelta)
shared_ptr< MultiField > getBPtr()
MultiFieldMatrix & getMatrix()