From: Peter Munch Date: Fri, 13 Sep 2019 08:04:29 +0000 (+0200) Subject: Add boost serialization for ConstructionData X-Git-Tag: v9.2.0-rc1~1078^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7de93b7eef8ca701111ca061181d9cecfebc585e;p=dealii.git Add boost serialization for ConstructionData --- diff --git a/doc/news/changes/minor/20190913PeterMunch-1 b/doc/news/changes/minor/20190913PeterMunch-1 new file mode 100644 index 0000000000..486bf7dc79 --- /dev/null +++ b/doc/news/changes/minor/20190913PeterMunch-1 @@ -0,0 +1,4 @@ +New: Add Boost serialization function to dealii::fullydistributed::CellData and +dealii::fullydistributed::ConstructionData. +
+(Peter Munch, 2019/09/13) diff --git a/include/deal.II/distributed/fully_distributed_tria.h b/include/deal.II/distributed/fully_distributed_tria.h index eef0b55d2d..b035b298bc 100644 --- a/include/deal.II/distributed/fully_distributed_tria.h +++ b/include/deal.II/distributed/fully_distributed_tria.h @@ -85,6 +85,13 @@ namespace parallel */ CellData() = default; + /** + * Boost serialization function + */ + template + void + serialize(Archive &ar, const unsigned int /*version*/); + /** * Unique CellID of the cell. */ @@ -118,7 +125,8 @@ namespace parallel * * @note Only used for 3D. */ - std::array::quads_per_cell> + std::array::quads_per_cell> manifold_quad_ids; /** @@ -139,6 +147,13 @@ namespace parallel template struct ConstructionData { + /** + * Boost serialization function + */ + template + void + serialize(Archive &ar, const unsigned int /*version*/); + /** * Cells of the locally-relevant coarse-grid triangulation. */ @@ -385,6 +400,42 @@ namespace parallel currently_processing_prepare_coarsening_and_refinement_for_internal_usage; }; + +#ifndef DOXYGEN + + template + template + void + CellData::serialize(Archive &ar, const unsigned int /*version*/) + { + ar &id; + ar &subdomain_id; + ar &level_subdomain_id; + ar &manifold_id; + if (dim >= 2) + ar &manifold_line_ids; + if (dim >= 3) + ar &manifold_quad_ids; + ar &boundary_ids; + } + + + template + template + void + ConstructionData::serialize(Archive &ar, + const unsigned int /*version*/) + { + ar &coarse_cells; + ar &coarse_cell_vertices; + ar &coarse_cell_index_to_coarse_cell_id; + ar &cell_infos; + ar &settings; + } + + +#endif + } // namespace fullydistributed } // namespace parallel diff --git a/tests/fullydistributed_grids/tests.h b/tests/fullydistributed_grids/tests.h index 67cdbd71bb..4ba696fc90 100644 --- a/tests/fullydistributed_grids/tests.h +++ b/tests/fullydistributed_grids/tests.h @@ -72,4 +72,55 @@ print_statistics(const DoFHandler &dof_handler, deallog << std::endl; } +namespace dealii +{ + namespace parallel + { + namespace fullydistributed + { + template + bool + operator==(const CellData &t1, const CellData &t2) + { + if (t1.id != t2.id) + return false; + if (t1.subdomain_id != t2.subdomain_id) + return false; + if (t1.level_subdomain_id != t2.level_subdomain_id) + return false; + if (t1.manifold_id != t2.manifold_id) + return false; + if (dim >= 2 && t1.manifold_line_ids != t2.manifold_line_ids) + return false; + if (dim >= 3 && t1.manifold_quad_ids != t2.manifold_quad_ids) + return false; + if (t1.boundary_ids != t2.boundary_ids) + return false; + + return true; + } + + template + bool + operator==(const ConstructionData &t1, + const ConstructionData &t2) + { + if (t1.coarse_cells != t2.coarse_cells) + return false; + if (t1.coarse_cell_vertices != t2.coarse_cell_vertices) + return false; + if (t1.coarse_cell_index_to_coarse_cell_id != + t2.coarse_cell_index_to_coarse_cell_id) + return false; + if (t1.cell_infos != t2.cell_infos) + return false; + if (t1.settings != t2.settings) + return false; + + return true; + } + } // namespace fullydistributed + } // namespace parallel +} // namespace dealii + #endif diff --git a/tests/serialization/parallel_fullydistributed_construction_data_1.cc b/tests/serialization/parallel_fullydistributed_construction_data_1.cc new file mode 100644 index 0000000000..67d52e1463 --- /dev/null +++ b/tests/serialization/parallel_fullydistributed_construction_data_1.cc @@ -0,0 +1,79 @@ +// --------------------------------------------------------------------- +// +// 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. +// +// --------------------------------------------------------------------- + + +// check serialization for ConstructionData + +#include +#include +#include + +#include +#include +#include + +#include + +#include "../fullydistributed_grids/tests.h" +#include "serialization.h" + +using namespace dealii; + +template +void +test(MPI_Comm comm) +{ + // create serial triangulation + Triangulation basetria; + GridGenerator::hyper_cube(basetria); + basetria.refine_global(1); + + GridTools::partition_triangulation_zorder( + Utilities::MPI::n_mpi_processes(comm), basetria); + + auto t1 = parallel::fullydistributed::Utilities:: + create_construction_data_from_triangulation(basetria, comm); + + // compare equal ConstructionDatas + auto t2 = t1; + verify(t1, t2); + + basetria.refine_global(1); + + GridTools::partition_triangulation_zorder( + Utilities::MPI::n_mpi_processes(comm), basetria); + + auto t3 = parallel::fullydistributed::Utilities:: + create_construction_data_from_triangulation(basetria, comm); + + // compare different ConstructionDatas + verify(t1, t3); +} + + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll all; + deallog << std::setprecision(3); + const MPI_Comm comm = MPI_COMM_WORLD; + + test<1>(comm); + test<2>(comm); + test<3>(comm); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/parallel_fullydistributed_construction_data_1.output b/tests/serialization/parallel_fullydistributed_construction_data_1.output new file mode 100644 index 0000000000..a636cf52b7 --- /dev/null +++ b/tests/serialization/parallel_fullydistributed_construction_data_1.output @@ -0,0 +1,14 @@ + +DEAL:0::0 0 0 0 2 0 0 0 2 0 2 0 0 4294967295 2 2 1 0 0 4294967295 0 0 3 0 0 0 0 0 1 0 0 0.00000000000000000e+00 1 1.00000000000000000e+00 1 5.00000000000000000e-01 2 0 0 1 0 0 1 0 0 0 2 0 0 0 0 0 4 0 1 0 0 0 4294967295 4294967295 0 0 1 0 0 0 0 0 4 1 1 0 0 0 4294967295 4294967295 1 0 1 1 0 + +DEAL:0::0 0 0 0 2 0 0 0 2 0 2 0 0 4294967295 2 2 1 0 0 4294967295 0 0 3 0 0 0 0 0 1 0 0 0.00000000000000000e+00 1 1.00000000000000000e+00 1 5.00000000000000000e-01 2 0 0 1 0 0 1 0 0 0 2 0 0 0 0 0 4 0 1 0 0 0 4294967295 4294967295 0 0 1 0 0 0 0 0 4 1 1 0 0 0 4294967295 4294967295 1 0 1 1 0 + +DEAL:0::0 0 0 0 4 0 0 0 4 0 4 5 8 0 0 4294967295 4 4 1 8 6 0 0 4294967295 4 5 8 2 7 0 0 4294967295 4 8 6 7 3 0 0 4294967295 0 0 9 0 0 0 0 0 2 0 0 0.00000000000000000e+00 0.00000000000000000e+00 2 1.00000000000000000e+00 0.00000000000000000e+00 2 0.00000000000000000e+00 1.00000000000000000e+00 2 1.00000000000000000e+00 1.00000000000000000e+00 2 5.00000000000000000e-01 0.00000000000000000e+00 2 0.00000000000000000e+00 5.00000000000000000e-01 2 1.00000000000000000e+00 5.00000000000000000e-01 2 5.00000000000000000e-01 1.00000000000000000e+00 2 5.00000000000000000e-01 5.00000000000000000e-01 4 0 0 1 2 3 0 0 1 0 0 0 4 0 0 0 0 0 4 0 2 0 0 0 4294967295 4294967295 4 4294967295 4294967295 4294967295 4294967295 0 0 2 0 0 0 0 0 2 0 4 1 2 0 0 0 4294967295 4294967295 4 4294967295 4294967295 4294967295 4294967295 2 0 1 0 2 0 4 2 2 0 0 0 4294967295 4294967295 4 4294967295 4294967295 4294967295 4294967295 2 0 0 0 3 0 4 3 2 0 0 0 4294967295 4294967295 4 4294967295 4294967295 4294967295 4294967295 2 0 1 0 3 0 0 + +DEAL:0::0 0 0 0 4 0 0 0 4 0 4 5 8 0 0 4294967295 4 4 1 8 6 0 0 4294967295 4 5 8 2 7 0 0 4294967295 4 8 6 7 3 0 0 4294967295 0 0 9 0 0 0 0 0 2 0 0 0.00000000000000000e+00 0.00000000000000000e+00 2 1.00000000000000000e+00 0.00000000000000000e+00 2 0.00000000000000000e+00 1.00000000000000000e+00 2 1.00000000000000000e+00 1.00000000000000000e+00 2 5.00000000000000000e-01 0.00000000000000000e+00 2 0.00000000000000000e+00 5.00000000000000000e-01 2 1.00000000000000000e+00 5.00000000000000000e-01 2 5.00000000000000000e-01 1.00000000000000000e+00 2 5.00000000000000000e-01 5.00000000000000000e-01 4 0 0 1 2 3 0 0 1 0 0 0 4 0 0 0 0 0 4 0 2 0 0 0 4294967295 4294967295 4 4294967295 4294967295 4294967295 4294967295 0 0 2 0 0 0 0 0 2 0 4 1 2 0 0 0 4294967295 4294967295 4 4294967295 4294967295 4294967295 4294967295 2 0 1 0 2 0 4 2 2 0 0 0 4294967295 4294967295 4 4294967295 4294967295 4294967295 4294967295 2 0 0 0 3 0 4 3 2 0 0 0 4294967295 4294967295 4 4294967295 4294967295 4294967295 4294967295 2 0 1 0 3 0 0 + +DEAL:0::0 0 0 0 8 0 0 0 8 0 8 9 21 10 20 22 26 0 0 4294967295 8 8 1 21 11 20 12 26 23 0 0 4294967295 8 9 21 2 13 22 26 14 24 0 0 4294967295 8 21 11 13 3 26 23 24 15 0 0 4294967295 8 10 20 22 26 4 16 17 25 0 0 4294967295 8 20 12 26 23 16 5 25 18 0 0 4294967295 8 22 26 14 24 17 25 6 19 0 0 4294967295 8 26 23 24 15 25 18 19 7 0 0 4294967295 0 0 27 0 0 0 0 0 3 0 0 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 3 1.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 3 0.00000000000000000e+00 1.00000000000000000e+00 0.00000000000000000e+00 3 1.00000000000000000e+00 1.00000000000000000e+00 0.00000000000000000e+00 3 0.00000000000000000e+00 0.00000000000000000e+00 1.00000000000000000e+00 3 1.00000000000000000e+00 0.00000000000000000e+00 1.00000000000000000e+00 3 0.00000000000000000e+00 1.00000000000000000e+00 1.00000000000000000e+00 3 1.00000000000000000e+00 1.00000000000000000e+00 1.00000000000000000e+00 3 5.00000000000000000e-01 0.00000000000000000e+00 0.00000000000000000e+00 3 0.00000000000000000e+00 5.00000000000000000e-01 0.00000000000000000e+00 3 0.00000000000000000e+00 0.00000000000000000e+00 5.00000000000000000e-01 3 1.00000000000000000e+00 5.00000000000000000e-01 0.00000000000000000e+00 3 1.00000000000000000e+00 0.00000000000000000e+00 5.00000000000000000e-01 3 5.00000000000000000e-01 1.00000000000000000e+00 0.00000000000000000e+00 3 0.00000000000000000e+00 1.00000000000000000e+00 5.00000000000000000e-01 3 1.00000000000000000e+00 1.00000000000000000e+00 5.00000000000000000e-01 3 5.00000000000000000e-01 0.00000000000000000e+00 1.00000000000000000e+00 3 0.00000000000000000e+00 5.00000000000000000e-01 1.00000000000000000e+00 3 1.00000000000000000e+00 5.00000000000000000e-01 1.00000000000000000e+00 3 5.00000000000000000e-01 1.00000000000000000e+00 1.00000000000000000e+00 3 5.00000000000000000e-01 0.00000000000000000e+00 5.00000000000000000e-01 3 5.00000000000000000e-01 5.00000000000000000e-01 0.00000000000000000e+00 3 0.00000000000000000e+00 5.00000000000000000e-01 5.00000000000000000e-01 3 1.00000000000000000e+00 5.00000000000000000e-01 5.00000000000000000e-01 3 5.00000000000000000e-01 1.00000000000000000e+00 5.00000000000000000e-01 3 5.00000000000000000e-01 5.00000000000000000e-01 1.00000000000000000e+00 3 5.00000000000000000e-01 5.00000000000000000e-01 5.00000000000000000e-01 8 0 0 1 2 3 4 5 6 7 0 0 1 0 0 0 8 0 0 0 0 0 4 0 3 0 0 0 4294967295 4294967295 0 0 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 0 0 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 0 0 3 0 0 0 0 0 2 0 4 0 4 1 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 1 0 2 0 4 0 4 2 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 0 0 3 0 4 0 4 3 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 1 0 3 0 4 0 4 4 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 0 0 2 0 5 0 4 5 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 1 0 2 0 5 0 4 6 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 0 0 3 0 5 0 4 7 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 1 0 3 0 5 0 0 + +DEAL:0::0 0 0 0 8 0 0 0 8 0 8 9 21 10 20 22 26 0 0 4294967295 8 8 1 21 11 20 12 26 23 0 0 4294967295 8 9 21 2 13 22 26 14 24 0 0 4294967295 8 21 11 13 3 26 23 24 15 0 0 4294967295 8 10 20 22 26 4 16 17 25 0 0 4294967295 8 20 12 26 23 16 5 25 18 0 0 4294967295 8 22 26 14 24 17 25 6 19 0 0 4294967295 8 26 23 24 15 25 18 19 7 0 0 4294967295 0 0 27 0 0 0 0 0 3 0 0 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 3 1.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 3 0.00000000000000000e+00 1.00000000000000000e+00 0.00000000000000000e+00 3 1.00000000000000000e+00 1.00000000000000000e+00 0.00000000000000000e+00 3 0.00000000000000000e+00 0.00000000000000000e+00 1.00000000000000000e+00 3 1.00000000000000000e+00 0.00000000000000000e+00 1.00000000000000000e+00 3 0.00000000000000000e+00 1.00000000000000000e+00 1.00000000000000000e+00 3 1.00000000000000000e+00 1.00000000000000000e+00 1.00000000000000000e+00 3 5.00000000000000000e-01 0.00000000000000000e+00 0.00000000000000000e+00 3 0.00000000000000000e+00 5.00000000000000000e-01 0.00000000000000000e+00 3 0.00000000000000000e+00 0.00000000000000000e+00 5.00000000000000000e-01 3 1.00000000000000000e+00 5.00000000000000000e-01 0.00000000000000000e+00 3 1.00000000000000000e+00 0.00000000000000000e+00 5.00000000000000000e-01 3 5.00000000000000000e-01 1.00000000000000000e+00 0.00000000000000000e+00 3 0.00000000000000000e+00 1.00000000000000000e+00 5.00000000000000000e-01 3 1.00000000000000000e+00 1.00000000000000000e+00 5.00000000000000000e-01 3 5.00000000000000000e-01 0.00000000000000000e+00 1.00000000000000000e+00 3 0.00000000000000000e+00 5.00000000000000000e-01 1.00000000000000000e+00 3 1.00000000000000000e+00 5.00000000000000000e-01 1.00000000000000000e+00 3 5.00000000000000000e-01 1.00000000000000000e+00 1.00000000000000000e+00 3 5.00000000000000000e-01 0.00000000000000000e+00 5.00000000000000000e-01 3 5.00000000000000000e-01 5.00000000000000000e-01 0.00000000000000000e+00 3 0.00000000000000000e+00 5.00000000000000000e-01 5.00000000000000000e-01 3 1.00000000000000000e+00 5.00000000000000000e-01 5.00000000000000000e-01 3 5.00000000000000000e-01 1.00000000000000000e+00 5.00000000000000000e-01 3 5.00000000000000000e-01 5.00000000000000000e-01 1.00000000000000000e+00 3 5.00000000000000000e-01 5.00000000000000000e-01 5.00000000000000000e-01 8 0 0 1 2 3 4 5 6 7 0 0 1 0 0 0 8 0 0 0 0 0 4 0 3 0 0 0 4294967295 4294967295 0 0 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 0 0 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 0 0 3 0 0 0 0 0 2 0 4 0 4 1 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 1 0 2 0 4 0 4 2 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 0 0 3 0 4 0 4 3 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 1 0 3 0 4 0 4 4 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 0 0 2 0 5 0 4 5 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 1 0 2 0 5 0 4 6 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 0 0 3 0 5 0 4 7 3 0 0 0 4294967295 4294967295 12 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 6 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 3 0 1 0 3 0 5 0 0 + +DEAL:0::OK