Public Member Functions | |
SchurMatrix (const MA_inverse &Ainv, const MB &B, const MDt &Dt, const MC &C, VectorMemory< BlockVector< double > > &mem, const std::vector< unsigned int > &signature=std::vector< unsigned int >(0)) | |
void | prepare_rhs (BlockVector< double > &dst, const BlockVector< double > &src) const |
void | vmult (BlockVector< double > &dst, const BlockVector< double > &src) const |
double | residual (BlockVector< double > &dst, const BlockVector< double > &src, const BlockVector< double > &rhs) const |
void | postprocess (BlockVector< double > &dst, const BlockVector< double > &src, const BlockVector< double > &rhs) const |
void | debug_level (unsigned int l) |
Private Member Functions | |
SchurMatrix (const SchurMatrix< MA_inverse, MB, MDt, MC > &) | |
SchurMatrix & | operator= (const SchurMatrix< MA_inverse, MB, MDt, MC > &) |
Private Attributes | |
const SmartPointer< const MA_inverse > | Ainv |
const SmartPointer< const MB > | B |
const SmartPointer< const MDt > | Dt |
const SmartPointer< const MC > | C |
VectorMemory< BlockVector < double > > & | mem |
std::vector< unsigned int > | signature |
unsigned int | debug |
Given a non-singular matrix A
(often positive definite) and a positive semi-definite matrix C
as well as matrices B
and Dt
of full rank, this class implements a new matrix, the Schur complement a the system of equations of the structure
* / \ / \ / \ * | A Dt | | u | - | f | * | -B C | | p | - | g | * \ / \ / \ / *
Multiplication with the Schur matrix S
is the operation
* S p = C p + B A-inverse Dt-transpose p, *
p
.The data handed to the Schur matrix are as follows:
A:
the inverse of A
is stored, instead of A
. This allows the application to use the most efficient form of inversion, iterative or direct.
B
, C:
these matrices are stored "as is".
Dt:
the computation of the Schur complement involves the function Tvmult
of the matrix Dt
, not vmult!
This way, it is sufficient to build only one matrix B
for the symmetric Schur complement and use it twice.
All matrices involved are of arbitrary type and vectors are BlockVectors. This way, SchurMatrix
can be coupled with any matrix classes providing vmult
and Tvmult
and can be even nested. Since SmartPointers of matrices are stored, the matrix blocks should be derived from Subscriptor.
Since the Schur complement of a matrix corresponds to a Gaussian block elimination, the right hand side of the condensed system must be preprocessed. Furthermore, the eliminated variable must be reconstructed after solving.
* g = g + B A-inverse f * u = A-inverse (f - D-transpose p) *
Applying these transformations, the solution of the system above by a SchurMatrix
schur
is coded as follows:
* schur.prepare_rhs (g, f); * solver.solve (schur, p, g, precondition); * schur.postprocess (u, p); *
SchurMatrix< MA_inverse, MB, MDt, MC >::SchurMatrix | ( | const MA_inverse & | Ainv, | |
const MB & | B, | |||
const MDt & | Dt, | |||
const MC & | C, | |||
VectorMemory< BlockVector< double > > & | mem, | |||
const std::vector< unsigned int > & | signature = std::vector<unsigned int>(0) | |||
) | [inline] |
Constructor. This constructor receives all the matrices needed. Furthermore, it gets a reference to a memory structure for obtaining block vectors.
Optionally, the length of the u-vector
can be provided.
For the meaning of the matrices see the class documentation.
SchurMatrix< MA_inverse, MB, MDt, MC >::SchurMatrix | ( | const SchurMatrix< MA_inverse, MB, MDt, MC > & | ) | [private] |
No copy constructor.
void SchurMatrix< MA_inverse, MB, MDt, MC >::prepare_rhs | ( | BlockVector< double > & | dst, | |
const BlockVector< double > & | src | |||
) | const [inline] |
Do block elimination of the right hand side. Given right hand sides for both components of the block system, this function provides the right hand side for the Schur complement.
The result is stored in the first argument, which is also part of the input data. If it is necessary to conserve the data, dst
must be copied before calling this function. This is reasonable, since in many cases, only the pre-processed right hand side is needed.
References Assert, BlockVectorBase< Vector< Number > >::block(), deallog, BlockVectorBase< Vector< Number > >::l2_norm(), BlockVectorBase< Vector< Number > >::n_blocks(), LogStream::pop(), LogStream::push(), and BlockVector< Number >::reinit().
void SchurMatrix< MA_inverse, MB, MDt, MC >::vmult | ( | BlockVector< double > & | dst, | |
const BlockVector< double > & | src | |||
) | const [inline] |
Multiplication with the Schur complement.
References BlockVectorBase< Vector< Number > >::block(), deallog, BlockVectorBase< Vector< Number > >::l2_norm(), LogStream::pop(), LogStream::push(), and BlockVector< Number >::reinit().
double SchurMatrix< MA_inverse, MB, MDt, MC >::residual | ( | BlockVector< double > & | dst, | |
const BlockVector< double > & | src, | |||
const BlockVector< double > & | rhs | |||
) | const [inline] |
Computation of the residual of the Schur complement.
References BlockVectorBase< Vector< Number > >::l2_norm(), and BlockVector< Number >::scale().
void SchurMatrix< MA_inverse, MB, MDt, MC >::postprocess | ( | BlockVector< double > & | dst, | |
const BlockVector< double > & | src, | |||
const BlockVector< double > & | rhs | |||
) | const [inline] |
Compute the eliminated variable from the solution of the Schur complement problem.
References Assert, BlockVectorBase< Vector< Number > >::block(), deallog, BlockVectorBase< Vector< Number > >::l2_norm(), BlockVectorBase< Vector< Number > >::n_blocks(), LogStream::pop(), LogStream::push(), BlockVector< Number >::reinit(), and BlockVectorBase< Vector< Number > >::sadd().
void SchurMatrix< MA_inverse, MB, MDt, MC >::debug_level | ( | unsigned int | l | ) | [inline] |
Select debugging information for log-file. Debug level 1 is defined and writes the norm of every vector before and after each operation. Debug level 0 turns off debugging information.
SchurMatrix& SchurMatrix< MA_inverse, MB, MDt, MC >::operator= | ( | const SchurMatrix< MA_inverse, MB, MDt, MC > & | ) | [private] |
No assignment.
const SmartPointer<const MA_inverse> SchurMatrix< MA_inverse, MB, MDt, MC >::Ainv [private] |
Pointer to inverse of upper left block.
const SmartPointer<const MB> SchurMatrix< MA_inverse, MB, MDt, MC >::B [private] |
Pointer to lower left block.
const SmartPointer<const MDt> SchurMatrix< MA_inverse, MB, MDt, MC >::Dt [private] |
Pointer to transpose of upper right block.
const SmartPointer<const MC> SchurMatrix< MA_inverse, MB, MDt, MC >::C [private] |
Pointer to lower right block.
VectorMemory<BlockVector<double> >& SchurMatrix< MA_inverse, MB, MDt, MC >::mem [private] |
Auxiliary memory for vectors.
std::vector<unsigned int> SchurMatrix< MA_inverse, MB, MDt, MC >::signature [private] |
Optional signature of the u-vector
.
unsigned int SchurMatrix< MA_inverse, MB, MDt, MC >::debug [private] |
Switch for debugging information.