ablastr constants : add variable templates to allow for flexibility in using single/double precision #5828
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this PR the constants in ablastr are first defined using variable templates and then specialized for
amrex::Real
, e.g., for mathematical constants:This is done with the intent of allowing the use of
double
precision constants even if the code is compiled in single precision (or vice versa if you really want it !), e.g. :I will need this feature to import the QED module from PICSAR into WarpX. I've started migrating the code in #5677 ,but the PR is becoming too big, so I decided to split it into smaller chunks.
The new feature is now used in the template function
Algorithms::KineticEnergy
. This function is conceived to be able to force double precision in some cases regardless of how WarpX has been compiled. Therefore, usingc
in double precision in these cases is coherent with its goal.In case you don't like the long namespace name
variable_template
, an alternative would be to call itvt
.Note that I've changed the variables from
static constexpr
toconstexpr
because, to my understanding,static
does not make any difference in this context.