From 1ae279fb94644db4bdaf2c09dbbe8c6773e95d38 Mon Sep 17 00:00:00 2001 From: kanschat Date: Sat, 25 Sep 2010 20:29:59 +0000 Subject: [PATCH] implement MGMatrixBlockVector git-svn-id: https://svn.dealii.org/trunk@22157 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/mg_level_object.h | 28 ++++++- deal.II/lac/include/lac/matrix_block.h | 88 +++++++++++++++++++-- 2 files changed, 110 insertions(+), 6 deletions(-) diff --git a/deal.II/base/include/base/mg_level_object.h b/deal.II/base/include/base/mg_level_object.h index 7b75ed4154..6cebc0c801 100644 --- a/deal.II/base/include/base/mg_level_object.h +++ b/deal.II/base/include/base/mg_level_object.h @@ -91,10 +91,20 @@ class MGLevelObject : public Subscriptor /** * Coarsest level for multigrid. */ + unsigned int min_level () const; + + /** + * Finest level for multigrid. + */ + unsigned int max_level () const; + + /** + * @deprecated Replaced by min_level() + */ unsigned int get_minlevel () const; /** - * Ignored + * @deprecated Replaced by max_level() */ unsigned int get_maxlevel () const; @@ -204,6 +214,22 @@ MGLevelObject::get_maxlevel () const } +template +unsigned int +MGLevelObject::min_level () const +{ + return minlevel; +} + + +template +unsigned int +MGLevelObject::max_level () const +{ + return minlevel + objects.size() - 1; +} + + template unsigned int MGLevelObject::memory_consumption () const diff --git a/deal.II/lac/include/lac/matrix_block.h b/deal.II/lac/include/lac/matrix_block.h index 00597ecd44..e44ddc07eb 100644 --- a/deal.II/lac/include/lac/matrix_block.h +++ b/deal.II/lac/include/lac/matrix_block.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -408,7 +409,7 @@ class MatrixBlockVector : public NamedData -class MGMatrixBlockVector : public NamedData > > +class MGMatrixBlockVector : public NamedData > > > { public: /** @@ -426,18 +427,26 @@ class MGMatrixBlockVector : public NamedData& sparsity); /** * Access a constant reference to * the block at position i. */ - const MatrixBlock& block(unsigned int i) const; + const MGLevelObject >& block(unsigned int i) const; /** * Access a reference to * the block at position i. */ - MatrixBlock& block(unsigned int i); + MGLevelObject >& block(unsigned int i); /** * The memory used by this object. @@ -461,10 +470,11 @@ namespace internal { template void - reinit(MatrixBlockVector& v, const BlockSparsityPattern& p) + reinit(MatrixBlockVector&, const BlockSparsityPattern&) { Assert(false, ExcNotImplemented()); } + template void @@ -473,6 +483,25 @@ namespace internal for (unsigned int i=0;imatrix.reinit(p.block(v(i)->row, v(i)->column)); } + + + template + void + reinit(MGMatrixBlockVector&, const MGLevelObject&) + { + Assert(false, ExcNotImplemented()); + } + + + template + void + reinit(MGMatrixBlockVector >& v, + const MGLevelObject& sparsity) + { + for (unsigned int i=0;imatrix[level].reinit(sparsity[level].block(v(i)->row, v(i)->column)); + } } @@ -719,6 +748,55 @@ MatrixBlockVector::matrix(unsigned int i) +//----------------------------------------------------------------------// + +template +inline void +MGMatrixBlockVector::add( + unsigned int row, unsigned int column, + const std::string& name, + const BlockIndices* block_indices) +{ + std_cxx1x::shared_ptr > > + p(new MGLevelObject >(row, column, block_indices)); + NamedData > >::add(p, name); +} + + +template +inline void +MGMatrixBlockVector::reinit(const MGLevelObject& sparsity) +{ + internal::reinit(*this, sparsity); +} + + + +template +inline const MGLevelObject >& +MGMatrixBlockVector::block(unsigned int i) const +{ + return *this->read(i); +} + + +template +inline MGLevelObject >& +MGMatrixBlockVector::block(unsigned int i) +{ + return *(*this)(i); +} + + +template +inline MATRIX& +MGMatrixBlockVector::matrix(unsigned int i) +{ + return (*this)(i)->matrix; +} + + + DEAL_II_NAMESPACE_CLOSE #endif -- 2.39.5