From d474cc49e8607bf7d421c1ff432b2abbf54bbd03 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Fri, 13 Sep 2019 07:55:21 +0200 Subject: [PATCH] Add Boost serialization function to CellData --- doc/news/changes/minor/20190913PeterMunch | 3 + include/deal.II/grid/tria.h | 18 ++++ tests/serialization/cell_data_1.cc | 105 ++++++++++++++++++++++ tests/serialization/cell_data_1.output | 54 +++++++++++ 4 files changed, 180 insertions(+) create mode 100644 doc/news/changes/minor/20190913PeterMunch create mode 100644 tests/serialization/cell_data_1.cc create mode 100644 tests/serialization/cell_data_1.output diff --git a/doc/news/changes/minor/20190913PeterMunch b/doc/news/changes/minor/20190913PeterMunch new file mode 100644 index 0000000000..3efa817380 --- /dev/null +++ b/doc/news/changes/minor/20190913PeterMunch @@ -0,0 +1,3 @@ +New: Add Boost serialization function to CellData. +
+(Peter Munch, 2019/09/13) diff --git a/include/deal.II/grid/tria.h b/include/deal.II/grid/tria.h index 7a65534303..b47e65a822 100644 --- a/include/deal.II/grid/tria.h +++ b/include/deal.II/grid/tria.h @@ -191,6 +191,13 @@ struct CellData * - manifold id to numbers::flat_manifold_id */ CellData(); + + /** + * Boost serialization function + */ + template + void + serialize(Archive &ar, const unsigned int version); }; @@ -4123,6 +4130,17 @@ inline CellData::CellData() manifold_id = numbers::flat_manifold_id; } +template +template +void +CellData::serialize(Archive &ar, const unsigned int /*version*/) +{ + ar &vertices; + ar &material_id; + ar &boundary_id; + ar &manifold_id; +} + namespace internal diff --git a/tests/serialization/cell_data_1.cc b/tests/serialization/cell_data_1.cc new file mode 100644 index 0000000000..472d63d0f4 --- /dev/null +++ b/tests/serialization/cell_data_1.cc @@ -0,0 +1,105 @@ +// --------------------------------------------------------------------- +// +// 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 CellData + +#include + +#include + +#include "serialization.h" + +namespace dealii +{ + template + bool + operator==(const CellData &t1, const CellData &t2) + { + for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; + i++) + if (t1.vertices[i] != t2.vertices[i]) + return false; + + if (t1.material_id != t2.material_id) + return false; + if (t1.boundary_id != t2.boundary_id) + return false; + if (t1.manifold_id != t2.manifold_id) + return false; + return true; + } +} // namespace dealii + +template +void +test() +{ + dealii::CellData t1; + + for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; i++) + t1.vertices[i] = i; + t1.material_id = 0; + t1.boundary_id = 1; + t1.manifold_id = 2; + + { + dealii::CellData t2 = t1; + verify(t1, t2); + } + + // test vertices + for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; i++) + { + dealii::CellData t2 = t1; + t2.vertices[i]++; + verify(t1, t2); + } + + // test material_id + { + dealii::CellData t2 = t1; + t2.material_id++; + verify(t1, t2); + } + + // test boundary_id + { + dealii::CellData t2 = t1; + t2.boundary_id++; + verify(t1, t2); + } + + // test manifold_id + { + dealii::CellData t2 = t1; + t2.manifold_id++; + verify(t1, t2); + } +} + + +int +main() +{ + initlog(); + deallog << std::setprecision(3); + + test<1>(); + test<2>(); + test<3>(); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/cell_data_1.output b/tests/serialization/cell_data_1.output new file mode 100644 index 0000000000..d290d61c82 --- /dev/null +++ b/tests/serialization/cell_data_1.output @@ -0,0 +1,54 @@ + +DEAL::0 0 2 0 1 1 1 2 + +DEAL::0 0 2 0 1 1 1 2 + +DEAL::0 0 2 0 1 1 1 2 + +DEAL::0 0 2 0 1 1 1 2 + +DEAL::0 0 2 0 1 1 1 2 + +DEAL::0 0 2 0 1 1 1 2 + +DEAL::0 0 4 0 1 2 3 1 1 2 + +DEAL::0 0 4 0 1 2 3 1 1 2 + +DEAL::0 0 4 0 1 2 3 1 1 2 + +DEAL::0 0 4 0 1 2 3 1 1 2 + +DEAL::0 0 4 0 1 2 3 1 1 2 + +DEAL::0 0 4 0 1 2 3 1 1 2 + +DEAL::0 0 4 0 1 2 3 1 1 2 + +DEAL::0 0 4 0 1 2 3 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::0 0 8 0 1 2 3 4 5 6 7 1 1 2 + +DEAL::OK -- 2.39.5