Skip to content

Commit

Permalink
Small modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrum committed Apr 14, 2023
1 parent e9a7e46 commit 5d10a22
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
18 changes: 14 additions & 4 deletions include/deal.II/base/function_signed_distance.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ namespace Functions
* @param top_right Top right point of the rectangle.
*/
Rectangle(const Point<dim> &bottom_left, const Point<dim> &top_right);
/**
* Constructor, takes a bounding box.
*
* @param bounding_box Bounding box.
*/
Rectangle(const BoundingBox<dim> bounding_box);

/**
* Calculates the signed distance from a given point @p p to the rectangle.
Expand Down Expand Up @@ -280,7 +286,6 @@ namespace Functions
* Constructor, takes the radius and center of the disk together
* with the width and the height of the notch.
*
*
* @param radius Radius of the disk.
* @param center Center of the disk.
* @param notch_width Width of the notch of the disk.
Expand All @@ -302,10 +307,15 @@ namespace Functions
const unsigned int component = 0) const override;

private:
/**
* Disk described by a sphere.
*/
const Functions::SignedDistance::Sphere<dim> sphere;
const BoundingBox<dim> notch;
const double radius;
const Point<dim> center_sphere;

/**
* Nothch described by a rectangle.
*/
const Functions::SignedDistance::Rectangle<dim> notch;
};
} // namespace SignedDistance
} // namespace Functions
Expand Down
16 changes: 10 additions & 6 deletions source/base/function_signed_distance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ namespace Functions



template <int dim>
Rectangle<dim>::Rectangle(const BoundingBox<dim> bounding_box)
: bounding_box(bounding_box)
{}



template <int dim>
double
Rectangle<dim>::value(const Point<dim> & p,
Expand All @@ -362,8 +369,7 @@ namespace Functions
const double notch_width,
const double notch_height)
: sphere(center, radius)
, notch(
{// bottom left
, notch(// bottom left
(dim == 1) ?
Point<dim>(center[0] - 0.5 * notch_width) :
(dim == 2) ?
Expand All @@ -382,9 +388,7 @@ namespace Functions
Point<dim>(center[0] + 0.5 * notch_width,
std::numeric_limits<
double>::max() /* notch is open in y-direction*/,
center[2] + notch_height - radius)})
, radius(radius)
, center_sphere(center)
center[2] + notch_height - radius))
{
Assert(
notch_width <= 2 * radius,
Expand All @@ -408,7 +412,7 @@ namespace Functions

// calculate the set difference between the level set functions of the
// sphere and the notch
return std::max(sphere.value(p), -notch.signed_distance(p));
return std::max(sphere.value(p), -notch.value(p));
}
} // namespace SignedDistance
} // namespace Functions
Expand Down

0 comments on commit 5d10a22

Please sign in to comment.