-
Notifications
You must be signed in to change notification settings - Fork 235
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
Keep the names of the variables with the table #11528
Conversation
The names of the variables X and Y of a table were read (from the `mdpa` file), but not stored. Now they are. This allows the user of a table to give meaning to the stored values and act differently if needed. Other changes include: - Removed some commented out code. - Use compiler-generated special member functions (e.g. copy constructors) rather than reimplementing the default behavior. - Single-argument constructors should be `explicit`. - Use nested namespace definitions to improve readability. - Removed needless indentation and some redundant comments.
FYI @KratosMultiphysics/altair |
My only comment is that maybe is better to use directly variables (which include names), because variables provide much mor info @KratosMultiphysics/technical-committee |
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.
Blocking to avoid accidental merge
And the size in that cae would be 2 doubles (2 pointers) |
@loumalouomega "Accidental" merges don't happen. A PR cannot be merged without an approval from someone with the correct privileges. You should only block a PR if you spot something that's a dealbreaker for you, but you must explain the problem you have in that case, instead of referring to *"accidental merge"*s. Now that you've blocked the PR, the only way you can unblock it is to approve it, which means that you'll have to track the progress of this PR and properly review it once changes are made. This can lead to a situation in which others may have to wait for you until you find the time to take care of your duties here. |
@technical-committee usually blocks "to avoid accidental merge" |
This may happen if someone approves before @technical-committee review and it is merged |
https://github.com/search?q=repo%3AKratosMultiphysics%2FKratos+accidental+merge&type=pullrequests |
BTW, I added a comment saying that I would like to discuss if variable is a better alternative to string |
Blocking the PR is not a solution to that problem. That's the job of code owners. |
I have considered to use variables directly, but I see two problems there:
|
I understand your point @matekelemen . The problem with code owners is that if we add for example the @KratosMultiphysics/technical-committee as code owner of kratos core, it will be much harder to get anything merged. Blocking a PR is the only way I see now to avoid "accidental merges" (someone merging something because they think its not an important change but it might actually be). I'd like to hear how you think this should be done (maybe in a new issue so everyone can comment) |
Well, I have shared to you a search result that shows like this is an extended practice to avoid potential API changes |
@avdg81 sorry but a recent change have conflicted this (it justb changes the C++ tests macros) |
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 remove my block, but wait until @KratosMultiphysics/technical-committee agrees
@loumalouomega: Sure, I will wait. I would appreciate it very much if someone from the @KratosMultiphysics/technical-committee would be so kind to review this PR. Many thanks in advance! |
Co-authored-by: Philipp Bucher <philipp.bucher@tum.de>
We had a brief look to this in the @KratosMultiphysics/technical-committee. @pooyan-dadvand will review and take care of this one. |
That's great. Thank you very much for the work done so far. I'm looking forward to the review of @pooyan-dadvand. |
I think this is a good addition. Nevertheless, I am not sure why are you deleting the explicit assignment operators and copy constructors? To my understanding, it is cleaner to explicitly setting them to default. |
Some more comments after reviewing: I think it would be better adding the names directly to the original template class and not only to the double specialization. Another possibility is to add the variables with the type of the template. This would have an extra benefit that we can then use them in the processes to get the values from the nodes. I should add that we had the pointer to variables in the first version of template but we had to took it off for using a table with a variable component. Now the variable component is the same type as a normal variable. So, we may turn back to the original idea. |
Dear @pooyan-dadvand, first of all thank you very much for taking the time to review my PR. I'm glad to read that you think this is a good addition. Regarding the removal of the copy assignment operators and copy constructors, please let me explain my considerations. First of all, there was a difference in the copy semantics of class template
But I can do this:
On the other hand, when we consider the template specialization When I looked at the implementation of the supported copy operations, I noticed that all they do is a member-wise copy. Which is exactly what the compiler would generate for you if you hadn't defined them. Assuming the implementation as it was, when new data members are added to the class, the programmer must not forget to handle them in the copy operations. This is OK if a member-wise copy is not the correct semantics for the class. But in this case, we actually want member-wise copy operations. In that case, it's better to let the compiler handle this. Since I don't see any problem in the ability to copy And last but not least, also the C++ Core Guidelines suggest to let the compiler generate the special member functions whenever appropriate. For further background, please refer to sections "C.20: If you can avoid defining default operations, do" (also known as the rule of zero) and "C.22: Make default operations consistent". If you feel that I have misunderstood your point, please let me know. Thanks. (I will now move on to respond to your second reply.) |
Yes, I agree. I think I've missed that one when I made the extensions. Thanks for pointing that out. When you agree that we should use strings rather than variables (see my reply below) I will add it to the class template and add a unit test for it as well.
Two things came to my mind in this regard:
|
Thanks for the explanation!
Fully agree that it is not correct and it would be better the unified one!
I think that I didn't explain myself correctly. I agree that using old style copy constructors for member-wise copying is not good anymore. I was referring to explicitly define them using |
The argument of arbitrary name is very valid and we can go with the current implementation.
I see your point, but the idea was to have the type of the variable inside the template of the table. Nevertheless, your argument for arbitrary name is valid and we can go with the string implementation. |
Here are my two cents on this problem of identifying variables from strings. I also encountered it many times. Are we going for arbitrary types of variables? I got the feeling that we have only limited types of variables such as template <class TComponentType>
bool DoSomethingWithVariable(const std::string& rVarName) {
if (KratosComponents<TComponentType>::Has(rVarName)) {
const auto& r_var = KratosComponents<TComponentType>::Get(rVarName);
// do something with var.
return true;
}
return false;
}
template<class... TComponentTypes>
class Doer
{
static bool DoSomething(const std::string& rVarName) {
return (... || (DoSomethingWithVariable<TComponentTypes>(
rVarName)));
}
}
// use case
Doer<Variable<double>,
Variable<int>>::DoSomething("STEP"); It is not ideal, but it does the job. |
I think that, as suggested by "C.20: If you can avoid defining default operations, do" of the C++ Core Guidelines, the preferred way should be to apply the rule of zero. Strictly speaking, the rule of zero doesn't apply here, since we must declare a (default) virtual destructor (class
However, if you insist on having If, on the other hand, you feel that no further changes are required, could you please approve this PR? |
Thanks for your consideration and for agreeing with the proposed implementation. |
Thanks for sharing your thoughts. Like you said, it is not ideal, but it does the job. |
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.
Thank you for the implementation and also your clear explanation!
Added the names for variables X and Y to the `Table` class template too, not just to the template specialization `Table<double, double>`.
Well, thank you for your thorough review and your questions :-). I really appreciate that. By the way, I have corrected a thing that you pointed out earlier. It was about adding the variable names to the class template |
@pooyan-dadvand: Just a friendly reminder that this PR needs your approval (once more) in order to be merged (assuming you agree with the latest changes). I only implemented one of your previous suggestions after your approval (see my previous comment), which means it was automatically withdrawn. My apologies for the inconvenience and thanks in advance for your help. |
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.
Thank you again!
📝 Description
The names of the variables X and Y of a table were read (from the
mdpa
file), but not stored. Now they are. This allows the user of a table to give meaning to the stored values and act differently if needed.🆕 Changelog
mdpa
file, no longer ignore the names of X and Y, but store them.explicit
.