]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add NoncontiguousPartitioner::temporary_storage_size 11765/head
authorPeter Munch <peterrmuench@gmail.com>
Tue, 16 Feb 2021 19:53:45 +0000 (20:53 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Tue, 16 Feb 2021 21:15:10 +0000 (22:15 +0100)
include/deal.II/base/mpi_noncontiguous_partitioner.h
include/deal.II/base/mpi_noncontiguous_partitioner.templates.h

index de17fc2d779b4349b71755566c75b7fabb3b79c8..deb0432970ae9eefaf0643ff6fcb285bfcb010cd 100644 (file)
@@ -99,10 +99,8 @@ namespace Utilities
        * used.
        *
        * @pre The size of the @p temporary_storage vector has to be at least
-       *   as large as the sum of the number of entries in the index sets
-       *   passed to the constructor and the reinit() functions. The reason
-       *   for this is that this vector is used as buffer for both sending
-       *   and receiving data.
+       *   temporary_storage_size. The reason for this is that this vector is
+       *   used as buffer for both sending and receiving data.
        */
       template <typename Number>
       void
@@ -124,7 +122,7 @@ namespace Utilities
        *   allows for padding and other post-processing of the received data.
        *
        * @pre The required size of the vectors are the same as in the functions
-       * above.
+       *   above.
        */
       template <typename Number>
       void
@@ -146,7 +144,7 @@ namespace Utilities
        *   destination vector.
        *
        * @pre The required size of the vectors are the same as in the functions
-       * above.
+       *   above.
        */
       template <typename Number>
       void
@@ -160,7 +158,15 @@ namespace Utilities
        * number of processes this process receives data from.
        */
       std::pair<unsigned int, unsigned int>
-      n_targets();
+      n_targets() const;
+
+      /**
+       * Return the size of the temporary storage needed by the
+       * export_to_ghosted_array() functions, if the temporary storage is
+       * handled by the user code.
+       */
+      unsigned int
+      temporary_storage_size() const;
 
       /**
        * Return memory consumption in Byte.
index 0b0426e526c8edde47272c1f3f4072ed325f6c74..958d45f968ce8aed96cf48b67e9a9e7169b6ceeb 100644 (file)
@@ -54,13 +54,21 @@ namespace Utilities
 
 
     std::pair<unsigned int, unsigned int>
-    NoncontiguousPartitioner::n_targets()
+    NoncontiguousPartitioner::n_targets() const
     {
       return {send_ranks.size(), recv_ranks.size()};
     }
 
 
 
+    unsigned int
+    NoncontiguousPartitioner::temporary_storage_size() const
+    {
+      return send_ptr.back();
+    }
+
+
+
     types::global_dof_index
     NoncontiguousPartitioner::memory_consumption()
     {
@@ -252,7 +260,7 @@ namespace Utilities
         requests.resize(send_ranks.size() + recv_ranks.size());
 
       if (this->buffers.size() != send_ptr.back() * sizeof(Number))
-        this->buffers.resize(send_ptr.back() * sizeof(Number), 0);
+        this->buffers.resize(this->temporary_storage_size() * sizeof(Number));
 
       // perform actual exchange
       this->template export_to_ghosted_array<Number>(

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.