DEAL_II_NAMESPACE_OPEN
-template <typename> class BlockVector;
-template <typename> class Vector;
-
/*! @addtogroup Matrix2
*@{
*/
* @author Guido Kanschat
* @date 2000-2005, 2010
*/
-template <typename number = double>
+template <typename number = double, typename BLOCK_VECTOR=BlockVector<number> >
class BlockMatrixArray : public Subscriptor
{
public:
void enter (const MATRIX &matrix,
const unsigned int row,
const unsigned int col,
- const double prefix = 1.,
+ const number prefix = 1.,
const bool transpose = false);
/**
/**
* Matrix-vector multiplication.
*/
- void vmult (BlockVector<number> &dst,
- const BlockVector<number> &src) const;
+ void vmult (BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const;
/**
* Matrix-vector multiplication adding to <tt>dst</tt>.
*/
- void vmult_add (BlockVector<number> &dst,
- const BlockVector<number> &src) const;
+ void vmult_add(BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const;
/**
* Transposed matrix-vector multiplication.
*/
- void Tvmult (BlockVector<number> &dst,
- const BlockVector<number> &src) const;
+ void Tvmult (BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const;
/**
* Transposed matrix-vector multiplication adding to <tt>dst</tt>.
*/
- void Tvmult_add (BlockVector<number> &dst,
- const BlockVector<number> &src) const;
+ void Tvmult_add (BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const;
/**
* Matrix scalar product between two vectors (at least for a symmetric
* matrix).
*/
- number matrix_scalar_product (const BlockVector<number> &u,
- const BlockVector<number> &v) const;
+ number matrix_scalar_product (const BLOCK_VECTOR &u,
+ const BLOCK_VECTOR &v) const;
/**
* Compute $u^T M u$. This is the square of the norm induced by the matrix
* assuming the matrix is symmetric positive definitive.
*/
- number matrix_norm_square (const BlockVector<number> &u) const;
+ number matrix_norm_square (const BLOCK_VECTOR &u) const;
/**
* Print the block structure as a LaTeX-array. This output will not be very
template<class MATRIX>
Entry (const MATRIX &matrix,
size_type row, size_type col,
- double prefix, bool transpose);
+ number prefix, bool transpose);
/**
* Copy constructor invalidating the old object. Since it is only used for
/**
* Factor in front of the matrix block.
*/
- double prefix;
+ number prefix;
/**
* Indicates that matrix block must be transposed for multiplication.
/**
* The matrix block itself.
*/
- PointerMatrixBase<Vector<number> > *matrix;
+ PointerMatrixBase<typename BLOCK_VECTOR::BlockType > *matrix;
};
/**
* @ingroup Preconditioners
* @author Guido Kanschat, 2001, 2005
*/
-template <typename number = double>
+template <typename number = double, typename BLOCK_VECTOR = BlockVector<number> >
class BlockTrianglePrecondition
- : private BlockMatrixArray<number>
+ : private BlockMatrixArray<number,BLOCK_VECTOR>
{
public:
/**
void enter (const MATRIX &matrix,
const size_type row,
const size_type col,
- const double prefix = 1.,
+ const number prefix = 1.,
const bool transpose = false);
/**
* Preconditioning.
*/
- void vmult (BlockVector<number> &dst,
- const BlockVector<number> &src) const;
+ void vmult (BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const;
/**
* Preconditioning adding to <tt>dst</tt>.
*/
- void vmult_add (BlockVector<number> &dst,
- const BlockVector<number> &src) const;
+ void vmult_add (BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const;
/**
* Transposed preconditioning
*/
- void Tvmult (BlockVector<number> &dst,
- const BlockVector<number> &src) const;
+ void Tvmult (BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const;
/**
* Transposed preconditioning adding to <tt>dst</tt>.
*/
- void Tvmult_add (BlockVector<number> &dst,
- const BlockVector<number> &src) const;
+ void Tvmult_add (BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const;
/**
* Make function of base class available.
* Add all off-diagonal contributions and return the entry of the diagonal
* element for one row.
*/
- void do_row (BlockVector<number> &dst,
+ void do_row (BLOCK_VECTOR &dst,
size_type row_num) const;
/**
#ifndef DOXYGEN
//---------------------------------------------------------------------------
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
template <class MATRIX>
inline
-BlockMatrixArray<number>::Entry::Entry (
+BlockMatrixArray<number, BLOCK_VECTOR>::Entry::Entry (
const MATRIX &m,
size_type row,
size_type col,
- double prefix,
+ number prefix,
bool transpose)
:
row (row),
col (col),
prefix (prefix),
transpose (transpose),
- matrix (new_pointer_matrix_base(m, Vector<number>(), typeid(*this).name()))
+ matrix (new_pointer_matrix_base(m, typename BLOCK_VECTOR::BlockType(), typeid(*this).name()))
{}
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
template <class MATRIX>
inline
void
-BlockMatrixArray<number>::enter (
+BlockMatrixArray<number, BLOCK_VECTOR>::enter (
const MATRIX &matrix,
unsigned int row,
unsigned int col,
- double prefix,
+ number prefix,
bool transpose)
{
Assert(row<n_block_rows(), ExcIndexRange(row, 0, n_block_rows()));
}
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
template <class STREAM>
inline
void
-BlockMatrixArray<number>::print_latex (STREAM &out) const
+BlockMatrixArray<number, BLOCK_VECTOR>::print_latex (STREAM &out) const
{
out << "\\begin{array}{"
<< std::string(n_block_cols(), 'c')
Table<2,std::string> array(n_block_rows(), n_block_cols());
- typedef std::map<const PointerMatrixBase<Vector<number> > *, std::string> NameMap;
+ typedef std::map<const PointerMatrixBase<typename BLOCK_VECTOR::BlockType > *, std::string> NameMap;
NameMap matrix_names;
typename std::vector<Entry>::const_iterator m = entries.begin();
{
std::pair<typename NameMap::iterator, bool> x =
matrix_names.insert(
- std::pair<const PointerMatrixBase<Vector<number> >*, std::string> (m->matrix,
+ std::pair<const PointerMatrixBase<typename BLOCK_VECTOR::BlockType >*, std::string> (m->matrix,
std::string("M")));
std::ostringstream stream;
stream << matrix_number++;
out << "\\end{array}" << std::endl;
}
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
template <class MATRIX>
inline
void
-BlockTrianglePrecondition<number>::enter (const MATRIX &matrix,
+BlockTrianglePrecondition<number, BLOCK_VECTOR>::enter (const MATRIX &matrix,
size_type row, size_type col,
- double prefix, bool transpose)
+ number prefix, bool transpose)
{
- BlockMatrixArray<number>::enter(matrix, row, col, prefix, transpose);
+ BlockMatrixArray<number, BLOCK_VECTOR>::enter(matrix, row, col, prefix, transpose);
}
#include <deal.II/lac/block_matrix_array.h>
#include <deal.II/lac/vector.h>
#include <deal.II/lac/block_vector.h>
+#include <deal.II/lac/trilinos_block_vector.h>
DEAL_II_NAMESPACE_OPEN
-template <typename number>
-BlockMatrixArray<number>::Entry::Entry (const Entry &e)
+template <typename number, typename BLOCK_VECTOR>
+BlockMatrixArray<number,BLOCK_VECTOR>::Entry::Entry (const Entry &e)
:
row(e.row),
col(e.col),
-template <typename number>
-BlockMatrixArray<number>::Entry::~Entry ()
+template <typename number, typename BLOCK_VECTOR>
+BlockMatrixArray<number,BLOCK_VECTOR>::Entry::~Entry ()
{
if (matrix)
delete matrix;
}
-
-template <typename number>
-BlockMatrixArray<number>::BlockMatrixArray ()
+template <typename number, typename BLOCK_VECTOR>
+BlockMatrixArray<number,BLOCK_VECTOR>::BlockMatrixArray ()
: block_rows (0),
block_cols (0)
{}
-template <typename number>
-BlockMatrixArray<number>::BlockMatrixArray (
+template <typename number, typename BLOCK_VECTOR>
+BlockMatrixArray<number,BLOCK_VECTOR>::BlockMatrixArray (
const unsigned int n_block_rows,
const unsigned int n_block_cols)
: block_rows (n_block_rows),
{}
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockMatrixArray<number>::initialize (
+BlockMatrixArray<number,BLOCK_VECTOR>::initialize (
const unsigned int n_block_rows,
const unsigned int n_block_cols)
{
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockMatrixArray<number>::reinit (
+BlockMatrixArray<number,BLOCK_VECTOR>::reinit (
const unsigned int n_block_rows,
const unsigned int n_block_cols)
{
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockMatrixArray<number>::clear ()
+BlockMatrixArray<number,BLOCK_VECTOR>::clear ()
{
entries.clear();
}
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockMatrixArray<number>::vmult_add (BlockVector<number> &dst,
- const BlockVector<number> &src) const
+BlockMatrixArray<number,BLOCK_VECTOR>::vmult_add (BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const
{
- GrowingVectorMemory<Vector<number> > mem;
+ GrowingVectorMemory<typename BLOCK_VECTOR::BlockType > mem;
Assert (dst.n_blocks() == block_rows,
ExcDimensionMismatch(dst.n_blocks(), block_rows));
Assert (src.n_blocks() == block_cols,
ExcDimensionMismatch(src.n_blocks(), block_cols));
- typename VectorMemory<Vector<number> >::Pointer p_aux(mem);
- Vector<number> &aux = *p_aux;
+ typename VectorMemory<typename BLOCK_VECTOR::BlockType >::Pointer p_aux(mem);
+ typename BLOCK_VECTOR::BlockType &aux = *p_aux;
typename std::vector<Entry>::const_iterator m = entries.begin();
typename std::vector<Entry>::const_iterator end = entries.end();
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockMatrixArray<number>::vmult (BlockVector<number> &dst,
- const BlockVector<number> &src) const
+BlockMatrixArray<number,BLOCK_VECTOR>::vmult (BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const
{
dst = 0.;
vmult_add (dst, src);
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockMatrixArray<number>::Tvmult_add (BlockVector<number> &dst,
- const BlockVector<number> &src) const
+BlockMatrixArray<number,BLOCK_VECTOR>::Tvmult_add (BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const
{
- GrowingVectorMemory<Vector<number> > mem;
+ GrowingVectorMemory<typename BLOCK_VECTOR::BlockType > mem;
Assert (dst.n_blocks() == block_cols,
ExcDimensionMismatch(dst.n_blocks(), block_cols));
Assert (src.n_blocks() == block_rows,
typename std::vector<Entry>::const_iterator m = entries.begin();
typename std::vector<Entry>::const_iterator end = entries.end();
- typename VectorMemory<Vector<number> >::Pointer p_aux(mem);
- Vector<number> &aux = *p_aux;
+ typename VectorMemory<typename BLOCK_VECTOR::BlockType >::Pointer p_aux(mem);
+ typename BLOCK_VECTOR::BlockType &aux = *p_aux;
for (; m != end ; ++m)
{
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockMatrixArray<number>::Tvmult (BlockVector<number> &dst,
- const BlockVector<number> &src) const
+BlockMatrixArray<number,BLOCK_VECTOR>::Tvmult (BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const
{
dst = 0.;
Tvmult_add (dst, src);
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
number
-BlockMatrixArray<number>::matrix_scalar_product (
- const BlockVector<number> &u,
- const BlockVector<number> &v) const
+BlockMatrixArray<number,BLOCK_VECTOR>::matrix_scalar_product (
+ const BLOCK_VECTOR &u,
+ const BLOCK_VECTOR &v) const
{
- GrowingVectorMemory<Vector<number> > mem;
+ GrowingVectorMemory<typename BLOCK_VECTOR::BlockType > mem;
Assert (u.n_blocks() == block_rows,
ExcDimensionMismatch(u.n_blocks(), block_rows));
Assert (v.n_blocks() == block_cols,
ExcDimensionMismatch(v.n_blocks(), block_cols));
- typename VectorMemory<Vector<number> >::Pointer p_aux(mem);
- Vector<number> &aux = *p_aux;
+ typename VectorMemory<typename BLOCK_VECTOR::BlockType >::Pointer p_aux(mem);
+ typename BLOCK_VECTOR::BlockType &aux = *p_aux;
typename std::vector<Entry>::const_iterator m;
typename std::vector<Entry>::const_iterator end = entries.end();
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
number
-BlockMatrixArray<number>::matrix_norm_square (
- const BlockVector<number> &u) const
+BlockMatrixArray<number,BLOCK_VECTOR>::matrix_norm_square (
+ const BLOCK_VECTOR &u) const
{
return matrix_scalar_product(u,u);
}
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
unsigned int
-BlockMatrixArray<number>::n_block_rows () const
+BlockMatrixArray<number,BLOCK_VECTOR>::n_block_rows () const
{
return block_rows;
}
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
unsigned int
-BlockMatrixArray<number>::n_block_cols () const
+BlockMatrixArray<number,BLOCK_VECTOR>::n_block_cols () const
{
return block_cols;
}
//---------------------------------------------------------------------------
-template <typename number>
-BlockTrianglePrecondition<number>::BlockTrianglePrecondition()
- : BlockMatrixArray<number> (),
+template <typename number, typename BLOCK_VECTOR>
+BlockTrianglePrecondition<number,BLOCK_VECTOR>::BlockTrianglePrecondition()
+ : BlockMatrixArray<number,BLOCK_VECTOR> (),
backward(false)
{}
-template <typename number>
-BlockTrianglePrecondition<number>::BlockTrianglePrecondition(
+template <typename number, typename BLOCK_VECTOR>
+BlockTrianglePrecondition<number,BLOCK_VECTOR>::BlockTrianglePrecondition(
const unsigned int block_rows)
:
- BlockMatrixArray<number> (block_rows, block_rows),
+ BlockMatrixArray<number,BLOCK_VECTOR> (block_rows, block_rows),
backward(false)
{}
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockTrianglePrecondition<number>::reinit (
+BlockTrianglePrecondition<number,BLOCK_VECTOR>::reinit (
const unsigned int n)
{
- BlockMatrixArray<number>::reinit(n,n);
+ BlockMatrixArray<number,BLOCK_VECTOR>::reinit(n,n);
}
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockTrianglePrecondition<number>::do_row (
- BlockVector<number> &dst,
+BlockTrianglePrecondition<number,BLOCK_VECTOR>::do_row (
+ BLOCK_VECTOR &dst,
size_type row_num) const
{
- GrowingVectorMemory<Vector<number> > mem;
- typename std::vector<typename BlockMatrixArray<number>::Entry>::const_iterator
+ GrowingVectorMemory<typename BLOCK_VECTOR::BlockType > mem;
+ typename std::vector<typename BlockMatrixArray<number,BLOCK_VECTOR>::Entry>::const_iterator
m = this->entries.begin();
- typename std::vector<typename BlockMatrixArray<number>::Entry>::const_iterator
+ typename std::vector<typename BlockMatrixArray<number,BLOCK_VECTOR>::Entry>::const_iterator
end = this->entries.end();
- std::vector<typename std::vector<typename BlockMatrixArray<number>::Entry>::const_iterator>
+ std::vector<typename std::vector<typename BlockMatrixArray<number,BLOCK_VECTOR>::Entry>::const_iterator>
diagonals;
- typename VectorMemory<Vector<number> >::Pointer p_aux(mem);
- Vector<number> &aux = *p_aux;
+ typename VectorMemory<typename BLOCK_VECTOR::BlockType >::Pointer p_aux(mem);
+ typename BLOCK_VECTOR::BlockType &aux = *p_aux;
aux.reinit(dst.block(row_num), true);
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockTrianglePrecondition<number>::vmult_add (
- BlockVector<number> &dst,
- const BlockVector<number> &src) const
+BlockTrianglePrecondition<number,BLOCK_VECTOR>::vmult_add (
+ BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const
{
Assert (dst.n_blocks() == n_block_rows(),
ExcDimensionMismatch(dst.n_blocks(), n_block_rows()));
Assert (src.n_blocks() == n_block_cols(),
ExcDimensionMismatch(src.n_blocks(), n_block_cols()));
- BlockVector<number> aux;
+ BLOCK_VECTOR aux;
aux.reinit(dst);
vmult(aux, src);
dst.add(aux);
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockTrianglePrecondition<number>::vmult (
- BlockVector<number> &dst,
- const BlockVector<number> &src) const
+BlockTrianglePrecondition<number,BLOCK_VECTOR>::vmult (
+ BLOCK_VECTOR &dst,
+ const BLOCK_VECTOR &src) const
{
Assert (dst.n_blocks() == n_block_rows(),
ExcDimensionMismatch(dst.n_blocks(), n_block_rows()));
}
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockTrianglePrecondition<number>::Tvmult (
- BlockVector<number> &,
- const BlockVector<number> &) const
+BlockTrianglePrecondition<number,BLOCK_VECTOR>::Tvmult (
+ BLOCK_VECTOR &,
+ const BLOCK_VECTOR &) const
{
Assert (false, ExcNotImplemented());
}
-template <typename number>
+template <typename number, typename BLOCK_VECTOR>
void
-BlockTrianglePrecondition<number>::Tvmult_add (
- BlockVector<number> &,
- const BlockVector<number> &) const
+BlockTrianglePrecondition<number,BLOCK_VECTOR>::Tvmult_add (
+ BLOCK_VECTOR &,
+ const BLOCK_VECTOR &) const
{
Assert (false, ExcNotImplemented());
}
template class BlockTrianglePrecondition<float>;
template class BlockTrianglePrecondition<double>;
+template class BlockMatrixArray<double, TrilinosWrappers::MPI::BlockVector>;
+template class BlockMatrixArray<float, TrilinosWrappers::MPI::BlockVector>;
+
DEAL_II_NAMESPACE_CLOSE