-
Notifications
You must be signed in to change notification settings - Fork 33
Adding in Triangular Quadrature set and GQ1-3 methods with accompanying Lua #209
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
base: main
Are you sure you want to change the base?
Conversation
|
Could you also add some regression tests to this PR? They don't need to be complicated. Just simple tests to verify that the methods are working correctly. |
|
Sure I have a 3d and 2d I can add-- I'll add them to the test/modules/LBS/transport_steady. |
|
You will need to do a few things first:
|
|
You still have 2 merge commits in your branch, so you did not rebase anything. You need to rebase on top of upstream
When you do the 2nd command, you will see something like this in a text editor: Then, you will remove line 2 ("Changed the configure_dep"). This commit creates a conflict that you would have to resolve. However, you should not be modifying that script in your PR anyway. Your PR is about a quadrature. That's why you will get rid of it. If those changes are needed, then they can come in a separate PR. Save and quit the editor. Git will rebase your branch and then you will have to force push it into your fork. I advised you to NOT create a clang-format patch, but you did that anyway, so 👎 . Last advise for future. Do not develop on |
49f2047 to
cf7b2e5
Compare
test/modules/linear_boltzmann_solvers/transport_steady/transport_2d_triangular_P0.lua
Outdated
Show resolved
Hide resolved
test/modules/linear_boltzmann_solvers/transport_steady/transport_2d_triangular_P0.lua
Outdated
Show resolved
Hide resolved
test/modules/linear_boltzmann_solvers/transport_steady/transport_2d_triangular_P0.lua
Outdated
Show resolved
Hide resolved
test/modules/linear_boltzmann_solvers/transport_steady/transport_2d_triangular_P0.lua
Outdated
Show resolved
Hide resolved
test/modules/linear_boltzmann_solvers/transport_steady/transport_2d_triangular_P0.lua
Outdated
Show resolved
Hide resolved
| unsigned int sn_; | ||
| unsigned int moments_; | ||
|
|
||
| void TriangleInit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check with @wdhawkins but we may need fo explicit names such as TriangleQuadratueInitialize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just go with Initialize for right now.
| void BuildDiscreteToMomentOperator(unsigned int scattering_order, int dimension) override; | ||
|
|
||
| void BuildMomentToDiscreteOperator(unsigned int scattering_order, int dimension) override; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check with @wdhawkins if dim will remain int or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be fine for now. It may change later one, but we can leave it for this commit.
| } | ||
|
|
||
| void | ||
| TriangleQuadrature::TriangleInit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment in .h file
| const auto GAUSS_LEG_QUAD = GaussLegendreQuadrature(sn_); | ||
|
|
||
| // Formulate the triangular quadrature | ||
| VecDbl newZi, newWeights; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check with @wdhawkins if we should name this Zi (technically you meant Xi) or Mu (for consistency).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be mu.
|
@emersonshands also, the golden values for the tests are missing (see how to modify the .json file in the proper folder) |
…a for quadratures modified.
…uced to 2d using OptimizeForPolarSymmetry.
…ll required to verify against benchmark.
Need verification due to python errors.
Refactoring variable names for standards
Additional test for GQ3 added, along with associated Henyey-G.S. forward peaked cross section file.
Waiting for response and gold file values.
| const auto GAUSS_LEG_QUAD = GaussLegendreQuadrature(sn_); | ||
|
|
||
| // Formulate the triangular quadrature | ||
| VecDbl newZi, newWeights; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing VecDbl is a typedef for std::vector<double>? If so, please use std::vector<double>.
| { | ||
| log.Log0Error() << "TriangleQuarature: " << method_ << " is not a valid method.\n" | ||
| << "Method must be 0, 1, 2, or 3." << std::endl; | ||
| Exit(510); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should throw an std::invalid_argument instead of Exit(510).
|
|
||
| // Formulate the triangular quadrature | ||
| VecDbl newZi, newWeights; | ||
| newZi.reserve(GAUSS_LEG_QUAD.qpoints.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No caps in GAUSS_LEG_QUAD or at least not all caps.
|
|
||
| int num_div = 1; | ||
| int weightPos = 0; | ||
| for (const auto& QUAD_POINT : GAUSS_LEG_QUAD.qpoints) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No all caps for QUAD_POINT.
| for (int v = 0; v < num_div; ++v) | ||
| { | ||
| double new_z_value = abs(QUAD_POINT.x); | ||
| double phi = deltaVPhi / 2.0 + (double)v * deltaVPhi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use static_cast<double>.
| double phi = deltaVPhi / 2.0 + (double)v * deltaVPhi; | ||
| double theta = acos(new_z_value); | ||
| double sinTheta = sqrt(1 - new_z_value * new_z_value); | ||
| // double weightCurrent = GAUSS_LEG_QUAD.weights[weightPos] / (num_div); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this commented line if it's not necessary.
| new_omega.x = sinTheta * cos(phi); | ||
| new_omega.y = sinTheta * sin(phi); | ||
| new_omega.z = new_z_value; | ||
| weights_.push_back(GAUSS_LEG_QUAD.weights[weightPos] * (M_PI / (2.0 * num_div))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you know the number of weights, omegas, and abscissae, reserve their size before the loop.
| new_omega.x = omegas_[point].x; // omegas[l].x*xsign; | ||
| new_omega.y = omegas_[point].y; // omegas[l].y*ysign; | ||
| new_omega.z = -omegas_[point].z; | ||
| double new_z_value = -omegas_[point].z; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of declaring these new variables, you can use the expressions inline in the lines below.
| // We need to fix the normalization to be 4*pi over the full sphere | ||
| double normal = 4.0 * M_PI; | ||
|
|
||
| const size_t NUM_DIRS = omegas_.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lower case for NUM_DIRS
| // need to cut after the formation. | ||
| if (m2d_op_built_ and d2m_op_built_ and moments_ >= 0 and !m_to_ell_em_map_.empty()) | ||
| { | ||
| int s_order = static_cast<int>(scattering_order); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the parameter an int and remove this cast.
|
|
||
| auto m2d_transposed = m2d_op_; | ||
| m_to_ell_em_map_.resize(moments_to_keep); | ||
| std::vector<std::vector<double>> m2dworking; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reserve m2dworking and d2mworking since you know the size.
| void | ||
| TriangleQuadrature::MakeHarmonicIndices(unsigned int scattering_order, int dimension) | ||
| { | ||
| int L = static_cast<int>(sn_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the unsigned int's in the header to int's and remove these casts.
| } | ||
|
|
||
| void | ||
| TriangleQuadrature::MakeHarmonicIndices(unsigned int scattering_order, int dimension) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change scattering_order to an int and remove the cast below.
| { | ||
| d2m_op_.clear(); | ||
|
|
||
| const size_t NUM_ANGLES = abscissae_.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NUM_ANGLES -> num_angles. Remove caps throughout the file.
This merge adds in the Gauss-Chebyshev triangular quadrature set with lua calls for the set. Additionally it has methods for forming the D&M matrices seperately from the standard angular quadrature methods currently in the repository. This includes the standard Sn method, termed method 0, uses the standard full rank harmonics mapping and forms both the D&M seperately. The additional first and second Galerkin Quadrature methods are mentioned in Comparison of Two Galerkin Quadrature Methods, Morel 2017, Ref.. Both form the full range D or M matrices then invert them to obtain the accompanying matrix, which in the case of a lower range expansion requires that both matrices be cut down to the required expansion. The third method, GQ3, has not been published yet and is focused on building the D&M matrices up to the desired degree by use of the modified Gram-Schmidt method. All three GQ methods are purpose built for anisotropic problems and are agnostic to the quadrature set with appropriate harmonic choices.
Further verification is needed against an anisotropic benchmark problem from Ref..