* are equal to save memory.
*/
bool same_diagonal;
+ /**
+ * Choose the inversion
+ * method for the blocks.
+ */
+ typename PreconditionBlockBase<inverse_type>::Inversion inversion;
+
+ /**
+ * The if #inversion is SVD,
+ * the threshold below which
+ * a singular value will be
+ * considered zero and thus
+ * not inverted. This
+ * parameter is used in the
+ * call to LAPACKFullMatrix::compute_inverse_svd().
+ */
+ double threshold;
};
unsigned int block_size () const;
/**
+ * @deprecated Use size()
+ * instead.
+ *
* The number of blocks of the
* matrix.
*/
*/
double relaxation;
- /**
- * Number of blocks.
- */
- unsigned int nblocks;
-
/**
* The permutation vector
*/
Accessor accessor;
};
- /**
- * Make initialization function
- * publicly available.
- */
PreconditionBlock<MATRIX, inverse_type>::initialize;
-
- /**
- * Make function of base class public again.
- */
PreconditionBlock<MATRIX, inverse_type>::clear;
-
- /**
- * Make function of base class public again.
- */
PreconditionBlock<MATRIX, inverse_type>::empty;
-
- /**
- * Make function of base class public again.
- */
PreconditionBlock<MATRIX, inverse_type>::el;
-
- /**
- * Make function of base class public again.
- */
PreconditionBlock<MATRIX, inverse_type>::set_same_diagonal;
-
- /**
- * Make function public.
- */
PreconditionBlock<MATRIX, inverse_type>::invert_diagblocks;
-
- /**
- * Make function public.
- */
PreconditionBlock<MATRIX, inverse_type>::block_size;
-
+ PreconditionBlockBase<inverse_type>::size;
+ PreconditionBlockBase<inverse_type>::inverse;
+ PreconditionBlockBase<inverse_type>::inverse_householder;
+ PreconditionBlockBase<inverse_type>::inverse_svd;
/**
- * Make function public.
+ * @deprecated Use size() instead
*/
PreconditionBlock<MATRIX, inverse_type>::n_blocks;
- /**
- * Make function accessible to iterator.
- */
- PreconditionBlock<MATRIX, inverse_type>::inverse;
- /**
- * Make function accessible.
- */
PreconditionBlock<MATRIX, inverse_type>::set_permutation;
/**
/**
* Make type publicly available.
*/
- using PreconditionBlock<MATRIX,inverse_type>::AdditionalData;
-
- /**
- * Make initialization function
- * publicly available.
- */
- using PreconditionBlock<MATRIX, inverse_type>::initialize;
-
- /**
- * Make function of base class public again.
- */
- using PreconditionBlock<MATRIX, inverse_type>::clear;
-
- /**
- * Make function of base class public again.
- */
- using PreconditionBlock<MATRIX, inverse_type>::empty;
-
- /**
- * Make function of base class public again.
- */
- using PreconditionBlock<MATRIX, inverse_type>::el;
-
- /**
- * Make function of base class public again.
- */
- using PreconditionBlock<MATRIX, inverse_type>::set_same_diagonal;
-
- /**
- * Make function of base class public again.
- */
- using PreconditionBlock<MATRIX, inverse_type>::invert_diagblocks;
- /**
- * Make function accessible.
- */
- using PreconditionBlock<MATRIX, inverse_type>::set_permutation;
+ PreconditionBlock<MATRIX,inverse_type>::AdditionalData;
+ PreconditionBlock<MATRIX, inverse_type>::initialize;
+ PreconditionBlock<MATRIX, inverse_type>::clear;
+ PreconditionBlock<MATRIX, inverse_type>::empty;
+ PreconditionBlockBase<inverse_type>::size;
+ PreconditionBlockBase<inverse_type>::inverse;
+ PreconditionBlockBase<inverse_type>::inverse_householder;
+ PreconditionBlockBase<inverse_type>::inverse_svd;
+ PreconditionBlock<MATRIX, inverse_type>::el;
+ PreconditionBlock<MATRIX, inverse_type>::set_same_diagonal;
+ PreconditionBlock<MATRIX, inverse_type>::invert_diagblocks;
+ PreconditionBlock<MATRIX, inverse_type>::set_permutation;
/**
* Execute block SOR
*/
PreconditionBlockSSOR ();
- /**
- * Make type publicly available.
- */
- using PreconditionBlockSOR<MATRIX,inverse_type>::AdditionalData;
+ // Keep AdditionalData accessible
+ PreconditionBlockSOR<MATRIX,inverse_type>::AdditionalData;
+ // The following are the
+ // functions of the base classes
+ // which we want to keep
+ // accessible.
/**
* Make initialization function
* publicly available.
*/
- using PreconditionBlockSOR<MATRIX,inverse_type>::initialize;
-
- /**
- * Make function of base class public again.
- */
- using PreconditionBlockSOR<MATRIX,inverse_type>::clear;
-
- /**
- * Make function of base class public again.
- */
- using PreconditionBlockSOR<MATRIX,inverse_type>::set_permutation;
-
- /**
- * Make function of base class public again.
- */
- using PreconditionBlockSOR<MATRIX, inverse_type>::empty;
-
- /**
- * Make function of base class public again.
- */
- using PreconditionBlockSOR<MATRIX, inverse_type>::el;
-
- /**
- * Make function of base class public again.
- */
- using PreconditionBlockSOR<MATRIX,inverse_type>::set_same_diagonal;
-
- /**
- * Make function of base class public again.
- */
- using PreconditionBlockSOR<MATRIX,inverse_type>::invert_diagblocks;
+ PreconditionBlockSOR<MATRIX,inverse_type>::initialize;
+ PreconditionBlockSOR<MATRIX,inverse_type>::clear;
+ PreconditionBlockBase<inverse_type>::size;
+ PreconditionBlockBase<inverse_type>::inverse;
+ PreconditionBlockBase<inverse_type>::inverse_householder;
+ PreconditionBlockBase<inverse_type>::inverse_svd;
+ PreconditionBlockSOR<MATRIX,inverse_type>::set_permutation;
+ PreconditionBlockSOR<MATRIX, inverse_type>::empty;
+ PreconditionBlockSOR<MATRIX, inverse_type>::el;
+ PreconditionBlockSOR<MATRIX,inverse_type>::set_same_diagonal;
+ PreconditionBlockSOR<MATRIX,inverse_type>::invert_diagblocks;
/**
* Execute block SSOR
#ifndef DOXYGEN
-template<class MATRIX, typename inverse_type>
-inline
-PreconditionBlock<MATRIX, inverse_type>::AdditionalData::
-AdditionalData (const unsigned int block_size,
- const double relaxation,
- const bool invert_diagonal,
- const bool same_diagonal)
- :
- relaxation (relaxation),
- block_size(block_size),
- invert_diagonal(invert_diagonal),
- same_diagonal(same_diagonal)
-{}
-
-
template<class MATRIX, typename inverse_type>
inline bool
PreconditionBlock<MATRIX, inverse_type>::empty () const
inline unsigned int
PreconditionBlock<MATRIX, inverse_type>::n_blocks () const
{
- return nblocks;
+ return this->size();
}
DEAL_II_NAMESPACE_OPEN
+template<class MATRIX, typename inverse_type>
+PreconditionBlock<MATRIX, inverse_type>::AdditionalData::
+AdditionalData (const unsigned int block_size,
+ const double relaxation,
+ const bool invert_diagonal,
+ const bool same_diagonal)
+ :
+ relaxation (relaxation),
+ block_size(block_size),
+ invert_diagonal(invert_diagonal),
+ same_diagonal(same_diagonal),
+ inversion(PreconditionBlockBase<inverse_type>::gauss_jordan),
+ threshold(0.)
+{}
+
+
template <typename number>
PreconditionBlockBase<number>::~PreconditionBlockBase ()
{}
Assert (A->m()%bsize==0, ExcWrongBlockSize(bsize, A->m()));
blocksize=bsize;
relaxation = parameters.relaxation;
- nblocks = A->m()/bsize;
- this->reinit(nblocks, blocksize, parameters.same_diagonal);
+ const unsigned int nblocks = A->m()/bsize;
+ this->reinit(nblocks, blocksize, parameters.same_diagonal,
+ parameters.inversion);
if (parameters.invert_diagonal)
invert_diagblocks();
Assert (A->m()%bsize==0, ExcWrongBlockSize(bsize, A->m()));
blocksize=bsize;
relaxation = parameters.relaxation;
- nblocks = A->m()/bsize;
+ const unsigned int nblocks = A->m()/bsize;
this->reinit(nblocks, blocksize, parameters.same_diagonal);
if (parameters.invert_diagonal)
// of the unkowns.
M_cell = 0;
- for (unsigned int cell=0; cell<nblocks; ++cell)
+ for (unsigned int cell=0; cell<this->size(); ++cell)
{
const unsigned int cell_start = cell*blocksize;
for (unsigned int row_cell=0; row_cell<blocksize; ++row_cell)
case PreconditionBlockBase<inverse_type>::householder:
this->inverse_householder(cell).initialize(M_cell);
break;
- case PreconditionBlockBase<inverse_type>::svd:
- this->inverse_svd(cell) = M_cell;
- this->inverse_svd(cell).compute_inverse_svd(0.);
- break;
+ case PreconditionBlockBase<inverse_type>::svd:
+ this->inverse_svd(cell) = M_cell;
+ this->inverse_svd(cell).compute_inverse_svd(0.);
+ break;
default:
Assert(false, ExcNotImplemented());
FullMatrix<number> M_cell(this->blocksize);
// Loop over all blocks
- for (unsigned int cell=0; cell < this->nblocks; ++cell)
+ for (unsigned int cell=0; cell < this->size(); ++cell)
{
const unsigned int permuted_block_start = permuted
? permutation[block_start]
// row, column are the global numbering
// of the unkowns.
unsigned int row, row_cell;
- unsigned int block_end=this->blocksize * this->nblocks;
+ unsigned int block_end=this->blocksize * this->size();
number2 b_cell_row;
FullMatrix<number> M_cell(this->blocksize);
- for (unsigned int cell=this->nblocks; cell!=0 ;)
+ for (unsigned int cell=this->size(); cell!=0 ;)
{
--cell;
const unsigned int block_start = block_end - this->blocksize;
}
if (this->store_diagonals())
this->diagonal(0) = M_cell;
- this->inverse(0).invert(M_cell);
+ switch(this->inversion)
+ {
+ case PreconditionBlockBase<inverse_type>::gauss_jordan:
+ this->inverse(0).invert(M_cell);
+ break;
+ case PreconditionBlockBase<inverse_type>::householder:
+ this->inverse_householder(0).initialize(M_cell);
+ break;
+ case PreconditionBlockBase<inverse_type>::svd:
+ this->inverse_svd(0) = M_cell;
+ this->inverse_svd(0).compute_inverse_svd(1.e-12);
+ break;
+ default:
+ Assert(false, ExcNotImplemented());
+ }
}
else
{
M_cell = 0;
- for (unsigned int cell=0; cell<nblocks; ++cell)
+ for (unsigned int cell=0; cell<this->size(); ++cell)
{
const unsigned int cell_start = cell*blocksize;
for (unsigned int row_cell=0; row_cell<blocksize; ++row_cell)
if (this->store_diagonals())
this->diagonal(cell) = M_cell;
- this->inverse(cell).invert(M_cell);
+ switch(this->inversion)
+ {
+ case PreconditionBlockBase<inverse_type>::gauss_jordan:
+ this->inverse(cell).invert(M_cell);
+ break;
+ case PreconditionBlockBase<inverse_type>::householder:
+ this->inverse_householder(cell).initialize(M_cell);
+ break;
+ case PreconditionBlockBase<inverse_type>::svd:
+ this->inverse_svd(cell) = M_cell;
+ this->inverse_svd(cell).compute_inverse_svd(1.e-12);
+ break;
+ default:
+ Assert(false, ExcNotImplemented());
+ }
}
}
this->inverses_computed(true);
if (!this->inverses_ready())
{
FullMatrix<number> M_cell(this->blocksize);
- for (unsigned int cell=0; cell < this->nblocks; ++cell)
+ for (unsigned int cell=0; cell < this->size(); ++cell)
{
for (row=cell*this->blocksize, row_cell=0;
row_cell<this->blocksize;
}
}
else
- for (unsigned int cell=0; cell < this->nblocks; ++cell)
+ for (unsigned int cell=0; cell < this->size(); ++cell)
{
for (row=cell*this->blocksize, row_cell=0;
row_cell<this->blocksize;
// inverses were not precomputed
FullMatrix<number> M_cell(this->blocksize);
- for (unsigned int cell=0; cell < this->nblocks; ++cell)
+ for (unsigned int cell=0; cell < this->size(); ++cell)
{
const unsigned int permuted_block_start = permuted
? this->permutation[block_start]
// row, column are the global numbering
// of the unkowns.
unsigned int row, row_cell;
- unsigned int block_end=this->blocksize * this->nblocks;
+ unsigned int block_end=this->blocksize * this->size();
number2 b_cell_row;
FullMatrix<number> M_cell(this->blocksize);
- for (unsigned int cell=this->nblocks; cell!=0 ;)
+ for (unsigned int cell=this->size(); cell!=0 ;)
{
--cell;
const unsigned int block_start = block_end - this->blocksize;
const double scaling = (2.-this->relaxation)/this->relaxation;
// Multiply with diagonal blocks
- for (unsigned int cell=0; cell < this->nblocks; ++cell)
+ for (unsigned int cell=0; cell < this->size(); ++cell)
{
unsigned int row = cell*this->blocksize;
const double scaling = (2.-this->relaxation)/this->relaxation;
// Multiply with diagonal blocks
- for (unsigned int cell=0; cell < this->nblocks; ++cell)
+ for (unsigned int cell=0; cell < this->size(); ++cell)
{
unsigned int row = cell*this->blocksize;