From: Wolfgang Bangerth Date: Fri, 13 Sep 2019 15:35:50 +0000 (-0600) Subject: Move operator== from a test to the CellData class itself. X-Git-Tag: v9.2.0-rc1~1110^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=edc17cb69b34fa1db239f4b6980ad09678f8bfdb;p=dealii.git 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. --- 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