Renaming of PHYSICAL_PROBLEM config option to SOLVER - #756
Conversation
pcarruscag
left a comment
There was a problem hiding this comment.
The idea makes sense, but can you please keep the GetRegime method in CConfig (even if that is not used as an option anymore) and avoid changing its use for very long and inexpressive conditionals?
The "new" GetRegime method can implement the conditional or (preferably) return a value cached during setup.
| /*--- Checks for incompressible flow problems. ---*/ | ||
|
|
||
| if ((Kind_Solver == EULER) && (Kind_Regime == INCOMPRESSIBLE)) { | ||
| if (Kind_Solver == INC_EULER) { |
There was a problem hiding this comment.
This looks nice, more expressive, and will allow cleaner code to be written.
| else if (Ref_Inc_NonDim == INITIAL_VALUES) { cout << "Non-Dimensional simulation using intialization values." << endl; } | ||
| else if (Ref_Inc_NonDim == REFERENCE_VALUES) { cout << "Non-Dimensional simulation using user-specified reference values." << endl; } | ||
| } | ||
| if (Kind_Solver == EULER || Kind_Solver == FEM_EULER || Kind_Solver == DISC_ADJ_EULER || |
There was a problem hiding this comment.
But this is the complete opposite, and it is all over the place so it is going to be a pain to maintain or even cleanup in the future.
|
@pcarruscag In general I agree with you. It is kind of messy. I reintroduced the |
|
I also like the idea of renaming to "SOLVER" but I would also say to avoid as much churn as possible in the conditionals throughout the code... looks like a wash when reading through the PR changes (almost as many +'s as -'s). Unless the changes are going to make something much more flexible or clear, I would say just keep Kind_Regime and set it in config postprocessing. |
|
Anyone else has comments ? |
| const bool compressible = (config->GetKind_Regime() == COMPRESSIBLE); | ||
| unsigned short Kind_Solver = config->GetKind_Solver(); | ||
| const bool compressible = (Kind_Solver == FEM_EULER) || | ||
| (Kind_Solver == FEM_NAVIER_STOKES) || |
There was a problem hiding this comment.
My comment is still valid I suppose.
There was a problem hiding this comment.
Which one? I reverted most of the GetRegimeType calls. I deliberately left it in some places to make clear for what solvers this part of the code is intended for. For the future we have to find a better way of getting properties for a certain kind of solver.
| CURRENT_FUNCTION); | ||
|
|
||
| if(config->GetKind_Regime() != COMPRESSIBLE) | ||
| if(Kind_Solver != EULER && Kind_Solver != NAVIER_STOKES && Kind_Solver != RANS && |
There was a problem hiding this comment.
This one is not solver specific
There was a problem hiding this comment.
Yeah it is. It only works and is intended for the compressible flow solver. What happens if the kind solver is not a flow solver ? I still think that this way is much more obvious for which solvers this part of the code is intended (and tested) for.
There was a problem hiding this comment.
Ok, we really need some more expressive and encapsulated way to express these things then.
| CURRENT_FUNCTION); | ||
|
|
||
| if(config->GetKind_Regime() != COMPRESSIBLE) | ||
| if(Kind_Solver != EULER && Kind_Solver != NAVIER_STOKES && Kind_Solver != RANS && |
There was a problem hiding this comment.
None of these in MMS classes seem to be solver specific
|
|
||
| bool compressible = (config->GetKind_Regime() == COMPRESSIBLE); | ||
| bool incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); | ||
| bool compressible = false; |
There was a problem hiding this comment.
This you can keep the same without making the switch statement any more complicated.
There was a problem hiding this comment.
Its even more complicated to understand when I keep it. Because then I'll have to add an if-statements later to distinguish between compressible/incompressible when actually allocating. This way you see immediately see what will be allocated (i.e. what boolean is set to true).
But anyway. All that this shows is that we have to do something about it at some point and neither approach adds or removes much readability. @rsanfer and myself have thought already about moving some the allocations to the iteration structure, as the only that class essentially has to know what is in the solver container. Likewise, the solver class is the only class that has to know what is in the numerics class and so on.
There was a problem hiding this comment.
And ideally own the actual container they instantiate.
oleburghardt
left a comment
There was a problem hiding this comment.
I agree with the compromise you made here.
From looking through the files changed, we have a lot of additional lines in places where we are in fact just asking whether we are dealing with a flow solver. Doing that via GetKind_Solver() is not so elegant anyway. So they are really a non-issue if one expects that to be changed in the future.
I like that one can avoid the regime conditional this way. I already merged this branch in one of mine and it also improves at least visually the switch-kind-solver-sections.
Proposed Changes
While I was writing some documentation on how to set up a basic problem, I noticed that the
PHYSICAL_PROBLEMhad lost its meaning over the the last couple of years and it is hard to explain why it is called like that. It now refers actually to a numerical method that solves a particular problem and not to the physical problem. So I renamed it toSOLVER.Additionally, I removed the
REGIME_TYPEoption and added the incompressible solvers as dedicated values (INC_EULER,INC_RANS,INC_NAVIER_STOKES) for the newSOLVERoption. The methodGetRegime_Type()is also removed and it is now explicitly checked for the kind of solvers. This way we remove the implicit assumption that every feature also works with the incompressible solvers. Developers have to deliberately add a check now ...It is a lot of code copy at the moment, but once the restructuring is finished we should be able to remove a lot of it.
Related Work
Resolve any issues (bug fix or feature request), note any related PRs, or mention interactions with the work of others, if any.
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.