23 nRowBlocks(offsets.Size() - 1),
24 nColBlocks(offsets.Size() - 1),
27 op(nRowBlocks, nRowBlocks),
28 coef(nRowBlocks, nColBlocks)
35 :
Operator(row_offsets_.Last(), col_offsets_.Last()),
37 nRowBlocks(row_offsets_.Size()-1),
38 nColBlocks(col_offsets_.Size()-1),
39 row_offsets(row_offsets_),
40 col_offsets(col_offsets_),
41 op(nRowBlocks, nColBlocks),
42 coef(nRowBlocks, nColBlocks)
56 delete op(iRow, iCol);
61 MFEM_VERIFY(row_offsets[iRow+1] - row_offsets[iRow] == opt->
NumRows() &&
62 col_offsets[iCol+1] - col_offsets[iCol] == opt->
NumCols(),
63 "incompatible Operator dimensions");
69 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
70 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
77 yblock.
Update(y, row_offsets);
79 for (
int iRow=0; iRow < nRowBlocks; ++iRow)
81 tmp.
SetSize(row_offsets[iRow+1] - row_offsets[iRow]);
83 for (
int jCol=0; jCol < nColBlocks; ++jCol)
85 if (op(iRow,jCol) && coef(iRow,jCol) != 0.)
87 op(iRow,jCol)->Mult(xblock.
GetBlock(jCol), tmp);
93 for (
int iRow=0; iRow < nRowBlocks; ++iRow)
102 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
103 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
110 yblock.
Update(y, col_offsets);
112 for (
int iRow=0; iRow < nColBlocks; ++iRow)
114 tmp.
SetSize(col_offsets[iRow+1] - col_offsets[iRow]);
116 for (
int jCol=0; jCol < nRowBlocks; ++jCol)
118 if (op(jCol,iRow) && coef(jCol,iRow) != 0.)
120 op(jCol,iRow)->MultTranspose(xblock.
GetBlock(jCol), tmp);
126 for (
int iRow=0; iRow < nColBlocks; ++iRow)
136 for (
int iRow=0; iRow < nRowBlocks; ++iRow)
138 for (
int jCol=0; jCol < nColBlocks; ++jCol)
140 delete op(iRow, jCol);
150 nBlocks(offsets_.Size() - 1),
160 MFEM_VERIFY(offsets[iblock+1] - offsets[iblock] == op->
Height() &&
161 offsets[iblock+1] - offsets[iblock] == op->
Width(),
162 "incompatible Operator dimensions");
174 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
175 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
182 yblock.
Update(y, offsets);
184 for (
int i=0; i<nBlocks; ++i)
196 for (
int i=0; i<nBlocks; ++i)
206 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
207 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
216 for (
int i=0; i<nBlocks; ++i)
228 for (
int i=0; i<nBlocks; ++i)
238 for (
int i=0; i<nBlocks; ++i)
247 :
Solver(offsets_.Last()),
249 nBlocks(offsets_.Size() - 1),
251 ops(nBlocks, nBlocks)
260 MFEM_VERIFY(offsets[iblock+1] - offsets[iblock] == op->
Height() &&
261 offsets[iblock+1] - offsets[iblock] == op->
Width(),
262 "incompatible Operator dimensions");
270 MFEM_VERIFY(iRow >= iCol,
"cannot set block in upper triangle");
271 MFEM_VERIFY(offsets[iRow+1] - offsets[iRow] == op->
NumRows() &&
272 offsets[iCol+1] - offsets[iCol] == op->
NumCols(),
273 "incompatible Operator dimensions");
275 ops(iRow, iCol) = op;
282 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
283 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
292 for (
int iRow=0; iRow < nBlocks; ++iRow)
294 tmp.
SetSize(offsets[iRow+1] - offsets[iRow]);
296 tmp2.
SetSize(offsets[iRow+1] - offsets[iRow]);
300 for (
int jCol=0; jCol < iRow; ++jCol)
304 ops(iRow,jCol)->Mult(yblock.
GetBlock(jCol), tmp);
310 ops(iRow,iRow)->Mult(tmp2, yblock.
GetBlock(iRow));
318 for (
int iRow=0; iRow < nBlocks; ++iRow)
328 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
329 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
336 yblock.
Update(y, offsets);
338 for (
int iRow=nBlocks-1; iRow >=0; --iRow)
340 tmp.
SetSize(offsets[iRow+1] - offsets[iRow]);
342 tmp2.
SetSize(offsets[iRow+1] - offsets[iRow]);
346 for (
int jCol=iRow+1; jCol < nBlocks; ++jCol)
350 ops(jCol,iRow)->MultTranspose(yblock.
GetBlock(jCol), tmp);
356 ops(iRow,iRow)->MultTranspose(tmp2, yblock.
GetBlock(iRow));
364 for (
int iRow=nBlocks-1; iRow >=0; --iRow)
374 for (
int iRow=0; iRow < nBlocks; ++iRow)
376 for (
int jCol=0; jCol < nBlocks; ++jCol)
378 delete ops(jCol,iRow);
void MakeRef(T *data_, int size_, bool own_data=false)
Make this Array a reference to a pointer.
void Mult(const Vector &x, Vector &y) const override
Operator application.
~BlockDiagonalPreconditioner()
void MultTranspose(const Vector &x, Vector &y) const override
Action of the transpose operator.
BlockDiagonalPreconditioner(const Array< int > &offsets)
Constructor that specifies the block structure.
void SetDiagonalBlock(int iblock, Operator *op)
Add a square block op in the block-entry (iblock, iblock).
void SetDiagonalBlock(int iblock, Operator *op)
Add block op in the block-entry (iblock, iblock).
void Mult(const Vector &x, Vector &y) const override
Operator application.
BlockLowerTriangularPreconditioner(const Array< int > &offsets)
void SetBlock(int iRow, int iCol, Operator *op)
Add a block opt in the block-entry (iblock, jblock).
~BlockLowerTriangularPreconditioner()
void MultTranspose(const Vector &x, Vector &y) const override
Action of the transpose operator.
void SetDiagonalBlock(int iblock, Operator *op, real_t c=1.0)
Add block op in the block-entry (iblock, iblock).
void Mult(const Vector &x, Vector &y) const override
Operator application.
BlockOperator(const Array< int > &offsets)
void SetBlock(int iRow, int iCol, Operator *op, real_t c=1.0)
Add a block op in the block-entry (iblock, jblock).
void MultTranspose(const Vector &x, Vector &y) const override
Action of the transpose operator.
void Update(real_t *data, const Array< int > &bOffsets)
Update method.
Vector & GetBlock(int i)
Get the i-th vector in the block.
int width
Dimension of the input / number of columns in the matrix.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
int height
Dimension of the output / number of rows in the matrix.
int NumCols() const
Get the number of columns (size of input) of the Operator. Synonym with Width().
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
int NumRows() const
Get the number of rows (size of output) of the Operator. Synonym with Height().
virtual const real_t * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
void SyncAliasMemory(const Vector &v) const
Update the alias memory location of the vector to match v.
int Size() const
Returns the size of the vector.
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
void SetSize(int s)
Resize the vector to size s.
virtual real_t * Write(bool on_dev=true)
Shortcut for mfem::Write(vec.GetMemory(), vec.Size(), on_dev).
Vector & Add(const real_t a, const Vector &Va)
(*this) += a * Va