18 : fespaces(fespaces_), cycleType(
CycleType::VCYCLE), preSmoothingSteps(1),
24 for (
int i = 0; i < operators.Size(); ++i)
26 if (ownedOperators[i])
30 if (ownedSmoothers[i])
40 operators.DeleteAll();
41 smoothers.DeleteAll();
47 for (
int i = 0; i <
bfs.Size(); ++i)
65 operators.Append(opr);
66 smoothers.Append(smoother);
67 ownedOperators.
Append(ownOperator);
68 ownedSmoothers.
Append(ownSmoother);
88 return operators[level];
93 return operators[level];
108 return smoothers[level];
113 return smoothers[level];
117 int postSmoothingSteps_)
119 cycleType = cycleType_;
120 preSmoothingSteps = preSmoothingSteps_;
121 postSmoothingSteps = postSmoothingSteps_;
135 MFEM_ABORT(
"SetOperator not supported in Multigrid");
138 void Multigrid::SmoothingStep(
int level,
bool transpose)
const
141 subtract(*X[level], *R[level], *R[level]);
150 add(*Y[level], 1.0, *Z[level], *Y[level]);
153 void Multigrid::Cycle(
int level)
const
161 for (
int i = 0; i < preSmoothingSteps; i++)
163 SmoothingStep(level,
false);
168 subtract(*X[level], *R[level], *R[level]);
183 for (
int correction = 0; correction < corrections; ++correction)
192 *Y[level] += *R[level];
195 for (
int i = 0; i < postSmoothingSteps; i++)
197 SmoothingStep(level,
true);
210 bfs.Last()->RecoverFEMSolution(X, b, x);
Array< BilinearForm * > bfs
Multigrid(const FiniteElementSpaceHierarchy &fespaces_)
Constructs an empty multigrid for the given FiniteElementSpaceHierarchy.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
Pointer to an Operator of a specified type.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
void add(const Vector &v1, const Vector &v2, Vector &v)
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
const FiniteElementSpaceHierarchy & fespaces
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
int Append(const T &el)
Append element 'el' to array, resize if necessary.
void FormFineLinearSystem(Vector &x, Vector &b, OperatorHandle &A, Vector &X, Vector &B)
Form the linear system A X = B, corresponding to the operator on the finest level.
virtual void SetOperator(const Operator &op) override
Not supported for multigrid.
void subtract(const Vector &x, const Vector &y, Vector &z)
virtual ~Multigrid()
Destructor.
int height
Dimension of the output / number of rows in the matrix.
void AddLevel(Operator *opr, Solver *smoother, bool ownOperator, bool ownSmoother)
Adds a level to the multigrid operator hierarchy.
Solver * GetSmootherAtLevel(int level) const
Returns smoother at given level.
const Operator * GetOperatorAtFinestLevel() const
Returns operator at finest level.
virtual void Mult(const Vector &x, Vector &y) const override
Application of the multigrid as a preconditioner.
int GetFinestLevelIndex() const
Returns the index of the finest level.
Array< Array< int > * > essentialTrueDofs
int NumLevels() const
Returns the number of levels.
const Operator * GetOperatorAtLevel(int level) const
Returns operator at given level.
void RecoverFineFEMSolution(const Vector &X, const Vector &b, Vector &x)
Recover the solution of a linear system formed with FormFineLinearSystem()
Operator * GetProlongationAtLevel(int level) const
Returns the prolongation operator from the finite element space at level to the finite element space ...
int width
Dimension of the input / number of columns in the matrix.
void SetCycleType(CycleType cycleType_, int preSmoothingSteps_, int postSmoothingSteps_)
Set the cycle type and number of pre- and post-smoothing steps used by Mult.