-
Notifications
You must be signed in to change notification settings - Fork 95
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
Move invert3x3
out of general purpose utils.hxx
header
#3018
Conversation
Only used in `Coordinates`, so make private implementation detail
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.
The negative small value is only used in tests.
As this is private, we can remove this usage.
Then the checks on the caller can be removed, making the code cleaner. Unfortunately I cannot suggest this, so I can push a commit if you agree, @ZedThree
tests/unit/mesh/test_invert3x3.cxx
Outdated
|
||
// Non-default small | ||
input = 0.; | ||
input(0, 0) = 1.0e-12; | ||
input(1, 1) = 1.0; | ||
input(2, 2) = 1.0; | ||
EXPECT_NO_THROW(invert3x3(input, -1.0e-10)); |
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.
// Non-default small | |
input = 0.; | |
input(0, 0) = 1.0e-12; | |
input(1, 1) = 1.0; | |
input(2, 2) = 1.0; | |
EXPECT_NO_THROW(invert3x3(input, -1.0e-10)); |
src/mesh/invert3x3.hxx
Outdated
/// If small is less than zero then instead of throwing we return false. | ||
/// This is ugly but can be used to support some use cases. |
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.
/// If small is less than zero then instead of throwing we return false. | |
/// This is ugly but can be used to support some use cases. |
src/mesh/invert3x3.hxx
Outdated
if (small >= 0) { | ||
throw BoutException("Determinant of matrix < {:e} --> Poorly conditioned", small); | ||
} | ||
return false; |
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.
if (small >= 0) { | |
throw BoutException("Determinant of matrix < {:e} --> Poorly conditioned", small); | |
} | |
return false; | |
throw BoutException("Determinant of metric component {:e} < {:e} --> Poorly conditioned", std::abs(det), small); |
src/mesh/invert3x3.hxx
Outdated
/// If small is less than zero then instead of throwing we return false. | ||
/// This is ugly but can be used to support some use cases. | ||
template <typename T> | ||
bool invert3x3(Matrix<T>& a, T small = 1.0e-15) { |
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.
bool invert3x3(Matrix<T>& a, T small = 1.0e-15) { | |
void invert3x3(Matrix<T>& a, T small = 1.0e-15) { |
src/mesh/invert3x3.hxx
Outdated
|
||
return true; |
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.
return true; |
Yes, I was tempted to do the same thing, although I realised the error message in So maybe we just remove the |
Right now the error is thrown from We can throw a more specific error, as it is only used to invert the metric tensor. |
Yes, exactly |
Introduce a new |
Allows throwing more specific error in coordinates
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.
Looks good, thanks @ZedThree
This works for 2D and 3D fields (and is also shorter code)
Only used in
Coordinates
, so make private implementation detailAlso return
bool
instead ofint