23 namespace SignedDistance
38 const unsigned int component)
const
50 const unsigned int component)
const
64 const unsigned int component)
const
69 const double distance = center_to_point.
norm();
72 unit_symmetric_tensor<dim>() / distance -
74 Utilities::fixed_power<3>(distance);
83 : point_in_plane(point)
94 const unsigned int component)
const
98 return normal * (point - point_in_plane);
127 const std::array<double, dim> &radii,
128 const double tolerance,
129 const unsigned int max_iter)
132 , tolerance(tolerance)
135 for (
unsigned int d = 0; d < dim; ++d)
144 const unsigned int component)
const
149 return point.
distance(center) - radii[0];
151 return compute_signed_distance_ellipse(point);
163 const unsigned int component)
const
169 grad = point - center;
172 const Point<dim> point_in_centered_coordinate_system =
173 Point<dim>(compute_closest_point_ellipse(point) - center);
174 grad = compute_analyical_normal_vector_on_ellipse(
175 point_in_centered_coordinate_system);
180 if (grad.
norm() > 1e-12)
181 return grad / grad.
norm();
193 for (
unsigned int d = 0; d < dim; ++d)
194 val += Utilities::fixed_power<2>((point[d] - center[d]) / radii[d]);
221 const double px =
std::abs(point[0] - center[0]);
222 const double py =
std::abs(point[1] - center[1]);
223 const double sign_px = std::copysign(1.0, point[0] - center[0]);
224 const double sign_py = std::copysign(1.0, point[1] - center[1]);
226 const double &a = radii[0];
227 const double &b = radii[1];
233 unsigned int iter = 0;
239 (a * a - b * b) * Utilities::fixed_power<3>(
std::cos(t)) / a;
241 (b * b - a * a) * Utilities::fixed_power<3>(
std::sin(t)) / b;
243 const double rx = x - ex;
244 const double ry = y - ey;
246 const double qx = px - ex;
247 const double qy = py - ey;
249 const double r = std::hypot(rx, ry);
251 const double q = std::hypot(qx, qy);
253 const double delta_c = r *
std::asin((rx * qy - ry * qx) / (r * q));
255 delta_t = delta_c /
std::sqrt(a * a + b * b - x * x - y * y);
263 while (
std::abs(delta_t) > tolerance && iter < max_iter);
269 return center +
Point<dim>(sign_px * x, sign_py * y);
290 const auto &a = radii[0];
291 const auto &b = radii[1];
292 const auto &x = point[0];
293 const auto &y = point[1];
314 if (point.
distance(center) < tolerance)
315 return *std::min_element(radii.begin(), radii.end()) * -1.;
317 const Point<2> &closest_point = compute_closest_point_ellipse(point);
319 const double distance =
320 std::hypot(closest_point[0] - point[0], closest_point[1] - point[1]);
322 return evaluate_ellipsoid(point) < 0.0 ? -distance : distance;
330 : bounding_box({bottom_left, top_right})
337 : bounding_box(bounding_box)
345 const unsigned int component)
const
349 return bounding_box.signed_distance(p);
357 const double notch_width,
358 const double notch_height)
362 Point<dim>(center[0] - 0.5 * notch_width) :
364 Point<dim>(center[0] - 0.5 * notch_width,
365 std::numeric_limits<double>::lowest()) :
366 Point<dim>(center[0] - 0.5 * notch_width,
369 std::numeric_limits<double>::lowest()),
372 Point<dim>(center[0] + 0.5 * notch_width) :
374 Point<dim>(center[0] + 0.5 * notch_width,
375 center[1] + notch_height -
radius) :
376 Point<dim>(center[0] + 0.5 * notch_width,
379 center[2] + notch_height -
radius))
382 notch_width <= 2 *
radius,
384 "The width of the notch must be less than the circle diameter."));
386 notch_height <= 2 *
radius,
388 "The height of the notch must be less than the circle diameter."));
396 const unsigned int component)
const
402 return std::max(sphere.value(p), -notch.value(p));
413 , axis(axis_direction / axis_direction.norm())
417 ExcMessage(
"Cylinder radius must be positive."));
422 ExcMessage(
"Axis vector must be normalized (||axis|| = 1)."));
429 const unsigned int)
const
432 const double s = q * axis;
435 return q_perp.
norm() - R;
442 const unsigned int)
const
445 const double s = q * axis;
448 const double r = q_perp.
norm();
456#include "base/function_signed_distance.inst"
double value(const Point< dim > &point, const unsigned int component=0) const override
Tensor< 1, dim > gradient(const Point< dim > &, const unsigned int component=0) const override
double compute_signed_distance_ellipse(const Point< dim > &point) const
Point< dim > compute_closest_point_ellipse(const Point< dim > &point) const
Ellipsoid(const Point< dim > ¢er, const std::array< double, dim > &radii, const double tolerance=1e-14, const unsigned int max_iter=10)
double evaluate_ellipsoid(const Point< dim > &point) const
const std::array< double, dim > radii
Tensor< 1, dim, double > compute_analyical_normal_vector_on_ellipse(const Point< dim > &point) const
Tensor< 1, dim > gradient(const Point< dim > &point, const unsigned int component=0) const override
double value(const Point< dim > &point, const unsigned int component=0) const override
const Tensor< 1, dim > axis
InfiniteCylinder(const double radius, const Tensor< 1, dim > &axis_direction=[] { Tensor< 1, dim > a;a[dim - 1]=1.0;return a;}(), const Point< dim > &axis_point=Point< dim >())
Plane(const Point< dim > &point, const Tensor< 1, dim > &normal)
double value(const Point< dim > &point, const unsigned int component=0) const override
SymmetricTensor< 2, dim > hessian(const Point< dim > &, const unsigned int component=0) const override
Tensor< 1, dim > gradient(const Point< dim > &, const unsigned int component=0) const override
const Tensor< 1, dim > normal
double value(const Point< dim > &p, const unsigned int component=0) const override
Rectangle(const Point< dim > &bottom_left, const Point< dim > &top_right)
Sphere(const Point< dim > ¢er=Point< dim >(), const double radius=1)
SymmetricTensor< 2, dim > hessian(const Point< dim > &point, const unsigned int component=0) const override
double value(const Point< dim > &point, const unsigned int component=0) const override
Tensor< 1, dim > gradient(const Point< dim > &point, const unsigned int component=0) const override
ZalesakDisk(const Point< dim > ¢er, const double radius, const double notch_width, const double notch_height)
double value(const Point< dim > &p, const unsigned int component=0) const override
numbers::NumberTraits< Number >::real_type distance(const Point< dim, Number > &p) const
numbers::NumberTraits< Number >::real_type norm() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NOT_IMPLEMENTED()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertIsFinite(number)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
inline ::VectorizedArray< Number, width > asin(const ::VectorizedArray< Number, width > &x)
constexpr SymmetricTensor< 2, dim, Number > symmetrize(const Tensor< 2, dim, Number > &t)
constexpr SymmetricTensor< 4, dim, Number > outer_product(const SymmetricTensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)