13 #include "../general/array.hpp"
24 nRowBlocks(offsets.Size() - 1),
25 nColBlocks(offsets.Size() - 1),
28 op(nRowBlocks, nRowBlocks)
37 :
Operator(row_offsets_.Last(), col_offsets_.Last()),
39 nRowBlocks(row_offsets_.Size()-1),
40 nColBlocks(col_offsets_.Size()-1),
43 op(nRowBlocks, nColBlocks)
46 row_offsets.
MakeRef(row_offsets_);
47 col_offsets.
MakeRef(col_offsets_);
59 MFEM_VERIFY(row_offsets[iRow+1] - row_offsets[iRow] == opt->
NumRows() &&
60 col_offsets[iCol+1] - col_offsets[iCol] == opt->
NumCols(),
61 "incompatible Operator dimensions");
67 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
68 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
74 for (
int iRow=0; iRow < nRowBlocks; ++iRow)
76 tmp.
SetSize(row_offsets[iRow+1] - row_offsets[iRow]);
77 for (
int jCol=0; jCol < nColBlocks; ++jCol)
81 op(iRow,jCol)->Mult(xblock.
GetBlock(jCol), tmp);
91 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
92 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
97 yblock.
Update(y.GetData(),col_offsets);
99 for (
int iRow=0; iRow < nColBlocks; ++iRow)
101 tmp.
SetSize(col_offsets[iRow+1] - col_offsets[iRow]);
102 for (
int jCol=0; jCol < nRowBlocks; ++jCol)
106 op(jCol,iRow)->MultTranspose(xblock.
GetBlock(jCol), tmp);
117 for (
int iRow=0; iRow < nRowBlocks; ++iRow)
118 for (
int jCol=0; jCol < nColBlocks; ++jCol)
119 delete op(jCol,iRow);
126 nBlocks(offsets_.Size() - 1),
137 MFEM_VERIFY(offsets[iblock+1] - offsets[iblock] == opt->
Height() &&
138 offsets[iblock+1] - offsets[iblock] == opt->
Width(),
139 "incompatible Operator dimensions");
147 MFEM_ASSERT(x.
Size() ==
width,
"incorrect input Vector size");
148 MFEM_ASSERT(y.
Size() ==
height,
"incorrect output Vector size");
153 for (
int i=0; i<nBlocks; ++i)
163 MFEM_ASSERT(x.
Size() ==
height,
"incorrect input Vector size");
164 MFEM_ASSERT(y.
Size() ==
width,
"incorrect output Vector size");
169 for (
int i=0; i<nBlocks; ++i)
179 for (
int i=0; i<nBlocks; ++i)
void SetSize(int s)
Resizes the vector if the new size is different.
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.
void SetBlock(int iRow, int iCol, Operator *op)
Add a block op in the block-entry (iblock, jblock).
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows.
void SetDiagonalBlock(int iblock, Operator *op)
Add block op in the block-entry (iblock, iblock).
~BlockDiagonalPreconditioner()
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.
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator.
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
void MakeRef(T *, int)
Make this Array a reference to a poiter.
Vector & GetBlock(int i)
Get the i-th vector in the block.
void SetDiagonalBlock(int iblock, Operator *op)
Add a square block op in the block-entry (iblock, iblock).