From: Timo Heister Date: Wed, 16 Dec 2020 16:40:31 +0000 (-0500) Subject: provide memory_consumption() for some Function* classes X-Git-Tag: v9.3.0-rc1~737^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82f8d8c7a12b921deec473b245950eae51be85de;p=dealii.git provide memory_consumption() for some Function* classes --- diff --git a/include/deal.II/base/function.h b/include/deal.II/base/function.h index 3ea52c8b08..f415820400 100644 --- a/include/deal.II/base/function.h +++ b/include/deal.II/base/function.h @@ -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., std::map) 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 & 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., std::map) is difficult. */ - std::size_t - memory_consumption() const; + virtual std::size_t + memory_consumption() const override; protected: /** diff --git a/include/deal.II/base/function_lib.h b/include/deal.II/base/function_lib.h index 82656a2d22..8e57b2c5a9 100644 --- a/include/deal.II/base/function_lib.h +++ b/include/deal.II/base/function_lib.h @@ -1435,6 +1435,12 @@ namespace Functions gradient(const Point & 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 & 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 & 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. diff --git a/source/base/function_lib.cc b/source/base/function_lib.cc index cb08a2f7e1..6f25f9df57 100644 --- a/source/base/function_lib.cc +++ b/source/base/function_lib.cc @@ -2538,6 +2538,19 @@ namespace Functions + template + std::size_t + InterpolatedTensorProductGridData::memory_consumption() const + { + return sizeof(*this) + + MemoryConsumption::memory_consumption(coordinate_values) - + sizeof(coordinate_values) + + MemoryConsumption::memory_consumption(data_values) - + sizeof(data_values); + } + + + template double InterpolatedTensorProductGridData::value( @@ -2722,6 +2735,16 @@ namespace Functions + template + std::size_t + InterpolatedUniformGridData::memory_consumption() const + { + return sizeof(*this) + data_values.memory_consumption() - + sizeof(data_values); + } + + + /* ---------------------- Polynomial ----------------------- */ @@ -2829,6 +2852,18 @@ namespace Functions } + + template + std::size_t + Polynomial::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>;