]> https://gitweb.dealii.org/ - dealii.git/commitdiff
provide memory_consumption() for some Function* classes
authorTimo Heister <timo.heister@gmail.com>
Wed, 16 Dec 2020 16:40:31 +0000 (11:40 -0500)
committerTimo Heister <timo.heister@gmail.com>
Thu, 17 Dec 2020 16:18:05 +0000 (11:18 -0500)
include/deal.II/base/function.h
include/deal.II/base/function_lib.h
source/base/function_lib.cc

index 3ea52c8b08509e4f9db412c91beb0e4a94057f14..f415820400f7dbffb315a9deeb69996fcaff3373 100644 (file)
@@ -390,10 +390,10 @@ public:
 
   /**
    * Return an estimate for the memory consumption, in bytes, of this object.
-   * This is not exact (but will usually be close) because calculating the
-   * memory usage of trees (e.g., <tt>std::map</tt>) is difficult.
+   *
+   * This function is virtual and can be overloaded by derived classes.
    */
-  std::size_t
+  virtual std::size_t
   memory_consumption() const;
 };
 
@@ -483,8 +483,8 @@ namespace Functions
     laplacian(const Point<dim> & point,
               const unsigned int component = 0) const override;
 
-    std::size_t
-    memory_consumption() const;
+    virtual std::size_t
+    memory_consumption() const override;
 
   protected:
     /**
@@ -602,11 +602,9 @@ public:
 
   /**
    * Return an estimate for the memory consumption, in bytes, of this object.
-   * This is not exact (but will usually be close) because calculating the
-   * memory usage of trees (e.g., <tt>std::map</tt>) is difficult.
    */
-  std::size_t
-  memory_consumption() const;
+  virtual std::size_t
+  memory_consumption() const override;
 
 protected:
   /**
index 82656a2d224821494aeedb1bd061508b88856aaf..8e57b2c5a958eb819588965b1381ad31dd527782 100644 (file)
@@ -1435,6 +1435,12 @@ namespace Functions
     gradient(const Point<dim> & p,
              const unsigned int component = 0) const override;
 
+    /**
+     * Return an estimate for the memory consumption, in bytes, of this object.
+     */
+    virtual std::size_t
+    memory_consumption() const override;
+
   protected:
     /**
      * Find the index in the table of the rectangle containing an input point
@@ -1540,6 +1546,12 @@ namespace Functions
     gradient(const Point<dim> & p,
              const unsigned int component = 0) const override;
 
+    /**
+     * Return an estimate for the memory consumption, in bytes, of this object.
+     */
+    virtual std::size_t
+    memory_consumption() const override;
+
   private:
     /**
      * The set of interval endpoints in each of the coordinate directions.
@@ -1608,6 +1620,12 @@ namespace Functions
     gradient(const Point<dim> & p,
              const unsigned int component = 0) const override;
 
+    /**
+     * Return an estimate for the memory consumption, in bytes, of this object.
+     */
+    virtual std::size_t
+    memory_consumption() const override;
+
   private:
     /**
      * The set of exponents.
index cb08a2f7e19e11fecacdd21f7cdee9374fb50443..6f25f9df574c21a8d2c53be07cd445bebcc44fa3 100644 (file)
@@ -2538,6 +2538,19 @@ namespace Functions
 
 
 
+  template <int dim>
+  std::size_t
+  InterpolatedTensorProductGridData<dim>::memory_consumption() const
+  {
+    return sizeof(*this) +
+           MemoryConsumption::memory_consumption(coordinate_values) -
+           sizeof(coordinate_values) +
+           MemoryConsumption::memory_consumption(data_values) -
+           sizeof(data_values);
+  }
+
+
+
   template <int dim>
   double
   InterpolatedTensorProductGridData<dim>::value(
@@ -2722,6 +2735,16 @@ namespace Functions
 
 
 
+  template <int dim>
+  std::size_t
+  InterpolatedUniformGridData<dim>::memory_consumption() const
+  {
+    return sizeof(*this) + data_values.memory_consumption() -
+           sizeof(data_values);
+  }
+
+
+
   /* ---------------------- Polynomial ----------------------- */
 
 
@@ -2829,6 +2852,18 @@ namespace Functions
   }
 
 
+
+  template <int dim>
+  std::size_t
+  Polynomial<dim>::memory_consumption() const
+  {
+    return sizeof(*this) + exponents.memory_consumption() - sizeof(exponents) +
+           MemoryConsumption::memory_consumption(coefficients) -
+           sizeof(coefficients);
+  }
+
+
+
   // explicit instantiations
   template class SquareFunction<1>;
   template class SquareFunction<2>;

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.