]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add copy addignment to MatrixFree::AdditionalData 8971/head
authorPeter Munch <peterrmuench@gmail.com>
Mon, 28 Oct 2019 14:01:32 +0000 (15:01 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Thu, 31 Oct 2019 18:23:59 +0000 (19:23 +0100)
include/deal.II/matrix_free/matrix_free.h
tests/matrix_free/additional_data_copy.cc [new file with mode: 0644]
tests/matrix_free/additional_data_copy.output [new file with mode: 0644]

index b31b0c3b352514cd63972d4f74afedad6f35f2b5..ef0003be65a1fe76edae4abde64ab05fb4a390b5 100644 (file)
@@ -267,6 +267,34 @@ public:
           other.cell_vectorization_categories_strict)
     {}
 
+    /**
+     * Copy assignment.
+     */
+    AdditionalData &
+    operator=(const AdditionalData &other)
+    {
+      tasks_parallel_scheme = other.tasks_parallel_scheme;
+      tasks_block_size      = other.tasks_block_size;
+      mapping_update_flags  = other.mapping_update_flags;
+      mapping_update_flags_boundary_faces =
+        other.mapping_update_flags_boundary_faces;
+      mapping_update_flags_inner_faces = other.mapping_update_flags_inner_faces;
+      mapping_update_flags_faces_by_cells =
+        other.mapping_update_flags_faces_by_cells;
+      mg_level            = other.mg_level;
+      store_plain_indices = other.store_plain_indices;
+      initialize_indices  = other.initialize_indices;
+      initialize_mapping  = other.initialize_mapping;
+      overlap_communication_computation =
+        other.overlap_communication_computation;
+      hold_all_faces_to_owned_cells = other.hold_all_faces_to_owned_cells;
+      cell_vectorization_category   = other.cell_vectorization_category;
+      cell_vectorization_categories_strict =
+        other.cell_vectorization_categories_strict;
+
+      return *this;
+    }
+
     /**
      * Set the scheme for task parallelism. There are four options available.
      * If set to @p none, the operator application is done in serial without
diff --git a/tests/matrix_free/additional_data_copy.cc b/tests/matrix_free/additional_data_copy.cc
new file mode 100644 (file)
index 0000000..85f573f
--- /dev/null
@@ -0,0 +1,89 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+
+// test copy constructor and copy assignment of MatrixFree::AdditionalData
+
+#include <deal.II/matrix_free/matrix_free.h>
+
+#include "../tests.h"
+
+std::ofstream logfile("output");
+
+template <typename T>
+bool
+operator==(const T &lhs, const T &rhs)
+{
+  return lhs.tasks_parallel_scheme == rhs.tasks_parallel_scheme &&
+         lhs.tasks_block_size == rhs.tasks_block_size &&
+         lhs.mapping_update_flags == rhs.mapping_update_flags &&
+         lhs.mapping_update_flags_boundary_faces ==
+           rhs.mapping_update_flags_boundary_faces &&
+         lhs.mapping_update_flags_inner_faces ==
+           rhs.mapping_update_flags_inner_faces &&
+         lhs.mapping_update_flags_faces_by_cells ==
+           rhs.mapping_update_flags_faces_by_cells &&
+         lhs.mg_level == rhs.mg_level &&
+         lhs.level_mg_handler == rhs.level_mg_handler &&
+         lhs.store_plain_indices == rhs.store_plain_indices &&
+         lhs.initialize_indices == rhs.initialize_indices &&
+         lhs.initialize_mapping == rhs.initialize_mapping &&
+         lhs.overlap_communication_computation ==
+           rhs.overlap_communication_computation &&
+         lhs.hold_all_faces_to_owned_cells ==
+           rhs.hold_all_faces_to_owned_cells &&
+         lhs.cell_vectorization_categories_strict ==
+           rhs.cell_vectorization_categories_strict &&
+         lhs.cell_vectorization_category == rhs.cell_vectorization_category;
+}
+
+int
+main()
+{
+  initlog();
+
+  using AD =
+    typename MatrixFree<2, double, VectorizedArray<double>>::AdditionalData;
+
+  AD ad;
+  ad.tasks_parallel_scheme = AD::TasksParallelScheme::partition_color;
+  ad.tasks_block_size      = 100;
+  ad.mapping_update_flags  = update_values;
+  ad.mapping_update_flags_boundary_faces  = update_values;
+  ad.mapping_update_flags_inner_faces     = update_values;
+  ad.mapping_update_flags_faces_by_cells  = update_values;
+  ad.mg_level                             = 10;
+  ad.store_plain_indices                  = false;
+  ad.initialize_indices                   = false;
+  ad.initialize_mapping                   = false;
+  ad.overlap_communication_computation    = false;
+  ad.hold_all_faces_to_owned_cells        = true;
+  ad.cell_vectorization_categories_strict = true;
+  ad.cell_vectorization_category          = {1, 2, 3};
+
+  {
+    // copy constructor
+    AD copy(ad);
+    Assert(copy == ad, ExcInternalError());
+  }
+
+  {
+    // copy assignment
+    AD copy;
+    copy = ad;
+    Assert(copy == ad, ExcInternalError());
+  }
+}
diff --git a/tests/matrix_free/additional_data_copy.output b/tests/matrix_free/additional_data_copy.output
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+

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.