19#ifdef DEAL_II_WITH_CGAL
39 const double &outer_ball_radius)
41# ifdef DEAL_II_WITH_CGAL
44 "The implicit function must have exactly one component."));
45 Assert(dealii_implicit_function.
value(interior_point) < 0,
47 "The implicit function must be negative at the interior point."));
48 Assert(outer_ball_radius > 0,
49 ExcMessage(
"The outer ball radius must be positive."));
51 ExcMessage(
"The triangulation must be empty."));
53 if constexpr (dim == 3)
55 using K = CGAL::Exact_predicates_inexact_constructions_kernel;
56 using NumberType = K::FT;
57 using Point_3 = K::Point_3;
58 using Sphere_3 = K::Sphere_3;
60 using Mesh_domain = CGAL::Labeled_mesh_domain_3<K>;
62 CGAL::Mesh_triangulation_3<Mesh_domain,
65 using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3<Tr, int, int>;
66 using Mesh_criteria = CGAL::Mesh_criteria_3<Tr>;
69 auto cgal_implicit_function = [&](
const Point_3 &p) {
71 dealii_implicit_function.
value(
Point<3>(p.x(), p.y(), p.z())));
74 Mesh_domain domain = Mesh_domain::create_implicit_mesh_domain(
75 cgal_implicit_function,
77 Point_3(interior_point[0], interior_point[1], interior_point[2]),
78 outer_ball_radius * outer_ball_radius));
80 Mesh_criteria criteria(CGAL::parameters::facet_size =
data.facet_size,
81 CGAL::parameters::facet_angle =
data.facet_angle,
82 CGAL::parameters::facet_distance =
84 CGAL::parameters::cell_radius_edge_ratio =
85 data.cell_radius_edge_ratio,
86 CGAL::parameters::cell_size =
data.cell_size);
88 auto cgal_triangulation = CGAL::make_mesh_3<C3t3>(domain, criteria);
89 CGALWrappers::cgal_triangulation_to_dealii_triangulation(
90 cgal_triangulation, tria);
92 else if constexpr (dim == 2)
95 using Tr = CGAL::Surface_mesh_default_triangulation_3;
96 using C2t3 = CGAL::Complex_2_in_triangulation_3<Tr>;
97 using GT = Tr::Geom_traits;
98 using Sphere_3 = GT::Sphere_3;
99 using Point_3 = GT::Point_3;
102 using Surface_3 = CGAL::Implicit_surface_3<GT, Function>;
106 auto cgal_implicit_function = [&](
const Point_3 &p) {
108 dealii_implicit_function.
value(
Point<3>(p.x(), p.y(), p.z())));
111 Surface_3 surface(cgal_implicit_function,
112 Sphere_3(Point_3(interior_point[0],
115 outer_ball_radius * outer_ball_radius));
121 CGAL::Surface_mesh_default_criteria_3<Tr> criteria(
data.angular_bound,
123 data.distance_bound);
124 CGAL::make_surface_mesh(c2t3,
127 CGAL::Non_manifold_tag());
128 CGAL::facets_in_complex_2_to_triangle_mesh(c2t3, mesh);
129 CGALWrappers::cgal_surface_mesh_to_dealii_triangulation(mesh, tria);
139 (void)dealii_implicit_function;
141 (void)interior_point;
142 (void)outer_ball_radius;
155# ifdef DEAL_II_WITH_CGAL
159 "The input triangulation cannot be empty when calling this function."));
163 "The output triangulation must be empty when calling this function."));
164 using K = CGAL::Exact_predicates_inexact_constructions_kernel;
165 using Point_3 = K::Point_3;
168 CGAL::Polyhedral_mesh_domain_with_features_3<
K,
169 CGAL::Surface_mesh<Point_3>>;
170 using Tr = CGAL::Mesh_triangulation_3<Mesh_domain,
173 using Mesh_criteria = CGAL::Mesh_criteria_3<Tr>;
175 CGAL::Mesh_complex_3_in_triangulation_3<Tr,
176 Mesh_domain::Corner_index,
177 Mesh_domain::Curve_index>;
179 CGAL::Surface_mesh<Point_3> mesh;
189 CGAL::Polygon_mesh_processing::triangulate_faces(mesh);
190 CGAL::Polygon_mesh_processing::stitch_borders(mesh);
191 Mesh_domain domain(mesh);
192 domain.detect_features();
193 Mesh_criteria criteria(CGAL::parameters::facet_size =
data.facet_size,
194 CGAL::parameters::facet_angle =
data.facet_angle,
195 CGAL::parameters::facet_distance =
197 CGAL::parameters::cell_radius_edge_ratio =
198 data.cell_radius_edge_ratio,
199 CGAL::parameters::cell_size =
data.cell_size);
200 const auto cgal_triangulation = CGAL::make_mesh_3<C3t3>(domain, criteria);
201 CGALWrappers::cgal_triangulation_to_dealii_triangulation(cgal_triangulation,
216# 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)
std::vector< index_type > data
void dealii_tria_to_cgal_surface_mesh(const ::Triangulation< dim, spacedim > &triangulation, CGAL::Surface_mesh< CGALPointType > &mesh)
CGAL::Surface_mesh< K_exact::Point_3 > Surface_mesh
CGAL::Sequential_tag ConcurrencyTag
CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt K
void surface_mesh_to_volumetric_mesh(const Triangulation< 2, 3 > &surface_tria, Triangulation< 3 > &vol_tria, const CGALWrappers::AdditionalData< 3 > &data=CGALWrappers::AdditionalData< 3 >{})
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)