20#ifdef DEAL_II_WITH_CGAL
40 const double & outer_ball_radius)
42# ifdef DEAL_II_WITH_CGAL
45 "The implicit function must have exactly one component."));
46 Assert(dealii_implicit_function.
value(interior_point) < 0,
48 "The implicit function must be negative at the interior point."));
49 Assert(outer_ball_radius > 0,
50 ExcMessage(
"The outer ball radius must be positive."));
52 ExcMessage(
"The triangulation must be empty."));
54 if constexpr (dim == 3)
56 using K = CGAL::Exact_predicates_inexact_constructions_kernel;
57 using NumberType = K::FT;
58 using Point_3 = K::Point_3;
59 using Sphere_3 = K::Sphere_3;
61 using Mesh_domain = CGAL::Labeled_mesh_domain_3<K>;
63 CGAL::Mesh_triangulation_3<Mesh_domain,
66 using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3<Tr, int, int>;
67 using Mesh_criteria = CGAL::Mesh_criteria_3<Tr>;
70 auto cgal_implicit_function = [&](
const Point_3 &p) {
72 dealii_implicit_function.
value(
Point<3>(p.x(), p.y(), p.z())));
75 Mesh_domain domain = Mesh_domain::create_implicit_mesh_domain(
76 cgal_implicit_function,
78 Point_3(interior_point[0], interior_point[1], interior_point[2]),
79 outer_ball_radius * outer_ball_radius));
81 Mesh_criteria criteria(CGAL::parameters::facet_size = data.
facet_size,
83 CGAL::parameters::facet_distance =
85 CGAL::parameters::cell_radius_edge_ratio =
87 CGAL::parameters::cell_size = data.
cell_size);
89 auto cgal_triangulation = CGAL::make_mesh_3<C3t3>(domain, criteria);
90 CGALWrappers::cgal_triangulation_to_dealii_triangulation(
91 cgal_triangulation,
tria);
93 else if constexpr (dim == 2)
96 using Tr = CGAL::Surface_mesh_default_triangulation_3;
97 using C2t3 = CGAL::Complex_2_in_triangulation_3<Tr>;
98 using GT = Tr::Geom_traits;
99 using Sphere_3 = GT::Sphere_3;
100 using Point_3 = GT::Point_3;
103 using Surface_3 = CGAL::Implicit_surface_3<GT, Function>;
104 using Surface_mesh = CGAL::Surface_mesh<Point_3>;
107 auto cgal_implicit_function = [&](
const Point_3 &p) {
109 dealii_implicit_function.
value(
Point<3>(p.x(), p.y(), p.z())));
112 Surface_3 surface(cgal_implicit_function,
113 Sphere_3(Point_3(interior_point[0],
116 outer_ball_radius * outer_ball_radius));
122 CGAL::Surface_mesh_default_criteria_3<Tr> criteria(data.angular_bound,
124 data.distance_bound);
125 CGAL::make_surface_mesh(c2t3,
128 CGAL::Non_manifold_tag());
129 CGAL::facets_in_complex_2_to_triangle_mesh(c2t3, mesh);
130 CGALWrappers::cgal_surface_mesh_to_dealii_triangulation(mesh,
tria);
140 (void)dealii_implicit_function;
142 (void)interior_point;
143 (void)outer_ball_radius;
156# ifdef DEAL_II_WITH_CGAL
160 "The input triangulation cannot be empty when calling this function."));
164 "The output triangulation must be empty when calling this function."));
165 using K = CGAL::Exact_predicates_inexact_constructions_kernel;
166 using Point_3 = K::Point_3;
169 CGAL::Polyhedral_mesh_domain_with_features_3<K,
170 CGAL::Surface_mesh<Point_3>>;
171 using Tr = CGAL::Mesh_triangulation_3<Mesh_domain,
174 using Mesh_criteria = CGAL::Mesh_criteria_3<Tr>;
176 CGAL::Mesh_complex_3_in_triangulation_3<Tr,
177 Mesh_domain::Corner_index,
178 Mesh_domain::Curve_index>;
180 CGAL::Surface_mesh<Point_3> mesh;
190 CGAL::Polygon_mesh_processing::triangulate_faces(mesh);
191 CGAL::Polygon_mesh_processing::stitch_borders(mesh);
192 Mesh_domain domain(mesh);
193 domain.detect_features();
194 Mesh_criteria criteria(CGAL::parameters::facet_size = data.
facet_size,
196 CGAL::parameters::facet_distance =
198 CGAL::parameters::cell_radius_edge_ratio =
200 CGAL::parameters::cell_size = data.
cell_size);
201 const auto cgal_triangulation = CGAL::make_mesh_3<C3t3>(domain, criteria);
202 CGALWrappers::cgal_triangulation_to_dealii_triangulation(cgal_triangulation,
217# include "grid_generator_cgal.inst"
const unsigned int n_components
virtual RangeNumberType value(const Point< dim > &p, const unsigned int component=0) const
unsigned int n_active_cells() const
unsigned int n_cells() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
void implicit_function(Triangulation< dim, 3 > &tria, const Function< 3 > &implicit_function, const CGALWrappers::AdditionalData< dim > &data=CGALWrappers::AdditionalData< dim >{}, const Point< 3 > &interior_point=Point< 3 >(), const double &outer_ball_radius=1.0)
void dealii_tria_to_cgal_surface_mesh(const ::Triangulation< dim, spacedim > &triangulation, CGAL::Surface_mesh< CGALPointType > &mesh)
CGAL::Sequential_tag ConcurrencyTag
void surface_mesh_to_volumetric_mesh(const Triangulation< 2, 3 > &surface_tria, Triangulation< 3 > &vol_tria, const CGALWrappers::AdditionalData< 3 > &data=CGALWrappers::AdditionalData< 3 >{})
double cell_radius_edge_ratio
const ::Triangulation< dim, spacedim > & tria