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);
121 for (
int iRow=0; iRow < nRowBlocks; ++iRow)
123 for (
int jCol=0; jCol < nColBlocks; ++jCol)
125 delete op(jCol,iRow);
136 nBlocks(offsets_.Size() - 1),
147 MFEM_VERIFY(offsets[iblock+1] - offsets[iblock] == opt->
Height() &&
148 offsets[iblock+1] - offsets[iblock] == opt->
Width(),
149 "incompatible Operator dimensions");
157 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
158 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
163 for (
int i=0; i<nBlocks; ++i)
180 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
181 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
186 for (
int i=0; i<nBlocks; ++i)
203 for (
int i=0; i<nBlocks; ++i)
212 :
Solver(offsets_.Last()),
214 nBlocks(offsets_.Size() - 1),
225 MFEM_VERIFY(offsets[iblock+1] - offsets[iblock] == op->
Height() &&
226 offsets[iblock+1] - offsets[iblock] == op->
Width(),
227 "incompatible Operator dimensions");
235 MFEM_VERIFY(iRow >= iCol,
"cannot set block in upper triangle");
236 MFEM_VERIFY(offsets[iRow+1] - offsets[iRow] == opt->
NumRows() &&
237 offsets[iCol+1] - offsets[iCol] == opt->
NumCols(),
238 "incompatible Operator dimensions");
240 op(iRow, iCol) = opt;
247 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
248 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
254 for (
int iRow=0; iRow < nBlocks; ++iRow)
256 tmp.
SetSize(offsets[iRow+1] - offsets[iRow]);
257 tmp2.
SetSize(offsets[iRow+1] - offsets[iRow]);
260 for (
int jCol=0; jCol < iRow; ++jCol)
264 op(iRow,jCol)->Mult(yblock.
GetBlock(jCol), tmp);
270 op(iRow,iRow)->Mult(tmp2, yblock.
GetBlock(iRow));
283 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
284 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
290 for (
int iRow=nBlocks-1; iRow >=0; --iRow)
292 tmp.
SetSize(offsets[iRow+1] - offsets[iRow]);
293 tmp2.
SetSize(offsets[iRow+1] - offsets[iRow]);
296 for (
int jCol=iRow+1; jCol < nBlocks; ++jCol)
300 op(jCol,iRow)->MultTranspose(yblock.
GetBlock(jCol), tmp);
306 op(iRow,iRow)->MultTranspose(tmp2, yblock.
GetBlock(iRow));
319 for (
int iRow=0; iRow < nBlocks; ++iRow)
321 for (
int jCol=0; jCol < nBlocks; ++jCol)
323 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.
double * GetData() const
Return a pointer to the beginning of the Vector data.
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)
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).
Vector & GetBlock(int i)
Get the i-th vector in the block.