From: Peter Munch Date: Wed, 1 Sep 2021 20:44:37 +0000 (+0200) Subject: Implement MGTransferGlobalCoarsening::memory_consumption() X-Git-Tag: v9.4.0-rc1~998^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc422253d554f3928315d5195251dbcec822d76f;p=dealii.git Implement MGTransferGlobalCoarsening::memory_consumption() --- diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.h index 64bbd4aa1e..62b2852585 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.h @@ -175,6 +175,12 @@ public: */ void interpolate(VectorType &dst, const VectorType &src) const; + + /** + * Return the memory consumption of the allocated memory in this class. + */ + std::size_t + memory_consumption() const; }; @@ -277,6 +283,12 @@ public: interpolate(LinearAlgebra::distributed::Vector & dst, const LinearAlgebra::distributed::Vector &src) const; + /** + * Return the memory consumption of the allocated memory in this class. + */ + std::size_t + memory_consumption() const; + private: /** * A multigrid transfer scheme. A multrigrid transfer class can have different @@ -521,6 +533,15 @@ public: MGLevelObject & dst, const InVector & src) const; + /** + * Return the memory consumption of the allocated memory in this class. + * + * @note Counts also the memory consumption of the underlying two-level + * transfer operators. + */ + std::size_t + memory_consumption() const; + private: /** * Collection of the two-level transfer operators. @@ -662,6 +683,23 @@ MGTransferGlobalCoarsening::interpolate_to_mg( this->transfer[l].interpolate(dst[l - 1], dst[l]); } + + +template +std::size_t +MGTransferGlobalCoarsening::memory_consumption() const +{ + std::size_t size = 0; + + const unsigned int min_level = transfer.min_level(); + const unsigned int max_level = transfer.max_level(); + + for (unsigned int l = min_level + 1; l <= max_level; ++l) + size += this->transfer[l].memory_consumption(); + + return size; +} + #endif DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h index 9a84dcabee..71c38856ef 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h @@ -2822,6 +2822,39 @@ MGTwoLevelTransfer>:: return cell_transfer.run(cell_transfer_test); } + + +template +std::size_t +MGTwoLevelTransfer>:: + memory_consumption() const +{ + std::size_t size = 0; + + for (const auto &scheme : schemes) + { + size += scheme.prolongation_matrix.memory_consumption(); + size += scheme.prolongation_matrix_1d.memory_consumption(); + size += scheme.restriction_matrix.memory_consumption(); + size += scheme.restriction_matrix_1d.memory_consumption(); + } + + size += partitioner_fine->memory_consumption(); + size += partitioner_coarse->memory_consumption(); + size += vec_fine.memory_consumption(); + size += vec_coarse.memory_consumption(); + size += + MemoryConsumption::memory_consumption(distribute_local_to_global_indices); + size += + MemoryConsumption::memory_consumption(distribute_local_to_global_values); + size += MemoryConsumption::memory_consumption(distribute_local_to_global_ptr); + size += MemoryConsumption::memory_consumption(weights); + size += MemoryConsumption::memory_consumption(level_dof_indices_coarse); + size += MemoryConsumption::memory_consumption(level_dof_indices_fine); + + return size; +} + DEAL_II_NAMESPACE_CLOSE #endif