44 bool isASet()
const {
return mIsASet; }
45 bool isRhsSet()
const {
return mIsRhsSet; }
53 void setCoarsestLevelAccuracy(Real accuracy) { mCoarsestLevelAccuracy = accuracy; }
54 Real getCoarsestLevelAccuracy()
const {
return mCoarsestLevelAccuracy; }
55 void setSmoothing(
int numPreSmooth,
int numPostSmooth) { mNumPreSmooth = numPreSmooth; mNumPostSmooth = numPostSmooth; }
56 int getNumPreSmooth()
const {
return mNumPreSmooth; }
57 int getNumPostSmooth()
const {
return mNumPostSmooth; }
70 Vec3i vecIdx(
int v,
int l)
const {
return Vec3i(v%mSize[l].x, (v%(mSize[l].x*mSize[l].y))/mSize[l].x, v/(mSize[l].x*mSize[l].y)); }
71 int linIdx(
Vec3i V,
int l)
const {
return V.x + V.y*mPitch[l].y + V.z*mPitch[l].z; }
72 bool inGrid(
Vec3i V,
int l)
const {
return V.x>=0 && V.y>=0 && V.z>=0 && V.x<mSize[l].x && V.y<mSize[l].y && V.z<mSize[l].z; }
74 void analyzeStencil(
int v,
bool is3D,
bool& isStencilSumNonZero,
bool& isEquationTrivial)
const;
76 void genCoarseGrid(
int l);
77 void genCoraseGridOperator(
int l);
79 void smoothGS(
int l,
bool reversedOrder);
80 void calcResidual(
int l);
81 Real calcResidualNorm(
int l);
84 void restrict(
int l_dst,
const std::vector<Real>& src, std::vector<Real>& dst)
const;
85 void interpolate(
int l_dst,
const std::vector<Real>& src, std::vector<Real>& dst)
const;
88 enum VertexType :
char {
97 struct CoarseningPath {
106 Real mCoarsestLevelAccuracy;
107 Real mTrivialEquationScale;
109 std::vector<std::vector<Real>> mA;
110 std::vector<std::vector<Real>> mx;
111 std::vector<std::vector<Real>> mb;
112 std::vector<std::vector<Real>> mr;
113 std::vector<std::vector<VertexType>> mType;
114 std::vector<std::vector<double>> mCGtmp1, mCGtmp2, mCGtmp3, mCGtmp4;
115 std::vector<Vec3i> mSize, mPitch;
116 std::vector<CoarseningPath> mCoarseningPaths0;
129 friend struct knActivateVertices;
130 friend struct knActivateCoarseVertices;
131 friend struct knSetRhs;
132 friend struct knGenCoarseGridOperator;
133 friend struct knSmoothColor;
134 friend struct knCalcResidual;
135 friend struct knResidualNormSumSqr;
136 friend struct knRestrict;
137 friend struct knInterpolate;
Definition: commonkernels.h:22
Real doVCycle(Grid< Real > &dst, const Grid< Real > *src=nullptr)
perform VCycle iteration
Definition: multigrid.cpp:420
void setTrivialEquationScale(Real scale)
Set factor for automated downscaling of trivial equations:
Definition: multigrid.h:67
Basic inlined vector class.
Definition: vectorbase.h:71
Multigrid solver.
Definition: multigrid.h:32
GridMg(const Vec3i &gridSize)
constructor: preallocates most of required memory for multigrid hierarchy
Definition: multigrid.cpp:221
void setRhs(const Grid< Real > &rhs)
set right-hand side after setting A
Definition: multigrid.cpp:394
void setA(const Grid< Real > *pA0, const Grid< Real > *pAi, const Grid< Real > *pAj, const Grid< Real > *pAk)
update system matrix A from symmetric 7-point stencil
Definition: multigrid.cpp:359