]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add const to variables and functions.
authorBruno Turcksin <bruno.turcksin@gmail.com>
Tue, 28 Jun 2016 13:12:38 +0000 (09:12 -0400)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 3 Aug 2016 20:34:02 +0000 (16:34 -0400)
include/deal.II/python/cell_accessor_wrapper.h
include/deal.II/python/triangulation_wrapper.h
source/python/cell_accessor_wrapper.cc
source/python/export_cell_accessor.cc
source/python/export_triangulation.cc
source/python/triangulation_wrapper.cc

index 86262fdafbc9aed04fd1cee97f29ff32d1b9608d..770cab14b11e2d95e8a5b586287efdbb56d19fef 100644 (file)
@@ -56,7 +56,7 @@ namespace PyDealII
     /**
      * Get the refine flag.
      */
-    std::string get_refine_flag();
+    std::string get_refine_flag() const;
 
     /**
      * Set the coarsen flag to true or false.
@@ -66,12 +66,12 @@ namespace PyDealII
     /**
      * Get the coarsen flag.
      */
-    bool get_coarsen_flag();
+    bool get_coarsen_flag() const;
 
     /**
      * Get the barycenter of the cell.
      */
-    PointWrapper get_barycenter();
+    PointWrapper get_barycenter() const;
 
     /**
      * Set the material id.
@@ -81,7 +81,7 @@ namespace PyDealII
     /**
      * Get the material id.
      */
-    int get_material_id();
+    int get_material_id() const;
 
     /**
      * Set the ith vertex of the cell to @p point_wrapper.
@@ -91,7 +91,7 @@ namespace PyDealII
     /**
      * Return the ith vertex of the cell.
      */
-    PointWrapper get_vertex(const int i);
+    PointWrapper get_vertex(const int i) const;
 
     /**
      * Set the manifold id.
@@ -101,7 +101,16 @@ namespace PyDealII
     /**
      * Get the manifold id.
      */
-    int get_manifold_id();
+    int get_manifold_id() const;
+
+    /**
+     * Exception.
+     */
+    DeclException2(ExcVertexDoesNotExist,
+                   int, int,
+                   << "Requested vertex number " << arg1
+                   << "does not exist. The largest vertex number "
+                   << "acceptable is "<< arg2-1);
 
   private:
     /**
index d0f1d433da328c1427724c7aa1b01301a4e655d7..fceaef00803ca91c76aa18685b87940300f98a00 100644 (file)
@@ -122,7 +122,7 @@ namespace PyDealII
     void execute_coarsening_and_refinement();
 
     /**
-     * Write grid to the output file @filename according to the given data format.
+     * Write mesh to the output file @filename according to the given data format.
      */
     void write(const std::string &filename, const std::string format) const;
 
index f1afc7e77570d18ce8fb9bf6d81e0db4cb584b45..8859b22fa3a6addcb5742e284c8e58d922efc7a1 100644 (file)
@@ -47,33 +47,17 @@ namespace PyDealII
                          dealii::RefinementPossibilities<dim>::Possibilities::cut_xy));
 #if dim==3
       else if (refinement_case.compare("cut_z") == 0)
-        {
-          AssertThrow(dim == 3,
-                      dealii::ExcMessage("cut_z can only be use for dim equals to 3."));
-          ref_case.reset(new dealii::RefinementCase<3>(
-                           dealii::RefinementPossibilities<3>::Possibilities::cut_z));
-        }
+        ref_case.reset(new dealii::RefinementCase<3>(
+                         dealii::RefinementPossibilities<3>::Possibilities::cut_z));
       else if (refinement_case.compare("cut_xz") == 0)
-        {
-          AssertThrow(dim == 3,
-                      dealii::ExcMessage("cut_xz can only be use for dim equals to 3."));
-          ref_case.reset(new dealii::RefinementCase<3>(
-                           dealii::RefinementPossibilities<3>::Possibilities::cut_xz));
-        }
+        ref_case.reset(new dealii::RefinementCase<3>(
+                         dealii::RefinementPossibilities<3>::Possibilities::cut_xz));
       else if (refinement_case.compare("cut_yz") == 0)
-        {
-          AssertThrow(dim == 3,
-                      dealii::ExcMessage("cut_yz can only be use for dim equals to 3."));
-          ref_case.reset(new dealii::RefinementCase<3>(
-                           dealii::RefinementPossibilities<3>::Possibilities::cut_yz));
-        }
+        ref_case.reset(new dealii::RefinementCase<3>(
+                         dealii::RefinementPossibilities<3>::Possibilities::cut_yz));
       else if (refinement_case.compare("cut_xyz") == 0)
-        {
-          AssertThrow(dim == 3,
-                      dealii::ExcMessage("cut_xyz can only be use for dim equals to 3."));
-          ref_case.reset(new dealii::RefinementCase<3>(
-                           dealii::RefinementPossibilities<3>::Possibilities::cut_xyz));
-        }
+        ref_case.reset(new dealii::RefinementCase<3>(
+                         dealii::RefinementPossibilities<3>::Possibilities::cut_xyz));
 #endif
       else
         AssertThrow(false,
@@ -85,10 +69,10 @@ namespace PyDealII
 
 
     template <int dim, int spacedim>
-    std::string get_refine_flag(void *cell_accessor)
+    std::string get_refine_flag(const void *cell_accessor)
     {
-      dealii::CellAccessor<dim,spacedim> *cell =
-        static_cast<dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
+      const dealii::CellAccessor<dim,spacedim> *cell =
+        static_cast<const dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
 
       std::string refine_flag;
       dealii::RefinementCase<dim> ref_case = cell->refine_flag_set();
@@ -159,10 +143,10 @@ namespace PyDealII
 
 
     template <int dim, int spacedim>
-    bool get_coarsen_flag(void *cell_accessor)
+    bool get_coarsen_flag(const void *cell_accessor)
     {
-      dealii::CellAccessor<dim,spacedim> *cell =
-        static_cast<dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
+      const dealii::CellAccessor<dim,spacedim> *cell =
+        static_cast<const dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
 
       return cell->coarsen_flag_set();
     }
@@ -170,10 +154,10 @@ namespace PyDealII
 
 
     template <int dim, int spacedim>
-    PointWrapper get_barycenter(void *cell_accessor)
+    PointWrapper get_barycenter(const void *cell_accessor)
     {
-      dealii::CellAccessor<dim,spacedim> *cell =
-        static_cast<dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
+      const dealii::CellAccessor<dim,spacedim> *cell =
+        static_cast<const dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
       dealii::Point<spacedim> barycenter = cell->barycenter();
       boost::python::list barycenter_list;
       for (int i=0; i<dim; ++i)
@@ -195,10 +179,10 @@ namespace PyDealII
 
 
     template <int dim, int spacedim>
-    int get_material_id(void *cell_accessor)
+    int get_material_id(const void *cell_accessor)
     {
-      dealii::CellAccessor<dim,spacedim> *cell =
-        static_cast<dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
+      const dealii::CellAccessor<dim,spacedim> *cell =
+        static_cast<const dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
 
       return cell->material_id();
     }
@@ -221,10 +205,10 @@ namespace PyDealII
 
 
     template <int dim, int spacedim>
-    PointWrapper get_vertex(const int i, void *cell_accessor)
+    PointWrapper get_vertex(const int i, const void *cell_accessor)
     {
-      dealii::CellAccessor<dim,spacedim> *cell =
-        static_cast<dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
+      const dealii::CellAccessor<dim,spacedim> *cell =
+        static_cast<const dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
       dealii::Point<spacedim> vertex = cell->vertex(i);
 
       boost::python::list coordinates;
@@ -247,10 +231,10 @@ namespace PyDealII
 
 
     template <int dim, int spacedim>
-    int get_manifold_id(void *cell_accessor)
+    int get_manifold_id(const void *cell_accessor)
     {
-      dealii::CellAccessor<dim,spacedim> *cell =
-        static_cast<dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
+      const dealii::CellAccessor<dim,spacedim> *cell =
+        static_cast<const dealii::CellAccessor<dim,spacedim>*>(cell_accessor);
       cell->manifold_id();
     }
   }
@@ -260,7 +244,7 @@ namespace PyDealII
   CellAccessorWrapper::CellAccessorWrapper(const CellAccessorWrapper &other)
     :
     dim(other.dim),
-    spacedim(other.dim)
+    spacedim(other.spacedim)
   {
     if ((dim == 2) && (spacedim == 2))
       {
@@ -362,7 +346,7 @@ namespace PyDealII
 
 
 
-  std::string CellAccessorWrapper::get_refine_flag()
+  std::string CellAccessorWrapper::get_refine_flag() const
   {
     if ((dim == 2) && (spacedim == 2))
       return internal::get_refine_flag<2,2>(cell_accessor);
@@ -386,7 +370,7 @@ namespace PyDealII
 
 
 
-  bool CellAccessorWrapper::get_coarsen_flag()
+  bool CellAccessorWrapper::get_coarsen_flag() const
   {
     if ((dim == 2) && (spacedim == 2))
       return internal::get_coarsen_flag<2,2>(cell_accessor);
@@ -397,7 +381,7 @@ namespace PyDealII
   }
 
 
-  PointWrapper CellAccessorWrapper::get_barycenter()
+  PointWrapper CellAccessorWrapper::get_barycenter() const
   {
     if ((dim == 2) && (spacedim == 2))
       return internal::get_barycenter<2,2>(cell_accessor);
@@ -423,7 +407,7 @@ namespace PyDealII
 
 
 
-  int CellAccessorWrapper::get_material_id()
+  int CellAccessorWrapper::get_material_id() const
   {
     if ((dim == 2) && (spacedim == 2))
       return internal::get_material_id<2,2>(cell_accessor);
@@ -439,7 +423,7 @@ namespace PyDealII
                                        PointWrapper &point_wrapper)
   {
     AssertThrow(i<std::pow(2,dim),
-                dealii::ExcMessage("The vertex does not exist."));
+                ExcVertexDoesNotExist(i, std::pow(2,dim)));
     if ((dim == 2) && (spacedim == 2))
       internal::set_vertex<2,2>(i, point_wrapper, cell_accessor);
     else if ((dim == 2) && (spacedim == 3))
@@ -450,10 +434,10 @@ namespace PyDealII
 
 
 
-  PointWrapper CellAccessorWrapper::get_vertex(const int i)
+  PointWrapper CellAccessorWrapper::get_vertex(const int i) const
   {
     AssertThrow(i<std::pow(2,dim),
-                dealii::ExcMessage("The vertex does not exist."));
+                ExcVertexDoesNotExist(i, std::pow(2,dim)));
     if ((dim == 2) && (spacedim == 2))
       return internal::get_vertex<2,2>(i, cell_accessor);
     else if ((dim == 2) && (spacedim == 3))
@@ -476,7 +460,7 @@ namespace PyDealII
 
 
 
-  int CellAccessorWrapper::get_manifold_id()
+  int CellAccessorWrapper::get_manifold_id() const
   {
     if ((dim == 2) && (spacedim == 2))
       internal::get_manifold_id<2,2>(cell_accessor);
index 05c82d9ba41d2cc0bae039a8cb1c9b34bcd10e0d..858b78811074295a54eafed4bf01ca73273c672e 100644 (file)
@@ -25,16 +25,16 @@ namespace PyDealII
                                                boost::python::init<TriangulationWrapper &, const int, const int> ())
     .add_property("refine_flag", &CellAccessorWrapper::get_refine_flag,
                   &CellAccessorWrapper::set_refine_flag,
-                  "Get the refine_flag of the cell. The possibilities are in 2D: isotropic, no_refinement, cut_x, cut_y, and cut_xy and in 3D: isotropic, no_refinement, cut_x, cut_y, cut_z, cut_xy, cut_xz, cut_yz, and cut_xyz.")
+                  "Get/Set the refine_flag of the cell. The possibilities are in 2D: isotropic, no_refinement, cut_x, cut_y, and cut_xy and in 3D: isotropic, no_refinement, cut_x, cut_y, cut_z, cut_xy, cut_xz, cut_yz, and cut_xyz.")
     .add_property("coarsen_flag", &CellAccessorWrapper::get_coarsen_flag,
                   &CellAccessorWrapper::set_coarsen_flag,
-                  "Get the coarsen_flag of the cell.")
+                  "Get/Set the coarsen_flag of the cell.")
     .add_property("material_id", &CellAccessorWrapper::get_material_id,
                   &CellAccessorWrapper::set_material_id,
-                  "Get the material_id of the cell.")
+                  "Get/Set the material_id of the cell.")
     .add_property("manifold_id", &CellAccessorWrapper::get_manifold_id,
                   &CellAccessorWrapper::set_manifold_id,
-                  "Get the manifold_id of the cell.")
+                  "Get/Set the manifold_id of the cell.")
     .def("barycenter", &CellAccessorWrapper::get_barycenter,
          "Return the barycenter of the current cell.",
          boost::python::args("self"))
index 63b855cbd6c0f48b84b7b5085d739bd38032568b..8bc6cdca319b9b3f43b0ba1244ad5e420e92d266 100644 (file)
@@ -88,7 +88,7 @@ namespace PyDealII
          boost::python::args("self"))
     .def("write",
          &TriangulationWrapper::write,
-         "Write grid to the output file according to the given data format. The possible formats are: none, dx, gnuplot, eps, ucd, xfig, msh, svg, mathgl, vtk, and vtu.",
+         "Write the mesh to the output file according to the given data format. The possible formats are: none, dx, gnuplot, eps, ucd, xfig, msh, svg, mathgl, vtk, and vtu.",
          boost::python::args("self", "filename", "format"))
     .def("save",
          &TriangulationWrapper::save,
index eb1010def362f77ec6caf8cc82540bd30a85d8ac..3a749cd5a9d9c8402fd00bf97f7b86a5a09318d4 100644 (file)
@@ -188,10 +188,10 @@ namespace PyDealII
     template <int dim, int spacedim>
     void write(const std::string &filename,
                const std::string &format,
-               void              *triangulation)
+               const void        *triangulation)
     {
-      dealii::Triangulation<dim,spacedim> *tria =
-        static_cast<dealii::Triangulation<dim,spacedim>*>(triangulation);
+      const dealii::Triangulation<dim,spacedim> *tria =
+        static_cast<const dealii::Triangulation<dim,spacedim>*>(triangulation);
 
       dealii::GridOut::OutputFormat output_format;
       if (format.compare("dx") == 0)

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.