From: Guido Kanschat Date: Fri, 18 Nov 2005 20:51:56 +0000 (+0000) Subject: add standard constructor for ProductMatrix X-Git-Tag: v8.0.0~12864 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67d40f3e20bc25ddbccee21642e25e9eea930407;p=dealii.git add standard constructor for ProductMatrix git-svn-id: https://svn.dealii.org/trunk@11771 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/matrix_lib.h b/deal.II/lac/include/lac/matrix_lib.h index d66b060557..31ea9468be 100644 --- a/deal.II/lac/include/lac/matrix_lib.h +++ b/deal.II/lac/include/lac/matrix_lib.h @@ -43,9 +43,17 @@ template class ProductMatrix : public PointerMatrixBase { public: + /** + * Standard constructor. Matrices + * and the memory pool must be + * added later using + * initialize(). + */ + ProductMatrix(); + /** * Constructor only assigning the - * memory pool. Matricesmust be + * memory pool. Matrices must be * added by reinit() later. */ ProductMatrix(VectorMemory& mem); @@ -67,6 +75,13 @@ class ProductMatrix : public PointerMatrixBase template void reinit(const MATRIX1& m1, const MATRIX2& m2); + /** + * Change the matrices and memory pool. + */ + template + void initialize(const MATRIX1& m1, const MATRIX2& m2, + VectorMemory& mem); + /** * Destructor. */ @@ -401,6 +416,12 @@ class InverseMatrixRichardson /*@}*/ //--------------------------------------------------------------------------- +template +ProductMatrix::ProductMatrix () + : m1(0), m2(0), mem(0, typeid(*this).name()) +{} + + template ProductMatrix::ProductMatrix (VectorMemory& m) : m1(0), m2(0), mem(&m, typeid(*this).name()) @@ -434,6 +455,22 @@ ProductMatrix::reinit ( } +template +template +void +ProductMatrix::initialize ( + const MATRIX1& mat1, + const MATRIX2& mat2, + VectorMemory& memory) +{ + mem = &memory; + if (m1) delete m1; + if (m2) delete m2; + m1 = new PointerMatrix(&mat1, typeid(*this).name()); + m2 = new PointerMatrix(&mat2, typeid(*this).name()); +} + + template ProductMatrix::~ProductMatrix () { @@ -446,6 +483,7 @@ template void ProductMatrix::vmult (VECTOR& dst, const VECTOR& src) const { + Assert (mem != 0, ExcNotInitialized()); Assert (m1 != 0, ExcNotInitialized()); Assert (m2 != 0, ExcNotInitialized()); @@ -461,6 +499,7 @@ template void ProductMatrix::vmult_add (VECTOR& dst, const VECTOR& src) const { + Assert (mem != 0, ExcNotInitialized()); Assert (m1 != 0, ExcNotInitialized()); Assert (m2 != 0, ExcNotInitialized()); @@ -476,6 +515,7 @@ template void ProductMatrix::Tvmult (VECTOR& dst, const VECTOR& src) const { + Assert (mem != 0, ExcNotInitialized()); Assert (m1 != 0, ExcNotInitialized()); Assert (m2 != 0, ExcNotInitialized()); @@ -491,6 +531,7 @@ template void ProductMatrix::Tvmult_add (VECTOR& dst, const VECTOR& src) const { + Assert (mem != 0, ExcNotInitialized()); Assert (m1 != 0, ExcNotInitialized()); Assert (m2 != 0, ExcNotInitialized());