From c9d2c8eda9702f376d9aede8eb4ba8051d216ced Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Tue, 28 Jun 2016 09:12:38 -0400 Subject: [PATCH] Add const to variables and functions. --- .../deal.II/python/cell_accessor_wrapper.h | 21 +++-- .../deal.II/python/triangulation_wrapper.h | 2 +- source/python/cell_accessor_wrapper.cc | 86 ++++++++----------- source/python/export_cell_accessor.cc | 8 +- source/python/export_triangulation.cc | 2 +- source/python/triangulation_wrapper.cc | 6 +- 6 files changed, 59 insertions(+), 66 deletions(-) diff --git a/include/deal.II/python/cell_accessor_wrapper.h b/include/deal.II/python/cell_accessor_wrapper.h index 86262fdafb..770cab14b1 100644 --- a/include/deal.II/python/cell_accessor_wrapper.h +++ b/include/deal.II/python/cell_accessor_wrapper.h @@ -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: /** diff --git a/include/deal.II/python/triangulation_wrapper.h b/include/deal.II/python/triangulation_wrapper.h index d0f1d433da..fceaef0080 100644 --- a/include/deal.II/python/triangulation_wrapper.h +++ b/include/deal.II/python/triangulation_wrapper.h @@ -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; diff --git a/source/python/cell_accessor_wrapper.cc b/source/python/cell_accessor_wrapper.cc index f1afc7e775..8859b22fa3 100644 --- a/source/python/cell_accessor_wrapper.cc +++ b/source/python/cell_accessor_wrapper.cc @@ -47,33 +47,17 @@ namespace PyDealII dealii::RefinementPossibilities::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 - std::string get_refine_flag(void *cell_accessor) + std::string get_refine_flag(const void *cell_accessor) { - dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + const dealii::CellAccessor *cell = + static_cast*>(cell_accessor); std::string refine_flag; dealii::RefinementCase ref_case = cell->refine_flag_set(); @@ -159,10 +143,10 @@ namespace PyDealII template - bool get_coarsen_flag(void *cell_accessor) + bool get_coarsen_flag(const void *cell_accessor) { - dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + const dealii::CellAccessor *cell = + static_cast*>(cell_accessor); return cell->coarsen_flag_set(); } @@ -170,10 +154,10 @@ namespace PyDealII template - PointWrapper get_barycenter(void *cell_accessor) + PointWrapper get_barycenter(const void *cell_accessor) { - dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + const dealii::CellAccessor *cell = + static_cast*>(cell_accessor); dealii::Point barycenter = cell->barycenter(); boost::python::list barycenter_list; for (int i=0; i - int get_material_id(void *cell_accessor) + int get_material_id(const void *cell_accessor) { - dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + const dealii::CellAccessor *cell = + static_cast*>(cell_accessor); return cell->material_id(); } @@ -221,10 +205,10 @@ namespace PyDealII template - PointWrapper get_vertex(const int i, void *cell_accessor) + PointWrapper get_vertex(const int i, const void *cell_accessor) { - dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + const dealii::CellAccessor *cell = + static_cast*>(cell_accessor); dealii::Point vertex = cell->vertex(i); boost::python::list coordinates; @@ -247,10 +231,10 @@ namespace PyDealII template - int get_manifold_id(void *cell_accessor) + int get_manifold_id(const void *cell_accessor) { - dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + const dealii::CellAccessor *cell = + static_cast*>(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(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(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); diff --git a/source/python/export_cell_accessor.cc b/source/python/export_cell_accessor.cc index 05c82d9ba4..858b788110 100644 --- a/source/python/export_cell_accessor.cc +++ b/source/python/export_cell_accessor.cc @@ -25,16 +25,16 @@ namespace PyDealII boost::python::init ()) .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")) diff --git a/source/python/export_triangulation.cc b/source/python/export_triangulation.cc index 63b855cbd6..8bc6cdca31 100644 --- a/source/python/export_triangulation.cc +++ b/source/python/export_triangulation.cc @@ -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, diff --git a/source/python/triangulation_wrapper.cc b/source/python/triangulation_wrapper.cc index eb1010def3..3a749cd5a9 100644 --- a/source/python/triangulation_wrapper.cc +++ b/source/python/triangulation_wrapper.cc @@ -188,10 +188,10 @@ namespace PyDealII template void write(const std::string &filename, const std::string &format, - void *triangulation) + const void *triangulation) { - dealii::Triangulation *tria = - static_cast*>(triangulation); + const dealii::Triangulation *tria = + static_cast*>(triangulation); dealii::GridOut::OutputFormat output_format; if (format.compare("dx") == 0) -- 2.39.5