From edc17cb69b34fa1db239f4b6980ad09678f8bfdb Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 13 Sep 2019 09:35:50 -0600 Subject: [PATCH] Move operator== from a test to the CellData class itself. This has the advantage that if that class ever gains a new member variable, it is much easier to update the code for operator== since it's obvious that one has to update it. If the code remained in the test, we would almost certainly forget to update it. --- include/deal.II/grid/tria.h | 18 ++++++---------- source/grid/tria.cc | 34 ++++++++++++++++++++++++++++++ tests/serialization/cell_data_1.cc | 20 ------------------ 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/include/deal.II/grid/tria.h b/include/deal.II/grid/tria.h index b47e65a822..052ba1b2c8 100644 --- a/include/deal.II/grid/tria.h +++ b/include/deal.II/grid/tria.h @@ -192,6 +192,12 @@ struct CellData */ CellData(); + /** + * Comparison operator. + */ + bool + operator==(const CellData &other) const; + /** * Boost serialization function */ @@ -4118,18 +4124,6 @@ private: #ifndef DOXYGEN -template -inline CellData::CellData() -{ - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) - vertices[i] = numbers::invalid_unsigned_int; - - material_id = 0; - - // And the manifold to be invalid - manifold_id = numbers::flat_manifold_id; -} - template template void diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 17efe915c0..b355cade3b 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -43,6 +43,40 @@ DEAL_II_NAMESPACE_OPEN + +template +CellData::CellData() + : material_id(0) + , manifold_id(numbers::flat_manifold_id) +{ + for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + vertices[i] = numbers::invalid_unsigned_int; +} + + + +template +bool +CellData::operator==(const CellData &other) const +{ + for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; i++) + if (vertices[i] != other.vertices[i]) + return false; + + if (material_id != other.material_id) + return false; + + if (boundary_id != other.boundary_id) + return false; + + if (manifold_id != other.manifold_id) + return false; + + return true; +} + + + bool SubCellData::check_consistency(const unsigned int dim) const { diff --git a/tests/serialization/cell_data_1.cc b/tests/serialization/cell_data_1.cc index 472d63d0f4..13802efbd3 100644 --- a/tests/serialization/cell_data_1.cc +++ b/tests/serialization/cell_data_1.cc @@ -22,26 +22,6 @@ #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 -- 2.39.5