From: Peter Munch Date: Mon, 28 Oct 2019 14:01:32 +0000 (+0100) Subject: Add copy addignment to MatrixFree::AdditionalData X-Git-Tag: v9.2.0-rc1~931^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aff09f4f4f06c4dab397e24ae36aa48afb01c61b;p=dealii.git Add copy addignment to MatrixFree::AdditionalData --- diff --git a/include/deal.II/matrix_free/matrix_free.h b/include/deal.II/matrix_free/matrix_free.h index b31b0c3b35..ef0003be65 100644 --- a/include/deal.II/matrix_free/matrix_free.h +++ b/include/deal.II/matrix_free/matrix_free.h @@ -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 index 0000000000..85f573fa83 --- /dev/null +++ b/tests/matrix_free/additional_data_copy.cc @@ -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 + +#include "../tests.h" + +std::ofstream logfile("output"); + +template +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>::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 index 0000000000..8b13789179 --- /dev/null +++ b/tests/matrix_free/additional_data_copy.output @@ -0,0 +1 @@ +