Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate involute surface into ORANGE construction #1342

Merged
merged 47 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
dc4653b
revert seperation of runtime
VHLM2001 Jul 30, 2024
640ccf4
Fix conflict that went silent
VHLM2001 Jul 30, 2024
0eecedb
Fix SurfaceTranslator.cc
VHLM2001 Jul 31, 2024
f055f43
Involute Shape Stuff
VHLM2001 Aug 7, 2024
407e0a8
Updated Shape and Test Geometry
VHLM2001 Aug 8, 2024
97daa35
IntersectRegion Involute tests
VHLM2001 Aug 9, 2024
8968d45
Working Adjacent Involute Model
VHLM2001 Aug 9, 2024
1b524b4
Start of Fuel Blade Input
VHLM2001 Aug 9, 2024
a707f9f
fix particle position
VHLM2001 Aug 9, 2024
61c7fd3
Clockwise weird behavior
VHLM2001 Aug 12, 2024
076dfc0
Fixing Sign
VHLM2001 Aug 12, 2024
dbda596
Clockwise Involute Unit Test
VHLM2001 Aug 12, 2024
aef2af7
Additional involute test case
VHLM2001 Aug 13, 2024
e336b69
Fixed a comment
VHLM2001 Aug 13, 2024
5d38f25
SoftSurfaceEqual Involute
VHLM2001 Aug 13, 2024
e595b2b
SurfaceIO update for Involute
VHLM2001 Aug 13, 2024
f7988d1
SurfaceTransator involute cleanup
VHLM2001 Aug 13, 2024
e913633
SoftSurfaceEqual Involute 2
VHLM2001 Aug 13, 2024
839b848
FaceNamer update
VHLM2001 Aug 13, 2024
4c7af4c
Update SurfaceHashPoint.hh
VHLM2001 Aug 13, 2024
09b9339
Variable name update
VHLM2001 Aug 13, 2024
18340da
Reordering
VHLM2001 Aug 13, 2024
3ca8136
Some clean up
VHLM2001 Aug 14, 2024
469b0b1
Fix order in OrangeTypes.cc
VHLM2001 Aug 14, 2024
1d0a4a2
Fix Json files for involute
VHLM2001 Aug 14, 2024
2bcc307
Merge branch 'develop' into involute-integration
VHLM2001 Aug 14, 2024
053e953
Weird floating point stuff
VHLM2001 Aug 14, 2024
3f6080a
Merge branch 'involute-integration' of https://github.com/VHLM2001/ce…
VHLM2001 Aug 14, 2024
5849f4e
Forgot a linne
VHLM2001 Aug 14, 2024
b65fa67
float debugging
VHLM2001 Aug 15, 2024
51f83c3
Weird float interaction with involute test case
VHLM2001 Aug 15, 2024
ee5ac00
Reorder involute to be after all other surfaces
sethrj Aug 20, 2024
b3f9d95
Format (clang-format version 18.1.6)
Aug 20, 2024
3f47763
Address review feedback
sethrj Aug 21, 2024
34f2619
Merge remote-tracking branch 'upstream/develop' into involute-integra…
sethrj Aug 21, 2024
87e123d
fixup! Address review feedback
sethrj Aug 21, 2024
07ada36
Fix gcc failure
sethrj Aug 27, 2024
d8c172a
Merge remote-tracking branch 'upstream/develop' into involute-integra…
sethrj Aug 28, 2024
3f79cbc
Disable involute at runtime
sethrj Aug 29, 2024
82a5ab5
Merge remote-tracking branch 'upstream/develop' into involute-integra…
sethrj Aug 29, 2024
4dedbd3
Don't ever print debug messages from device when not DEBUG
sethrj Aug 29, 2024
bfdaabf
Fix runtime error messages on HIP NDEBUG
sethrj Aug 29, 2024
f6bf5a9
Merge branch 'develop' into involute-integration
sethrj Aug 29, 2024
e3cbf3c
Merge remote-tracking branch 'upstream/develop' into involute-integra…
sethrj Sep 5, 2024
46a7344
Prevent involutes at runtime, period
sethrj Sep 5, 2024
2338f27
fixup! Prevent involutes at runtime, period
sethrj Sep 5, 2024
9a71884
Revert changes to assertion for now
sethrj Sep 5, 2024
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: 1 addition & 0 deletions src/orange/OrangeTypes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ char const* to_cstring(SurfaceType value)
"kz",
"sq",
"gq",
"inv"
// clang-format on
};
return to_cstring_impl(value);
Expand Down
1 change: 1 addition & 0 deletions src/orange/OrangeTypes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ enum class SurfaceType : unsigned char
kz, //!< Cone parallel to Z axis
sq, //!< Simple quadric
gq, //!< General quadric
inv, //!< Involute
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved
size_ //!< Sentinel value for number of surface types
};

Expand Down
78 changes: 78 additions & 0 deletions src/orange/orangeinp/IntersectRegion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "orange/surf/PlaneAligned.hh"
#include "orange/surf/SimpleQuadric.hh"
#include "orange/surf/SphereCentered.hh"
#include "orange/surf/Involute.hh"

#include "IntersectSurfaceBuilder.hh"
#include "ObjectIO.json.hh"
Expand Down Expand Up @@ -90,6 +91,83 @@ void Box::output(JsonPimpl* j) const
to_json_pimpl(j, *this);
}

//---------------------------------------------------------------------------//
// Involute
//---------------------------------------------------------------------------//
/*!
* Construct with prarameters and half height.
*/
Involute::Involute(Real3 const& radii, Real2 const& displacement,
Sign sign, real_type halfheight) :
radii_(radii), a_(displacement), tmin_(), tmax_(), sign_(sign), hh_{halfheight}
{
for (auto i : range(3))
{
CELER_VALIDATE(radii_[i] >= 0, << "negative radius: " << radii_[i]);
}

tmin_ = std::sqrt(clamp_to_nonneg(ipow<2>(radii_[1]/radii_[0]) - 1));
tmax_ = std::sqrt(clamp_to_nonneg(ipow<2>(radii_[2]/radii_[0]) - 1));

for (auto i : range(2))
{
CELER_VALIDATE(a_[i] >= 0, << "negative displacment angle: " << a_[i]);
}
CELER_VALIDATE(a_[1] > a_[0],
<< "nonpositive delta displacment: " << a_[1]-a_[0]);
CELER_VALIDATE(hh_ > 0, << "nonpositive half-height: " << hh_);

CELER_VALIDATE(tmin_ > 0, << "nonpositive inner radius: " << tmin_);
CELER_VALIDATE(tmax_ > tmin_, << "outer radius smaller than inner radius: "
<< tmax_);
CELER_VALIDATE(tmax_ < tmin_ + 2 * constants::pi - (a_[1]-a_[0]),
<< "radial bounds result in angular overlaped: "
<< tmin_ + 2 * constants::pi - (a_[1]-a_[0]) - tmax_);
}

//---------------------------------------------------------------------------//
/*!
* Build surfaces.
*/
void Involute::build(IntersectSurfaceBuilder& insert_surface) const
{
if (sign_ == Sign::clockwise)
{
insert_surface(Sense::outside, celeritas::Involute{{0,0}, radii_[0],
eumod(a_[0], 2*constants::pi),
sign_, tmin_,
tmax_+a_[1]-a_[0]});
insert_surface(Sense::inside, celeritas::Involute{{0,0}, radii_[0],
eumod(a_[1], 2*constants::pi),
sign_, tmin_,
tmax_+a_[1]-a_[0]});
}
else
{
insert_surface(Sense::inside, celeritas::Involute{{0,0}, radii_[0],
eumod(a_[0], 2*constants::pi),
sign_, tmin_,
tmax_+a_[1]-a_[0]});
insert_surface(Sense::outside, celeritas::Involute{{0,0}, radii_[0],
eumod(a_[1], 2*constants::pi),
sign_, tmin_,
tmax_+a_[1]-a_[0]});
}
insert_surface(Sense::outside, PlaneZ{-hh_});
insert_surface(Sense::inside, PlaneZ{hh_});
insert_surface(Sense::inside, CCylZ{radii_[2]});
insert_surface(Sense::outside, CCylZ{radii_[1]});
}

//---------------------------------------------------------------------------//
/*!
* Write output to the given JSON object.
*/
void Involute::output(JsonPimpl* j) const
{
to_json_pimpl(j, *this);
}

//---------------------------------------------------------------------------//
// CONE
//---------------------------------------------------------------------------//
Expand Down
45 changes: 45 additions & 0 deletions src/orange/orangeinp/IntersectRegion.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "corecel/math/Turn.hh"
#include "orange/OrangeTypes.hh"

#include "../surf/detail/InvoluteSolver.hh"
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved

namespace celeritas
{
struct JsonPimpl;
Expand Down Expand Up @@ -84,6 +86,49 @@ class Box final : public IntersectRegionInterface
Real3 hw_;
};

//---------------------------------------------------------------------------//
/*!
* An involute centered on the origin.
*
* \note Be aware there's also an involute *surface* at orange/surf/Involute.hh
* in a different namespace.
*/
class Involute final : public IntersectRegionInterface
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved
{
public:
//! Enum defining chirality of involute
using Sign = celeritas::detail::InvoluteSolver::Sign;


// Construct with radius
explicit Involute(Real3 const& radii, Real2 const& displacement,
Sign sign, real_type halfheight);

// Build surfaces
void build(IntersectSurfaceBuilder&) const final;

// Output to JSON
void output(JsonPimpl*) const final;

//// ACCESSORS ////

//! Radius
Real3 radii() const { return radii_; }
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved
Real2 a() const { return a_; }
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved
real_type tmin() const { return tmin_; }
real_type tmax() const { return tmax_; }
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved
Sign sign() const { return sign_; }
real_type hh() const { return hh_; }
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved

private:
Real3 radii_;
Real2 a_;
real_type tmin_;
real_type tmax_;
Sign sign_;
real_type hh_;
};

//---------------------------------------------------------------------------//
/*!
* A closed cone along the Z axis centered on the origin.
Expand Down
1 change: 1 addition & 0 deletions src/orange/orangeinp/IntersectSurfaceBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ CSB_INSTANTIATE(ConeAligned<Axis::y>);
CSB_INSTANTIATE(ConeAligned<Axis::z>);
CSB_INSTANTIATE(SimpleQuadric);
CSB_INSTANTIATE(GeneralQuadric);
CSB_INSTANTIATE(Involute);
#undef CSB_INSTANTIATE
//! \endcond

Expand Down
10 changes: 10 additions & 0 deletions src/orange/orangeinp/ObjectIO.json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ void to_json(nlohmann::json& j, Sphere const& cr)
{
j = {{"_type", "sphere"}, SIO_ATTR_PAIR(cr, radius)};
}
void to_json(nlohmann::json& j, Involute const& cr)
{
j = {{"_type", "involute"},
SIO_ATTR_PAIR(cr, radii),
SIO_ATTR_PAIR(cr, a),
SIO_ATTR_PAIR(cr, tmin),
SIO_ATTR_PAIR(cr, tmax),
SIO_ATTR_PAIR(cr, sign),
SIO_ATTR_PAIR(cr, hh)};
}
//!@}

//---------------------------------------------------------------------------//
Expand Down
2 changes: 2 additions & 0 deletions src/orange/orangeinp/ObjectIO.json.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class InfWedge;
class Parallelepiped;
class Prism;
class Sphere;
class Involute;

//---------------------------------------------------------------------------//

Expand Down Expand Up @@ -74,6 +75,7 @@ void to_json(nlohmann::json& j, InfWedge const& cr);
void to_json(nlohmann::json& j, Parallelepiped const& cr);
void to_json(nlohmann::json& j, Prism const& cr);
void to_json(nlohmann::json& j, Sphere const& cr);
void to_json(nlohmann::json& j, Involute const& cr);

//---------------------------------------------------------------------------//
} // namespace orangeinp
Expand Down
1 change: 1 addition & 0 deletions src/orange/orangeinp/detail/LocalSurfaceInserter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ LSI_INSTANTIATE(ConeAligned<Axis::y>);
LSI_INSTANTIATE(ConeAligned<Axis::z>);
LSI_INSTANTIATE(SimpleQuadric);
LSI_INSTANTIATE(GeneralQuadric);
LSI_INSTANTIATE(Involute);

#undef LSI_INSTANTIATE
//! \endcond
Expand Down
2 changes: 2 additions & 0 deletions src/orange/orangeinp/detail/SurfaceHashPoint.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ struct SurfaceHashPoint
return std::sqrt(s.radius_sq());
}

real_type operator()(Involute const& s) const { return s.r_b(); }
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved

template<Axis T>
real_type operator()(CylAligned<T> const& s) const
{
Expand Down
9 changes: 9 additions & 0 deletions src/orange/surf/FaceNamer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ std::string FaceNamer::Impl::operator()(Sphere const&) const
return "s";
}

//---------------------------------------------------------------------------//
/*!
* Construct a name for an involute.
*/
std::string FaceNamer::Impl::operator()(Involute const&) const
{
return "inv";
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved
}

//---------------------------------------------------------------------------//
/*!
* Construct a name for a cone.
Expand Down
2 changes: 2 additions & 0 deletions src/orange/surf/FaceNamer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class FaceNamer
std::string operator()(SimpleQuadric const&) const;

std::string operator()(GeneralQuadric const&) const;

std::string operator()(Involute const&) const;
};
};

Expand Down
2 changes: 1 addition & 1 deletion src/orange/surf/Involute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Involute::Involute(Real2 const& origin,
CELER_EXPECT(tmin_ >= 0);
CELER_EXPECT(tmax_ > tmin_ && tmax_ < 2 * constants::pi + tmin_);

if (sign)
if (sign == Sign::clockwise)
{
a_ = constants::pi - a_;
r_b_ = -r_b_;
Expand Down
4 changes: 2 additions & 2 deletions src/orange/surf/Involute.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class Involute
//// CLASS ATTRIBUTES ////

// Surface type identifier
static SurfaceType surface_type()
static CELER_CONSTEXPR_FUNCTION SurfaceType surface_type()
{
CELER_NOT_IMPLEMENTED("runtime involute");
return SurfaceType::inv;
}

// Safety
Expand Down
15 changes: 15 additions & 0 deletions src/orange/surf/SoftSurfaceEqual.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ bool SoftSurfaceEqual::operator()(SphereCentered const& a,
return this->soft_eq_sq(a.radius_sq(), b.radius_sq());
}

//---------------------------------------------------------------------------//
/*!
* Compare two centered involutes for near equality.
*/
bool SoftSurfaceEqual::operator()(Involute const& a, Involute const& b) const
{
return this->soft_eq_sq(a.r_b(), b.r_b()) && this->soft_eq_sq(a.a(), b.a())
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved
&& this->soft_eq_sq(a.sign() == Involute::Sign::clockwise,
b.sign() == Involute::Sign::clockwise)
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved
&& this->soft_eq_sq(a.tmin(), b.tmin())
&& this->soft_eq_sq(a.tmax(), b.tmax())
&& this->soft_eq_sq(a.origin()[0], b.origin()[0])
&& this->soft_eq_sq(a.origin()[1], b.origin()[1]);
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved
}

//---------------------------------------------------------------------------//
/*!
* Compare two aligned cylinders for near equality.
Expand Down
2 changes: 2 additions & 0 deletions src/orange/surf/SoftSurfaceEqual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class SoftSurfaceEqual

bool operator()(Sphere const&, Sphere const&) const;

bool operator()(Involute const&, Involute const&) const;

template<Axis T>
bool operator()(ConeAligned<T> const&, ConeAligned<T> const&) const;

Expand Down
10 changes: 10 additions & 0 deletions src/orange/surf/SurfaceClipper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ void SurfaceClipper::operator()(GeneralQuadric const&) const
*int_ = BoundingBox{};
}

//---------------------------------------------------------------------------//
/*!
* Clip the bounding boxes to an involute.
*/
void SurfaceClipper::operator()(Involute const&) const
{
// We no longer can guarantee any point being inside the shape; reset it
*int_ = BoundingBox{};
}

//---------------------------------------------------------------------------//
/*!
* Clip a variant surface.
Expand Down
2 changes: 2 additions & 0 deletions src/orange/surf/SurfaceClipper.hh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class SurfaceClipper

void operator()(GeneralQuadric const&) const;

void operator()(Involute const&) const;

// Apply to a surface with unknown type
void operator()(VariantSurface const& surf) const;

Expand Down
3 changes: 2 additions & 1 deletion src/orange/surf/SurfaceIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ std::ostream& operator<<(std::ostream& os, SphereCentered const& s)
std::ostream& operator<<(std::ostream& os, Involute const& s)
{
os << "Involute: r, a, sign, tmin, tmax =" << s.r_b() << ' ' << s.a()
<< ' ' << s.sign() << ' ' << s.tmin() << ' ' << s.tmax() << " at "
<< ' ' << (s.sign() == Involute::Sign::clockwise) << ' ' << s.tmin()
<< ' ' << s.tmax() << " at "
<< s.origin();
return os;
}
Expand Down
2 changes: 2 additions & 0 deletions src/orange/surf/SurfaceTypeTraits.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ORANGE_SURFACE_TRAITS(ky, ConeAligned<Axis::y>);
ORANGE_SURFACE_TRAITS(kz, ConeAligned<Axis::z>);
ORANGE_SURFACE_TRAITS(sq, SimpleQuadric);
ORANGE_SURFACE_TRAITS(gq, GeneralQuadric);
ORANGE_SURFACE_TRAITS(inv, Involute);
// clang-format on

#undef ORANGE_SURFACE_TRAITS
Expand Down Expand Up @@ -90,6 +91,7 @@ visit_surface_type(F&& func, SurfaceType st)
ORANGE_ST_VISIT_CASE(kz);
ORANGE_ST_VISIT_CASE(sq);
ORANGE_ST_VISIT_CASE(gq);
ORANGE_ST_VISIT_CASE(inv);
default:
CELER_ASSERT_UNREACHABLE();
}
Expand Down
1 change: 1 addition & 0 deletions src/orange/surf/detail/AllSurfaces.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "../CylAligned.hh"
#include "../CylCentered.hh"
#include "../GeneralQuadric.hh"
#include "../Involute.hh"
#include "../Plane.hh"
#include "../PlaneAligned.hh"
#include "../SimpleQuadric.hh"
Expand Down
4 changes: 2 additions & 2 deletions src/orange/surf/detail/InvoluteSolver.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class InvoluteSolver
using Real2 = Array<real_type, 2>;

//! Enum defining chirality of involute
enum Sign : bool
enum class Sign : bool
{
counterclockwise = 0,
clockwise, //!< Apply symmetry when solving
Expand Down Expand Up @@ -152,7 +152,7 @@ InvoluteSolver::operator()(Real3 const& pos,
real_type v = dir[1];

// Mirror systemm for counterclockwise involutes
if (sign_)
if (sign_==Sign::clockwise)
VHLM2001 marked this conversation as resolved.
Show resolved Hide resolved
{
x = -x;
u = -u;
Expand Down
Loading