Conversation
Test summary 254 files 410 suites 9s ⏱️ Results for commit 109dd84. ♻️ This comment has been updated with latest results. |
|
Update: both questions resolved
|
…sub not being declared inline properly
sethrj
left a comment
There was a problem hiding this comment.
This is really amazing work @osanstrong ! I have a couple of comments so far from a quick review, but I think what you've got is practically perfect.
| /*! | ||
| * Shorthand for subtracting vector b from vector a | ||
| */ | ||
| CELER_FUNCTION Real3 Toroid::sub(Real3 const& a, Real3 const& b) |
There was a problem hiding this comment.
This and sq can be CELER_CONSTEXPR_FUNCTION; you can also include ArrayOperator.hh (which we discourage by default because it's easy to write surprisingly inefficient expressions like (x = a - b + c * d)) and just use a - b.
| { | ||
| auto [x0, y0, z0] = sub(pos, origin_); | ||
|
|
||
| real_type d = std::sqrt(sq(x0) + sq(y0)); |
There was a problem hiding this comment.
Use hypot from corecel/math/Algorithms.hh
| real_type d = std::sqrt(sq(x0) + sq(y0)); | |
| real_type d = hypot(x0, y0); |
| real_type A0 = 4 * sq(r_); | ||
| real_type B0 = sq(r_) - sq(a_); |
There was a problem hiding this comment.
We try to keep to the variable formatting standards even for math equations (no uppercase), and it looks like you might even be able to easily eliminate these two variables since they're only used once (q, u)
|
|
||
| real_type f = 1 - sq(az); | ||
| real_type g = f + p * sq(az); | ||
| real_type l = 2 * (x0 * ax + y0 * ay); |
There was a problem hiding this comment.
l is also dangerous since it looks like 1 and I 🙃
| if (val < 0) | ||
| return SignedSense::inside; | ||
| else if (val > 0) | ||
| return SignedSense::outside; | ||
| else | ||
| return SignedSense::on; |
There was a problem hiding this comment.
From orange/SenseUtils.hh, use real_to_sense
| if (val < 0) | |
| return SignedSense::inside; | |
| else if (val > 0) | |
| return SignedSense::outside; | |
| else | |
| return SignedSense::on; | |
| return real_to_sense(val); |
elliottbiondo
left a comment
There was a problem hiding this comment.
Looks great @osanstrong! Just a couple of things.
| * \f[ | ||
| * (x^2 + y^2 + p*y^2 + B_0) - A_0 * (x^2 + y^2) = 0 | ||
| * \f] | ||
| * where \f[p = a^2/b^2, A_0 = 4*r^2, and B_0 = (r^2-a^2)\f]. |
There was a problem hiding this comment.
For inline LaTeX use \f$ ... \f$
There was a problem hiding this comment.
Let's also add this to the user docs
| namespace celeritas | ||
| { | ||
| //---------------------------------------------------------------------------// | ||
| /** |
There was a problem hiding this comment.
| /** | |
| /* |
| { | ||
| //---------------------------------------------------------------------------// | ||
| /** | ||
| * Construct toroid from origin point and radii |
There was a problem hiding this comment.
| * Construct toroid from origin point and radii | |
| * Construct toroid from origin point and radii. |
| /** | ||
| * Construct toroid from origin point and radii | ||
| * | ||
| * \param origin 3d origin of the toroid. |
There was a problem hiding this comment.
| * \param origin 3d origin of the toroid. | |
| * \param Origin 3d origin of the toroid. |
There was a problem hiding this comment.
No, origin is the name of the parameter, which should be lowercase
| , a_(ellipse_xy_radius) | ||
| , b_(ellipse_z_radius) | ||
| { | ||
| CELER_EXPECT(major_radius > 0); |
There was a problem hiding this comment.
It doesn't matter too much, but usually we validate the member data rather than the arguments
There was a problem hiding this comment.
The reason I validate data is it'll also catch the error or forgetting to initialize it :)
| * around a central axis. This shape can be used in everything from pipe bends | ||
| * to tokamaks in fusion reactors. Possesses a major radius r, and ellipse | ||
| * radii a and b, as shown in the below diagram: | ||
| * ___ _________ ___ |
There was a problem hiding this comment.
Put ASCII art in a \verbatim block
| CELER_FUNCTION real_type ellipse_z_radius() const { return b_; } | ||
|
|
||
| //! View of data for type-deleted storage | ||
| CELER_FUNCTION StorageSpan data() const { return {&origin_[0], 4}; } |
There was a problem hiding this comment.
The length should be 6: i.e., 3 for origin_ then r_, a_, b_.
@sethrj this is non-standard C++ and not actually guaranteed to work. Seems like a short function for manually serializing these would be better.
There was a problem hiding this comment.
I think it's legal and we use it for the other shapes, but I agree an insert mechanism like the recent work with @amandalund is better. But for now let's stick with this.
There was a problem hiding this comment.
Yeah it's fine here. For posterity, I don't think it's legal in the general case; see the layout section here:
https://en.cppreference.com/w/cpp/language/data_members.html
"Alignment requirements may necessitate padding between members, or after the last member of a class."
Since these members are are all standard-sized POD, specifically doubles, the compiler is not going to add padding, but it strictly speaking doing so would be legal.
There was a problem hiding this comment.
Well it seems you're right; this is an old class and I had just been working in C so perhaps I misunderstood a C rule. Okeydoke, I'll add a construction utility to the to-do list 🙃
| * Calculate the coefficients of the polynomial corresponding to the given | ||
| * ray's intersections with the toroid. | ||
| * | ||
| * Written referencing Graphics Gems II. |
There was a problem hiding this comment.
Add the citation key arvo_graphics-gems_1995
| } | ||
| } | ||
|
|
||
| Real3 add(Real3 const a, Real3 const b) |
There was a problem hiding this comment.
Use ArrayOperator.hh
Add z aligned, elliptical toroid surface.
Adds the surface class Toroid, representing an elliptical toroid with ellipse radii a and b, revolved at major radius r around a z-aligned axis at an origin o:
This PR does not fully integrate the Toroid surface, only adding the Toroid class (using prior Ferrari quartic solver implementation), an accompanying test file, and required SurfaceIO details.