15 #ifndef _CONJUGATEGRADIENT_H 16 #define _CONJUGATEGRADIENT_H 25 static const bool CG_DEBUG =
false;
30 enum PreconditionType { PC_None=0, PC_ICP, PC_mICP, PC_MGP };
36 virtual bool iterate() = 0;
37 virtual void solve(
int maxIter) = 0;
41 virtual void setMGPreconditioner(PreconditionType method,
GridMg* MG) = 0;
44 virtual Real getSigma()
const = 0;
45 virtual Real getIterations()
const = 0;
46 virtual Real getResNorm()
const = 0;
47 virtual void setAccuracy(Real
set) = 0;
48 virtual Real getAccuracy()
const = 0;
53 void setUseL2Norm(
bool set) { mUseL2Norm =
set; }
66 template<
class APPLYMAT>
76 void solve(
int maxIter);
79 void setMGPreconditioner(PreconditionType method,
GridMg* MG);
83 Real getSigma()
const {
return mSigma; }
84 Real getIterations()
const {
return mIterations; }
86 Real getResNorm()
const {
return mResNorm; }
88 void setAccuracy(Real
set) { mAccuracy=
set; }
89 Real getAccuracy()
const {
return mAccuracy; }
104 PreconditionType mPcMethod;
void MakeLaplaceMatrix(FlagGrid &flags, Grid< Real > &A0, Grid< Real > &Ai, Grid< Real > &Aj, Grid< Real > &Ak, MACGrid *fractions=0)
Definition: conjugategrad.h:130
Definition: commonkernels.h:22
Grid< Real > * mpPCA0
preconditioning grids
Definition: conjugategrad.h:106
void forceReinit()
force reinit upon next iterate() call, can be used for doing multiple solves
Definition: conjugategrad.h:80
Real mSigma
sigma / residual
Definition: conjugategrad.h:110
virtual void forceReinit()=0
force reinit upon next iterate() call, can be used for doing multiple solves
Real mResNorm
norm of the residual
Definition: conjugategrad.h:114
Multigrid solver.
Definition: multigrid.h:32
Basic CG interface.
Definition: conjugategrad.h:28
void ApplyMatrix2D(FlagGrid &flags, Grid< Real > &dst, Grid< Real > &src, Grid< Real > &A0, Grid< Real > &Ai, Grid< Real > &Aj, Grid< Real > &Ak)
Definition: conjugategrad.h:125
Real mAccuracy
accuracy of solver (max. residuum)
Definition: conjugategrad.h:112
void ApplyMatrix(FlagGrid &flags, Grid< Real > &dst, Grid< Real > &src, Grid< Real > &A0, Grid< Real > &Ai, Grid< Real > &Aj, Grid< Real > &Ak)
Definition: conjugategrad.h:120
Run single iteration of the cg solver.
Definition: conjugategrad.h:67