public:
typedef std::vector<CellAccessorWrapper>::iterator iterator;
+ /**
+ * Declare some symbolic names for mesh smoothing. These values are copied
+ * from the Triangulation class, please find the documentation for their
+ * meanings.
+ */
+ enum MeshSmoothing
+ {
+ none = 0x0,
+ limit_level_difference_at_vertices = 0x1,
+ eliminate_unrefined_islands = 0x2,
+ patch_level_1 = 0x4,
+ coarsest_level_1 = 0x8,
+ allow_anisotropic_smoothing = 0x10,
+ eliminate_refined_inner_islands = 0x100,
+ eliminate_refined_boundary_islands = 0x200,
+ do_not_produce_unrefined_islands = 0x400,
+ smoothing_on_refinement =
+ (limit_level_difference_at_vertices | eliminate_unrefined_islands),
+ smoothing_on_coarsening =
+ (eliminate_refined_inner_islands | eliminate_refined_boundary_islands |
+ do_not_produce_unrefined_islands),
+ maximum_smoothing = 0xffff ^ allow_anisotropic_smoothing
+ };
+
/**
* Constructor. Takes a string @p dim with one of the following values
- * "2D", "2d", "3D", or "3d".
+ * "2D", "2d", "3D", or "3d". The optional @p mesh_smoothing determines
+ * the level of smoothness of the mesh size function that should be enforced
+ * upon mesh refinement. The optional @p check_for_distorted_cells
+ * determines whether the triangulation should check whether any of the
+ * cells are distorted.
*/
- TriangulationWrapper(const std::string &dim);
+ TriangulationWrapper(const std::string &dim,
+ const int mesh_smoothing = none,
+ const bool check_for_distorted_cells = false);
/**
* Constructor. Takes a string @p dim with one of the following values
* "2D", "2d", "3D", or "3d" and a string @p spacedim with one of the
* following values "2D", "2d", "3D", or "3d". The dimension of @p spacedim
- * must be larger than the dimension of @p dim
+ * must be larger than the dimension of @p dim. The optional @p mesh_smoothing
+ * determines the level of smoothness of the mesh size function that should
+ * be enforced upon mesh refinement. The optional @p check_for_distorted_cells
+ * determines whether the triangulation should check whether any of the
+ * cells are distorted.
*/
- TriangulationWrapper(const std::string &dim, const std::string &spacedim);
+ TriangulationWrapper(const std::string &dim,
+ const std::string &spacedim,
+ const int mesh_smoothing = none,
+ const bool check_for_distorted_cells = false);
/**
* Destructor.
void
reset_manifold(const int number);
+ /*! @copydoc Triangulation::get_mesh_smoothing
+ */
+ int
+ get_mesh_smoothing();
+
+ /*! @copydoc Triangulation::set_mesh_smoothing
+ */
+ void
+ set_mesh_smoothing(const int mesh_smoothing);
+
/*! @copydoc Triangulation::refine_global
*/
void
* Helper function for the constructors.
*/
void
- setup(const std::string &dimension, const std::string &spacedimension);
+ setup(const std::string &dimension,
+ const std::string &spacedimension,
+ const int mesh_smoothing,
+ const bool check_for_distorted_cells);
/**
* Dimension of the underlying Triangulation object.
+ const char get_mesh_smoothing_docstring[] =
+ "Return the mesh smoothing requirements that are obeyed. \n";
+
+
+
+ const char set_mesh_smoothing_docstring[] =
+ "Set the mesh smoothing to mesh_smoothing. \n";
+
+
+
const char transform_docstring[] =
"Transform the vertices of the given triangulation by applying the \n"
"function object provided as first argument to all its vertices. \n";
{
boost::python::class_<TriangulationWrapper>(
"Triangulation",
- boost::python::init<const std::string &>(boost::python::args("dim")))
- .def(boost::python::init<const std::string &, const std::string &>(
- boost::python::args("dim", "spacedim")))
+ boost::python::init<const std::string &,
+ boost::python::optional<const int, const bool>>(
+ boost::python::args("dim",
+ "mesh_smoothing",
+ "check_for_distorted_cells")))
+ .def(boost::python::init<const std::string &,
+ const std::string &,
+ boost::python::optional<const int, const bool>>(
+ boost::python::args(
+ "dim", "spacedim", "mesh_smoothing", "check_for_distorted_cells")))
.def("n_active_cells",
&TriangulationWrapper::n_active_cells,
n_active_cells_docstring,
.def("reset_manifold",
&TriangulationWrapper::reset_manifold,
reset_manifold_docstring,
- boost::python::args("self", "number"));
+ boost::python::args("self", "number"))
+ .def("get_mesh_smoothing",
+ &TriangulationWrapper::get_mesh_smoothing,
+ get_mesh_smoothing_docstring,
+ boost::python::args("self"))
+ .def("set_mesh_smoothing",
+ &TriangulationWrapper::set_mesh_smoothing,
+ set_mesh_smoothing_docstring,
+ boost::python::args("self", "mesh_smoothing"));
+
+ boost::python::enum_<TriangulationWrapper::MeshSmoothing>("MeshSmoothing")
+ .value("none", TriangulationWrapper::none)
+ .value("limit_level_difference_at_vertices",
+ TriangulationWrapper::limit_level_difference_at_vertices)
+ .value("eliminate_unrefined_islands",
+ TriangulationWrapper::eliminate_unrefined_islands)
+ .value("patch_level_1", TriangulationWrapper::patch_level_1)
+ .value("coarsest_level_1", TriangulationWrapper::coarsest_level_1)
+ .value("allow_anisotropic_smoothing",
+ TriangulationWrapper::allow_anisotropic_smoothing)
+ .value("eliminate_refined_inner_islands",
+ TriangulationWrapper::eliminate_refined_inner_islands)
+ .value("eliminate_refined_boundary_islands",
+ TriangulationWrapper::eliminate_refined_boundary_islands)
+ .value("do_not_produce_unrefined_islands",
+ TriangulationWrapper::do_not_produce_unrefined_islands)
+ .value("smoothing_on_refinement",
+ TriangulationWrapper::smoothing_on_refinement)
+ .value("smoothing_on_coarsening",
+ TriangulationWrapper::smoothing_on_coarsening)
+ .value("maximum_smoothing", TriangulationWrapper::maximum_smoothing);
}
} // namespace python
- TriangulationWrapper::TriangulationWrapper(const std::string &dimension)
+ TriangulationWrapper::TriangulationWrapper(
+ const std::string &dimension,
+ const int mesh_smoothing,
+ const bool check_for_distorted_cells)
{
if ((dimension.compare("2D") == 0) || (dimension.compare("2d") == 0))
- setup("2D", "2D");
+ setup("2D", "2D", mesh_smoothing, check_for_distorted_cells);
else if ((dimension.compare("3D") == 0) || (dimension.compare("3d") == 0))
- setup("3D", "3D");
+ setup("3D", "3D", mesh_smoothing, check_for_distorted_cells);
else
AssertThrow(false, ExcMessage("Dimension needs to be 2D or 3D"));
}
- TriangulationWrapper::TriangulationWrapper(const std::string &dimension,
- const std::string &spacedimension)
+ TriangulationWrapper::TriangulationWrapper(
+ const std::string &dimension,
+ const std::string &spacedimension,
+ const int mesh_smoothing,
+ const bool check_for_distorted_cells)
{
- setup(dimension, spacedimension);
+ setup(dimension, spacedimension, mesh_smoothing, check_for_distorted_cells);
}
+ int
+ TriangulationWrapper::get_mesh_smoothing()
+ {
+ if ((dim == 2) && (spacedim == 2))
+ {
+ Triangulation<2, 2> *tria =
+ static_cast<Triangulation<2, 2> *>(triangulation);
+ return (int)tria->get_mesh_smoothing();
+ }
+ else if ((dim == 2) && (spacedim == 3))
+ {
+ Triangulation<2, 3> *tria =
+ static_cast<Triangulation<2, 3> *>(triangulation);
+ return (int)tria->get_mesh_smoothing();
+ }
+ else
+ {
+ Triangulation<3, 3> *tria =
+ static_cast<Triangulation<3, 3> *>(triangulation);
+ return (int)tria->get_mesh_smoothing();
+ }
+ }
+
+
+
+ void
+ TriangulationWrapper::set_mesh_smoothing(const int mesh_smoothing)
+ {
+ if ((dim == 2) && (spacedim == 2))
+ {
+ Triangulation<2, 2> *tria =
+ static_cast<Triangulation<2, 2> *>(triangulation);
+ tria->set_mesh_smoothing(
+ (Triangulation<2, 2>::MeshSmoothing)mesh_smoothing);
+ }
+ else if ((dim == 2) && (spacedim == 3))
+ {
+ Triangulation<2, 3> *tria =
+ static_cast<Triangulation<2, 3> *>(triangulation);
+ tria->set_mesh_smoothing(
+ (Triangulation<2, 3>::MeshSmoothing)mesh_smoothing);
+ }
+ else
+ {
+ Triangulation<3, 3> *tria =
+ static_cast<Triangulation<3, 3> *>(triangulation);
+ tria->set_mesh_smoothing(
+ (Triangulation<3, 3>::MeshSmoothing)mesh_smoothing);
+ }
+ }
+
+
+
void
TriangulationWrapper::setup(const std::string &dimension,
- const std::string &spacedimension)
+ const std::string &spacedimension,
+ const int mesh_smoothing,
+ const bool check_for_distorted_cells)
{
if ((dimension.compare("2D") == 0) || (dimension.compare("2d") == 0))
{
(spacedimension.compare("2d") == 0))
{
spacedim = 2;
- triangulation = new Triangulation<2, 2>();
+ triangulation = new Triangulation<2, 2>(
+ (Triangulation<2, 2>::MeshSmoothing)mesh_smoothing,
+ check_for_distorted_cells);
}
else if ((spacedimension.compare("3D") == 0) ||
(spacedimension.compare("3d") == 0))
{
spacedim = 3;
- triangulation = new Triangulation<2, 3>();
+ triangulation = new Triangulation<2, 3>(
+ (Triangulation<2, 3>::MeshSmoothing)mesh_smoothing,
+ check_for_distorted_cells);
}
else
AssertThrow(false,
AssertThrow(false, ExcMessage("Spacedimension needs to be 3D."));
dim = 3;
spacedim = 3;
- triangulation = new Triangulation<3, 3>();
+ triangulation = new Triangulation<3, 3>(
+ (Triangulation<3, 3>::MeshSmoothing)mesh_smoothing,
+ check_for_distorted_cells);
}
else
AssertThrow(false, ExcMessage("Dimension needs to be 2D or 3D."));
triangulation.generate_cheese(holes)
n_cells = triangulation.n_active_cells()
self.assertEqual(n_cells, 175)
-
+
def test_generate_general_cell(self):
for dim in self.restricted_dim:
triangulation = Triangulation(dim[0], dim[1])
self.assertEqual(n_cells, 8)
+ def test_mesh_smoothing(self):
+ tria = Triangulation('2D')
+ self.assertEqual(tria.get_mesh_smoothing(), MeshSmoothing.none)
+ tria.set_mesh_smoothing(MeshSmoothing.maximum_smoothing)
+ self.assertEqual(tria.get_mesh_smoothing(), MeshSmoothing.maximum_smoothing)
+
+ tria = Triangulation('2D', MeshSmoothing.limit_level_difference_at_vertices)
+ self.assertEqual(tria.get_mesh_smoothing(), MeshSmoothing.limit_level_difference_at_vertices)
+
+ tria = Triangulation('2D', '3D', MeshSmoothing.none, False)
+ tria.set_mesh_smoothing(MeshSmoothing.limit_level_difference_at_vertices)
+ self.assertEqual(tria.get_mesh_smoothing(), MeshSmoothing.limit_level_difference_at_vertices)
+
+ tria = Triangulation('3D', MeshSmoothing.limit_level_difference_at_vertices | MeshSmoothing.do_not_produce_unrefined_islands)
+ self.assertEqual(tria.get_mesh_smoothing(), MeshSmoothing.limit_level_difference_at_vertices | MeshSmoothing.do_not_produce_unrefined_islands)
+
+
if __name__ == '__main__':
unittest.main()