Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion EBGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "Source/EBGeometry_SimpleTimer.hpp"
#include "Source/EBGeometry_Transform.hpp"
#include "Source/EBGeometry_Triangle.hpp"
#include "Source/EBGeometry_Triangle2D.hpp"

/*!
@brief Name space for all of EBGeometry
Expand Down
5 changes: 5 additions & 0 deletions Examples/AMReX_Shapes/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ main(int argc, char* argv[])

func = std::make_shared<EBGeometry::PerlinSDF<T>>(0.5, 2.0 * Vec3::one(), 0.5, 4);
}
else if (whichGeom == 14) { // Rounded cylinder
rb = RealBox({-1, -1, -1}, {1, 1, 1});

func = std::make_shared<EBGeometry::RoundedCylinderSDF<T>>(0.5, 0.1, 1.0);
}

// AMReX uses the opposite sign.
func = EBGeometry::Complement<T>(func);
Expand Down
61 changes: 61 additions & 0 deletions Source/EBGeometry_AnalyticDistanceFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,67 @@ class PerlinSDF : public SignedDistanceFunction<T>
};
};

/*!
@brief Rounded cylinder signed-distance function
*/
template <class T>
class RoundedCylinderSDF : public SignedDistanceFunction<T>
{
public:
/*!
@brief Disallowed default constructor
*/
RoundedCylinderSDF() = delete;

/*!
@brief Full constructor. User inputs the radius, curvature, and height. Adjust parameters as necessary.
@param[in] a_radius Cylinder outer radius
@param[in] a_curvature Corner curvature
@param[in] a_height Cylinder height
*/
RoundedCylinderSDF(const T a_radius, const T a_curvature, const T a_height) noexcept
{
m_majorRadius = a_radius - a_curvature;
m_minorRadius = a_curvature;
m_height = 0.5 * a_height - a_curvature;
}

/*!
@brief Destructor (does nothing).
*/
virtual ~RoundedCylinderSDF() noexcept
{}

/*!
@brief Signed distance function for the rounded box
*/
virtual T
signedDistance(const Vec3T<T>& a_point) const noexcept override
{
const auto xz = sqrt(a_point[2] * a_point[2] + a_point[0] * a_point[0]);
const auto d1 = Vec2T<T>(xz - 2.0 * m_majorRadius + m_minorRadius, std::abs(a_point[1]) - m_height);
const auto d2 = Vec2T<T>(std::max(d1.x, 0.0), std::max(d1.y, 0.0));

return std::min(std::max(d1.x, d1.y), 0.0) + sqrt(d2.x * d2.x + d2.y * d2.y) - m_minorRadius;
}

protected:
/*!
@brief Major radius
*/
T m_majorRadius;

/*!
@brief Minor radius
*/
T m_minorRadius;

/*!
@brief Minor radius
*/
T m_height;
};

#include "EBGeometry_NamespaceFooter.hpp"

#endif
19 changes: 1 addition & 18 deletions Source/EBGeometry_Triangle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

// Our includes
#include "EBGeometry_Vec.hpp"
#include "EBGeometry_Triangle2D.hpp"

namespace EBGeometry {

Expand Down Expand Up @@ -228,32 +227,16 @@ namespace EBGeometry {
@brief Triangle vertex normals
*/
std::array<Vec3, 3> m_vertexNormals{Vec3::max(), Vec3::max(), Vec3::max()};

/*!
@brief Triangle edge normals
*/
std::array<Vec3, 3> m_edgeNormals{Vec3::max(), Vec3::max(), Vec3::max()};

/*!
@brief 2D projection of the triangle to one of the Cartesian coordinate directions
*/
Triangle2D<T> m_triangle2D;

/*!
@brief Triangle meta-data normals
*/
Meta m_metaData;

/*!
@brief Returns the "projection" of a point to an edge.
@details This function parametrizes the edge as x(t) = x0 + (x1-x0)*t and
returns where on the this edge the point a_x0 projects. If projects onto the
edge if t = [0,1] and to one of the start/end vertices otherwise.
@param[in] a_point Query point
@param[in] a_x0 Starting edge coordinate
@param[in] a_x1 Final edge coordinate
*/
T
projectPointToEdge(const Vec3& a_point, const Vec3& a_x0, const Vec3& a_x1) const noexcept;
};
} // namespace EBGeometry

Expand Down
204 changes: 0 additions & 204 deletions Source/EBGeometry_Triangle2D.hpp

This file was deleted.

Loading