]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
memory_consumption
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 Dec 2003 14:19:36 +0000 (14:19 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 Dec 2003 14:19:36 +0000 (14:19 +0000)
git-svn-id: https://svn.dealii.org/trunk@8234 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/mg_level_object.h
deal.II/deal.II/include/multigrid/mg_matrix.h
deal.II/deal.II/include/multigrid/mg_smoother.h
deal.II/deal.II/include/multigrid/mg_transfer.h
deal.II/deal.II/include/multigrid/mg_transfer.templates.h
deal.II/deal.II/source/multigrid/mg_transfer_block.cc

index f3ddd24d1ea167f5c5f95e82eaa7ced1974bd356..4d5298eb22e81768d28301280022ac5c3c78456b 100644 (file)
@@ -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<Object>::get_maxlevel () const
 }
 
 
+template<class Object>
+unsigned int
+MGLevelObject<Object>::memory_consumption () const
+{
+  unsigned int result = sizeof(*this);
+  typedef typename std::vector<boost::shared_ptr<Object> >::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
index 7c56efd2cd2f181df0656bc8bca6c1c12a816522..8cd9349d095ee3c93043d0de540801766505dc1a 100644 (file)
@@ -76,7 +76,13 @@ class MGMatrix : public MGMatrixBase<VECTOR>
                                    * 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<MATRIX, VECTOR>::Tvmult_add (unsigned int level,
 }
 
 
+template <class MATRIX, class VECTOR>
+unsigned int
+MGMatrix<MATRIX, VECTOR>::memory_consumption () const
+{
+  return sizeof(*this) + matrix->memory_consumption();
+}
+
 /*----------------------------------------------------------------------*/
 
 template <class MATRIX, typename number>
index 5a1583fc287bfbd37f15c7cffd23f871f4ca8bbd..e8fa3ec764504761bbb4f144611f85d7c138c240 100644 (file)
@@ -321,7 +321,13 @@ class MGSmootherRelaxation : public MGSmootherBase<VECTOR>
                                      * methods.
                                      */
     MGLevelObject<RELAX> smoothers;
+
+                                    /**
+                                     * Memory used by this object.
+                                     */
+    unsigned int memory_consumption () const;
     
+
  private:
                                     /**
                                      * Pointer to the matrices.
@@ -558,4 +564,18 @@ MGSmootherRelaxation<MATRIX, RELAX, VECTOR>::smooth(
   mem.free(d);
 }
 
+
+//TODO:[GK] Add other values
+template <class MATRIX, class RELAX, class VECTOR>
+inline unsigned int
+MGSmootherRelaxation<MATRIX, RELAX, VECTOR>::
+memory_consumption () const
+{
+  return sizeof(*this)
+    + matrices.memory_consumption()
+    + smoothers.memory_consumption();
+}
+
+
+
 #endif
index 8a5388648c4396190a036aebe47a9c7a663688bc..d6d87ce7e6b8d252f5e10f804927a53f5c7742b1 100644 (file)
@@ -164,6 +164,12 @@ class MGTransferPrebuilt : public MGTransferBase<Vector<number> >
                                      */
     DeclException0(ExcMatricesNotBuilt);
 
+                                    /**
+                                     * Memory used by this object.
+                                     */
+    unsigned int memory_consumption () const;
+    
+
   private:
 
                                   /**
@@ -257,6 +263,13 @@ class MGTransferPrebuilt : public MGTransferBase<Vector<number> >
  */
 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<unsigned int> component_start;
   
                                   /**
-                                   * Start index of eah component on
+                                   * Start index of each component on
                                    * all levels.
                                    */
     std::vector<std::vector<unsigned int> > mg_component_start;
@@ -500,6 +513,8 @@ class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
                      OutVector                                 &dst,
                      const MGLevelObject<BlockVector<number> > &src) const;
 
+    MGTransferBlockBase::memory_consumption;
+    
   private:
                                     /**
                                      * Structure that is used to
@@ -765,6 +780,11 @@ class MGTransferSelect : public MGTransferBase<Vector<number> >,
                      BlockVector<number2>                 &dst,
                      const MGLevelObject<Vector<number> > &src) const;
 
+                                    /**
+                                     * Memory used by this object.
+                                     */
+    unsigned int memory_consumption () const;
+    
   private:
                                     /**
                                      * Transfer from multi-level vector to
index 53c3b513b5ac2f32af62443d7ece54190bc3a902..8e9d24677894276307908fa4214256cf3365772a 100644 (file)
@@ -256,6 +256,24 @@ MGTransferPrebuilt<number>::copy_from_mg_add (
 }
 
 
+template <typename number>
+unsigned int
+MGTransferPrebuilt<number>::memory_consumption () const
+{
+  unsigned int result = sizeof(*this);
+  result += sizeof(unsigned int) * sizes.size();
+#ifdef DEAL_PREFER_MATRIX_EZ
+  std::vector<boost::shared_ptr<SparseMatrixEZ<double> > >::const_iterator m;
+  const std::vector<boost::shared_ptr<SparseMatrixEZ<double> > >::const_iterator end = prolongation_matrices.end();
+  for (m = prolongation_matrices.begin(); m != end ; ++m)
+    result += *m->memory_consumption();
+#else
+  for (unsigned int i=0;i<prolongation_matrices.size();++i)
+    result += prolongation_matrices[i]->memory_consumption()
+             + prolongation_sparsities[i]->memory_consumption();
+#endif
+  return result;
+}
 
 /* --------------------- MGTransferSelect -------------- */
 
@@ -599,6 +617,13 @@ MGTransferSelect<number>::do_copy_from_mg_add (
 }
 
 
+template <typename number>
+unsigned int
+MGTransferSelect<number>::memory_consumption () const
+{
+  return sizeof(int) + MGTransferBlockBase::memory_consumption();
+}
+
 
 /* --------------------- MGTransferBlock -------------- */
 
index 58dc133144cbfd59f77cd8e6889aec346cc7c984..51e3a2bf7bbb45cea69fe96a8a8dee7740d73f38 100644 (file)
@@ -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<boost::shared_ptr<SparseMatrixEZ<double> > >::const_iterator m;
+  const std::vector<boost::shared_ptr<SparseMatrixEZ<double> > >::const_iterator end = prolongation_matrices.end();
+  for (m = prolongation_matrices.begin(); m != end ; ++m)
+    result += *m->memory_consumption();
+#else
+  for (unsigned int i=0;i<prolongation_matrices.size();++i)
+    result += prolongation_matrices[i]->memory_consumption()
+             + prolongation_sparsities[i]->memory_consumption();
+#endif
+  return result;
+}
+
+
 
 template <typename number>
 template <int dim>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.