]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement memory consumption monitors to most classes.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 26 Nov 2000 21:40:40 +0000 (21:40 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 26 Nov 2000 21:40:40 +0000 (21:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@3502 0785d39b-7218-0410-832d-ea1e28bc413d

71 files changed:
deal.II/base/include/base/data_out_base.h
deal.II/base/include/base/function.h
deal.II/base/include/base/function_derivative.h
deal.II/base/include/base/function_lib.h
deal.II/base/include/base/logstream.h
deal.II/base/include/base/memory_consumption.h [new file with mode: 0644]
deal.II/base/include/base/multithread_info.h
deal.II/base/include/base/parameter_handler.h
deal.II/base/include/base/quadrature.h
deal.II/base/include/base/smartpointer.h
deal.II/base/include/base/tensor.h
deal.II/base/include/base/tensor_base.h
deal.II/base/source/data_out_base.all_dimensions.cc
deal.II/base/source/data_out_base.cc
deal.II/base/source/function.cc
deal.II/base/source/function_derivative.cc
deal.II/base/source/function_lib.cc
deal.II/base/source/log.cc
deal.II/base/source/memory_consumption.cc [new file with mode: 0644]
deal.II/base/source/multithread_info.cc
deal.II/base/source/parameter_handler.cc
deal.II/base/source/quadrature.cc
deal.II/deal.II/include/dofs/dof_constraints.h
deal.II/deal.II/include/dofs/dof_handler.h
deal.II/deal.II/include/dofs/dof_levels.h
deal.II/deal.II/include/fe/fe.h
deal.II/deal.II/include/fe/fe_lib.criss_cross.h
deal.II/deal.II/include/fe/fe_system.h
deal.II/deal.II/include/fe/fe_values.h
deal.II/deal.II/include/grid/grid_out.h
deal.II/deal.II/include/grid/intergrid_map.h
deal.II/deal.II/include/grid/persistent_tria.h
deal.II/deal.II/include/grid/tria.h
deal.II/deal.II/include/grid/tria_hex.h
deal.II/deal.II/include/grid/tria_iterator.h
deal.II/deal.II/include/grid/tria_levels.h
deal.II/deal.II/include/grid/tria_line.h
deal.II/deal.II/include/grid/tria_quad.h
deal.II/deal.II/source/dofs/dof_handler.cc
deal.II/deal.II/source/dofs/dof_levels.cc [new file with mode: 0644]
deal.II/deal.II/source/fe/fe.cc
deal.II/deal.II/source/fe/fe_system.cc
deal.II/deal.II/source/fe/fe_values.cc
deal.II/deal.II/source/grid/grid_out.all_dimensions.cc
deal.II/deal.II/source/grid/intergrid_map.cc
deal.II/deal.II/source/grid/persistent_tria.cc
deal.II/deal.II/source/grid/tria.all_dimensions.cc
deal.II/deal.II/source/grid/tria.cc
deal.II/lac/include/lac/block_indices.h
deal.II/lac/include/lac/block_sparse_matrix.h
deal.II/lac/include/lac/block_sparse_matrix.templates.h
deal.II/lac/include/lac/block_sparsity_pattern.h
deal.II/lac/include/lac/block_vector.h
deal.II/lac/include/lac/block_vector.templates.h
deal.II/lac/include/lac/full_matrix.h
deal.II/lac/include/lac/full_matrix.templates.h
deal.II/lac/include/lac/precondition_block.h
deal.II/lac/include/lac/precondition_block.templates.h
deal.II/lac/include/lac/sparse_ilu.h
deal.II/lac/include/lac/sparse_ilu.templates.h
deal.II/lac/include/lac/sparse_matrix.h
deal.II/lac/include/lac/sparse_matrix.templates.h
deal.II/lac/include/lac/sparse_vanka.h
deal.II/lac/include/lac/sparse_vanka.templates.h
deal.II/lac/include/lac/sparsity_pattern.h
deal.II/lac/include/lac/swappable_vector.h
deal.II/lac/include/lac/swappable_vector.templates.h
deal.II/lac/include/lac/vector.h
deal.II/lac/include/lac/vector.templates.h
deal.II/lac/source/block_sparsity_pattern.cc
deal.II/lac/source/sparsity_pattern.cc

index da9b67032fce7e2e900c785a95002812cbbaca7b..71ca79938e5bf41fb4bec0330f08dcca4fe61627 100644 (file)
@@ -418,6 +418,24 @@ class DataOutBase
                                          */
        Patch ();
 
+                                        /**
+                                         * Determine an estimate for
+                                         * the memory consumption (in
+                                         * bytes) of this
+                                         * object. Since sometimes
+                                         * the size of objects can
+                                         * not be determined exactly
+                                         * (for example: what is the
+                                         * memory consumption of an
+                                         * STL @p{map} type with a
+                                         * certain number of
+                                         * elements?), this is only
+                                         * an estimate. however often
+                                         * quite close to the true
+                                         * value.
+                                         */
+       unsigned int memory_consumption () const;
+       
                                         /**
                                          * Exception
                                          */
@@ -471,6 +489,24 @@ class DataOutBase
                                          * all previous contents of this object.
                                          */
        void parse_parameters (ParameterHandler &prm);
+
+                                        /**
+                                         * Determine an estimate for
+                                         * the memory consumption (in
+                                         * bytes) of this
+                                         * object. Since sometimes
+                                         * the size of objects can
+                                         * not be determined exactly
+                                         * (for example: what is the
+                                         * memory consumption of an
+                                         * STL @p{map} type with a
+                                         * certain number of
+                                         * elements?), this is only
+                                         * an estimate. however often
+                                         * quite close to the true
+                                         * value.
+                                         */
+       unsigned int memory_consumption () const;
     };
 
                                     /**
@@ -509,6 +545,24 @@ class DataOutBase
                                          * all previous contents of this object.
                                          */
        void parse_parameters (ParameterHandler &prm);
+
+                                        /**
+                                         * Determine an estimate for
+                                         * the memory consumption (in
+                                         * bytes) of this
+                                         * object. Since sometimes
+                                         * the size of objects can
+                                         * not be determined exactly
+                                         * (for example: what is the
+                                         * memory consumption of an
+                                         * STL @p{map} type with a
+                                         * certain number of
+                                         * elements?), this is only
+                                         * an estimate. however often
+                                         * quite close to the true
+                                         * value.
+                                         */
+       unsigned int memory_consumption () const;
     };
 
                                     /**
@@ -520,39 +574,39 @@ class DataOutBase
                                      */
     struct PovrayFlags 
     {
-                                     /**
-                                      * Normal vector interpolation,
-                                      * if set to true
-                                      *
-                                      * default = false
-                                      */
-      bool smooth;
-
-                                      /**
-                                      * Use bicubic patches (b-splines)
-                                      * instead of triangles.
-                                      *
-                                      * default = false
-                                      */
-      bool bicubic_patch;
-
-                                      /**
-                                      * include external "data.inc"
-                                      * with camera, light and
-                                      * texture definition for the
-                                      * scene.
-                                      *
-                                      * default = false
-                                      */
-      bool external_data;
-
-                                      /**
-                                      * Constructor.
-                                      */
-      PovrayFlags (const bool smooth = false,
-                  const bool bicubic_patch = false,
-                  const bool external_data = false);
+                                        /**
+                                         * Normal vector interpolation,
+                                         * if set to true
+                                         *
+                                         * default = false
+                                         */
+       bool smooth;
+       
+                                        /**
+                                         * Use bicubic patches (b-splines)
+                                         * instead of triangles.
+                                         *
+                                         * default = false
+                                         */
+       bool bicubic_patch;
 
+                                        /**
+                                         * include external "data.inc"
+                                         * with camera, light and
+                                         * texture definition for the
+                                         * scene.
+                                         *
+                                         * default = false
+                                         */
+       bool external_data;
+       
+                                        /**
+                                         * Constructor.
+                                         */
+       PovrayFlags (const bool smooth = false,
+                    const bool bicubic_patch = false,
+                    const bool external_data = false);
+       
                                         /**
                                          * Declare all flags with name
                                          * and type as offered by this
@@ -570,6 +624,24 @@ class DataOutBase
                                          * all previous contents of this object.
                                          */
        void parse_parameters (ParameterHandler &prm);
+
+                                        /**
+                                         * Determine an estimate for
+                                         * the memory consumption (in
+                                         * bytes) of this
+                                         * object. Since sometimes
+                                         * the size of objects can
+                                         * not be determined exactly
+                                         * (for example: what is the
+                                         * memory consumption of an
+                                         * STL @p{map} type with a
+                                         * certain number of
+                                         * elements?), this is only
+                                         * an estimate. however often
+                                         * quite close to the true
+                                         * value.
+                                         */
+       unsigned int memory_consumption () const;
     };
 
 
@@ -847,6 +919,24 @@ class DataOutBase
                                          * all previous contents of this object.
                                          */
        void parse_parameters (ParameterHandler &prm);
+
+                                        /**
+                                         * Determine an estimate for
+                                         * the memory consumption (in
+                                         * bytes) of this
+                                         * object. Since sometimes
+                                         * the size of objects can
+                                         * not be determined exactly
+                                         * (for example: what is the
+                                         * memory consumption of an
+                                         * STL @p{map} type with a
+                                         * certain number of
+                                         * elements?), this is only
+                                         * an estimate. however often
+                                         * quite close to the true
+                                         * value.
+                                         */
+       unsigned int memory_consumption () const;
     };
 
                                     /**
@@ -885,6 +975,24 @@ class DataOutBase
                                          * all previous contents of this object.
                                          */
        void parse_parameters (ParameterHandler &prm);
+
+                                        /**
+                                         * Determine an estimate for
+                                         * the memory consumption (in
+                                         * bytes) of this
+                                         * object. Since sometimes
+                                         * the size of objects can
+                                         * not be determined exactly
+                                         * (for example: what is the
+                                         * memory consumption of an
+                                         * STL @p{map} type with a
+                                         * certain number of
+                                         * elements?), this is only
+                                         * an estimate. however often
+                                         * quite close to the true
+                                         * value.
+                                         */
+       unsigned int memory_consumption () const;
     };
 
                                     /**
@@ -952,6 +1060,23 @@ class DataOutBase
                           const GmvFlags                     &flags,
                           ostream                            &out);
 
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object. Since sometimes
+                                     * the size of objects can
+                                     * not be determined exactly
+                                     * (for example: what is the
+                                     * memory consumption of an
+                                     * STL @p{map} type with a
+                                     * certain number of
+                                     * elements?), this is only
+                                     * an estimate. however often
+                                     * quite close to the true
+                                     * value.
+                                     */
+    static unsigned int memory_consumption ();
 
                                     /**
                                      * Exception
@@ -1353,6 +1478,24 @@ class DataOutInterface : private DataOutBase
                                      */
     void parse_parameters (ParameterHandler &prm);
     
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object. Since sometimes
+                                     * the size of objects can
+                                     * not be determined exactly
+                                     * (for example: what is the
+                                     * memory consumption of an
+                                     * STL @p{map} type with a
+                                     * certain number of
+                                     * elements?), this is only
+                                     * an estimate. however often
+                                     * quite close to the true
+                                     * value.
+                                     */
+    unsigned int memory_consumption () const;
+
                                     /**
                                      * Exception
                                      */
index 3b5404ec91145d3a0d18aa272083dd051c36334f..69ef98668a6f87e425670c698a3d47ae1524339e 100644 (file)
@@ -255,6 +255,24 @@ class Function : public FunctionTime,
                                      */
     virtual void vector_laplacian_list (const vector<Point<dim> > &points,
                                        vector<Vector<double> >   &values) const;
+
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object. Since sometimes
+                                     * the size of objects can
+                                     * not be determined exactly
+                                     * (for example: what is the
+                                     * memory consumption of an
+                                     * STL @p{map} type with a
+                                     * certain number of
+                                     * elements?), this is only
+                                     * an estimate. however often
+                                     * quite close to the true
+                                     * value.
+                                     */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -455,6 +473,24 @@ class ConstantFunction : public ZeroFunction<dim>
     virtual void vector_value_list (const vector<Point<dim> > &points,
                                    vector<Vector<double> >   &values) const;
 
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object. Since sometimes
+                                     * the size of objects can
+                                     * not be determined exactly
+                                     * (for example: what is the
+                                     * memory consumption of an
+                                     * STL @p{map} type with a
+                                     * certain number of
+                                     * elements?), this is only
+                                     * an estimate. however often
+                                     * quite close to the true
+                                     * value.
+                                     */
+    unsigned int memory_consumption () const;
+
   protected:
                                     /**
                                      * Store the constant function value.
@@ -505,6 +541,24 @@ class ComponentSelectFunction : public ConstantFunction<dim>
     virtual void vector_value_list (const vector<Point<dim> > &points,
                                    vector<Vector<double> >   &values) const;
 
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object. Since sometimes
+                                     * the size of objects can
+                                     * not be determined exactly
+                                     * (for example: what is the
+                                     * memory consumption of an
+                                     * STL @p{map} type with a
+                                     * certain number of
+                                     * elements?), this is only
+                                     * an estimate. however often
+                                     * quite close to the true
+                                     * value.
+                                     */
+    unsigned int memory_consumption () const;
+
   protected:
     const unsigned int selected;
 };
index 2d0f7aca93d1d5b61a6ca756740954e77a9d3eac..9400f0fff567a437cd29bd765c8b1c67c8339784 100644 (file)
 #include <base/exceptions.h>
 #include <base/function.h>
 
-/**
- * Names of difference formulas.
- */
-enum DifferenceFormula
-{
-  Euler,
-  UpwindEuler,
-  FourthOrder
-};
-
 
 /**
  * Derivative of a function object.  The value access functions of
@@ -45,77 +35,105 @@ enum DifferenceFormula
 template <int dim>
 class FunctionDerivative : public Function<dim>
 {
-public:
-                                  /**
-                                   * Constructor. Provided are the
-                                   * function to compute derivatives
-                                   * of and the direction vector of
-                                   * the differentiation.
-                                   */
-  FunctionDerivative (const Function<dim>& f,
-                     const Point<dim>& direction);
+  public:
+                                    /**
+                                     * Names of difference formulas.
+                                     */
+    enum DifferenceFormula
+    {
+         Euler,
+         UpwindEuler,
+         FourthOrder
+    };
 
-                                  /**
-                                   * Set step size of the difference
-                                   * formula. This is set to the
-                                   * default in the constructor.
-                                   */
-  void set_h (double h_new = 1.e-6);
-  
-                                  /**
-                                   * Choose the difference formula.
-                                   * This is set to the default in
-                                   * the constructor.
-                                   *
-                                   * Formulas implemented right now
-                                   * are first order backward Euler
-                                   * (@p{UpwindEuler}), second order
-                                   * symmetric Euler (@p{Euler}) and
-                                   * a symmetric fourth order formula
-                                   * (@p{FourthOrder}).
-                                   */
-  void set_formula (DifferenceFormula formula = Euler);
-  
-                                  /**
-                                   * Function value at one point.
-                                   */
-  virtual double value (const Point<dim>   &p,
-                       const unsigned int  component = 0) const;
-  
-                                  /**
-                                   * Function values at multiple points.
-                                   */
-  virtual void value_list (const vector<Point<dim> > &points,
-                          vector<double>            &values,
-                          const unsigned int         component = 0) const;
 
+                                    /**
+                                     * Constructor. Provided are the
+                                     * function to compute derivatives
+                                     * of and the direction vector of
+                                     * the differentiation.
+                                     */
+    FunctionDerivative (const Function<dim>& f,
+                       const Point<dim>& direction);
+    
+                                    /**
+                                     * Set step size of the difference
+                                     * formula. This is set to the
+                                     * default in the constructor.
+                                     */
+    void set_h (double h_new = 1.e-6);
+    
+                                    /**
+                                     * Choose the difference formula.
+                                     * This is set to the default in
+                                     * the constructor.
+                                     *
+                                     * Formulas implemented right now
+                                     * are first order backward Euler
+                                     * (@p{UpwindEuler}), second order
+                                     * symmetric Euler (@p{Euler}) and
+                                     * a symmetric fourth order formula
+                                     * (@p{FourthOrder}).
+                                     */
+    void set_formula (DifferenceFormula formula = Euler);
+    
+                                    /**
+                                     * Function value at one point.
+                                     */
+    virtual double value (const Point<dim>   &p,
+                         const unsigned int  component = 0) const;
+    
+                                    /**
+                                     * Function values at multiple points.
+                                     */
+    virtual void value_list (const vector<Point<dim> > &points,
+                            vector<double>            &values,
+                            const unsigned int         component = 0) const;    
 
-  DeclException0(ExcInvalidFormula);
-  
-private:
-                                  /**
-                                   * Function for differentiation.
-                                   */
-  const Function<dim>& f;
-                                  /**
-                                   * Differentiation vector.
-                                   */
-  Point<dim> direction;
-  
-                                  /**
-                                   * Step size of the difference formula.
-                                   */
-  double h;
-                                  /**
-                                   * Difference formula.
-                                   */
-  DifferenceFormula formula;
-                                  /**
-                                   * Helper object. Contains the
-                                   * increment vector for the
-                                   * formula.
-                                   */
-  Point<dim> incr;
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object. Since sometimes
+                                     * the size of objects can
+                                     * not be determined exactly
+                                     * (for example: what is the
+                                     * memory consumption of an
+                                     * STL @p{map} type with a
+                                     * certain number of
+                                     * elements?), this is only
+                                     * an estimate. however often
+                                     * quite close to the true
+                                     * value.
+                                     */
+    unsigned int memory_consumption () const;
+    
+    DeclException0(ExcInvalidFormula);
+    
+  private:
+                                    /**
+                                     * Function for differentiation.
+                                     */
+    const Function<dim>& f;
+                                    /**
+                                     * Differentiation vector.
+                                     */
+    Point<dim> direction;
+    
+                                    /**
+                                     * Step size of the difference formula.
+                                     */
+    double h;
+                                    /**
+                                     * Difference formula.
+                                     */
+    DifferenceFormula formula;
+                                    /**
+                                     * Helper object. Contains the
+                                     * increment vector for the
+                                     * formula.
+                                     */
+    Point<dim> incr;
 };
 
 #endif
index 299a9beb8c88cdfa3ccd0cc22fcf82a847da8d42..19f43e7ab0c5784ef338e32a484b5bdd577450df 100644 (file)
@@ -406,11 +406,30 @@ class JumpFunction : public Function<dim>
                                 vector<double>            &values,
                                 const unsigned int         component = 0) const;
 
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object. Since sometimes
+                                     * the size of objects can
+                                     * not be determined exactly
+                                     * (for example: what is the
+                                     * memory consumption of an
+                                     * STL @p{map} type with a
+                                     * certain number of
+                                     * elements?), this is only
+                                     * an estimate. however often
+                                     * quite close to the true
+                                     * value.
+                                     */
+    unsigned int memory_consumption () const;
+
   protected:
                                     /**
                                      * Advection vector.
                                      */
     const Point<dim> direction;
+
                                     /**
                                      * Steepness (maximal derivative)
                                      * of the slope.
index 370d3df0a711515f443445a1af0b6fc395a36db3..b73a7ed0d1ad30d79610830360d5e3bfffbcb03d 100644 (file)
  *
  * The usual usage of this class is through the pregenerated object
  * @p{deallog}. Typical steps are
- * <OL>
- * <LI> @p{deallog.attach(ostream)}: write logging information into a file.
- * <LI> @p{deallog.depth_console(n)}: restrict output on screen to outer loops.
- * <LI> Before entering a new phase of your program, e.g. a new loop,
- * @p{deallog.push("loopname")}.
- * <LI> @p{deallog << anything << endl;} to write logging information
- * (Usage of @p{endl} is mandatory!).
- * <LI> @p{deallog.pop()} when leaving that stage entered with @p{push}.
- * </OL>
+ * @begin{itemize}
+ * @item @p{deallog.attach(ostream)}: write logging information into a file.
+ * @item @p{deallog.depth_console(n)}: restrict output on screen to outer loops.
+ * @item Before entering a new phase of your program, e.g. a new loop,
+ *       @p{deallog.push("loopname")}.
+ * @item @p{deallog << anything << endl;} to write logging information
+ *       (Usage of @p{endl} is mandatory!).
+ * @item @p{deallog.pop()} when leaving that stage entered with @p{push}.
+ * @end{itemize}
  *
  * @author Guido Kanschat, Wolfgang Bangerth, 1999
  */
@@ -213,10 +213,24 @@ class LogStream
                                      */
     LogStream & operator << (void (f)(LogStream &));
 
+
                                     /**
-                                     * Declare this function as a friend.
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object. Since sometimes
+                                     * the size of objects can
+                                     * not be determined exactly
+                                     * (for example: what is the
+                                     * memory consumption of an
+                                     * STL @p{map} type with a
+                                     * certain number of
+                                     * elements?), this is only
+                                     * an estimate. however often
+                                     * quite close to the true
+                                     * value.
                                      */
-    friend void endl (LogStream &);
+    unsigned int memory_consumption () const;
 
                                     /**
                                      * Exception
@@ -230,6 +244,11 @@ class LogStream
                                      * the contents of the prefix stack.
                                      */
     void print_line_head();
+
+                                    /**
+                                     * Declare this function as a friend.
+                                     */
+    friend void endl (LogStream &);
 };
 
 
diff --git a/deal.II/base/include/base/memory_consumption.h b/deal.II/base/include/base/memory_consumption.h
new file mode 100644 (file)
index 0000000..2eb08c9
--- /dev/null
@@ -0,0 +1,423 @@
+//----------------------------  memory_consumption.h  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  memory_consumption.h  ---------------------------
+#ifndef __deal2__memory_consumption_h
+#define __deal2__memory_consumption_h
+
+
+#include <string>
+#include <vector>
+#include <utility>
+
+
+
+/**
+ * Basic types, vectors of basic types, strings, vectors of composed types 
+ *
+ * @author Wolfgang Bangerth, 2000
+ */
+namespace MemoryConsumption
+{
+                                  /**
+                                   * Determine the amount of memory
+                                   * in bytes consumed by a @p{bool}
+                                   * variable.
+                                   */
+    inline
+    unsigned int memory_consumption (const bool) 
+    {
+      return sizeof(bool);
+    };
+
+                                  /**
+                                   * Determine the amount of memory
+                                   * in bytes consumed by a @p{char}
+                                   * variable.
+                                   */
+    inline
+    unsigned int memory_consumption (const char)
+    {
+      return sizeof(char);
+    };
+
+                                  /**
+                                   * Determine the amount of memory
+                                   * in bytes consumed by a
+                                   * @p{short int} variable.
+                                   */
+    inline
+    unsigned int memory_consumption (const short int) 
+    {
+      return sizeof(short int);
+    };
+  
+
+                                  /**
+                                   * Determine the amount of memory
+                                   * in bytes consumed by a
+                                   * @p{short unsigned int} variable.
+                                   */
+    inline
+    unsigned int memory_consumption (const short unsigned int) 
+    {
+      return sizeof(short unsigned int);
+    };
+
+
+
+                                  /**
+                                   * Determine the amount of memory
+                                   * in bytes consumed by a @p{int}
+                                   * variable.
+                                   */
+    inline
+    unsigned int memory_consumption (const int) 
+    {
+      return sizeof(int);
+    };
+  
+
+                                  /**
+                                   * Determine the amount of memory
+                                   * in bytes consumed by a @p{unsigned int}
+                                   * variable.
+                                   */
+    inline
+    unsigned int memory_consumption (const unsigned int) 
+    {
+      return sizeof(unsigned int);
+    };
+
+
+                                  /**
+                                   * Determine the amount of memory
+                                   * in bytes consumed by a @p{float}
+                                   * variable.
+                                   */
+    inline
+    unsigned int memory_consumption (const float)
+    {
+      return sizeof(float);
+    };
+
+
+
+                                  /**
+                                   * Determine the amount of memory
+                                   * in bytes consumed by a @p{double}
+                                   * variable.
+                                   */
+    inline
+    unsigned int memory_consumption (const double)
+    {
+      return sizeof(double);
+    };
+
+                                  /**
+                                   * Determine an estimate of the
+                                   * amount of memory in bytes
+                                   * consumed by a @p{string}
+                                   * variable.
+                                   */
+    unsigned int memory_consumption (const string &s);
+
+                                  /**
+                                   * Determine an estimate of the
+                                   * amount of memory in bytes
+                                   * consumed by a @p{vector} of
+                                   * certain elements. It does so by
+                                   * looping over all elements of the
+                                   * vector and determining their
+                                   * sizes using the
+                                   * @p{memory_consumption}
+                                   * functions. If the elements are
+                                   * of constant size, there might be
+                                   * another global function
+                                   * @p{memory_consumption} for this
+                                   * data type or if there is a
+                                   * member function of that class of
+                                   * that names that returns a
+                                   * constant value and the compiler
+                                   * will unroll this loop so that
+                                   * the operation is fast. If the
+                                   * size of the data elements is
+                                   * variable, for example if they do
+                                   * memory allocation themselves,
+                                   * then the operation will
+                                   * necessarily be more expensive.
+                                   *
+                                   * Using the algorithm, in
+                                   * particular the loop over all
+                                   * elements, it is possible to also
+                                   * compute the memory consumption
+                                   * of vectors of vectors, vectors
+                                   * of strings, etc, where the
+                                   * individual elements may have
+                                   * vastly different sizes.
+                                   *
+                                   * Note that this algorithm also
+                                   * takes into account the size of
+                                   * elements that are allocated by
+                                   * this vector but not currently
+                                   * used.
+                                   *
+                                   * For the most commonly used
+                                   * vectors, there are special
+                                   * functions that compute the size
+                                   * without a loop. This also
+                                   * applies for the special case of
+                                   * vectors of bools.
+                                   */
+    template <typename T>
+      unsigned int memory_consumption (const vector<T> &v)
+      {
+       unsigned int mem = sizeof(vector<T>);
+       const unsigned int n = v.size();
+       for (unsigned int i=0; i<n; ++i)
+         mem += memory_consumption(v[i]);
+       mem += (v.capacity() - n)*sizeof(T);
+       return mem;
+      };
+
+
+
+                                    /**
+                                     * Estimate the amount of memory
+                                     * (in bytes) occupied by a
+                                     * C-style array. Since in this
+                                     * library we do not usually
+                                     * store simple data elements
+                                     * like @p{double}s in such
+                                     * arrays (but rather use STL
+                                     * @p{vector}s or deal.II
+                                     * @p{Vector} objects), we do not
+                                     * provide specializations like
+                                     * for the @p{vector} arrays, but
+                                     * always use the loop over all
+                                     * elements.
+                                     */
+    template <typename T, int N>
+      unsigned int memory_consumption (const T (&v)[N])
+      {
+       unsigned int mem = 0;
+       for (unsigned int i=0; i<N; ++i)
+         mem += memory_consumption(v[i]);
+       return mem;
+      };
+
+
+                                    /**
+                                     * Specialization of the
+                                     * determination of the memory
+                                     * consumption of a vector, here
+                                     * for a vector of @p{bool}s.
+                                     *
+                                     * This is a special case, as the
+                                     * bools are not stored
+                                     * one-by-one, but as a bit
+                                     * field.
+                                     */
+    inline
+      unsigned int memory_consumption (const vector<bool> &v)
+      {
+       return v.capacity() / 8 + sizeof(v);
+      };
+
+    
+                                    /**
+                                     * Specialization of the
+                                     * determination of the memory
+                                     * consumption of a vector, here
+                                     * for a vector of @p{int}s.
+                                     */
+    inline
+      unsigned int memory_consumption (const vector<int> &v)
+      {
+       return (v.capacity() * sizeof(int) +
+               sizeof(v));
+      };
+    
+    
+                                    /**
+                                     * Specialization of the
+                                     * determination of the memory
+                                     * consumption of a vector, here
+                                     * for a vector of @p{double}s.
+                                     */
+    inline
+      unsigned int memory_consumption (const vector<double> &v)
+      {
+       return (v.capacity() * sizeof(double) +
+               sizeof(v));
+      };
+    
+    
+                                    /**
+                                     * Specialization of the
+                                     * determination of the memory
+                                     * consumption of a vector, here
+                                     * for a vector of @p{float}s.
+                                     */
+    inline
+      unsigned int memory_consumption (const vector<float> &v)
+      {
+       return (v.capacity() * sizeof(float) +
+               sizeof(v));
+      };
+    
+    
+                                    /**
+                                     * Specialization of the
+                                     * determination of the memory
+                                     * consumption of a vector, here
+                                     * for a vector of @p{char}s.
+                                     */
+    inline
+      unsigned int memory_consumption (const vector<char> &v)
+      {
+       return (v.capacity() * sizeof(char) +
+               sizeof(v));
+      };
+    
+
+    
+                                    /**
+                                     * Specialization of the
+                                     * determination of the memory
+                                     * consumption of a vector, here
+                                     * for a vector of @p{unsigned char}s.
+                                     */
+    inline
+      unsigned int memory_consumption (const vector<unsigned char> &v)
+      {
+       return (v.capacity() * sizeof(unsigned char) +
+               sizeof(v));
+      };
+
+
+
+    
+                                    /**
+                                     * Specialization of the
+                                     * determination of the memory
+                                     * consumption of a vector, here
+                                     * for a vector of pointers.
+                                     */
+    template <typename T>
+    inline
+      unsigned int memory_consumption (const vector<T *> &v)
+      {
+       return (v.capacity() * sizeof(T *) +
+               sizeof(v));
+      };
+    
+
+                                    /**
+                                     * Determine an estimate of the
+                                     * amount of memory in bytes
+                                     * consumed by a pair of values.
+                                     */
+    template <typename A, typename B>
+      inline
+      unsigned int memory_consumption (const pair<A,B> &p)
+      {
+       return (memory_consumption(p.first) +
+               memory_consumption(p.second));
+      };
+    
+                                    /**
+                                     * Return the amount of memory
+                                     * used by a pointer. Make sure
+                                     * that you are really interested
+                                     * in this, and not the amount of
+                                     * memory required by the object
+                                     * pointed to.
+                                     */
+    template <typename T>
+      inline
+      unsigned int
+      memory_consumption (const T * const)
+      {
+       return sizeof(T*);
+      };
+
+
+
+                                    /**
+                                     * Return the amount of memory
+                                     * used by a pointer. Make sure
+                                     * that you are really interested
+                                     * in this, and not the amount of
+                                     * memory required by the object
+                                     * pointed to.
+                                     *
+                                     * This function is the same as
+                                     * above, but for non-const
+                                     * pointers
+                                     */
+    template <typename T>
+      inline
+      unsigned int
+      memory_consumption (T * const)
+      {
+       return sizeof(T*);
+      };
+
+
+
+                                    /**
+                                     * Return the amount of memory
+                                     * used by a void pointer. Make
+                                     * sure that you are really
+                                     * interested in this, and not
+                                     * the amount of memory required
+                                     * by the object pointed to.
+                                     *
+                                     * Note that we needed this
+                                     * function since @p{void} is no
+                                     * type and a @p{void*} is thus
+                                     * not caught by the general
+                                     * @p{T*} template function
+                                     * above.
+                                     */
+    inline
+      unsigned int
+      memory_consumption (void * const)
+      {
+       return sizeof(void*);
+      };
+    
+    
+                                    /**
+                                     * For all other types which are
+                                     * not explicitely listed: try if
+                                     * there is a member function
+                                     * called
+                                     * @p{memory_consumption}. If
+                                     * this is not the case, then the
+                                     * compiler will in any case
+                                     * complain that this last exit
+                                     * does not work.
+                                     */
+    template <typename T>
+      inline
+      unsigned int
+      memory_consumption (const T &t)
+      {
+       return t.memory_consumption();
+      };
+}
+
+
+
+#endif
+
index c9f5a54d066614c969c2b749f99ec332d5ba5fd3..e2f277d5ef4d022938f7a3651edd58773dff99ac 100644 (file)
@@ -65,6 +65,24 @@ class MultithreadInfo
                                      */
     unsigned int n_default_threads;
 
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object. Since sometimes
+                                     * the size of objects can
+                                     * not be determined exactly
+                                     * (for example: what is the
+                                     * memory consumption of an
+                                     * STL @p{map} type with a
+                                     * certain number of
+                                     * elements?), this is only
+                                     * an estimate. however often
+                                     * quite close to the true
+                                     * value.
+                                     */
+    static unsigned int memory_consumption ();
+
                                     /**
                                      * Exception
                                      */
index a17c5291fd0404b684fcd8376ff1fa5ba4dd6af9..c58c12948c0caf245db1044db60e23c1eb7da407 100644 (file)
@@ -86,6 +86,45 @@ namespace Patterns
                                          * this function.
                                          */
        virtual PatternBase * clone () const = 0;
+
+                                        /**
+                                         * Determine an estimate for
+                                         * the memory consumption (in
+                                         * bytes) of this object. To
+                                         * avoid unnecessary
+                                         * overhead, we do not force
+                                         * derivd classes to provide
+                                         * this function as a virtual
+                                         * overloaded one, but rather
+                                         * try to cast the present
+                                         * object to one of the known
+                                         * derived classes and if
+                                         * that fails then take the
+                                         * size of this base class
+                                         * instead and add 32 byte
+                                         * (this value is arbitrary,
+                                         * it should account for
+                                         * virtual function tables,
+                                         * and some possible data
+                                         * elements). Since there are
+                                         * usually not many thousands
+                                         * of objects of this type
+                                         * around, and since the
+                                         * @p{memory_consumption}
+                                         * mechanism is used to find
+                                         * out where memory in the
+                                         * range of many megabytes
+                                         * is, this seems like a
+                                         * reasonable approximation.
+                                         *
+                                         * On the other hand, if you
+                                         * know that your class
+                                         * deviates from this
+                                         * assumption significantly,
+                                         * you can still overload
+                                         * this function.
+                                         */
+       virtual unsigned int memory_consumption () const;
     };
     
                                     /**
@@ -361,6 +400,13 @@ namespace Patterns
                                          */
        virtual PatternBase * clone () const;
 
+                                        /**
+                                         * Determine an estimate for
+                                         * the memory consumption (in
+                                         * bytes) of this object.
+                                         */
+       unsigned int memory_consumption () const;
+
       private:
                                         /**
                                          * List of valid strings as
@@ -434,6 +480,13 @@ namespace Patterns
                                          */
        virtual PatternBase * clone () const;
 
+                                        /**
+                                         * Determine an estimate for
+                                         * the memory consumption (in
+                                         * bytes) of this object.
+                                         */
+       unsigned int memory_consumption () const;
+
                                         /**
                                          * Exception.
                                          */
@@ -1007,7 +1060,7 @@ class ParameterHandler
                                      * Return status of this object:
                                      * @p{true}=clean or @p{false}=error occured.
                                      */
-    bool ok() const;
+    bool ok () const;
 
                                     /**
                                      * clear status bit and contents.
@@ -1107,14 +1160,22 @@ class ParameterHandler
                                    */
     void log_parameters (LogStream& out);
 
-                                  /**
-                                   * Log parameters in
-                                   * subsection. The subsection is
-                                   * determined by the
-                                   * @p{subsection_path} member *
-                                   * variable.
-                                   */
-  void log_parameters_section (LogStream& out);
+                                    /**
+                                     * Log parameters in
+                                     * subsection. The subsection is
+                                     * determined by the
+                                     * @p{subsection_path} member *
+                                     * variable.
+                                     */
+    void log_parameters_section (LogStream& out);    
+
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object.
+                                     */
+    unsigned int memory_consumption () const;
 
                                     /**
                                      * Exception
@@ -1158,55 +1219,85 @@ class ParameterHandler
                                      * entry content and regexp, and
                                      * list of subsections.
                                      */
-    struct Section {
+    struct Section 
+    {
        ~Section ();
 
        typedef map<string, pair<string,Patterns::PatternBase*> > EntryType;
        
        EntryType             entries;
        map<string, Section*> subsections;
+
+                                        /**
+                                         * Determine an estimate for
+                                         * the memory consumption (in
+                                         * bytes) of this
+                                         * object. Since sometimes
+                                         * the size of objects can
+                                         * not be determined exactly
+                                         * (for example: what is the
+                                         * memory consumption of an
+                                         * STL @p{map} type with a
+                                         * certain number of
+                                         * elements?), this is only
+                                         * an estimate. however often
+                                         * quite close to the true
+                                         * value.
+                                         */
+       unsigned int memory_consumption () const;
     };
 
                                     /**
-                                     * Path of presently selected subsections;
-                                     * empty list means top level
+                                     * Path of presently selected
+                                     * subsections; empty list means
+                                     * top level
                                      */
     vector<string> subsection_path;
 
                                     /**
-                                     * List of default values organized as a
-                                     * tree of subsections
+                                     * List of default values
+                                     * organized as a tree of
+                                     * subsections
                                      */
     Section defaults;
     
                                     /**
-                                     * Analogue list of changed entries. The
-                                     * tree of subsections is there even if there
-                                     * are no changed entry values in a
-                                     * subsection; therefore @p{enter_subsection}
-                                     * has to create the tree in both @p{Defaults}
-                                     * and @p{changed_entries}.
+                                     * Analogue list of changed
+                                     * entries. The tree of
+                                     * subsections is there even if
+                                     * there are no changed entry
+                                     * values in a subsection;
+                                     * therefore @p{enter_subsection}
+                                     * has to create the tree in both
+                                     * @p{Defaults} and
+                                     * @p{changed_entries}.
                                      */
     Section changed_entries;
 
                                     /**
                                      * Scan one line of input.
-                                     * @p{lineno} is the number of the line presently
-                                     * scanned (for the logs if there are messages).
-                                     * @return @p{false} if line contained stuff
-                                     * that could not be understood, the uppermost
-                                     * subsection was to be left by an @p{END} or
-                                     * @p{end} statement, a value for a non-declared
-                                     * entry was given or teh entry value did not
-                                     * match the regular expression. @p{true}
-                                     * otherwise
+                                     * @p{lineno} is the number of
+                                     * the line presently scanned
+                                     * (for the logs if there are
+                                     * messages).  @return @p{false}
+                                     * if line contained stuff that
+                                     * could not be understood, the
+                                     * uppermost subsection was to be
+                                     * left by an @p{END} or @p{end}
+                                     * statement, a value for a
+                                     * non-declared entry was given
+                                     * or teh entry value did not
+                                     * match the regular
+                                     * expression. @p{true} otherwise
                                      */
     bool scan_line (string line, const unsigned int lineno);
 
                                     /**
-                                     * Get a pointer to the @p{Section} structure
-                                     * in the @p{Defaults} tree
-                                     * for the subsection we are presently in.
+                                     * Get a pointer to the
+                                     * @p{Section} structure in the
+                                     * @p{Defaults} tree for the
+                                     * subsection we are presently
+                                     * in.
                                      */
     Section*       get_present_defaults_subsection ();
     
@@ -1231,6 +1322,7 @@ class ParameterHandler
 };
 
 
+
 /**
  *   The class @p{MultipleParameterLoop} offers an easy possibility to test several
  *   parameter sets during one run of the program. For this it uses the
@@ -1455,7 +1547,8 @@ class MultipleParameterLoop : public ParameterHandler
                                      * This is the class the helper class or the
                                      * problem class has to be derived of.
                                      */
-    class UserClass {
+    class UserClass 
+    {
       public:
                                         /**
                                          * @p{create_new} must provide a clean
@@ -1515,13 +1608,24 @@ class MultipleParameterLoop : public ParameterHandler
                                      */
     void loop (UserClass &uc);
 
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object.
+                                     */
+    unsigned int memory_consumption () const;
+
   private:
                                     /**
-                                     * Declare what a multiple entry is: a variant
-                                     * entry (in curly braces @p{{}}) or an
-                                     * array (in double curly braces @p{{{}}}).
+                                     * Declare what a multiple entry
+                                     * is: a variant * entry (in
+                                     * curly braces @p{{}}) or an
+                                     * array (in double curly braces
+                                     * @p{{{}}}).
                                      */
-    enum MultipleEntryType {
+    enum MultipleEntryType 
+    {
          variant, array
     };
 
@@ -1529,7 +1633,8 @@ class MultipleParameterLoop : public ParameterHandler
                                      * An object in the list of entries with
                                      * multiple values.
                                      */
-    class Entry {
+    class Entry 
+    {
       public:
                                         /**
                                          * Constructor
@@ -1577,6 +1682,14 @@ class MultipleParameterLoop : public ParameterHandler
                                          * entry or an array.
                                          */
        MultipleEntryType      type;
+
+                                        /**
+                                         * Determine an estimate for
+                                         * the memory consumption (in
+                                         * bytes) of this
+                                         * object.
+                                         */
+       unsigned int memory_consumption () const;
     };
 
                                     /**
index ddfd70c2a284d6e6e1c07c5e5c8377a9e3e8e90f..b786abf8c1c876dd6b9f594932090d58a15586be 100644 (file)
@@ -125,6 +125,14 @@ class Quadrature : public Subscriptor
                                      */
     const vector<double> & get_weights () const;
 
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object.
+                                     */
+    unsigned int memory_consumption () const;
+
   protected:
                                     /**
                                      * List of quadrature points. To be filled
index 7a810d08c060e7a7ddfb2871367f641a63860af9..a87be47f2358cdb38acf9f9d4e4c0cc332cf2173 100644 (file)
@@ -154,6 +154,17 @@ class SmartPointer
                                      * variable which we are given.
                                      */
     void swap (T *&tt);
+
+                                    /**
+                                     * Return an estimate of the
+                                     * amount of memory (in bytes)
+                                     * used by this class. Note in
+                                     * particular, that this only
+                                     * includes the amount of memory
+                                     * used by @it{this} object, not
+                                     * by the object pointed to.
+                                     */
+    unsigned int memory_consumption () const;
     
   private:
                                     /**
@@ -295,6 +306,16 @@ void SmartPointer<T>::swap (T *&tt)
 
 
 
+template <typename T>
+inline
+unsigned int SmartPointer<T>::memory_consumption () const
+{
+  return sizeof(SmartPointer<T>);
+};
+
+
+
+
 /**
  * Global function to swap the contents of two smart pointers. As both
  * objects to which the pointers point retain to be subscribed to, we
index 98e6576fb72d90032b646485598c49ba6063a99f..750bfc1b0ae797805dbf124cd7ad9f203f8b80a3 100644 (file)
@@ -162,6 +162,14 @@ class Tensor
                                      */
     void clear ();
 
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object.
+                                     */
+    static unsigned int memory_consumption ();
+
 //                                  /**
 //                                   * Exception
 //                                   */
@@ -196,9 +204,7 @@ class Tensor
 
 
 /*--------------------------- Inline functions -----------------------------*/
-// in the following, declarations of operators look rather weird because they are
-// split over several lines. this is necessary, however, because otherwise doc++
-// gets really confused about this all... :-(
+
 
 
 template <int rank_, int dim>
@@ -368,6 +374,16 @@ void Tensor<rank_,dim>::clear ()
 };
 
 
+
+template <int rank_, int dim>
+inline
+unsigned int
+Tensor<rank_,dim>::memory_consumption ()
+{
+  return sizeof(Tensor<rank_,dim>);
+};
+
+
 /* ----------------- Non-member functions operating on tensors. ------------ */
 
 
index 123f16d6a295b8222050c8ed2c9860e0168782d5..8eb3d210c8829f8e3186e462e1577702aa26aba8 100644 (file)
@@ -213,6 +213,14 @@ class Tensor<1,dim>
                                      */
     void unroll (Vector<double> &result) const;
 
+                                    /**
+                                     * Determine an estimate for
+                                     * the memory consumption (in
+                                     * bytes) of this
+                                     * object.
+                                     */
+    static unsigned int memory_consumption ();
+
   protected:
                                     /**
                                      * Help function for unroll.
@@ -452,6 +460,16 @@ void Tensor<1,dim>::clear ()
 
 
 
+template <int dim>
+inline
+unsigned int
+Tensor<1,dim>::memory_consumption ()
+{
+  return sizeof(Tensor<1,dim>);
+};
+
+
+
 /**
  * Output operator for tensors of rank 1. Print the elements
  * consecutively, with a space in between.
index 2fcad5f315cf89d170434d57bb96c220bb46b796..d6dc2f4d65aab6b21cbfead8018d6463cafa1759 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <base/data_out_base.h>
 #include <base/parameter_handler.h>
+#include <base/memory_consumption.h>
 
 
 DataOutBase::UcdFlags::UcdFlags (const bool write_preamble) :
@@ -45,6 +46,15 @@ void DataOutBase::UcdFlags::parse_parameters (ParameterHandler &prm)
 };
 
 
+unsigned int
+DataOutBase::UcdFlags::memory_consumption () const
+{
+                                  // only simple data elements, so
+                                  // use sizeof operator
+  return sizeof (*this);
+};
+
+
 
 void DataOutBase::GnuplotFlags::declare_parameters (ParameterHandler &/*prm*/)
 {};
@@ -56,6 +66,17 @@ void DataOutBase::GnuplotFlags::parse_parameters (ParameterHandler &/*prm*/)
 
 
 
+unsigned int
+DataOutBase::GnuplotFlags::memory_consumption () const
+{
+                                  // only simple data elements, so
+                                  // use sizeof operator
+  return sizeof (*this);
+};
+
+
+
+
 void DataOutBase::PovrayFlags::declare_parameters (ParameterHandler &prm)
 {
   prm.declare_entry ("Use smooth triangles", "false",
@@ -77,6 +98,16 @@ void DataOutBase::PovrayFlags::parse_parameters (ParameterHandler &prm)
 
 
 
+unsigned int
+DataOutBase::PovrayFlags::memory_consumption () const
+{
+                                  // only simple data elements, so
+                                  // use sizeof operator
+  return sizeof (*this);
+};
+
+
+
 DataOutBase::EpsFlags::EpsFlags (const unsigned int  height_vector,
                                 const unsigned int  color_vector,
                                 const SizeType      size_type,
@@ -267,6 +298,16 @@ void DataOutBase::EpsFlags::parse_parameters (ParameterHandler &prm)
 
 
 
+unsigned int
+DataOutBase::EpsFlags::memory_consumption () const
+{
+                                  // only simple data elements, so
+                                  // use sizeof operator
+  return sizeof (*this);
+};
+
+
+
 void DataOutBase::GmvFlags::declare_parameters (ParameterHandler &/*prm*/)
 {};
 
@@ -274,3 +315,21 @@ void DataOutBase::GmvFlags::declare_parameters (ParameterHandler &/*prm*/)
 
 void DataOutBase::GmvFlags::parse_parameters (ParameterHandler &/*prm*/)
 {};
+
+
+unsigned int
+DataOutBase::GmvFlags::memory_consumption () const
+{
+                                  // only simple data elements, so
+                                  // use sizeof operator
+  return sizeof (*this);
+};
+
+
+
+unsigned int DataOutBase::memory_consumption ()
+{
+  return 0;
+};
+
+
index 32238b275de595794b857a691360fa76979892b9..ea55db556b752ff1dfdcfd5ce22aec170c8db8a3 100644 (file)
@@ -15,6 +15,7 @@
 #include <base/data_out_base.h>
 #include <base/parameter_handler.h>
 #include <base/thread_management.h>
+#include <base/memory_consumption.h>
 
 #include <iomanip>
 #include <ctime>
@@ -34,6 +35,20 @@ DataOutBase::Patch<dim,spacedim>::Patch () :
 
 
 
+template <int dim, int spacedim>
+unsigned int
+DataOutBase::Patch<dim,spacedim>::memory_consumption () const
+{
+  return (sizeof(vertices) / sizeof(vertices[0]) * 
+         MemoryConsumption::memory_consumption(vertices[0])
+         +
+         MemoryConsumption::memory_consumption(n_subdivisions)
+         +
+         MemoryConsumption::memory_consumption(data));
+};
+
+
+
 template <int dim, int spacedim>
 void DataOutBase::write_ucd (const vector<Patch<dim,spacedim> > &patches,
                             const vector<string>               &data_names,
@@ -1774,7 +1789,6 @@ DataOutBase::write_gmv_reorder_data_vectors (const vector<Patch<dim,spacedim> >
 
 
 
-
 /* --------------------------- class DataOutInterface ---------------------- */
 
 
@@ -2031,6 +2045,21 @@ void DataOutInterface<dim,spacedim>::parse_parameters (ParameterHandler &prm)
 }
 
 
+template <int dim, int spacedim>
+unsigned int 
+DataOutInterface<dim,spacedim>::memory_consumption () const
+{
+  return (sizeof (default_fmt) +
+         MemoryConsumption::memory_consumption (ucd_flags) +
+         MemoryConsumption::memory_consumption (gnuplot_flags) +
+         MemoryConsumption::memory_consumption (povray_flags) +
+         MemoryConsumption::memory_consumption (eps_flags) +
+         MemoryConsumption::memory_consumption (gmv_flags));
+};
+
+
+
+
 // explicit instantiations. functions in DataOutBase are instantiated by
 // the respective functions in DataOut_Interface
 template class DataOutInterface<data_out_dimension,data_out_dimension>;
index aa19b5436eb1ee528f926490936640d6b504d591..3444ced4ebf0c115023c8736855e3d8ff97a6858 100644 (file)
@@ -175,6 +175,18 @@ void Function<dim>::vector_laplacian_list (const vector<Point<dim> > &points,
     this->vector_laplacian (points[i], laplacians[i]);
 }
 
+
+
+template <int dim>
+unsigned int
+Function<dim>::memory_consumption () const
+{
+                                  // only simple data elements, so
+                                  // use sizeof operator
+  return sizeof (*this);
+};
+
+
 //------------------------------------------------------------//
 
 template <int dim>
@@ -341,6 +353,17 @@ void ConstantFunction<dim>::vector_value_list (const vector<Point<dim> > &points
     };
 };
 
+
+
+template <int dim>
+unsigned int
+ConstantFunction<dim>::memory_consumption () const
+{
+                                  // only simple data elements, so
+                                  // use sizeof operator
+  return sizeof (*this);
+};
+
 //------------------------------------------------------------//
 
 template <int dim>
@@ -383,6 +406,17 @@ void ComponentSelectFunction<dim>::vector_value_list (const vector<Point<dim> >
 }
 
 
+
+template <int dim>
+unsigned int
+ComponentSelectFunction<dim>::memory_consumption () const
+{
+                                  // only simple data elements, so
+                                  // use sizeof operator
+  return sizeof (*this);
+};
+
+
 // explicit instantiations
 
 template class Function<1>;
index e6d8ed09784a5bb0c78ab2f0bdd7531fd3e56af6..f1abe317c3b54f48621e158482dffe8e8527a33a 100644 (file)
 template <int dim>
 FunctionDerivative<dim>::FunctionDerivative (const Function<dim>& f,
                                             const Point<dim>& dir)
-  :
-  Function<dim> (f.n_components, f.get_time()),
-  f(f),
-  direction(dir)
+               :
+               Function<dim> (f.n_components, f.get_time()),
+               f(f),
+               direction(dir)
 {
   set_h();
   set_formula();
@@ -57,15 +57,15 @@ FunctionDerivative<dim>::value (const Point<dim>   &p,
 {
   switch (formula)
     {
-    case Euler:
-      return (f.value(p+incr, component)-f.value(p-incr, component))/(2*h);
-    case UpwindEuler:
-      return (f.value(p, component)-f.value(p-incr, component))/h;
-    case FourthOrder:
-      return (-f.value(p+2*incr, component) + 8*f.value(p+incr, component)
-             -8*f.value(p-incr, component) + f.value(p-2*incr, component))/(12*h);
-    default:
-      Assert(false, ExcInvalidFormula());
+      case Euler:
+           return (f.value(p+incr, component)-f.value(p-incr, component))/(2*h);
+      case UpwindEuler:
+           return (f.value(p, component)-f.value(p-incr, component))/h;
+      case FourthOrder:
+           return (-f.value(p+2*incr, component) + 8*f.value(p+incr, component)
+                   -8*f.value(p-incr, component) + f.value(p-2*incr, component))/(12*h);
+      default:
+           Assert(false, ExcInvalidFormula());
     }
   return 0.;
 }
@@ -147,6 +147,17 @@ FunctionDerivative<dim>::value_list (const vector<Point<dim> > &points,
 }
 
 
+
+template <int dim>
+unsigned int
+FunctionDerivative<dim>::memory_consumption () const
+{
+                                  // only simple data elements, so
+                                  // use sizeof operator
+  return sizeof (*this);
+};
+
+
 template FunctionDerivative<1>;
 template FunctionDerivative<2>;
 template FunctionDerivative<3>;
index b27e0e391fb060c49d16b807e427eacdd6b2396c..66df13b3196d18bd60835e7be5050d009de929b1 100644 (file)
@@ -888,6 +888,17 @@ JumpFunction<dim>::gradient_list (const vector<Point<dim> > &p,
 }
 
 
+
+template <int dim>
+unsigned int
+JumpFunction<dim>::memory_consumption () const
+{
+                                  // only simple data elements, so
+                                  // use sizeof operator
+  return sizeof (*this);
+};
+
+
 template SquareFunction<1>;
 template SquareFunction<2>;
 template SquareFunction<3>;
index a799ae2b1ea03bbadacabfb675226b33e85df68a..88c4c2494b1c1be2a4faa0f6833746083893bfd1 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <base/logstream.h>
 #include <base/job_identifier.h>
+#include <base/memory_consumption.h>
 
 #include <sys/resource.h>
 #include <iomanip>
@@ -141,3 +142,21 @@ LogStream::operator << (void (f)(LogStream &))
 }
 
 
+
+unsigned int
+LogStream::memory_consumption () const
+{
+  unsigned int mem = sizeof(*this);
+                                  // to determine size of stack
+                                  // elements, we have to copy the
+                                  // stack since we can't access
+                                  // elements from further below
+  stack<string> tmp;
+  while (tmp.size() > 0)
+    {
+      mem += MemoryConsumption::memory_consumption (tmp.top());
+      tmp.pop ();
+    };
+  
+  return mem;
+};
diff --git a/deal.II/base/source/memory_consumption.cc b/deal.II/base/source/memory_consumption.cc
new file mode 100644 (file)
index 0000000..62a2177
--- /dev/null
@@ -0,0 +1,36 @@
+//----------------------------  function.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  function.cc  ---------------------------
+
+
+#include <base/memory_consumption.h>
+
+
+namespace MemoryConsumption 
+{
+  unsigned int memory_consumption (const string &s)
+  {
+    return sizeof(s) + s.length();
+  };
+
+
+   
+  unsigned int memory_consumption (const vector<string> &v)
+    {
+      unsigned int mem = sizeof(v);
+      for (unsigned int i=0; i<v.size(); ++i)
+       mem += memory_consumption(v[i]);
+      return mem;
+    };
+  
+
+};
index 7931d8014131b2d9a12279fb825887105e858593..4e5a3061c212a66ac616037d8573e3e4937d13be 100644 (file)
@@ -90,6 +90,15 @@ MultithreadInfo::MultithreadInfo () :
 
 
 
+unsigned int
+MultithreadInfo::memory_consumption ()
+{
+                                  // only simple data elements, so
+                                  // use sizeof operator
+  return sizeof (MultithreadInfo);
+};
+
+
 
 // definition of the variable which is declared `extern' in the .h file
 MultithreadInfo multithread_info;
index 9b49941a220ab99c2d60042243200858905ae217..d14c953178660e27ac77835539b6aa33379adf99 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <base/parameter_handler.h>
 #include <base/logstream.h>
+#include <base/memory_consumption.h>
 #include <fstream>
 #include <iomanip>
 #include <strstream>
@@ -30,6 +31,23 @@ namespace Patterns
   {};
 
 
+  unsigned int
+    PatternBase::memory_consumption () const
+    {
+      if (dynamic_cast<const Integer*>(this) != 0)
+       return sizeof(Integer);
+      else if (dynamic_cast<const Double*>(this) != 0)
+       return sizeof(Double);
+      else if (dynamic_cast<const Bool*>(this) != 0)
+       return sizeof(Bool);
+      else if (dynamic_cast<const Anything*>(this) != 0)
+       return sizeof(Anything);
+      else
+       return sizeof(*this) + 32;
+    };
+  
+
+
 
   Integer::Integer (const int lower_bound,
                    const int upper_bound) :
@@ -195,6 +213,13 @@ namespace Patterns
   };
 
 
+  unsigned int
+    Selection::memory_consumption () const
+    {
+      return (sizeof(PatternBase) +
+             MemoryConsumption::memory_consumption(sequence));
+    };
+  
 
   MultipleSelection::MultipleSelection (const string &seq)
   {
@@ -287,6 +312,14 @@ namespace Patterns
   };
 
 
+  unsigned int
+    MultipleSelection::memory_consumption () const
+    {
+      return (sizeof(PatternBase) +
+             MemoryConsumption::memory_consumption(sequence));
+    };
+
+
 
   Bool::Bool () :
                  Selection ("true|false")
@@ -767,7 +800,7 @@ void ParameterHandler::print_parameters_section (ostream           &out,
 
 
 
-void ParameterHandler::log_parameters_section (LogStream           &out)
+void ParameterHandler::log_parameters_section (LogStream &out)
 {
   Section *pd = get_present_defaults_subsection ();
   Section *pc = get_present_changed_subsection ();
@@ -1002,7 +1035,20 @@ const ParameterHandler::Section* ParameterHandler::get_present_changed_subsectio
 };
 
 
-ParameterHandler::Section::~Section () {
+
+unsigned int 
+ParameterHandler::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (status) +
+         MemoryConsumption::memory_consumption (subsection_path) +
+         MemoryConsumption::memory_consumption (defaults) +
+         MemoryConsumption::memory_consumption (changed_entries));
+};
+
+
+
+ParameterHandler::Section::~Section () 
+{
   entries.clear ();
 
   map<string, Section*>::iterator p;
@@ -1010,12 +1056,28 @@ ParameterHandler::Section::~Section () {
   for (p=subsections.begin(); p!=subsections.end(); ++p)
     delete p->second;
 
+  subsections.clear ();
+};
+
+
 
-subsections.clear ();
+unsigned int 
+ParameterHandler::Section::memory_consumption () const
+{
+  unsigned int mem = 0;
+  for (EntryType::const_iterator i=entries.begin(); i!=entries.end(); ++i)
+    mem += (MemoryConsumption::memory_consumption (i->first) +
+           MemoryConsumption::memory_consumption (i->second.first) +
+           MemoryConsumption::memory_consumption (*i->second.second));
+  for (map<string, Section*>::const_iterator i=subsections.begin(); i!=subsections.end(); ++i)
+    mem += (MemoryConsumption::memory_consumption (i->first) +
+           MemoryConsumption::memory_consumption (*(i->second)));
+  return mem;
 };
 
 
 
+
 MultipleParameterLoop::MultipleParameterLoop() :
                n_branches(0)
 {};
@@ -1224,6 +1286,19 @@ void MultipleParameterLoop::fill_entry_values (const unsigned int run_no)
 
 
 
+
+unsigned int 
+MultipleParameterLoop::memory_consumption () const
+{
+  unsigned int mem = ParameterHandler::memory_consumption ();
+  for (unsigned int i=0; i<multiple_choices.size(); ++i)
+    mem += multiple_choices[i].memory_consumption ();
+  
+  return mem;
+};
+
+
+
 MultipleParameterLoop::Entry::Entry (const vector<string> &ssp,
                                     const string& Name,
                                     const string& Value) :
@@ -1279,3 +1354,13 @@ void MultipleParameterLoop::Entry::split_different_values ()
 };
 
 
+unsigned int 
+MultipleParameterLoop::Entry::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (subsection_path) +
+         MemoryConsumption::memory_consumption (entry_name) +
+         MemoryConsumption::memory_consumption (entry_value) +
+         MemoryConsumption::memory_consumption (different_values) +
+         sizeof (type));
+};
+
index e95a9adedfe6e922978bf363594d25cbfe57dfe2..4009ab68ba9558f6045fbf499cf1bd45df3e3e66 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <grid/geometry_info.h>
 #include <base/quadrature.h>
+#include <base/memory_consumption.h>
 #include <cmath>
 
 
@@ -179,6 +180,16 @@ const vector<double> & Quadrature<0>::get_weights () const
 
 
 
+template <int dim>
+unsigned int
+Quadrature<dim>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (quadrature_points) +
+         MemoryConsumption::memory_consumption (weights));
+};
+
+
+
 template <>
 void QProjector<2>::project_to_face (const Quadrature<1> &quadrature,
                                     const unsigned int   face_no,
index 526304a923ab5dce4c6dd35ab49d98d82c00d3e3..62999bfb9edb88c72cd35bf25e283df9da92db22 100644 (file)
@@ -386,6 +386,13 @@ class ConstraintMatrix : public Subscriptor
                                      */
     void print (ostream &) const;
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
 
                                     /**
                                      * Exception
index a63945377e3e7a46d7efab72d33cf975b3e7137d..4fcd1af23df1de4cba01a8dc8abcafa0dd6e690c 100644 (file)
@@ -1000,6 +1000,20 @@ class DoFHandler  :  public Subscriptor,
                                      */
     const Triangulation<dim> & get_tria () const;
     
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     *
+                                     * This function is made virtual,
+                                     * since a dof handler object
+                                     * might be accessed through a
+                                     * pointers to thisr base class,
+                                     * although the actual object
+                                     * might be a derived class.
+                                     */
+    virtual unsigned int memory_consumption () const;
+
                                     /**
                                      * Exception
                                      */
index a5c11806eab3df63c9b956d57bf62ce43c7d9c14..931a76de104389703a956fed7c8d36e74b950572 100644 (file)
@@ -91,6 +91,13 @@ class DoFLevel<1>
                                      * detailed information.
                                      */
     vector<unsigned int> line_dofs;
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -111,6 +118,13 @@ class DoFLevel<2> : public DoFLevel<1>
                                      * detailed information.
                                      */
     vector<unsigned int> quad_dofs;
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -131,6 +145,13 @@ class DoFLevel<3> : public DoFLevel<2>
                                      * detailed information.
                                      */
     vector<unsigned int> hex_dofs;
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 };
 
 
index ebd8319e3ad2b649e0332500de07f7967bdc860e..e76da58d47d0ebacaaff5ad0004af62a8b15da8d 100644 (file)
@@ -349,6 +349,19 @@ class FiniteElementBase : public Subscriptor,
                                      */
     bool restriction_is_additive (const unsigned int component) const;
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     *
+                                     * This function is made virtual,
+                                     * since finite element objects
+                                     * are usually accessed through
+                                     * pointers to their base class,
+                                     * rather than the class itself.
+                                     */
+    virtual unsigned int memory_consumption () const;
+
                                     /**
                                      * Exception
                                      */
index d927390925619abf9d5e8260c9a94eb9f1cf2685..3a0a8eca4c6ab72f841153c71940f11c26ec4b19 100644 (file)
  * @author Wolfgang Bangerth, 1998
  */
 template <int dim>
-class FECrissCross : public FiniteElement<dim> {
+class FECrissCross : public FiniteElement<dim> 
+{
   public:
                                     /**
                                      * Constructor
@@ -348,6 +349,7 @@ class FECrissCross : public FiniteElement<dim> {
 };
 
 
+
 /**
  * Quadrature formula for the criss-cross element. This quadrature
  * formula uses one point at the barycenter of each of the four subtriangles.
@@ -356,7 +358,8 @@ class FECrissCross : public FiniteElement<dim> {
  * formula is not implemented for one space dimension.
  */
 template <int dim>
-class QCrissCross1 : public Quadrature<dim> {
+class QCrissCross1 : public Quadrature<dim> 
+{
   public:
     QCrissCross1 ();
 
index 74cbf0684186904adc1e06eeddafb77a718fb06b..de52dd70b63d2ceed2c1f91b4bd26f998c6f7215 100644 (file)
@@ -430,6 +430,19 @@ class FESystem : public FiniteElement<dim>
                                      */
     virtual const FiniteElement<dim>& base_element(unsigned int index) const;
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     *
+                                     * This function is made virtual,
+                                     * since finite element objects
+                                     * are usually accessed through
+                                     * pointers to their base class,
+                                     * rather than the class itself.
+                                     */
+    virtual unsigned int memory_consumption () const;
+
   private:
 
                                     /**
@@ -449,7 +462,7 @@ class FESystem : public FiniteElement<dim>
                                      * created by the constructor and
                                      * constant afterwards.
                                      */
-    vector< ElementPair > base_elements;
+    vector<ElementPair> base_elements;
 
 
                                     /**
index e32fdc8ba660e1bb25b9ac0aaed03de3312284bc..60721f32f139618da1cc4fb50e528a2501364474 100644 (file)
@@ -584,6 +584,13 @@ class FEValuesBase
                                      */
     const DoFHandler<dim>::cell_iterator & get_cell() const;
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
                                     /**
                                      * Exception
                                      */
@@ -787,6 +794,7 @@ class FEValuesBase
 };
 
 
+
 /**
  * Represent a finite element evaluated with a specific quadrature rule on
  * a cell.
@@ -852,6 +860,13 @@ class FEValues : public FEValuesBase<dim>
                                      */
     void reinit (const typename DoFHandler<dim>::cell_iterator &);
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
   private:
                                     /**
                                      * Store the gradients of the shape
@@ -1009,6 +1024,13 @@ class FEFaceValuesBase : public FEValuesBase<dim>
                                      */
     DoFHandler<dim>::face_iterator get_face() const;
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
 
   protected:
                                     /**
@@ -1090,6 +1112,7 @@ class FEFaceValuesBase : public FEValuesBase<dim>
 };
 
 
+
 /**
  * Represent a finite element evaluated with a specific quadrature rule on
  * the face of a cell.
index d0f0c30a3f9239217d8738838184ff94aabd1641..c7e77805760a7ef6b89ec2343223b717799fa1de 100644 (file)
@@ -548,6 +548,12 @@ class GridOut
                                      */
     static string get_output_format_names ();
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 
                                     /**
                                      * Exception
index 527e6a0579e4bfc4a7bb4046d2ea0f52c7f225c4..d654f2ff3c39ad362366775169dba3873b9390ac 100644 (file)
@@ -175,6 +175,13 @@ class InterGridMap
                                      * destination grid.
                                      */
     const GridClass<dim> & get_destination_grid () const;
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
     
                                     /**
                                      * Exception
index 82c83753c5b796449bcf6ce376203cfd0b18d674..61558aef80452505bac6f2bc8aaf3fc0a082a3ad 100644 (file)
@@ -200,6 +200,13 @@ class PersistentTriangulation : public Triangulation<dim>
                                      */
     virtual void read_flags(istream &in);
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    virtual unsigned int memory_consumption () const;
+
                                     /**
                                      * Exception.
                                      */
index 51d5239befe026038a877660f245c962f13b15ba..a77b9561026933f43cb1669f8c85d3652b337c40 100644 (file)
@@ -398,6 +398,13 @@ struct TriaNumberCache<1>
                                      * by default.
                                      */
     TriaNumberCache ();
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -451,6 +458,13 @@ struct TriaNumberCache<2> : public TriaNumberCache<1>
                                      * by default.
                                      */
     TriaNumberCache ();
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -504,6 +518,13 @@ struct TriaNumberCache<3> : public TriaNumberCache<2>
                                      * by default.
                                      */
     TriaNumberCache ();
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -2842,6 +2863,20 @@ class Triangulation : public TriaDimensionInfo<dim>,
     unsigned int max_adjacent_cells () const;
                                     /*@}*/
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     *
+                                     * This function is made virtual,
+                                     * since a triangulation object
+                                     * might be accessed through a
+                                     * pointer to this base class,
+                                     * even if the actual object is a
+                                     * derived class.
+                                     */
+    virtual unsigned int memory_consumption () const;
+    
 
                                     /**
                                      *  @name Exceptions
@@ -2981,7 +3016,7 @@ class Triangulation : public TriaDimensionInfo<dim>,
                                  vector<bool>       &v,
                                  const unsigned int  magic_number2,
                                  istream            &in);
-    
+
   private:
                                     /**
                                      *  Refine all cells on all levels which
@@ -3089,7 +3124,13 @@ class Triangulation : public TriaDimensionInfo<dim>,
     vector<bool>                     vertices_used;
 
                                     /**
-                                     *  Collection of boundary objects.
+                                     *  Collection of boundary
+                                     *  objects. We only need 255
+                                     *  objects rather than 256,
+                                     *  since the indicator 255 is
+                                     *  reserved for interior faces
+                                     *  and can thus never be
+                                     *  associated with a boundary.
                                      */
     const Boundary<dim>* boundary[255];
 
index 86f8e18fa8386e149c06d1012f0fb7d170afba97..d4fa9f5ae18fb1ce4690f3ced35023c908e0b4a0 100644 (file)
@@ -64,6 +64,13 @@ class Hexahedron
                                      */
     void set_quad (const int i, const int index);
     
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    static unsigned int memory_consumption ();
+
                                     /**
                                      *  Exception
                                      */ 
@@ -113,4 +120,12 @@ void Hexahedron::set_quad (const int i, const int index)
 };
 
 
+
+inline
+unsigned int
+Hexahedron::memory_consumption ()
+{
+  return sizeof(Hexahedron);
+};
+
 #endif
index 87d88a2a0dcd7777f56fe009e36cd7d0e8354d0c..b1ba1a4d161105f147eb2bfbc9704d40b1716f9b 100644 (file)
@@ -460,6 +460,14 @@ class TriaRawIterator : public bidirectional_iterator<Accessor,int>
     void print (ostream &out) const;
 
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
+
                                     /**@name Exceptions*/
                                     /*@{*/
                                     /**
@@ -507,7 +515,8 @@ class TriaRawIterator : public bidirectional_iterator<Accessor,int>
  *   @em{used} lines, quads, cells, etc.
  */
 template <int dim, typename Accessor>
-class TriaIterator : public TriaRawIterator<dim,Accessor> {
+class TriaIterator : public TriaRawIterator<dim,Accessor> 
+{
   public:
                                     /**
                                      *  Empty constructor. Such an object
@@ -653,7 +662,8 @@ class TriaIterator : public TriaRawIterator<dim,Accessor> {
  *   refined and thus a cell on which calculations on the finest level are done.
  */
 template <int dim, typename Accessor>
-class TriaActiveIterator : public TriaIterator<dim,Accessor> {
+class TriaActiveIterator : public TriaIterator<dim,Accessor> 
+{
   public:
                                     /**
                                      *  Empty constructor. Such an object
@@ -940,6 +950,16 @@ TriaRawIterator<dim,Accessor>::print (ostream &out) const
 
 
 
+template <int dim, typename Accessor>
+inline
+unsigned int
+TriaRawIterator<dim,Accessor>::memory_consumption () const
+{
+  return sizeof(TriaRawIterator<dim,Accessor>);
+};
+
+
+
 template <int dim, typename Accessor>
 template <typename OtherAccessor>
 inline
index b4dcba9959806cd9707853a7d82e3c292efcdc1d..7d622d6c78267d501c4a6bd3a03574247be19b2c 100644 (file)
@@ -156,6 +156,13 @@ class TriangulationLevel<0>
                                      */
     void monitor_memory (const unsigned int true_dimension) const;
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
                                     /**
                                      *  Exception
                                      */
@@ -318,6 +325,13 @@ class TriangulationLevel<1> : public TriangulationLevel<0>
                                      *  @ref{TriangulationLevel} classes.
                                      */
     void monitor_memory (const unsigned int true_dimension) const;
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -353,21 +367,26 @@ class TriangulationLevel<2> :  public TriangulationLevel<1>
                                          */
        vector<Quad> quads;
                                         /**
-                                         *  Same as for the @ref{TriangulationLevel<1>::LinesData}@p{::chilren}
-                                         *  array, but since there are four
-                                         *  children, the index points to the
-                                         *  first while the other three are
-                                         *  following immediately afterwards.
+                                         *  Same as for the
+                                         *  @ref{TriangulationLevel<1>::LinesData}@p{::chilren}
+                                         *  array, but since there
+                                         *  are four children, the
+                                         *  index points to the first
+                                         *  while the other three are
+                                         *  following immediately
+                                         *  afterwards.
                                          */
        vector<int>  children;
 
                                         /**
-                                         *  Same as for @ref{TriangulationLevel<1>::LinesData}@p{::used}.
+                                         *  Same as for
+                                         *  @ref{TriangulationLevel<1>::LinesData}@p{::used}.
                                          */
        vector<bool> used;
 
                                         /**
-                                         *  Same as for @ref{TriangulationLevel<1>::LinesData}@p{::used}.
+                                         *  Same as for
+                                         *  @ref{TriangulationLevel<1>::LinesData}@p{::used}.
                                          */
        vector<bool> user_flags;
 
@@ -425,6 +444,13 @@ class TriangulationLevel<2> :  public TriangulationLevel<1>
                                      *  @ref{TriangulationLevel} classes.
                                      */
     void monitor_memory (const unsigned int true_dimension) const;
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 };
 
 
@@ -450,7 +476,8 @@ class TriangulationLevel<3> :  public TriangulationLevel<2>
                                      *  level.
                                      *
                                      *  It is fully analogous to the
-                                     *  @ref{TriangulationLevel<1>::LinesData} structure inherited from
+                                     *  @ref{TriangulationLevel<1>::LinesData}
+                                     *  structure inherited from
                                      *  @ref{Triangulation<1>}.
                                      */
     struct HexesData
@@ -460,21 +487,26 @@ class TriangulationLevel<3> :  public TriangulationLevel<2>
                                          */
        vector<Hexahedron> hexes;
                                         /**
-                                         *  Same as for the @ref{TriangulationLevel<1>::LinesData}@p{::chilren}
-                                         *  array, but since there are four
-                                         *  children, the index points to the
-                                         *  first while the other three are
-                                         *  following immediately afterwards.
+                                         *  Same as for the
+                                         *  @ref{TriangulationLevel<1>::LinesData}@p{::chilren}
+                                         *  array, but since there
+                                         *  are four children, the
+                                         *  index points to the first
+                                         *  while the other three are
+                                         *  following immediately
+                                         *  afterwards.
                                          */
        vector<int>  children;
 
                                         /**
-                                         *  Same as for @ref{TriangulationLevel<1>::LinesData}@p{::used}.
+                                         *  Same as for
+                                         *  @ref{TriangulationLevel<1>::LinesData}@p{::used}.
                                          */
        vector<bool> used;
 
                                         /**
-                                         *  Same as for @ref{TriangulationLevel<1>::LinesData}@p{::used}.
+                                         *  Same as for
+                                         *  @ref{TriangulationLevel<1>::LinesData}@p{::used}.
                                          */
        vector<bool> user_flags;
 
@@ -532,6 +564,13 @@ class TriangulationLevel<3> :  public TriangulationLevel<2>
                                      *  @ref{TriangulationLevel} classes.
                                      */
     void monitor_memory (const unsigned int true_dimension) const;
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 };
 
 
index ba4afc90cece190d637bf01807fdefe8fd8798b8..0f86ce87d330075adabcb517a26f9333a0815c91 100644 (file)
@@ -52,6 +52,13 @@ class Line
                                      */
     void set_vertex (const int i, const int index);
     
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    static unsigned int memory_consumption ();
+
                                     /**
                                      *  Exception
                                      */
@@ -71,7 +78,7 @@ class Line
 /*----------------------------- Inline Function: Line ------------------------*/
 
 
-inline                               // wahrlich inline hier!
+inline                               // truly in-line here!
 Line::Line (const int i0, const int i1)
 {
   end_points[0] = i0;
@@ -99,4 +106,13 @@ void Line::set_vertex (const int i, const int index)
 };
 
 
+
+inline
+unsigned int
+Line::memory_consumption ()
+{
+  return sizeof(Line);
+};
+
+
 #endif
index 56820e999d378eabd3f4f6b574d3cb75391d6221..61641c511c832fdd2ea96f591fd103f1f6bd6065 100644 (file)
@@ -60,6 +60,13 @@ class Quad
                                      */
     void set_line (const int i, const int index);
     
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    static unsigned int memory_consumption ();
+
                                     /**
                                      *  Exception
                                      */ 
@@ -105,4 +112,12 @@ void Quad::set_line (const int i, const int index)
 };
 
 
+
+inline
+unsigned int
+Quad::memory_consumption ()
+{
+  return sizeof(Quad);
+};
+
 #endif
index e3336135d33b8b431c7aa22636bc225c0d62bc10..5fb6a07912539795adde9eb0c6c9184a77b36017 100644 (file)
@@ -12,6 +12,7 @@
 //----------------------------  dof_handler.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <dofs/dof_handler.h>
 #include <dofs/dof_levels.h>
 #include <dofs/dof_accessor.h>
@@ -1253,6 +1254,24 @@ const Triangulation<dim> & DoFHandler<dim>::get_tria () const
 
 
 
+template <int dim>
+unsigned int
+DoFHandler<dim>::memory_consumption () const
+{
+  unsigned int mem = (MemoryConsumption::memory_consumption (tria) +
+                     MemoryConsumption::memory_consumption (selected_fe) +
+                     MemoryConsumption::memory_consumption (tria) +
+                     MemoryConsumption::memory_consumption (levels) +
+                     MemoryConsumption::memory_consumption (used_dofs) +
+                     MemoryConsumption::memory_consumption (vertex_dofs));
+  for (unsigned int i=0; i<levels.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (*levels[i]);
+  
+  return mem;
+};
+
+
+
 template <int dim>
 void DoFHandler<dim>::distribute_dofs (const FiniteElement<dim> &ff,
                                       const unsigned int        offset)
diff --git a/deal.II/deal.II/source/dofs/dof_levels.cc b/deal.II/deal.II/source/dofs/dof_levels.cc
new file mode 100644 (file)
index 0000000..bbde931
--- /dev/null
@@ -0,0 +1,41 @@
+//----------------------------  dof_levels.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  dof_levels.cc  ---------------------------
+
+
+#include <base/memory_consumption.h>
+#include <dofs/dof_levels.h>
+
+
+unsigned int
+DoFLevel<1>::memory_consumption () const
+{
+  return MemoryConsumption::memory_consumption (line_dofs);
+};
+
+
+
+unsigned int
+DoFLevel<2>::memory_consumption () const
+{
+  return (DoFLevel<1>::memory_consumption () +
+         MemoryConsumption::memory_consumption (quad_dofs));
+};
+
+
+
+unsigned int
+DoFLevel<3>::memory_consumption () const
+{
+  return (DoFLevel<2>::memory_consumption () +
+         MemoryConsumption::memory_consumption (hex_dofs));
+};
index d9234f41d7c6bbd90c6e2832e7c288edf7e8e47e..6813a265d48b358314d898219c8063c2f9309638 100644 (file)
@@ -13,6 +13,7 @@
 
 
 #include <fe/fe.h>
+#include <base/memory_consumption.h>
 #include <base/quadrature.h>
 #include <grid/tria.h>
 #include <grid/tria_iterator.h>
@@ -246,6 +247,28 @@ bool FiniteElementBase<dim>::operator == (const FiniteElementBase<dim> &f) const
 };
 
 
+
+template <int dim>
+unsigned int
+FiniteElementBase<dim>::memory_consumption () const
+{
+  return (sizeof(FiniteElementData<dim>) +
+         MemoryConsumption::
+         memory_consumption<FullMatrix<double>, sizeof(restriction)/sizeof(restriction[0])>
+         (restriction)+
+         MemoryConsumption::memory_consumption
+         <FullMatrix<double>, sizeof(prolongation)/sizeof(prolongation[0])>
+         (prolongation) +
+         MemoryConsumption::memory_consumption (interface_constraints) +
+         MemoryConsumption::memory_consumption (system_to_component_table) +
+         MemoryConsumption::memory_consumption (face_system_to_component_table) +
+         MemoryConsumption::memory_consumption (component_to_system_table) +
+         MemoryConsumption::memory_consumption (face_component_to_system_table) +
+         MemoryConsumption::memory_consumption (component_to_base_table) +
+         MemoryConsumption::memory_consumption (restriction_is_additive_flags));
+};
+
+
 /*------------------------------- FiniteElement ----------------------*/
 
 
index 54979a122b6f899dcf2e05b58515744f10245014..b91fe98f8970d5f45bb6a4d418429052eac281df 100644 (file)
@@ -12,6 +12,7 @@
 //----------------------------  fe_system.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <fe/fe_system.h>
 #include <grid/tria_iterator.h>
 #include <dofs/dof_accessor.h>
@@ -1069,6 +1070,26 @@ FESystem<dim>::fill_fe_values (const DoFHandler<dim>::cell_iterator &cell,
 }
 
 
+
+template <int dim>
+unsigned int
+FESystem<dim>::memory_consumption () const 
+{
+                                  // neglect size of data stored in
+                                  // @p{base_elements} due to some
+                                  // problems with teh
+                                  // compiler. should be neglectable
+                                  // after all, considering the size
+                                  // of the data of the subelements
+  unsigned int mem = (FiniteElement<dim>::memory_consumption () +
+                     sizeof (base_elements));
+  for (unsigned int i=0; i<base_elements.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (*base_elements[i].first);
+  return mem;
+};
+
+
+
 // explicit instantiations
 template class FESystem<deal_II_dimension>;
 
index 3e02dbb2f1b3b344ec27d22aada34c756afa274c..c93fc0803904df5b04a52c62212826a44482d1a8 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <fe/fe.h>
 #include <fe/fe_values.h>
+#include <base/memory_consumption.h>
 #include <base/quadrature.h>
 #include <grid/tria_iterator.h>
 #include <grid/tria_accessor.h>
@@ -362,6 +363,29 @@ double FEValuesBase<dim>::JxW (const unsigned int i) const
 };
 
 
+
+template <int dim>
+unsigned int
+FEValuesBase<dim>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (shape_values) +
+         MemoryConsumption::memory_consumption (shape_gradients) +
+         MemoryConsumption::memory_consumption (shape_2nd_derivatives) +
+         MemoryConsumption::memory_consumption (weights) +
+         MemoryConsumption::memory_consumption (JxW_values) +
+         MemoryConsumption::memory_consumption (quadrature_points) +
+         MemoryConsumption::memory_consumption (support_points) +
+         MemoryConsumption::memory_consumption (jacobi_matrices) +
+         MemoryConsumption::memory_consumption (jacobi_matrices_grad) +
+         MemoryConsumption::memory_consumption (shape_values_transform) +
+         MemoryConsumption::memory_consumption (selected_dataset) +
+         MemoryConsumption::memory_consumption (jacobi_matrices) +
+         sizeof(update_flags) +
+         MemoryConsumption::memory_consumption (present_cell) +
+         MemoryConsumption::memory_consumption (fe));
+};
+
+
 /*------------------------------- FEValues -------------------------------*/
 
 template <int dim>
@@ -502,6 +526,19 @@ void FEValues<dim>::reinit (const typename DoFHandler<dim>::cell_iterator &cell)
 };
 
 
+
+template <int dim>
+unsigned int
+FEValues<dim>::memory_consumption () const
+{
+  return (FEValuesBase<dim>::memory_consumption () +
+         MemoryConsumption::memory_consumption (unit_shape_gradients) +
+         MemoryConsumption::memory_consumption (unit_shape_2nd_derivatives) +
+         MemoryConsumption::memory_consumption (unit_shape_gradients_transform) +
+         MemoryConsumption::memory_consumption (unit_quadrature_points));
+};
+
+
 /*------------------------------- FEFaceValuesBase --------------------------*/
 
 
@@ -551,6 +588,24 @@ FEFaceValuesBase<dim>::normal_vector (const unsigned int i) const
 };
 
 
+
+
+template <int dim>
+unsigned int
+FEFaceValuesBase<dim>::memory_consumption () const
+{
+  return (FEValuesBase<dim>::memory_consumption () +
+         MemoryConsumption::memory_consumption (unit_shape_gradients) +
+         MemoryConsumption::memory_consumption (unit_shape_2nd_derivatives) +
+         MemoryConsumption::memory_consumption (unit_shape_gradients_transform) +
+         MemoryConsumption::memory_consumption (unit_face_quadrature_points) +
+         MemoryConsumption::memory_consumption (unit_quadrature_points) +
+         MemoryConsumption::memory_consumption (face_jacobi_determinants) +
+         MemoryConsumption::memory_consumption (normal_vectors) +
+         MemoryConsumption::memory_consumption (present_face));
+};
+
+
 /*------------------------------- FEFaceValues -------------------------------*/
 
 
index 983baaeb9bdc909c773867f5e462a0f8e9ceb121..aa1aa5088d740cdae7941c3c291c0617506d2c58 100644 (file)
@@ -117,8 +117,18 @@ GridOut::parse_output_format (const string &format_name)
 };
 
 
-string GridOut::get_output_format_names () {
+string GridOut::get_output_format_names () 
+{
   return "gnuplot|eps";
 };
 
 
+unsigned int
+GridOut::memory_consumption () const
+{
+  return (sizeof(ucd_flags) +
+         sizeof(gnuplot_flags) +
+         sizeof(eps_flags_1) +
+         sizeof(eps_flags_2) +
+         sizeof(eps_flags_3));
+};
index 6c20a2bad747f17b9d824fb2e19ee9485f1d516e..1ade48150aa688c64d704b9d00a45c5b88af9b9d 100644 (file)
@@ -12,6 +12,7 @@
 //----------------------------  intergrid_map.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <grid/tria.h>
 #include <dofs/dof_handler.h>
 #include <grid/tria_accessor.h>
@@ -196,7 +197,17 @@ InterGridMap<GridClass,dim>::get_destination_grid () const
   return *destination_grid;
 };
 
-  
+
+
+template <template <int> class GridClass, int dim>
+unsigned int
+InterGridMap<GridClass,dim>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (mapping) +
+         MemoryConsumption::memory_consumption (source_grid) +
+         MemoryConsumption::memory_consumption (destination_grid));
+};
+
 
   
 // explicit instantiations
index 77194d2a8cd5b7e68c6cdff6dc2676e90150e778..08a05991dda70242ac6c81a911611a9af1979495 100644 (file)
@@ -12,6 +12,7 @@
 //----------------------------  persistent_tria.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <grid/persistent_tria.h>
 #include <grid/magic_numbers.h>
 #include <iostream>
@@ -160,6 +161,18 @@ PersistentTriangulation<dim>::read_flags(istream &in)
 }
 
 
+
+template <int dim>
+unsigned int
+PersistentTriangulation<dim>::memory_consumption () const
+{
+  return (Triangulation<dim>::memory_consumption () +
+         MemoryConsumption::memory_consumption (coarse_grid) +
+         MemoryConsumption::memory_consumption (refine_flags) +
+         MemoryConsumption::memory_consumption (coarsen_flags));
+};
+
+
 // explicit instantiations
 template class PersistentTriangulation<deal_II_dimension>;
 
index 44594d5efb260d48c376251a573cd9c7c709281e..92d641626bed49e0889556482aeef0e5e732ad95 100644 (file)
@@ -12,6 +12,7 @@
 //----------------------------  tria.all_dimensions.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <grid/tria.h>
 #include <grid/tria_levels.h>
 #include <grid/tria_boundary.h>
@@ -177,6 +178,16 @@ void TriangulationLevel<0>::monitor_memory (const unsigned int true_dimension) c
 
 
 
+unsigned int
+TriangulationLevel<0>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (refine_flags) +
+         MemoryConsumption::memory_consumption (coarsen_flags) +
+         MemoryConsumption::memory_consumption (neighbors));
+};
+
+
+
 void TriangulationLevel<1>::reserve_space (const unsigned int new_lines)
 {
   const unsigned int new_size = new_lines +
@@ -257,6 +268,19 @@ void TriangulationLevel<1>::monitor_memory (const unsigned int true_dimension) c
 
 
 
+unsigned int
+TriangulationLevel<1>::memory_consumption () const
+{
+  return (TriangulationLevel<0>::memory_consumption() +
+         MemoryConsumption::memory_consumption (lines.lines) +
+         MemoryConsumption::memory_consumption (lines.children) +
+         MemoryConsumption::memory_consumption (lines.used) +
+         MemoryConsumption::memory_consumption (lines.user_flags) +
+         MemoryConsumption::memory_consumption (lines.material_id) +
+         MemoryConsumption::memory_consumption (lines.user_pointers));
+};
+  
+
 void TriangulationLevel<2>::reserve_space (const unsigned int new_quads)
 {
   const unsigned int new_size = new_quads +
@@ -328,6 +352,20 @@ void TriangulationLevel<2>::monitor_memory (const unsigned int true_dimension) c
 
 
 
+unsigned int
+TriangulationLevel<2>::memory_consumption () const
+{
+  return (TriangulationLevel<1>::memory_consumption() +
+         MemoryConsumption::memory_consumption (quads.quads) +
+         MemoryConsumption::memory_consumption (quads.children) +
+         MemoryConsumption::memory_consumption (quads.used) +
+         MemoryConsumption::memory_consumption (quads.user_flags) +
+         MemoryConsumption::memory_consumption (quads.material_id) +
+         MemoryConsumption::memory_consumption (quads.user_pointers));
+};
+
+
+
 void TriangulationLevel<3>::reserve_space (const unsigned int new_hexes)
 {
   const unsigned int new_size = new_hexes +
@@ -399,6 +437,20 @@ void TriangulationLevel<3>::monitor_memory (const unsigned int true_dimension) c
 
 
 
+unsigned int
+TriangulationLevel<3>::memory_consumption () const
+{
+  return (TriangulationLevel<2>::memory_consumption() +
+         MemoryConsumption::memory_consumption (hexes.hexes) +
+         MemoryConsumption::memory_consumption (hexes.children) +
+         MemoryConsumption::memory_consumption (hexes.used) +
+         MemoryConsumption::memory_consumption (hexes.user_flags) +
+         MemoryConsumption::memory_consumption (hexes.material_id) +
+         MemoryConsumption::memory_consumption (hexes.user_pointers));
+};
+
+
+
 TriaNumberCache<1>::TriaNumberCache () :
                n_lines (0),
                n_active_lines (0) 
@@ -408,6 +460,16 @@ TriaNumberCache<1>::TriaNumberCache () :
 
 
 
+unsigned int
+TriaNumberCache<1>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (n_lines) +
+         MemoryConsumption::memory_consumption (n_lines_level) +
+         MemoryConsumption::memory_consumption (n_active_lines) +
+         MemoryConsumption::memory_consumption (n_active_lines_level));
+};
+
+
 TriaNumberCache<2>::TriaNumberCache () :
                n_quads (0),
                n_active_quads (0) 
@@ -417,9 +479,33 @@ TriaNumberCache<2>::TriaNumberCache () :
 
 
 
+unsigned int
+TriaNumberCache<2>::memory_consumption () const
+{
+  return (TriaNumberCache<1>::memory_consumption () +
+         MemoryConsumption::memory_consumption (n_quads) +
+         MemoryConsumption::memory_consumption (n_quads_level) +
+         MemoryConsumption::memory_consumption (n_active_quads) +
+         MemoryConsumption::memory_consumption (n_active_quads_level));
+};
+
+
+
 TriaNumberCache<3>::TriaNumberCache () :
                n_hexes (0),
                n_active_hexes (0) 
                                                 // all other fields are
                                                 // default constructed
 {};
+
+
+
+unsigned int
+TriaNumberCache<3>::memory_consumption () const
+{
+  return (TriaNumberCache<2>::memory_consumption () +
+         MemoryConsumption::memory_consumption (n_hexes) +
+         MemoryConsumption::memory_consumption (n_hexes_level) +
+         MemoryConsumption::memory_consumption (n_active_hexes) +
+         MemoryConsumption::memory_consumption (n_active_hexes_level));
+};
index fd4c96b52b5329f25cde500e2029c456444836d1..fc21e14a58eb69d4fe5f58cccc05e858424ff269 100644 (file)
@@ -12,6 +12,7 @@
 //----------------------------  tria.cc  ---------------------------
 
 
+#include <base/memory_consumption.h>
 #include <grid/tria.h>
 #include <grid/tria_levels.h>
 #include <grid/tria_boundary.h>
@@ -7394,6 +7395,27 @@ void Triangulation<dim>::read_bool_vector (const unsigned int  magic_number1,
 };
 
 
+
+template <int dim>
+unsigned int
+Triangulation<dim>::memory_consumption () const 
+{
+  unsigned int mem = 0;
+  mem += MemoryConsumption::memory_consumption(levels);
+  for (unsigned int i=0; i<levels.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (*levels[i]);
+  mem += MemoryConsumption::memory_consumption (vertices);
+  mem += MemoryConsumption::memory_consumption (vertices_used);
+  mem += sizeof(boundary);
+  mem += sizeof(smooth_grid);
+  mem += MemoryConsumption::memory_consumption (number_cache);
+
+  return mem;
+};
+
+  
+
+
 template <int dim>
 void Triangulation<dim>::update_number_cache_lines () 
 {
index a48c81800fdb0f6c4c0dec5c78d6fbc62b6df48e..6869bb1b4b12405f3eb18dc3f8882cadef1814c3 100644 (file)
@@ -117,6 +117,13 @@ class BlockIndices
                                      * objects.
                                      */
     void swap (BlockIndices &b);
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
     
   private:
                                     /**
@@ -272,6 +279,16 @@ BlockIndices::swap (BlockIndices &b)
 
 
 
+inline
+unsigned int
+BlockIndices::memory_consumption () const
+{
+  return (sizeof(*this) + 
+         start_indices.size() * sizeof(start_indices[0]));
+};
+
+
+
 /* ----------------- global functions ---------------------------- */
 
 
index a1b70e92a2deafc8f11f9a93b6606015f8d0ab1a..82bd776c51e261fde7972426d6b1112d921ba5e9 100644 (file)
@@ -437,6 +437,13 @@ class BlockSparseMatrix : public Subscriptor
     const BlockSparsityPattern &
     get_sparsity_pattern () const;
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
                                     /**
                                      * Exception
                                      */
index e7cb56603ce94a8d3d0dd2d3eade0d77f319dd15..52abe1a3df79872818ece692c1799e235ebe05ea 100644 (file)
@@ -14,6 +14,7 @@
 #define __deal2__block_sparse_matrix_templates_h
 
 
+#include <base/memory_consumption.h>
 #include <lac/block_sparse_matrix.h>
 
 
@@ -120,4 +121,17 @@ BlockSparseMatrix<number,rows,columns>::get_sparsity_pattern () const
 
 
 
+template <typename number, int  rows, int columns>
+unsigned int
+BlockSparseMatrix<number,rows,columns>::memory_consumption () const
+{
+  unsigned int mem = sizeof(*this);
+  for (unsigned int r=0; r<rows; ++r)
+    for (unsigned int c=0; c<columns; ++c)
+      mem += MemoryConsumption::memory_consumption(sub_objects[r][c]);
+  return mem;
+};
+
+
+
 #endif // ifdef block_sparse_matrix_templates_h
index 029cbbb2a837eb9c1c6837fc5a3bffb2ce9cc9ec..bd9655893ec9b8c0da34da5677cee1cee5c9dbbc 100644 (file)
@@ -310,6 +310,13 @@ class BlockSparsityPattern : public Subscriptor
                                      */
     bool is_compressed () const;
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
                                     /**
                                      * Exception
                                      */
index c7fce8a4c4c348a4b5ee406c352798cde6d8e4e1..b9b6b6071b526d2f50925cf868bff1f97b874180 100644 (file)
@@ -481,6 +481,14 @@ class BlockVector
                                      * file, but not more.
                                      */
     void block_read (istream &in);
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
                                     //@}
 
   protected:
index 8af6af75d719593150a7fbf53675df17bb7585ba..47434977c7fe20d54b683849e1877f2a8cb32be1 100644 (file)
@@ -14,6 +14,7 @@
 #define __deal2__block_vector_templates_h
 
 
+#include <base/memory_consumption.h>
 #include <lac/block_vector.h>
 #include <cmath>
 #include <algorithm>
@@ -466,6 +467,7 @@ void BlockVector<Number>::print (ostream &out,
 }
 
 
+
 template <typename Number>
 void BlockVector<Number>::block_write (ostream &out) const
 {
@@ -476,6 +478,7 @@ void BlockVector<Number>::block_write (ostream &out) const
 }
 
 
+
 template <typename Number>
 void BlockVector<Number>::block_read (istream &in)
 {
@@ -485,4 +488,20 @@ void BlockVector<Number>::block_read (istream &in)
     }  
 }
 
+
+template <typename Number>
+unsigned int
+BlockVector<Number>::memory_consumption () const
+{
+  unsigned int mem = sizeof(num_blocks);
+  for (unsigned int i=0; i<components.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (components[i]);
+  mem += MemoryConsumption::memory_consumption (block_indices);
+  return mem;
+};
+
+
+
+
+
 #endif
index b9b23aeecc8af47a6d34ce266dbd67c40e9a9329..63d46318f9e3ed40591133529046b9d47e76fe67 100644 (file)
@@ -561,6 +561,13 @@ class FullMatrix : public Subscriptor
                                      */
     void print_formatted (ostream &out,
                          const unsigned int presicion=3) const;
+    
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 
                                     /**
                                      * Exception
index 1843378d29e0516135c647fe32c80900b9c4d3c7..c819b10efb1af4d8da0a71f5ac8db940b4b61e8e 100644 (file)
@@ -1458,4 +1458,14 @@ FullMatrix<number>::least_squares(Vector<number2>& dst, Vector<number2>& src)
   return sqrt(sum);
 }
 
+
+
+template <typename number>
+unsigned int
+FullMatrix<number>::memory_consumption () const
+{
+  return sizeof(*this) + val_size*sizeof(number);
+};
+
+
 #endif
index 509bab60faf6bb4240a2ce3f2bfbec99e57af5eb..d8ba3d0e54078b6cccf966b6357cdd79c2c144b1 100644 (file)
@@ -164,6 +164,13 @@ class PreconditionBlock
                                      */
     unsigned int block_size () const;
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
                                     /**
                                      * Determine, whether inverses
                                      * have been computed.
index 776d1f5ad66a2ec9e855d71d0c44fed8d89dfd4e..52effedff9838acb94833453b7b4db9760454df9 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <base/exceptions.h>
 #include <base/logstream.h>
+#include <base/memory_consumption.h>
 #include <lac/precondition_block.h>
 #include <lac/vector.h>
 #include <lac/full_matrix.h>
@@ -197,6 +198,22 @@ void PreconditionBlock<number,inverse_type>::invert_diagblocks()
 }
 
 
+
+template <typename number, typename inverse_type>
+unsigned int
+PreconditionBlock<number,inverse_type>::memory_consumption () const
+{
+  unsigned int mem = sizeof(*this);
+  for (unsigned int i=0; i<var_inverse.size(); ++i)
+    mem += MemoryConsumption::memory_consumption(var_inverse[i]);
+  for (unsigned int i=0; i<var_diagonal.size(); ++i)
+    mem += MemoryConsumption::memory_consumption(var_diagonal[i]);
+  return mem;
+};
+
+
+
+
 /*--------------------- PreconditionBlockJacobi -----------------------*/
 
 
index ef14099b0ccfcbd10c59f5f3360a5dca0b042f6a..e87efffec74eb476f3b272ba390c5fd23737d0ec 100644 (file)
@@ -195,6 +195,13 @@ class SparseILU : protected SparseMatrix<number>
     void vmult (Vector<somenumber>       &dst,
                const Vector<somenumber> &src) const;
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
                                     /**
                                      * Exception
                                      */
index 15a1f059f9032bbea542b9c4d937319a217dfba0..e32255de437dea0fda34b3a19c1423f683588dea 100644 (file)
@@ -339,6 +339,16 @@ void SparseILU<number>::apply_decomposition (Vector<somenumber>       &dst,
 };
 
 
+
+template <typename number>
+unsigned int
+SparseILU<number>::memory_consumption () const
+{
+  return SparseMatrix<number>::memory_consumption ();
+};
+
+
+
 /*----------------------------   sparse_ilu.templates.h     ---------------------------*/
 
 #endif
index 57902399df61c02e4bbdff16199c878810361420..ffd0d5f5cad3e094703bd8c097eb109b6541ee96 100644 (file)
@@ -692,6 +692,13 @@ class SparseMatrix : public Subscriptor
                          const unsigned int  width       = 0,
                          const char         *zero_string = " ",
                          const double        denominator = 1.) const;
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
     
                                     /**
                                      * Exception
index ced79b2c3340592634965e2b2f1cd3e38ca079fd..c1db80dc5515ac84bb1d37f8250c623225ef932b 100644 (file)
@@ -1004,4 +1004,14 @@ void SparseMatrix<number>::print_formatted (ostream &out,
 //  out.setf (0, ios::floatfield);                 // reset output format
 };
 
+
+
+template <typename number>
+unsigned int
+SparseMatrix<number>::memory_consumption () const
+{
+  return sizeof(*this) + max_len*sizeof(number);
+};
+
+
 #endif
index 5213b4102ad4c964e6eab98b425c8d98d6ec60d2..af1907743c19e4bdedada05c9f101e5c13c96949 100644 (file)
@@ -264,6 +264,13 @@ class SparseVanka
     void apply_preconditioner (Vector<number2>       &dst,
                               const Vector<number2> &src,
                               const vector<bool>    *dof_mask = 0) const;    
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
     
   private:
                                     /**
@@ -519,6 +526,13 @@ class SparseBlockVanka : public SparseVanka<number>
     void vmult (Vector<number2>       &dst,
                     const Vector<number2> &src) const;
     
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
   private:
                                     /**
                                      * Store the number of blocks.
index 8386d6da6d0ce382c6a8f9aba77547f9e7823280..ff6f398ff64286a2d763210a34f03914c92ccd4d 100644 (file)
@@ -14,6 +14,7 @@
 #define __deal2__sparse_vanka_templates_h
 
 
+#include <base/memory_consumption.h>
 #include <lac/sparse_vanka.h>
 #include <lac/full_matrix.h>
 #include <lac/sparse_matrix.h>
@@ -363,6 +364,22 @@ SparseVanka<number>::apply_preconditioner (Vector<number2>       &dst,
 };
 
 
+
+template <typename number>
+unsigned int
+SparseVanka<number>::memory_consumption () const
+{
+  unsigned int mem = (sizeof(*this) +
+                     MemoryConsumption::memory_consumption (selected));
+  for (unsigned int i=0; i<inverses.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (*inverses[i]);
+  
+  return mem;
+};
+
+
+
+
 template <typename number>
 SparseBlockVanka<number>::SparseBlockVanka (const SparseMatrix<number> &M,
                                            const vector<bool>         &selected,
@@ -576,4 +593,18 @@ void SparseBlockVanka<number>::vmult (Vector<number2>       &dst,
     }
 }
 
+
+
+template <typename number>
+unsigned int
+SparseBlockVanka<number>::memory_consumption () const
+{
+  unsigned int mem = SparseVanka<number>::memory_consumption();
+  for (unsigned int i=0; i<dof_masks.size(); ++i)
+    mem += MemoryConsumption::memory_consumption (dof_masks[i]);
+  return mem;
+};
+
+         
+
 #endif
index 9e2165b58b8f938beeae591854ef770cab522008..fbf44987ce2cf0a0140cc006ed8ed0b220afeb4e 100644 (file)
@@ -499,6 +499,12 @@ class SparsityPattern : public Subscriptor
                                      */
     const unsigned int * get_column_numbers () const;
 
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
 
                                     /**
                                      * Exception
index 11bfd2d6503be0fcb9178357db19ee3d3f857e23..d8e172ed5127b7d53d462e3c25396acdca1abeab 100644 (file)
@@ -221,6 +221,13 @@ class SwappableVector : public Vector<number>
                                      */
     const string & get_filename () const;
    
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
+
                                     /**
                                      * Exception.
                                      */ 
index 48a5b760e1db8b21663518fcd4846c3c146d366d..94f14e652baee778a7f64d3ebc5743441176b012 100644 (file)
@@ -14,6 +14,7 @@
 #define __deal2__swappable_vector_templates_h
 
 
+#include <base/memory_consumption.h>
 #include <lac/swappable_vector.h>
 #include <fstream>
 #include <iostream>
@@ -262,5 +263,17 @@ SwappableVector<number>::get_filename () const
 
 
 
+template <typename number>
+unsigned int
+SwappableVector<number>::memory_consumption () const
+{
+  return (MemoryConsumption::memory_consumption (filename) +
+         sizeof(lock) +
+         MemoryConsumption::memory_consumption (data_is_preloaded) +
+         Vector<number>::memory_consumption ());
+};
+
+
+
 
 #endif // __deal2__swappable_vector_templates_h
index 12212d1f33d3ddef912c4f549efbc3950b066724..dc8f79a22e9cd2457b3afc16f9ed859ceda5bf8a 100644 (file)
@@ -448,6 +448,13 @@ class Vector {
                                      * file, but not more.
                                      */
     void block_read (istream &in);
+
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
+    unsigned int memory_consumption () const;
                                     //@}
 
                                     /**
index fa171fdd583648806d71d29da5e8b42e1c657ad5..4ef8a4a25c6af7f84eae9c80a3b8c2e56a1167b5 100644 (file)
@@ -667,4 +667,14 @@ void Vector<Number>::block_read (istream &in)
   AssertThrow (in, ExcIO());
 }
 
+
+
+template <typename Number>
+unsigned int
+Vector<Number>::memory_consumption () const
+{
+  return sizeof(*this) + (maxdim * sizeof(Number));
+};
+
+
 #endif
index 452e12e1e1471b3df686a144e1daaca64393f4fc..2ffe42ef26b60d5fdc3b2cc2d986dcce01b558ee 100644 (file)
@@ -11,6 +11,7 @@
 //
 //----------------------------  block_block_sparsity_pattern.cc  ---------------------------
 
+#include <base/memory_consumption.h>
 #include <lac/block_sparsity_pattern.h>
 
 
@@ -214,3 +215,19 @@ BlockSparsityPattern::is_compressed () const
   return true;
 };
 
+
+unsigned int
+BlockSparsityPattern::memory_consumption () const
+{
+  unsigned int mem = 0;
+  mem += (MemoryConsumption::memory_consumption (rows) +
+         MemoryConsumption::memory_consumption (columns) +
+         MemoryConsumption::memory_consumption (sub_objects) +
+         MemoryConsumption::memory_consumption (row_indices) +
+         MemoryConsumption::memory_consumption (column_indices));
+  for (unsigned int r=0; r<rows; ++r)
+    for (unsigned int c=0; c<columns; ++c)
+      mem += MemoryConsumption::memory_consumption (*sub_objects[r][c]);
+  
+  return mem;
+};
index 27a1e29d690773543da41a9e9bd3575d41194cd5..81bb2999ee0172e9c2ee3823c5fcf306ad183f13 100644 (file)
@@ -611,3 +611,12 @@ SparsityPattern::bandwidth () const
   return b;
 };
 
+
+
+unsigned int
+SparsityPattern::memory_consumption () const
+{
+  return (sizeof(*this) +
+         max_dim * sizeof(unsigned int) +
+         max_vec_len * sizeof(unsigned int));
+};

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.