void
generate_hyper_ball(PointWrapper ¢er, const double radius = 1.);
+ /*! @copydoc GridGenerator::hyper_ball_balanced
+ */
+ void
+ generate_hyper_ball_balanced(const PointWrapper ¢er = PointWrapper(),
+ const double radius = 1.);
+
/*! @copydoc GridGenerator::hyper_sphere
*/
void
generate_hyper_ball,
1,
2)
+ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(generate_hyper_ball_balanced_overloads,
+ generate_hyper_ball_balanced,
+ 0,
+ 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(generate_hyper_sphere_overloads,
generate_hyper_sphere,
1,
+ const char generate_hyper_ball_balanced_docstring[] =
+ "This is an alternative to hyper_ball with 12 cells in 2d and 32 cells \n"
+ "in 3d, which provides a better balance between the size of the cells \n"
+ "around the outer curved boundaries and the cell in the interior. \n";
+
+
+
const char generate_hyper_sphere_docstring[] =
"Generate a hyper sphere, i.e., a surface of a ball in spacedim \n"
"dimensions. This function only exists for dim+1=spacedim in 2 and 3 \n"
generate_hyper_ball_overloads(
boost::python::args("self", "center", "radius"),
generate_hyper_ball_docstring))
+ .def("generate_hyper_ball_balanced",
+ &TriangulationWrapper::generate_hyper_ball_balanced,
+ generate_hyper_ball_balanced_overloads(
+ boost::python::args("self", "center", "radius"),
+ generate_hyper_ball_balanced_docstring))
.def("generate_hyper_sphere",
&TriangulationWrapper::generate_hyper_sphere,
generate_hyper_sphere_overloads(
+ template <int dim>
+ void
+ generate_hyper_ball_balanced(const PointWrapper ¢er,
+ const double radius,
+ void *triangulation)
+ {
+ // Cast the PointWrapper object to Point<dim>
+ Point<dim> center_point =
+ center.get_point() ?
+ *(static_cast<const Point<dim> *>(center.get_point())) :
+ Point<dim>();
+
+ Triangulation<dim> *tria =
+ static_cast<Triangulation<dim> *>(triangulation);
+ tria->clear();
+ GridGenerator::hyper_ball_balanced(*tria, center_point, radius);
+ }
+
+
+
template <int dim, int spacedim>
void
generate_hyper_sphere(PointWrapper ¢er,
+ void
+ TriangulationWrapper::generate_hyper_ball_balanced(const PointWrapper ¢er,
+ const double radius)
+ {
+ AssertThrow(
+ dim == spacedim,
+ ExcMessage(
+ "This function is only implemented for dim equal to spacedim."));
+ if (dim == 2)
+ internal::generate_hyper_ball_balanced<2>(center, radius, triangulation);
+ else
+ internal::generate_hyper_ball_balanced<3>(center, radius, triangulation);
+ }
+
+
+
void
TriangulationWrapper::generate_hyper_shell(PointWrapper ¢er,
const double inner_radius,
n_cells = triangulation.n_active_cells()
self.assertEqual(n_cells, n_cells_ref)
+ def test_hyper_ball_balanced(self):
+ for dim in self.dim:
+ triangulation = Triangulation(dim[0])
+ triangulation.generate_hyper_ball_balanced()
+ n_cells = triangulation.n_active_cells()
+ if (dim[0] == '2D'):
+ self.assertEqual(n_cells, 12)
+ else:
+ self.assertEqual(n_cells, 32)
+
def test_hyper_sphere(self):
triangulation = Triangulation('2D', '3D')
center = Point([0, 0])