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 all 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
20 changes: 18 additions & 2 deletions src/orange/OrangeTypes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ enum class Sense : bool
/*!
* Enumeration for mapping surface classes to integers.
*
* These are ordered by number of coefficients needed for their representation:
* 1 for `p.|sc|c.c`, 3 for `c.`, 4 for `[ps]|k.`, 7 for `sq`, and 10 for `gq`.
* These are ordered roughly by complexity. The storage requirement for
* corresponding surfaces are:
* - 1 for `p.|sc|c.c`,
* - 3 for `c.`,
* - 4 for `[ps]|k.`,
* - 7 for `sq`, and
* - 10 for `gq`.
*
* See \c orange/surf/SurfaceTypeTraits.hh for how these map to classes.
*/
Expand All @@ -126,6 +131,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 Expand Up @@ -211,6 +217,16 @@ enum class BoundaryResult : bool
exiting = true
};

//---------------------------------------------------------------------------//
/*!
* Chirality of a twirly object (currently only Involute).
*/
enum class Chirality : bool
{
left, //!< Sinistral, spiraling counterclockwise
right, //!< Dextral, spiraling clockwise
};

//---------------------------------------------------------------------------//
/*!
* Volume logic encoding.
Expand Down
7 changes: 7 additions & 0 deletions src/orange/detail/SurfacesRecordBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ auto SurfacesRecordBuilder::operator()(VecSurface const& surfaces) -> result_typ

// Functor to save the surface type and data, and the data offset
auto emplace_surface = [this](auto&& s) {
if constexpr (std::remove_reference_t<decltype(s)>::surface_type()
== SurfaceType::inv)
{
// See discussion on
// https://github.com/celeritas-project/celeritas/pull/1342
CELER_NOT_IMPLEMENTED("runtime involute support");
}
types_.push_back(s.surface_type());
auto data = s.data();
auto real_range = reals_.insert_back(data.begin(), data.end());
Expand Down
84 changes: 81 additions & 3 deletions src/orange/orangeinp/IntersectRegion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
#include "corecel/math/SoftEqual.hh"
#include "geocel/BoundingBox.hh"
#include "geocel/Types.hh"
#include "orange/OrangeTypes.hh"
#include "orange/orangeinp/detail/PolygonUtils.hh"
#include "orange/surf/ConeAligned.hh"
#include "orange/surf/CylCentered.hh"
#include "orange/surf/Involute.hh"
#include "orange/surf/PlaneAligned.hh"
#include "orange/surf/SimpleQuadric.hh"
#include "orange/surf/SphereCentered.hh"
Expand Down Expand Up @@ -647,6 +649,82 @@ void InfWedge::output(JsonPimpl* j) const
to_json_pimpl(j, *this);
}

//---------------------------------------------------------------------------//
// Involute
//---------------------------------------------------------------------------//
/*!
* Construct with prarameters and half height.
*/
Involute::Involute(Real3 const& radii,
Real2 const& displacement,
Chirality sign,
real_type halfheight)
: radii_(radii), a_(displacement), t_bounds_(), sign_(sign), hh_{halfheight}
{
CELER_VALIDATE(radii_[0] > 0,
<< "nonpositive involute radius: " << radii_[0]);
CELER_VALIDATE(radii_[1] > radii_[0],
<< "inner cylinder radius " << radii_[1]
<< " is not greater than involute radius " << radii_[0]);
CELER_VALIDATE(radii_[2] > radii_[1],
<< "outer cylinder radius " << radii_[2]
<< " is not greater than inner cyl radius " << radii_[1]);

CELER_VALIDATE(a_[1] > a_[0],
<< "nonpositive delta displacment: " << a_[1] - a_[0]);
CELER_VALIDATE(hh_ > 0, << "nonpositive half-height: " << hh_);

for (auto i : range(2))
{
t_bounds_[i] = std::sqrt(
clamp_to_nonneg(ipow<2>(radii_[i + 1] / radii_[0]) - 1));
}
auto outer_isect = t_bounds_[0] + 2 * constants::pi - (a_[1] - a_[0]);
CELER_VALIDATE(t_bounds_[1] < outer_isect,
<< "radial bounds result in angular overlap: "
<< outer_isect - t_bounds_[1]);
}

//---------------------------------------------------------------------------//
/*!
* Build surfaces.
*/
void Involute::build(IntersectSurfaceBuilder& insert_surface) const
{
using InvSurf = ::celeritas::Involute;

insert_surface(Sense::outside, PlaneZ{-hh_});
insert_surface(Sense::inside, PlaneZ{hh_});
insert_surface(Sense::outside, CCylZ{radii_[1]});
insert_surface(Sense::inside, CCylZ{radii_[2]});
// Make an inside and outside involute
Real2 const xy{0, 0};
auto sense = (sign_ == Chirality::right ? Sense::outside : Sense::inside);
static char const* names[] = {"invl", "invr"};

for (auto i : range(2))
{
insert_surface(sense,
InvSurf{xy,
radii_[0],
eumod(a_[i], 2 * constants::pi),
sign_,
t_bounds_[0],
t_bounds_[1] + a_[1] - a_[0]},
std::string{names[i]});
sense = flip_sense(sense);
}
}

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

//---------------------------------------------------------------------------//
// PARALLELEPIPED
//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -687,18 +765,18 @@ void Parallelepiped::build(IntersectSurfaceBuilder& insert_surface) const
constexpr auto Y = to_int(Axis::y);
constexpr auto Z = to_int(Axis::z);

// cache trigonometric values
// Cache trigonometric values
real_type sinth, costh, sinphi, cosphi, sinal, cosal;
sincos(theta_, &sinth, &costh);
sincos(phi_, &sinphi, &cosphi);
sincos(alpha_, &sinal, &cosal);

// base vectors
// Base vectors
auto a = hpr_[X] * Real3{1, 0, 0};
auto b = hpr_[Y] * Real3{sinal, cosal, 0};
auto c = hpr_[Z] * Real3{sinth * cosphi, sinth * sinphi, costh};

// positioning the planes
// Position the planes
auto xnorm = make_unit_vector(cross_product(b, c));
auto ynorm = make_unit_vector(cross_product(c, a));
auto xoffset = dot_product(a, xnorm);
Expand Down
47 changes: 47 additions & 0 deletions src/orange/orangeinp/IntersectRegion.hh
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,53 @@ class InfWedge final : public IntersectRegionInterface
Turn interior_;
};

//---------------------------------------------------------------------------//
/*!
* An involute "blade" centered on the origin.
*
* This is the intersection of two parallel involutes with a cylindrical shell.
* The three radii, which must be in ascending order, are that of the involute,
* the inner cylinder, and the outer cylinder.
*
* The "chirality" of the involute is viewed from the \em +z axis looking down:
* whether it spirals to the right or left.
*/
class Involute final : public IntersectRegionInterface
{
public:
// Construct with radius
explicit Involute(Real3 const& radii,
Real2 const& displacement,
Chirality chirality,
real_type halfheight);

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

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

//// ACCESSORS ////

//! Radii: Rdius of involute, minimum radius, maximum radius
Real3 const& radii() const { return radii_; }
//! Displacement angle
Real2 const& displacement_angle() const { return a_; }
//! Angular bounds of involute
Real2 const& t_bounds() const { return t_bounds_; }
//! Chirality of involute: turning left or right
Chirality chirality() const { return sign_; }
//! Halfheight
real_type halfheight() const { return hh_; }

private:
Real3 radii_;
Real2 a_;
Real2 t_bounds_;
Chirality sign_;
real_type hh_;
};

//---------------------------------------------------------------------------//
/*!
* A general parallelepiped 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
9 changes: 9 additions & 0 deletions src/orange/orangeinp/ObjectIO.json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ 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, displacement_angle),
SIO_ATTR_PAIR(cr, t_bounds),
SIO_ATTR_PAIR(cr, chirality),
SIO_ATTR_PAIR(cr, halfheight)};
}
//!@}

//---------------------------------------------------------------------------//
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
5 changes: 5 additions & 0 deletions src/orange/orangeinp/detail/SurfaceHashPoint.hh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ struct SurfaceHashPoint
return norm(s.origin());
}

real_type operator()(Involute const& s) const
{
return s.displacement_angle();
}

real_type operator()(SimpleQuadric const& s) const
{
return std::sqrt(s.zeroth());
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
4 changes: 2 additions & 2 deletions src/orange/surf/Involute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace celeritas
Involute::Involute(Real2 const& origin,
real_type radius,
real_type displacement,
Sign sign,
Chirality sign,
real_type tmin,
real_type tmax)
: origin_(origin), r_b_(radius), a_(displacement), tmin_(tmin), tmax_(tmax)
Expand All @@ -33,7 +33,7 @@ Involute::Involute(Real2 const& origin,
CELER_EXPECT(tmin_ >= 0);
CELER_EXPECT(tmax_ > tmin_ && tmax_ < 2 * constants::pi + tmin_);

if (sign)
if (sign == Chirality::right)
{
a_ = constants::pi - a_;
r_b_ = -r_b_;
Expand Down
Loading
Loading