From: guido Date: Fri, 5 Dec 2003 14:19:36 +0000 (+0000) Subject: memory_consumption X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c3aab1388aceb202db59e0bbd84a5550957f89b;p=dealii-svn.git memory_consumption git-svn-id: https://svn.dealii.org/trunk@8234 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/multigrid/mg_level_object.h b/deal.II/deal.II/include/multigrid/mg_level_object.h index f3ddd24d1e..4d5298eb22 100644 --- a/deal.II/deal.II/include/multigrid/mg_level_object.h +++ b/deal.II/deal.II/include/multigrid/mg_level_object.h @@ -84,9 +84,19 @@ class MGLevelObject : public Subscriptor */ void clear(); - ////// + /** + * @brief Coarsest level for multigrid. + */ unsigned int get_minlevel () const; + + /** + * Ignored + */ unsigned int get_maxlevel () const; + /** + * Memory used by this object. + */ + unsigned int memory_consumption () const; private: /** @@ -178,6 +188,20 @@ MGLevelObject::get_maxlevel () const } +template +unsigned int +MGLevelObject::memory_consumption () const +{ + unsigned int result = sizeof(*this); + typedef typename std::vector >::const_iterator Iter; + const Iter end = objects.end(); + for (Iter o=objects.begin(); o!=end; ++o) + result += o->memory_consumption(); + + return result; +} + + /*----------------------- mg_level_object.h -----------------------*/ #endif diff --git a/deal.II/deal.II/include/multigrid/mg_matrix.h b/deal.II/deal.II/include/multigrid/mg_matrix.h index 7c56efd2cd..8cd9349d09 100644 --- a/deal.II/deal.II/include/multigrid/mg_matrix.h +++ b/deal.II/deal.II/include/multigrid/mg_matrix.h @@ -76,7 +76,13 @@ class MGMatrix : public MGMatrixBase * a certain level. */ virtual void Tvmult_add(unsigned int level, VECTOR& dst, - const VECTOR& src) const; + const VECTOR& src) const; + + /** + * Memory used by this object. + */ + unsigned int memory_consumption () const; + private: /** @@ -244,6 +250,13 @@ MGMatrix::Tvmult_add (unsigned int level, } +template +unsigned int +MGMatrix::memory_consumption () const +{ + return sizeof(*this) + matrix->memory_consumption(); +} + /*----------------------------------------------------------------------*/ template diff --git a/deal.II/deal.II/include/multigrid/mg_smoother.h b/deal.II/deal.II/include/multigrid/mg_smoother.h index 5a1583fc28..e8fa3ec764 100644 --- a/deal.II/deal.II/include/multigrid/mg_smoother.h +++ b/deal.II/deal.II/include/multigrid/mg_smoother.h @@ -321,7 +321,13 @@ class MGSmootherRelaxation : public MGSmootherBase * methods. */ MGLevelObject smoothers; + + /** + * Memory used by this object. + */ + unsigned int memory_consumption () const; + private: /** * Pointer to the matrices. @@ -558,4 +564,18 @@ MGSmootherRelaxation::smooth( mem.free(d); } + +//TODO:[GK] Add other values +template +inline unsigned int +MGSmootherRelaxation:: +memory_consumption () const +{ + return sizeof(*this) + + matrices.memory_consumption() + + smoothers.memory_consumption(); +} + + + #endif diff --git a/deal.II/deal.II/include/multigrid/mg_transfer.h b/deal.II/deal.II/include/multigrid/mg_transfer.h index 8a5388648c..d6d87ce7e6 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.h @@ -164,6 +164,12 @@ class MGTransferPrebuilt : public MGTransferBase > */ DeclException0(ExcMatricesNotBuilt); + /** + * Memory used by this object. + */ + unsigned int memory_consumption () const; + + private: /** @@ -257,6 +263,13 @@ class MGTransferPrebuilt : public MGTransferBase > */ class MGTransferBlockBase { + public: + /** + * Memory used by this object. + */ + unsigned int memory_consumption () const; + + protected: /** * Actually build the prolongation @@ -307,7 +320,7 @@ class MGTransferBlockBase std::vector component_start; /** - * Start index of eah component on + * Start index of each component on * all levels. */ std::vector > mg_component_start; @@ -500,6 +513,8 @@ class MGTransferBlock : public MGTransferBase >, OutVector &dst, const MGLevelObject > &src) const; + MGTransferBlockBase::memory_consumption; + private: /** * Structure that is used to @@ -765,6 +780,11 @@ class MGTransferSelect : public MGTransferBase >, BlockVector &dst, const MGLevelObject > &src) const; + /** + * Memory used by this object. + */ + unsigned int memory_consumption () const; + private: /** * Transfer from multi-level vector to diff --git a/deal.II/deal.II/include/multigrid/mg_transfer.templates.h b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h index 53c3b513b5..8e9d246778 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.templates.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h @@ -256,6 +256,24 @@ MGTransferPrebuilt::copy_from_mg_add ( } +template +unsigned int +MGTransferPrebuilt::memory_consumption () const +{ + unsigned int result = sizeof(*this); + result += sizeof(unsigned int) * sizes.size(); +#ifdef DEAL_PREFER_MATRIX_EZ + std::vector > >::const_iterator m; + const std::vector > >::const_iterator end = prolongation_matrices.end(); + for (m = prolongation_matrices.begin(); m != end ; ++m) + result += *m->memory_consumption(); +#else + for (unsigned int i=0;imemory_consumption() + + prolongation_sparsities[i]->memory_consumption(); +#endif + return result; +} /* --------------------- MGTransferSelect -------------- */ @@ -599,6 +617,13 @@ MGTransferSelect::do_copy_from_mg_add ( } +template +unsigned int +MGTransferSelect::memory_consumption () const +{ + return sizeof(int) + MGTransferBlockBase::memory_consumption(); +} + /* --------------------- MGTransferBlock -------------- */ diff --git a/deal.II/deal.II/source/multigrid/mg_transfer_block.cc b/deal.II/deal.II/source/multigrid/mg_transfer_block.cc index 58dc133144..51e3a2bf7b 100644 --- a/deal.II/deal.II/source/multigrid/mg_transfer_block.cc +++ b/deal.II/deal.II/source/multigrid/mg_transfer_block.cc @@ -299,6 +299,26 @@ void MGTransferBlockBase::build_matrices ( #endif } +//TODO:[GK] Add all those little vectors. +unsigned int +MGTransferBlockBase::memory_consumption () const +{ + unsigned int result = sizeof(*this); + result += sizeof(unsigned int) * sizes.size(); +#ifdef DEAL_PREFER_MATRIX_EZ + std::vector > >::const_iterator m; + const std::vector > >::const_iterator end = prolongation_matrices.end(); + for (m = prolongation_matrices.begin(); m != end ; ++m) + result += *m->memory_consumption(); +#else + for (unsigned int i=0;imemory_consumption() + + prolongation_sparsities[i]->memory_consumption(); +#endif + return result; +} + + template template