24 nRowBlocks(offsets.Size() - 1),
25 nColBlocks(offsets.Size() - 1),
28 op(nRowBlocks, nRowBlocks),
29 coef(nRowBlocks, nColBlocks)
36 :
Operator(row_offsets_.Last(), col_offsets_.Last()),
38 nRowBlocks(row_offsets_.Size()-1),
39 nColBlocks(col_offsets_.Size()-1),
40 row_offsets(row_offsets_),
41 col_offsets(col_offsets_),
42 op(nRowBlocks, nColBlocks),
43 coef(nRowBlocks, nColBlocks)
57 delete op(iRow, iCol);
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 yblock.
Update(y,row_offsets);
79 for (
int iRow=0; iRow < nRowBlocks; ++iRow)
81 tmp.
SetSize(row_offsets[iRow+1] - row_offsets[iRow]);
82 for (
int jCol=0; jCol < nColBlocks; ++jCol)
84 if (op(iRow,jCol) && coef(iRow,jCol) != 0.)
86 op(iRow,jCol)->Mult(xblock.
GetBlock(jCol), tmp);
92 for (
int iRow=0; iRow < nRowBlocks; ++iRow)
101 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
102 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
108 yblock.
Update(y,col_offsets);
110 for (
int iRow=0; iRow < nColBlocks; ++iRow)
112 tmp.
SetSize(col_offsets[iRow+1] - col_offsets[iRow]);
113 for (
int jCol=0; jCol < nRowBlocks; ++jCol)
115 if (op(jCol,iRow) && coef(jCol,iRow) != 0.)
117 op(jCol,iRow)->MultTranspose(xblock.
GetBlock(jCol), tmp);
123 for (
int iRow=0; iRow < nColBlocks; ++iRow)
133 for (
int iRow=0; iRow < nRowBlocks; ++iRow)
135 for (
int jCol=0; jCol < nColBlocks; ++jCol)
137 delete op(iRow,jCol);
148 nBlocks(offsets_.Size() - 1),
152 ops =
static_cast<Operator *
>(NULL);
158 MFEM_VERIFY(offsets[iblock+1] - offsets[iblock] == op->
Height() &&
159 offsets[iblock+1] - offsets[iblock] == op->
Width(),
160 "incompatible Operator dimensions");
172 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
173 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
181 for (
int i=0; i<nBlocks; ++i)
193 for (
int i=0; i<nBlocks; ++i)
203 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
204 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
212 for (
int i=0; i<nBlocks; ++i)
224 for (
int i=0; i<nBlocks; ++i)
234 for (
int i=0; i<nBlocks; ++i)
243 :
Solver(offsets_.Last()),
245 nBlocks(offsets_.Size() - 1),
247 ops(nBlocks, nBlocks)
249 ops =
static_cast<Operator *
>(NULL);
256 MFEM_VERIFY(offsets[iblock+1] - offsets[iblock] == op->
Height() &&
257 offsets[iblock+1] - offsets[iblock] == op->
Width(),
258 "incompatible Operator dimensions");
266 MFEM_VERIFY(iRow >= iCol,
"cannot set block in upper triangle");
267 MFEM_VERIFY(offsets[iRow+1] - offsets[iRow] == op->
NumRows() &&
268 offsets[iCol+1] - offsets[iCol] == op->
NumCols(),
269 "incompatible Operator dimensions");
271 ops(iRow, iCol) = op;
278 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
279 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
285 for (
int iRow=0; iRow < nBlocks; ++iRow)
287 tmp.
SetSize(offsets[iRow+1] - offsets[iRow]);
288 tmp2.
SetSize(offsets[iRow+1] - offsets[iRow]);
291 for (
int jCol=0; jCol < iRow; ++jCol)
295 ops(iRow,jCol)->Mult(yblock.
GetBlock(jCol), tmp);
301 ops(iRow,iRow)->Mult(tmp2, yblock.
GetBlock(iRow));
314 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
315 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
321 for (
int iRow=nBlocks-1; iRow >=0; --iRow)
323 tmp.
SetSize(offsets[iRow+1] - offsets[iRow]);
324 tmp2.
SetSize(offsets[iRow+1] - offsets[iRow]);
327 for (
int jCol=iRow+1; jCol < nBlocks; ++jCol)
331 ops(jCol,iRow)->MultTranspose(yblock.
GetBlock(jCol), tmp);
337 ops(iRow,iRow)->MultTranspose(tmp2, yblock.
GetBlock(iRow));
350 for (
int iRow=0; iRow < nBlocks; ++iRow)
352 for (
int jCol=0; jCol < nBlocks; ++jCol)
354 delete ops(jCol,iRow);
void MakeRef(T *data_, int size_, bool own_data=false)
Make this Array a reference to a pointer.
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator.
~BlockDiagonalPreconditioner()
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
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).
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator.
void SetDiagonalBlock(int iblock, Operator *op)
Add block op in the block-entry (iblock, iblock).
BlockLowerTriangularPreconditioner(const Array< int > &offsets)
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
void SetBlock(int iRow, int iCol, Operator *op)
Add a block opt in the block-entry (iblock, jblock).
~BlockLowerTriangularPreconditioner()
void SetDiagonalBlock(int iblock, Operator *op, real_t c=1.0)
Add block op in the block-entry (iblock, iblock).
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).
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
virtual void MultTranspose(const Vector &x, Vector &y) const
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.
void SetSize(int s)
Resize the vector to size s.
real_t * GetData() const
Return a pointer to the beginning of the Vector data.
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