-
Notifications
You must be signed in to change notification settings - Fork 178
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
Use string instead of integer to select WarpX algorithms #168
Conversation
@@ -0,0 +1,88 @@ | |||
#include <WarpXAlgorithmSelection.H> | |||
|
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 find that I need to #include <map>
here to compile this on Summit.
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.
OK, thanks. I'll add this.
// Read user input ; use "default" if it is not found | ||
std::string algo = "default"; | ||
pp.query( pp_search_key, algo ); | ||
|
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.
You could use std::transform(algo.begin(), algo.end(), algo.begin(), ::tolower);
here so that users could put either Boris
or boris
, say.
Source/WarpX.cpp
Outdated
ParmParse pp("algo"); | ||
current_deposition_algo = GetAlgorithmInteger(pp, "current_deposition"); | ||
charge_deposition_algo = GetAlgorithmInteger(pp, "charge_deposition"); | ||
field_gathering_algo = GetAlgorithmInteger(pp, "charge_deposition"); |
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.
Should this be "field_gathering"
?
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.
Ah, yes indeed! Thanks for catching this!
Is it worth distinguishing between things like the |
I think that it's okay to prevent users from using routines that will run on the CPU. (We don't want them to use them by accident without knowing that they will be slow.) Regarding CKC in particular: we could easily add the required |
@atmyers I think the PR is ready for merging. |
Overview
This PR modifies the way in which users choose the algorithm in the input script: instead of using integers, users now enter a string - which is often more meaningful to them. Note that this will break backward-compatibility ; previous script will abort with an error message explaining that an integer is not a valid algorithm.
Internally, WarpX still uses integers, as a switch for different algorithms. (This is mainly for compatibility with PICSAR, and other Fortran routines.) Therefore, at initialization, the string entered by the user is matched to the appropriate integer using maps. (These maps are not used anymore, after initialization.)
This PR ensures that:
When reviewing this PR
There are a lot of files changed, because all the input scripts had to be modified. However, when reviewing this PR, I would recommend to look at the following files, in the following order:
parameters.rst
: documentation explaining the new way in which the user enters the algorithmWarpX.cpp
: initialization of the algorithm integers, calling the functionGetAlgorithmInteger
WarpXAlgorithmSelection.cpp
: definition ofGetAlgorithmInteger
WarpXAlgorithmSelection.H
: enumeration defining integers for compatibility with PICSAR/Fortran.