From: Bruno Turcksin Date: Fri, 22 Jul 2016 15:00:43 +0000 (-0400) Subject: Change namespace for the python wrapper. X-Git-Tag: v8.5.0-rc1~809^2~6 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dac56c6fb0a3ded61317fb039a73781526ce3719;p=dealii.git Change namespace for the python wrapper. --- diff --git a/include/deal.II/python/cell_accessor_wrapper.h b/include/deal.II/python/cell_accessor_wrapper.h index 770cab14b1..a3269c2588 100644 --- a/include/deal.II/python/cell_accessor_wrapper.h +++ b/include/deal.II/python/cell_accessor_wrapper.h @@ -18,7 +18,9 @@ #include -namespace PyDealII +DEAL_II_NAMESPACE_OPEN + +namespace python { class PointWrapper; class TriangulationWrapper; @@ -131,4 +133,6 @@ namespace PyDealII }; } +DEAL_II_NAMESPACE_CLOSE + #endif diff --git a/include/deal.II/python/point_wrapper.h b/include/deal.II/python/point_wrapper.h index 8d53b7564e..75f3a01fe3 100644 --- a/include/deal.II/python/point_wrapper.h +++ b/include/deal.II/python/point_wrapper.h @@ -15,10 +15,13 @@ #ifndef dealii__point_wrapper_h #define dealii__point_wrapper_h + +#include #include +DEAL_II_NAMESPACE_OPEN -namespace PyDealII +namespace python { class PointWrapper { @@ -133,4 +136,6 @@ namespace PyDealII } } +DEAL_II_NAMESPACE_CLOSE + #endif diff --git a/include/deal.II/python/triangulation_wrapper.h b/include/deal.II/python/triangulation_wrapper.h index c29a242eea..29a35545b0 100644 --- a/include/deal.II/python/triangulation_wrapper.h +++ b/include/deal.II/python/triangulation_wrapper.h @@ -21,7 +21,9 @@ #include #include -namespace PyDealII +DEAL_II_NAMESPACE_OPEN + +namespace python { class CellAccessorWrapper; @@ -214,4 +216,6 @@ namespace PyDealII } } +DEAL_II_NAMESPACE_CLOSE + #endif diff --git a/source/python/cell_accessor_wrapper.cc b/source/python/cell_accessor_wrapper.cc index 8859b22fa3..1b17a91f0b 100644 --- a/source/python/cell_accessor_wrapper.cc +++ b/source/python/cell_accessor_wrapper.cc @@ -18,7 +18,9 @@ #include #include -namespace PyDealII +DEAL_II_NAMESPACE_OPEN + +namespace python { namespace internal { @@ -26,42 +28,42 @@ namespace PyDealII void set_refine_flag(const std::string &refinement_case, void *cell_accessor) { - dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + CellAccessor *cell = + static_cast*>(cell_accessor); - std::unique_ptr> ref_case; + std::unique_ptr> ref_case; if (refinement_case.compare("isotropic") == 0) - ref_case.reset(new dealii::RefinementCase( - dealii::RefinementPossibilities::Possibilities::isotropic_refinement)); + ref_case.reset(new RefinementCase( + RefinementPossibilities::Possibilities::isotropic_refinement)); else if (refinement_case.compare("no_refinement") == 0) - ref_case.reset(new dealii::RefinementCase( - dealii::RefinementPossibilities::Possibilities::no_refinement)); + ref_case.reset(new RefinementCase( + RefinementPossibilities::Possibilities::no_refinement)); else if (refinement_case.compare("cut_x") == 0) - ref_case.reset(new dealii::RefinementCase( - dealii::RefinementPossibilities::Possibilities::cut_x)); + ref_case.reset(new RefinementCase( + RefinementPossibilities::Possibilities::cut_x)); else if (refinement_case.compare("cut_y") == 0) - ref_case.reset(new dealii::RefinementCase( - dealii::RefinementPossibilities::Possibilities::cut_y)); + ref_case.reset(new RefinementCase( + RefinementPossibilities::Possibilities::cut_y)); else if (refinement_case.compare("cut_xy") == 0) - ref_case.reset(new dealii::RefinementCase( - dealii::RefinementPossibilities::Possibilities::cut_xy)); + ref_case.reset(new RefinementCase( + RefinementPossibilities::Possibilities::cut_xy)); #if dim==3 else if (refinement_case.compare("cut_z") == 0) - ref_case.reset(new dealii::RefinementCase<3>( - dealii::RefinementPossibilities<3>::Possibilities::cut_z)); + ref_case.reset(new RefinementCase<3>( + RefinementPossibilities<3>::Possibilities::cut_z)); else if (refinement_case.compare("cut_xz") == 0) - ref_case.reset(new dealii::RefinementCase<3>( - dealii::RefinementPossibilities<3>::Possibilities::cut_xz)); + ref_case.reset(new RefinementCase<3>( + RefinementPossibilities<3>::Possibilities::cut_xz)); else if (refinement_case.compare("cut_yz") == 0) - ref_case.reset(new dealii::RefinementCase<3>( - dealii::RefinementPossibilities<3>::Possibilities::cut_yz)); + ref_case.reset(new RefinementCase<3>( + RefinementPossibilities<3>::Possibilities::cut_yz)); else if (refinement_case.compare("cut_xyz") == 0) - ref_case.reset(new dealii::RefinementCase<3>( - dealii::RefinementPossibilities<3>::Possibilities::cut_xyz)); + ref_case.reset(new RefinementCase<3>( + RefinementPossibilities<3>::Possibilities::cut_xyz)); #endif else AssertThrow(false, - dealii::ExcMessage("Unknown refinement possibility.")); + ExcMessage("Unknown refinement possibility.")); cell->set_refine_flag(*ref_case); } @@ -71,11 +73,11 @@ namespace PyDealII template std::string get_refine_flag(const void *cell_accessor) { - const dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + const CellAccessor *cell = + static_cast*>(cell_accessor); std::string refine_flag; - dealii::RefinementCase ref_case = cell->refine_flag_set(); + RefinementCase ref_case = cell->refine_flag_set(); switch (static_cast(ref_case)) { case (0) : @@ -120,7 +122,7 @@ namespace PyDealII } default : { - AssertThrow(false, dealii::ExcMessage("Internal error.")); + AssertThrow(false, ExcMessage("Internal error.")); } } @@ -132,8 +134,8 @@ namespace PyDealII template void set_coarsen_flag(const bool coarsen_flag, void *cell_accessor) { - dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + CellAccessor *cell = + static_cast*>(cell_accessor); if (coarsen_flag == true) cell->set_coarsen_flag(); else @@ -145,8 +147,8 @@ namespace PyDealII template bool get_coarsen_flag(const void *cell_accessor) { - const dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + const CellAccessor *cell = + static_cast*>(cell_accessor); return cell->coarsen_flag_set(); } @@ -156,9 +158,9 @@ namespace PyDealII template PointWrapper get_barycenter(const void *cell_accessor) { - const dealii::CellAccessor *cell = - static_cast*>(cell_accessor); - dealii::Point barycenter = cell->barycenter(); + const CellAccessor *cell = + static_cast*>(cell_accessor); + Point barycenter = cell->barycenter(); boost::python::list barycenter_list; for (int i=0; i void set_material_id(const int material_id, void *cell_accessor) { - dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + CellAccessor *cell = + static_cast*>(cell_accessor); cell->set_material_id(material_id); } @@ -181,8 +183,8 @@ namespace PyDealII template int get_material_id(const void *cell_accessor) { - const dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + const CellAccessor *cell = + static_cast*>(cell_accessor); return cell->material_id(); } @@ -194,10 +196,10 @@ namespace PyDealII PointWrapper &point_wrapper, void *cell_accessor) { - dealii::CellAccessor *cell = - static_cast*>(cell_accessor); - dealii::Point *point = - static_cast*>(point_wrapper.get_point()); + CellAccessor *cell = + static_cast*>(cell_accessor); + Point *point = + static_cast*>(point_wrapper.get_point()); cell->vertex(i) = *point; } @@ -207,9 +209,9 @@ namespace PyDealII template PointWrapper get_vertex(const int i, const void *cell_accessor) { - const dealii::CellAccessor *cell = - static_cast*>(cell_accessor); - dealii::Point vertex = cell->vertex(i); + const CellAccessor *cell = + static_cast*>(cell_accessor); + Point vertex = cell->vertex(i); boost::python::list coordinates; for (int i=0; i void set_manifold_id(const int manifold_id, void *cell_accessor) { - dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + CellAccessor *cell = + static_cast*>(cell_accessor); cell->set_manifold_id(manifold_id); } @@ -233,8 +235,8 @@ namespace PyDealII template int get_manifold_id(const void *cell_accessor) { - const dealii::CellAccessor *cell = - static_cast*>(cell_accessor); + const CellAccessor *cell = + static_cast*>(cell_accessor); cell->manifold_id(); } } @@ -248,24 +250,24 @@ namespace PyDealII { if ((dim == 2) && (spacedim == 2)) { - dealii::CellAccessor<2,2> *other_cell = - static_cast*>(other.cell_accessor); - cell_accessor = new dealii::CellAccessor<2,2>(*other_cell); + CellAccessor<2,2> *other_cell = + static_cast*>(other.cell_accessor); + cell_accessor = new CellAccessor<2,2>(*other_cell); } else if ((dim == 2) && (spacedim == 3)) { - dealii::CellAccessor<2,3> *other_cell = - static_cast*>(other.cell_accessor); - cell_accessor = new dealii::CellAccessor<2,3>(*other_cell); + CellAccessor<2,3> *other_cell = + static_cast*>(other.cell_accessor); + cell_accessor = new CellAccessor<2,3>(*other_cell); } else if ((dim == 3) && (spacedim == 3)) { - dealii::CellAccessor<3,3> *other_cell = - static_cast*>(other.cell_accessor); - cell_accessor = new dealii::CellAccessor<3,3>(*other_cell); + CellAccessor<3,3> *other_cell = + static_cast*>(other.cell_accessor); + cell_accessor = new CellAccessor<3,3>(*other_cell); } else - AssertThrow(false, dealii::ExcMessage("Wrong dim-spacedim combination.")); + AssertThrow(false, ExcMessage("Wrong dim-spacedim combination.")); } @@ -279,24 +281,24 @@ namespace PyDealII spacedim = triangulation_wrapper.get_spacedim(); if ((dim == 2) && (spacedim == 2)) { - dealii::Triangulation<2,2> *tmp = static_cast*> ( - triangulation_wrapper.get_triangulation()); - cell_accessor = new dealii::CellAccessor<2,2>(tmp ,level, index); + Triangulation<2,2> *tmp = static_cast*> ( + triangulation_wrapper.get_triangulation()); + cell_accessor = new CellAccessor<2,2>(tmp ,level, index); } else if ((dim == 2) && (spacedim == 3)) { - dealii::Triangulation<2,3> *tmp = static_cast*> ( - triangulation_wrapper.get_triangulation()); - cell_accessor = new dealii::CellAccessor<2,3>(tmp, level, index); + Triangulation<2,3> *tmp = static_cast*> ( + triangulation_wrapper.get_triangulation()); + cell_accessor = new CellAccessor<2,3>(tmp, level, index); } else if ((dim == 3) && (spacedim == 3)) { - dealii::Triangulation<3,3> *tmp = static_cast*> ( - triangulation_wrapper.get_triangulation()); - cell_accessor = new dealii::CellAccessor<3,3>(tmp, level, index); + Triangulation<3,3> *tmp = static_cast*> ( + triangulation_wrapper.get_triangulation()); + cell_accessor = new CellAccessor<3,3>(tmp, level, index); } else - AssertThrow(false, dealii::ExcMessage("Wrong dim-spacedim combination.")); + AssertThrow(false, ExcMessage("Wrong dim-spacedim combination.")); } @@ -309,20 +311,20 @@ namespace PyDealII { // We cannot call delete on a void pointer so cast the void pointer back // first. - dealii::CellAccessor<2,2> *tmp = - static_cast*>(cell_accessor); + CellAccessor<2,2> *tmp = + static_cast*>(cell_accessor); delete tmp; } else if ((dim == 2) && (spacedim == 3)) { - dealii::CellAccessor<3,3> *tmp = - static_cast*>(cell_accessor); + CellAccessor<3,3> *tmp = + static_cast*>(cell_accessor); delete tmp; } else { - dealii::CellAccessor<3,3> *tmp = - static_cast*>(cell_accessor); + CellAccessor<3,3> *tmp = + static_cast*>(cell_accessor); delete tmp; } @@ -395,8 +397,8 @@ namespace PyDealII void CellAccessorWrapper::set_material_id(const int material_id) { - AssertThrow(material_id < dealii::numbers::invalid_material_id, - dealii::ExcMessage("material_id is too large.")); + AssertThrow(material_id < numbers::invalid_material_id, + ExcMessage("material_id is too large.")); if ((dim == 2) && (spacedim == 2)) return internal::set_material_id<2,2>(material_id, cell_accessor); else if ((dim == 2) && (spacedim == 3)) @@ -470,3 +472,5 @@ namespace PyDealII internal::get_manifold_id<3,3>(cell_accessor); } } + +DEAL_II_NAMESPACE_CLOSE diff --git a/source/python/export_cell_accessor.cc b/source/python/export_cell_accessor.cc index 87c994b178..fef76167ca 100644 --- a/source/python/export_cell_accessor.cc +++ b/source/python/export_cell_accessor.cc @@ -17,7 +17,9 @@ #include #include -namespace PyDealII +DEAL_II_NAMESPACE_OPEN + +namespace python { const char refine_flag_docstring [] = "Get/Set the refine_flag of the cell. In 2D, the possibilities are: \n" @@ -104,3 +106,4 @@ namespace PyDealII } } +DEAL_II_NAMESPACE_CLOSE diff --git a/source/python/export_point.cc b/source/python/export_point.cc index e8ab162efb..1fbb7ed736 100644 --- a/source/python/export_point.cc +++ b/source/python/export_point.cc @@ -18,7 +18,9 @@ #include #include -namespace PyDealII +DEAL_II_NAMESPACE_OPEN + +namespace python { void export_point() { @@ -32,3 +34,5 @@ namespace PyDealII "Get the z component of the point."); } } + +DEAL_II_NAMESPACE_CLOSE diff --git a/source/python/export_triangulation.cc b/source/python/export_triangulation.cc index f22f7a0507..755c09d522 100644 --- a/source/python/export_triangulation.cc +++ b/source/python/export_triangulation.cc @@ -17,7 +17,9 @@ #include #include -namespace PyDealII +DEAL_II_NAMESPACE_OPEN + +namespace python { // Macro to enable default arguments @@ -216,3 +218,5 @@ namespace PyDealII boost::python::args("self", "filename")); } } + +DEAL_II_NAMESPACE_CLOSE diff --git a/source/python/point_wrapper.cc b/source/python/point_wrapper.cc index bdda73fae6..8c9778fca8 100644 --- a/source/python/point_wrapper.cc +++ b/source/python/point_wrapper.cc @@ -16,7 +16,9 @@ #include #include -namespace PyDealII +DEAL_II_NAMESPACE_OPEN + +namespace python { PointWrapper::PointWrapper() : @@ -29,15 +31,15 @@ namespace PyDealII { dim = boost::python::len(coord); if (dim == 2) - point = new dealii::Point<2> (boost::python::extract(coord[0]), - boost::python::extract(coord[1])); + point = new Point<2> (boost::python::extract(coord[0]), + boost::python::extract(coord[1])); else if (dim == 3) - point = new dealii::Point<3> (boost::python::extract(coord[0]), - boost::python::extract(coord[1]), - boost::python::extract(coord[2])); + point = new Point<3> (boost::python::extract(coord[0]), + boost::python::extract(coord[1]), + boost::python::extract(coord[2])); else AssertThrow(false, - dealii::ExcMessage("The list of coordinates must contain two or three elements.")); + ExcMessage("The list of coordinates must contain two or three elements.")); } @@ -70,9 +72,9 @@ namespace PyDealII double PointWrapper::get_x() const { if (dim == 2) - return (*static_cast*>(point))(0); + return (*static_cast*>(point))(0); else - return (*static_cast*>(point))(0); + return (*static_cast*>(point))(0); } @@ -80,9 +82,9 @@ namespace PyDealII void PointWrapper::set_x(double x) { if (dim == 2) - (*static_cast*>(point))(0) = x; + (*static_cast*>(point))(0) = x; else - (*static_cast*>(point))(0) = x; + (*static_cast*>(point))(0) = x; } @@ -90,9 +92,9 @@ namespace PyDealII double PointWrapper::get_y() const { if (dim == 2) - return (*static_cast*>(point))(1); + return (*static_cast*>(point))(1); else - return (*static_cast*>(point))(1); + return (*static_cast*>(point))(1); } @@ -100,9 +102,9 @@ namespace PyDealII void PointWrapper::set_y(double y) { if (dim == 2) - (*static_cast*>(point))(1) = y; + (*static_cast*>(point))(1) = y; else - (*static_cast*>(point))(1) = y; + (*static_cast*>(point))(1) = y; } @@ -110,10 +112,10 @@ namespace PyDealII double PointWrapper::get_z() const { if (dim == 3) - return (*static_cast*>(point))(2); + return (*static_cast*>(point))(2); else AssertThrow(false, - dealii::ExcMessage("The z coordinate is only available for three-dimensional points")); + ExcMessage("The z coordinate is only available for three-dimensional points")); } @@ -121,10 +123,10 @@ namespace PyDealII void PointWrapper::set_z(double z) { if (dim == 3) - (*static_cast*>(point))(2) = z; + (*static_cast*>(point))(2) = z; else AssertThrow(false, - dealii::ExcMessage("The z coordinate is only available for three-dimensional points")); + ExcMessage("The z coordinate is only available for three-dimensional points")); } @@ -138,12 +140,12 @@ namespace PyDealII { // We cannot call delete on a void pointer so cast the void pointer back // first. - dealii::Point<2> *tmp = static_cast*>(point); + Point<2> *tmp = static_cast*>(point); delete tmp; } else { - dealii::Point<3> *tmp = static_cast*>(point); + Point<3> *tmp = static_cast*>(point); delete tmp; } point = nullptr; @@ -157,20 +159,22 @@ namespace PyDealII dim = other.dim; AssertThrow(other.point != nullptr, - dealii::ExcMessage("Underlying point does not exist.")); + ExcMessage("Underlying point does not exist.")); if (dim == 2) { - dealii::Point<2> *other_point = static_cast*>(other.point); - point = new dealii::Point<2> ((*other_point)[0], (*other_point)[1]); + Point<2> *other_point = static_cast*>(other.point); + point = new Point<2> ((*other_point)[0], (*other_point)[1]); } else if (dim == 3) { - dealii::Point<3> *other_point = static_cast*>(other.point); - point = new dealii::Point<3> ((*other_point)[0], (*other_point)[1], (*other_point)[2]); + Point<3> *other_point = static_cast*>(other.point); + point = new Point<3> ((*other_point)[0], (*other_point)[1], (*other_point)[2]); } else AssertThrow(false, - dealii::ExcMessage("The dimension of the point should be 2 or 3.")); + ExcMessage("The dimension of the point should be 2 or 3.")); } } + +DEAL_II_NAMESPACE_CLOSE diff --git a/source/python/triangulation_wrapper.cc b/source/python/triangulation_wrapper.cc index 61efcbcaee..ea0e0c2ae0 100644 --- a/source/python/triangulation_wrapper.cc +++ b/source/python/triangulation_wrapper.cc @@ -23,7 +23,9 @@ #include #include -namespace PyDealII +DEAL_II_NAMESPACE_OPEN + +namespace python { namespace internal { @@ -33,10 +35,10 @@ namespace PyDealII const bool colorize, void *triangulation) { - dealii::Triangulation *tria = - static_cast*>(triangulation); + Triangulation *tria = + static_cast*>(triangulation); tria->clear(); - dealii::GridGenerator::hyper_cube(*tria, left, right, colorize); + GridGenerator::hyper_cube(*tria, left, right, colorize); } @@ -46,14 +48,14 @@ namespace PyDealII void *triangulation) { // Cast the PointWrapper objects to Point - std::vector> points(dim+1); + std::vector> points(dim+1); for (int i=0; i*>((wrapped_points[i]).get_point())); + points[i] = *(static_cast*>((wrapped_points[i]).get_point())); - dealii::Triangulation *tria = - static_cast*>(triangulation); + Triangulation *tria = + static_cast*>(triangulation); tria->clear(); - dealii::GridGenerator::simplex(*tria, points); + GridGenerator::simplex(*tria, points); } @@ -64,10 +66,10 @@ namespace PyDealII const double right, void *triangulation) { - dealii::Triangulation *tria = - static_cast*>(triangulation); + Triangulation *tria = + static_cast*>(triangulation); tria->clear(); - dealii::GridGenerator::subdivided_hyper_cube(*tria, repetitions, left, right); + GridGenerator::subdivided_hyper_cube(*tria, repetitions, left, right); } @@ -79,17 +81,17 @@ namespace PyDealII void *triangulation) { AssertThrow(p1.get_dim() == dim, - dealii::ExcMessage("Dimension of p1 is not the same as the dimension of the Triangulation.")); + ExcMessage("Dimension of p1 is not the same as the dimension of the Triangulation.")); AssertThrow(p2.get_dim() == dim, - dealii::ExcMessage("Dimension of p2 is not the same as the dimension of the Triangulation.")); + ExcMessage("Dimension of p2 is not the same as the dimension of the Triangulation.")); // Cast the PointWrapper object to Point - dealii::Point point_1 = *(static_cast*>(p1.get_point())); - dealii::Point point_2 = *(static_cast*>(p2.get_point())); + Point point_1 = *(static_cast*>(p1.get_point())); + Point point_2 = *(static_cast*>(p2.get_point())); - dealii::Triangulation *tria = - static_cast*>(triangulation); + Triangulation *tria = + static_cast*>(triangulation); tria->clear(); - dealii::GridGenerator::hyper_rectangle(*tria, point_1, point_2, colorize); + GridGenerator::hyper_rectangle(*tria, point_1, point_2, colorize); } @@ -102,18 +104,18 @@ namespace PyDealII void *triangulation) { AssertThrow(p1.get_dim() == dim, - dealii::ExcMessage("Dimension of p1 is not the same as the dimension of the Triangulation.")); + ExcMessage("Dimension of p1 is not the same as the dimension of the Triangulation.")); AssertThrow(p2.get_dim() == dim, - dealii::ExcMessage("Dimension of p2 is not the same as the dimension of the Triangulation.")); + ExcMessage("Dimension of p2 is not the same as the dimension of the Triangulation.")); // Cast the PointWrapper object to Point - dealii::Point point_1 = *(static_cast*>(p1.get_point())); - dealii::Point point_2 = *(static_cast*>(p2.get_point())); + Point point_1 = *(static_cast*>(p1.get_point())); + Point point_2 = *(static_cast*>(p2.get_point())); - dealii::Triangulation *tria = - static_cast*>(triangulation); + Triangulation *tria = + static_cast*>(triangulation); tria->clear(); - dealii::GridGenerator::subdivided_hyper_rectangle(*tria, repetitions, point_1, - point_2, colorize); + GridGenerator::subdivided_hyper_rectangle(*tria, repetitions, point_1, + point_2, colorize); } @@ -124,13 +126,13 @@ namespace PyDealII void *triangulation) { // Cast the PointWrapper object to Point - dealii::Point center_point = *(static_cast*>( - center.get_point())); + Point center_point = *(static_cast*>( + center.get_point())); - dealii::Triangulation *tria = - static_cast*>(triangulation); + Triangulation *tria = + static_cast*>(triangulation); tria->clear(); - dealii::GridGenerator::hyper_ball(*tria, center_point, radius); + GridGenerator::hyper_ball(*tria, center_point, radius); } @@ -140,13 +142,13 @@ namespace PyDealII void *triangulation) { // Extract the shift vector from the python list - dealii::Tensor<1,spacedim> shift_vector; + Tensor<1,spacedim> shift_vector; for (int i=0; i(shift_list[i]); - dealii::Triangulation *tria = - static_cast*>(triangulation); - dealii::GridTools::shift(shift_vector, *tria); + Triangulation *tria = + static_cast*>(triangulation); + GridTools::shift(shift_vector, *tria); } @@ -156,14 +158,14 @@ namespace PyDealII TriangulationWrapper &triangulation_2, void *triangulation) { - dealii::Triangulation *tria = - static_cast*>(triangulation); + Triangulation *tria = + static_cast*>(triangulation); tria->clear(); - dealii::Triangulation *tria_1 = - static_cast*>(triangulation_1.get_triangulation()); - dealii::Triangulation *tria_2 = - static_cast*>(triangulation_2.get_triangulation()); - dealii::GridGenerator::merge_triangulations(*tria_1, *tria_2, *tria); + Triangulation *tria_1 = + static_cast*>(triangulation_1.get_triangulation()); + Triangulation *tria_2 = + static_cast*>(triangulation_2.get_triangulation()); + GridGenerator::merge_triangulations(*tria_1, *tria_2, *tria); // We need to reassign tria to triangulation because tria was cleared // inside merge_triangulations. triangulation = tria; @@ -174,8 +176,8 @@ namespace PyDealII template boost::python::list active_cells(TriangulationWrapper &triangulation_wrapper) { - dealii::Triangulation *tria = - static_cast*>( + Triangulation *tria = + static_cast*>( triangulation_wrapper.get_triangulation()); boost::python::list cells; for (auto cell : tria->active_cell_iterators()) @@ -192,34 +194,34 @@ namespace PyDealII const std::string &format, const void *triangulation) { - const dealii::Triangulation *tria = - static_cast*>(triangulation); + const Triangulation *tria = + static_cast*>(triangulation); - dealii::GridOut::OutputFormat output_format; + GridOut::OutputFormat output_format; if (format.compare("dx") == 0) - output_format = dealii::GridOut::OutputFormat::dx; + output_format = GridOut::OutputFormat::dx; else if (format.compare("gnuplot") == 0) - output_format = dealii::GridOut::OutputFormat::gnuplot; + output_format = GridOut::OutputFormat::gnuplot; else if (format.compare("eps") == 0) - output_format = dealii::GridOut::OutputFormat::eps; + output_format = GridOut::OutputFormat::eps; else if (format.compare("ucd") == 0) - output_format = dealii::GridOut::OutputFormat::ucd; + output_format = GridOut::OutputFormat::ucd; else if (format.compare("xfig") == 0) - output_format = dealii::GridOut::OutputFormat::xfig; + output_format = GridOut::OutputFormat::xfig; else if (format.compare("msh") == 0) - output_format = dealii::GridOut::OutputFormat::msh; + output_format = GridOut::OutputFormat::msh; else if (format.compare("svg") == 0) - output_format = dealii::GridOut::OutputFormat::svg; + output_format = GridOut::OutputFormat::svg; else if (format.compare("mathgl") == 0) - output_format = dealii::GridOut::OutputFormat::mathgl; + output_format = GridOut::OutputFormat::mathgl; else if (format.compare("vtk") == 0) - output_format = dealii::GridOut::OutputFormat::vtk; + output_format = GridOut::OutputFormat::vtk; else if (format.compare("vtu") == 0) - output_format = dealii::GridOut::OutputFormat::vtu; + output_format = GridOut::OutputFormat::vtu; else - output_format = dealii::GridOut::OutputFormat::none; + output_format = GridOut::OutputFormat::none; - dealii::GridOut mesh_writer; + GridOut mesh_writer; std::ofstream ofs(filename); mesh_writer.write(*tria, ofs, output_format); ofs.close(); @@ -237,7 +239,7 @@ namespace PyDealII else if ((dimension.compare("3D")==0) || (dimension.compare("3d")==0)) setup("3D", "3D"); else - AssertThrow(false, dealii::ExcMessage("Dimension needs to be 2D or 3D")); + AssertThrow(false, ExcMessage("Dimension needs to be 2D or 3D")); } @@ -262,20 +264,20 @@ namespace PyDealII { // We cannot call delete on a void pointer so cast the void pointer back // first. - dealii::Triangulation<2,2> *tmp = - static_cast*>(triangulation); + Triangulation<2,2> *tmp = + static_cast*>(triangulation); delete tmp; } else { - dealii::Triangulation<2,3> *tmp = - static_cast*>(triangulation); + Triangulation<2,3> *tmp = + static_cast*>(triangulation); delete tmp; } } else { - dealii::Triangulation<3,3> *tmp = static_cast*>(triangulation); + Triangulation<3,3> *tmp = static_cast*>(triangulation); delete tmp; } triangulation = nullptr; @@ -288,11 +290,11 @@ namespace PyDealII unsigned int TriangulationWrapper::n_active_cells() const { if ((dim == 2) && (spacedim == 2)) - return (*static_cast*>(triangulation)).n_active_cells(); + return (*static_cast*>(triangulation)).n_active_cells(); else if ((dim == 2) && (spacedim == 3)) - return (*static_cast*>(triangulation)).n_active_cells(); + return (*static_cast*>(triangulation)).n_active_cells(); else - return (*static_cast*>(triangulation)).n_active_cells(); + return (*static_cast*>(triangulation)).n_active_cells(); } @@ -314,16 +316,16 @@ namespace PyDealII void TriangulationWrapper::generate_simplex(boost::python::list &vertices) { AssertThrow(boost::python::len(vertices) == dim+1, - dealii::ExcMessage("The number of vertices should be equal to dim+1.")); + ExcMessage("The number of vertices should be equal to dim+1.")); AssertThrow(dim == spacedim, - dealii::ExcMessage("This function is only implemented for dim equal to spacedim.")); + ExcMessage("This function is only implemented for dim equal to spacedim.")); // Extract the PointWrapper object from the python list std::vector wrapped_points(dim+1); for (int i=0; i(vertices[i]); AssertThrow(wrapped_points[i].get_dim() == dim, - dealii::ExcMessage("Point of wrong dimension.")); + ExcMessage("Point of wrong dimension.")); } if (dim == 2) @@ -368,7 +370,7 @@ namespace PyDealII const bool colorize) { AssertThrow(boost::python::len(repetition_list) == dim, - dealii::ExcMessage("The list of repetitions must have the same length as the number of dimension.")); + ExcMessage("The list of repetitions must have the same length as the number of dimension.")); // Extract the repetitions from the python list std::vector repetitions(dim); @@ -392,7 +394,7 @@ namespace PyDealII const double radius) { AssertThrow(dim == spacedim, - dealii::ExcMessage("This function is only implemented for dim equal to spacedim.")); + ExcMessage("This function is only implemented for dim equal to spacedim.")); if (dim == 2) internal::generate_hyper_ball<2>(center, radius, triangulation); else @@ -404,7 +406,7 @@ namespace PyDealII void TriangulationWrapper::shift(boost::python::list &shift_list) { AssertThrow(boost::python::len(shift_list) == spacedim, - dealii::ExcMessage("Size of the shift vector is not equal to spacedim.")); + ExcMessage("Size of the shift vector is not equal to spacedim.")); if ((dim == 2) && (spacedim == 2)) internal::shift<2,2>(shift_list, triangulation); else if ((dim ==2) && (spacedim == 3)) @@ -419,13 +421,13 @@ namespace PyDealII TriangulationWrapper &triangulation_2) { AssertThrow(triangulation_1.get_dim() == triangulation_2.get_dim(), - dealii::ExcMessage("Triangulation_1 and Triangulation_2 should have the same dimension.")); + ExcMessage("Triangulation_1 and Triangulation_2 should have the same dimension.")); AssertThrow(dim == triangulation_2.get_dim(), - dealii::ExcMessage("Triangulation and Triangulation_2 should have the same dimension.")); + ExcMessage("Triangulation and Triangulation_2 should have the same dimension.")); AssertThrow(triangulation_1.get_spacedim() == triangulation_2.get_spacedim(), - dealii::ExcMessage("Triangulation_1 and Triangulation_2 should have the same space dimension.")); + ExcMessage("Triangulation_1 and Triangulation_2 should have the same space dimension.")); AssertThrow(spacedim == triangulation_2.get_spacedim(), - dealii::ExcMessage("Triangulation and Triangulation_2 should have the same space dimension.")); + ExcMessage("Triangulation and Triangulation_2 should have the same space dimension.")); if ((triangulation_1.get_dim() == 2) && (triangulation_1.get_spacedim() == 2)) internal::merge_triangulations<2,2>(triangulation_1, triangulation_2, triangulation); @@ -441,20 +443,20 @@ namespace PyDealII { if ((dim == 2) && (spacedim == 2)) { - dealii::Triangulation<2,2> *tria = - static_cast*>(triangulation); + Triangulation<2,2> *tria = + static_cast*>(triangulation); tria->refine_global(n); } else if ((dim == 2) && (spacedim == 3)) { - dealii::Triangulation<2,3> *tria = - static_cast*>(triangulation); + Triangulation<2,3> *tria = + static_cast*>(triangulation); tria->refine_global(n); } else { - dealii::Triangulation<3,3> *tria = - static_cast*>(triangulation); + Triangulation<3,3> *tria = + static_cast*>(triangulation); tria->refine_global(n); } } @@ -465,20 +467,20 @@ namespace PyDealII { if ((dim == 2) && (spacedim == 2)) { - dealii::Triangulation<2,2> *tria = - static_cast*>(triangulation); + Triangulation<2,2> *tria = + static_cast*>(triangulation); tria->execute_coarsening_and_refinement(); } else if ((dim == 2) && (spacedim == 3)) { - dealii::Triangulation<2,3> *tria = - static_cast*>(triangulation); + Triangulation<2,3> *tria = + static_cast*>(triangulation); tria->execute_coarsening_and_refinement(); } else { - dealii::Triangulation<3,3> *tria = - static_cast*>(triangulation); + Triangulation<3,3> *tria = + static_cast*>(triangulation); tria->execute_coarsening_and_refinement(); } } @@ -505,24 +507,24 @@ namespace PyDealII if ((dim == 2) && (spacedim == 2)) { - dealii::Triangulation<2,2> *tria = - static_cast*>(triangulation); + Triangulation<2,2> *tria = + static_cast*>(triangulation); oa << *tria; } else if ((dim == 2) && (spacedim == 3)) { { - dealii::Triangulation<2,3> *tria = - static_cast*>(triangulation); + Triangulation<2,3> *tria = + static_cast*>(triangulation); oa << *tria; } } else { - dealii::Triangulation<3,3> *tria = - static_cast*>(triangulation); + Triangulation<3,3> *tria = + static_cast*>(triangulation); oa << *tria; } @@ -537,22 +539,22 @@ namespace PyDealII if ((dim == 2) && (spacedim == 2)) { - dealii::Triangulation<2,2> *tria = - static_cast*>(triangulation); + Triangulation<2,2> *tria = + static_cast*>(triangulation); ia >> *tria; } else if ((dim == 2) && (spacedim == 3)) { - dealii::Triangulation<2,3> *tria = - static_cast*>(triangulation); + Triangulation<2,3> *tria = + static_cast*>(triangulation); ia >> *tria; } else { - dealii::Triangulation<3> *tria = - static_cast*>(triangulation); + Triangulation<3> *tria = + static_cast*>(triangulation); ia >> *tria; } @@ -582,27 +584,29 @@ namespace PyDealII (spacedimension.compare("2d") == 0)) { spacedim = 2; - triangulation = new dealii::Triangulation<2,2>(); + triangulation = new Triangulation<2,2>(); } else if ((spacedimension.compare("3D") == 0) || (spacedimension.compare("3d") == 0)) { spacedim = 3; - triangulation = new dealii::Triangulation<2,3>(); + triangulation = new Triangulation<2,3>(); } else - AssertThrow(false, dealii::ExcMessage("Spacedimension needs to be 2D or 3D.")); + AssertThrow(false, ExcMessage("Spacedimension needs to be 2D or 3D.")); } else if ((dimension.compare("3D") == 0) || (dimension.compare("3d") == 0)) { if ((spacedimension.compare("3D") != 0) && (spacedimension.compare("3d") != 0)) - AssertThrow(false, dealii::ExcMessage("Spacedimension needs to be 3D.")); + AssertThrow(false, ExcMessage("Spacedimension needs to be 3D.")); dim = 3; spacedim = 3; - triangulation = new dealii::Triangulation<3,3>(); + triangulation = new Triangulation<3,3>(); } else - AssertThrow(false, dealii::ExcMessage("Dimension needs to be 2D or 3D.")); + AssertThrow(false, ExcMessage("Dimension needs to be 2D or 3D.")); } } + +DEAL_II_NAMESPACE_CLOSE diff --git a/source/python/wrappers.cc b/source/python/wrappers.cc index bd3ee4144e..dc09aa874b 100644 --- a/source/python/wrappers.cc +++ b/source/python/wrappers.cc @@ -13,15 +13,20 @@ // // --------------------------------------------------------------------- +#include #include -namespace PyDealII +DEAL_II_NAMESPACE_OPEN + +namespace python { void export_cell_accessor(); void export_point(); void export_triangulation(); } +DEAL_II_NAMESPACE_CLOSE + char const *pydealii_docstring = " \n" "PyDealII \n" @@ -38,7 +43,7 @@ BOOST_PYTHON_MODULE(PyDealII) doc_options.enable_py_signatures(); doc_options.disable_cpp_signatures(); - PyDealII::export_cell_accessor(); - PyDealII::export_point(); - PyDealII::export_triangulation(); + dealii::python::export_cell_accessor(); + dealii::python::export_point(); + dealii::python::export_triangulation(); }