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
PreconditionRelaxation: step w. relaxation #13285
PreconditionRelaxation: step w. relaxation #13285
Conversation
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. It's time we get to use C++20 concepts :-)
I assume you're going to test this in a follow-up patch somewhere?
|
||
template <typename U> | ||
static decltype( | ||
std::declval<U const>().step(std::declval<VectorType &>(), |
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.
For consistency with other place:
std::declval<U const>().step(std::declval<VectorType &>(), | |
std::declval<const U>().step(std::declval<VectorType &>(), |
|
||
public: | ||
static const bool value = | ||
!std::is_same<bool, decltype(detect(std::declval<T>()))>::value; |
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.
Let's turn this around to make it read like "if this complicated type is 'bool'":
!std::is_same<bool, decltype(detect(std::declval<T>()))>::value; | |
!std::is_same<decltype(detect(std::declval<T>())),bool>::value; |
|
||
template <typename U> | ||
static decltype( | ||
std::declval<U const>().Tstep(std::declval<VectorType &>(), |
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.
std::declval<U const>().Tstep(std::declval<VectorType &>(), | |
std::declval<const U>().Tstep(std::declval<VectorType &>(), |
|
||
public: | ||
static const bool value = | ||
!std::is_same<bool, decltype(detect(std::declval<T>()))>::value; |
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.
!std::is_same<bool, decltype(detect(std::declval<T>()))>::value; | |
!std::is_same<decltype(detect(std::declval<T>())),bool>::value; |
static decltype( | ||
std::declval<U const>().step(std::declval<VectorType &>(), | ||
std::declval<const VectorType &>(), | ||
std::declval<const double>())) | ||
detect(const U &); |
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.
What do you do if the function, for whatever reason, returns bool
? I suspect that's not very likely, but a common trick is to make the other function return an object of type X
where X
is a locally declared struct type. No member function of an external class can reasonably return such an X
.
We could just roll our own |
I was thinking of How does |
@bangerth I used the following code as template: dealii/include/deal.II/matrix_free/type_traits.h Lines 215 to 241 in ad71f79
I don't know all details SFINAE. I don't know why these lines were written like this. Maybe we could proceed with this PR like it is and postpone a possible clean up to later: there are some function in |
Yes. |
Yes, if there is existing art that does it the same way, let's stick with it! |
It pretty much does exactly what we are doing here but standardized (and shorter), see https://en.cppreference.com/w/cpp/experimental/is_detected. It might never hit the standard since there are concepts in |
I would accept a patch based on this. |
Add specialization for preconditioners with: