]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move operator== from a test to the CellData class itself.
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 13 Sep 2019 15:35:50 +0000 (09:35 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 13 Sep 2019 15:37:42 +0000 (09:37 -0600)
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
source/grid/tria.cc
tests/serialization/cell_data_1.cc

index b47e65a82262bc60ee9e05ed8aa594ec04e3fc30..052ba1b2c848a239ead2eeb554e5ce7f6855c4e9 100644 (file)
@@ -192,6 +192,12 @@ struct CellData
    */
   CellData();
 
+  /**
+   * Comparison operator.
+   */
+  bool
+  operator==(const CellData<structdim> &other) const;
+
   /**
    * Boost serialization function
    */
@@ -4118,18 +4124,6 @@ private:
 #ifndef DOXYGEN
 
 
-template <int structdim>
-inline CellData<structdim>::CellData()
-{
-  for (unsigned int i = 0; i < GeometryInfo<structdim>::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 <int structdim>
 template <class Archive>
 void
index 17efe915c0b3322a888f6abaf630cfad85e15603..b355cade3be1b45e54aa5376e99b319e0b413d7b 100644 (file)
 
 DEAL_II_NAMESPACE_OPEN
 
+
+template <int structdim>
+CellData<structdim>::CellData()
+  : material_id(0)
+  , manifold_id(numbers::flat_manifold_id)
+{
+  for (unsigned int i = 0; i < GeometryInfo<structdim>::vertices_per_cell; ++i)
+    vertices[i] = numbers::invalid_unsigned_int;
+}
+
+
+
+template <int structdim>
+bool
+CellData<structdim>::operator==(const CellData<structdim> &other) const
+{
+  for (unsigned int i = 0; i < GeometryInfo<structdim>::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
 {
index 472d63d0f4ae41b3f3d6dc6e4ce69b13d842e13b..13802efbd395101746bcb2b903edda182b8b8816 100644 (file)
 
 #include "serialization.h"
 
-namespace dealii
-{
-  template <int structdim>
-  bool
-  operator==(const CellData<structdim> &t1, const CellData<structdim> &t2)
-  {
-    for (unsigned int i = 0; i < GeometryInfo<structdim>::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 <int structdim>
 void

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.