13 #include "../general/array.hpp"
24 nRowBlocks(offsets.Size() - 1),
25 nColBlocks(offsets.Size() - 1),
28 op(nRowBlocks, nRowBlocks),
29 coef(nRowBlocks, nColBlocks)
38 :
Operator(row_offsets_.Last(), col_offsets_.Last()),
40 nRowBlocks(row_offsets_.Size()-1),
41 nColBlocks(col_offsets_.Size()-1),
44 op(nRowBlocks, nColBlocks),
45 coef(nRowBlocks, nColBlocks)
48 row_offsets.
MakeRef(row_offsets_);
49 col_offsets.
MakeRef(col_offsets_);
62 MFEM_VERIFY(row_offsets[iRow+1] - row_offsets[iRow] == opt->
NumRows() &&
63 col_offsets[iCol+1] - col_offsets[iCol] == opt->
NumCols(),
64 "incompatible Operator dimensions");
70 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
71 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
77 for (
int iRow=0; iRow < nRowBlocks; ++iRow)
79 tmp.
SetSize(row_offsets[iRow+1] - row_offsets[iRow]);
80 for (
int jCol=0; jCol < nColBlocks; ++jCol)
84 op(iRow,jCol)->Mult(xblock.
GetBlock(jCol), tmp);
94 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
95 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
100 yblock.
Update(y.GetData(),col_offsets);
102 for (
int iRow=0; iRow < nColBlocks; ++iRow)
104 tmp.
SetSize(col_offsets[iRow+1] - col_offsets[iRow]);
105 for (
int jCol=0; jCol < nRowBlocks; ++jCol)
109 op(jCol,iRow)->MultTranspose(xblock.
GetBlock(jCol), tmp);
120 for (
int iRow=0; iRow < nRowBlocks; ++iRow)
121 for (
int jCol=0; jCol < nColBlocks; ++jCol)
123 delete op(jCol,iRow);
132 nBlocks(offsets_.Size() - 1),
143 MFEM_VERIFY(offsets[iblock+1] - offsets[iblock] == opt->
Height() &&
144 offsets[iblock+1] - offsets[iblock] == opt->
Width(),
145 "incompatible Operator dimensions");
153 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
154 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
159 for (
int i=0; i<nBlocks; ++i)
174 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
175 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
180 for (
int i=0; i<nBlocks; ++i)
194 for (
int i=0; i<nBlocks; ++i)
202 :
Solver(offsets_.Last()),
204 nBlocks(offsets_.Size() - 1),
215 MFEM_VERIFY(offsets[iblock+1] - offsets[iblock] == op->
Height() &&
216 offsets[iblock+1] - offsets[iblock] == op->
Width(),
217 "incompatible Operator dimensions");
225 MFEM_VERIFY(iRow >= iCol,
"cannot set block in upper triangle");
226 MFEM_VERIFY(offsets[iRow+1] - offsets[iRow] == opt->
NumRows() &&
227 offsets[iCol+1] - offsets[iCol] == opt->
NumCols(),
228 "incompatible Operator dimensions");
230 op(iRow, iCol) = opt;
237 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
238 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
244 for (
int iRow=0; iRow < nBlocks; ++iRow)
246 tmp.
SetSize(offsets[iRow+1] - offsets[iRow]);
247 tmp2.
SetSize(offsets[iRow+1] - offsets[iRow]);
250 for (
int jCol=0; jCol < iRow; ++jCol)
254 op(iRow,jCol)->Mult(yblock.
GetBlock(jCol), tmp);
260 op(iRow,iRow)->Mult(tmp2, yblock.
GetBlock(iRow));
273 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
274 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
280 for (
int iRow=nBlocks-1; iRow >=0; --iRow)
282 tmp.
SetSize(offsets[iRow+1] - offsets[iRow]);
283 tmp2.
SetSize(offsets[iRow+1] - offsets[iRow]);
286 for (
int jCol=iRow+1; jCol < nBlocks; ++jCol)
290 op(jCol,iRow)->MultTranspose(yblock.
GetBlock(jCol), tmp);
296 op(iRow,iRow)->MultTranspose(tmp2, yblock.
GetBlock(iRow));
309 for (
int iRow=0; iRow < nBlocks; ++iRow)
311 for (
int jCol=0; jCol < nBlocks; ++jCol)
313 delete op(jCol,iRow);
void SetSize(int s)
Resize the vector to size s.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
int Size() const
Returns the size of the vector.
void Update(double *data, const Array< int > &bOffsets)
Update method.
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
~BlockDiagonalPreconditioner()
void SetBlock(int iRow, int iCol, Operator *op)
Add a block op in the block-entry (iblock, jblock).
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
BlockDiagonalPreconditioner(const Array< int > &offsets)
Constructor that specifies the block structure.
BlockOperator(const Array< int > &offsets)
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
void SetDiagonalBlock(int iblock, Operator *op, double c=1.0)
Add block op in the block-entry (iblock, iblock).
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator.
int NumRows() const
Get the number of rows (size of output) of the Operator. Synonym with Height().
int NumCols() const
Get the number of columns (size of input) of the Operator. Synonym with Width().
~BlockLowerTriangularPreconditioner()
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator.
int height
Dimension of the output / number of rows in the matrix.
void SetDiagonalBlock(int iblock, Operator *op)
Add block op in the block-entry (iblock, iblock).
Vector & Add(const double a, const Vector &Va)
(*this) += a * Va
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
void MakeRef(T *, int)
Make this Array a reference to a pointer.
BlockLowerTriangularPreconditioner(const Array< int > &offsets)
Vector & GetBlock(int i)
Get the i-th vector in the block.
int width
Dimension of the input / number of columns in the matrix.
void SetBlock(int iRow, int iCol, Operator *op, double c=1.0)
Add a block op in the block-entry (iblock, jblock).
void SetDiagonalBlock(int iblock, Operator *op)
Add a square block op in the block-entry (iblock, iblock).