diff options
author | 2021-06-09 20:00:02 -0700 | |
---|---|---|
committer | 2021-06-09 20:00:02 -0700 | |
commit | 4974f07209ebc5e0578fc383057b4be383cdf318 (patch) | |
tree | 975c08a91b02f5c584e8b38c5536faf2c8257933 /Source/Utils/write_atomic_data_cpp.py | |
parent | 0967eb5835bf0ff5c82d97a98316a9b9f6c936fd (diff) | |
download | WarpX-4974f07209ebc5e0578fc383057b4be383cdf318.tar.gz WarpX-4974f07209ebc5e0578fc383057b4be383cdf318.tar.zst WarpX-4974f07209ebc5e0578fc383057b4be383cdf318.zip |
ion_map_ids: static & const access (#2010)
This fixes the `ion_map_ids` atom-to-number object:
- declare static, so the file can be included in multiple
translation units
- use `.at()`:
- missing entries do not cause an insertion
- missing entries will throw
- access is `const`, so we can declare the whole object
`static const` as well.
Diffstat (limited to '')
-rw-r--r-- | Source/Utils/write_atomic_data_cpp.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/Utils/write_atomic_data_cpp.py b/Source/Utils/write_atomic_data_cpp.py index 9070b71ac..d1df7a3ea 100644 --- a/Source/Utils/write_atomic_data_cpp.py +++ b/Source/Utils/write_atomic_data_cpp.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2019-2020 Axel Huebl, Luca Fedeli, Maxence Thevenet +# Copyright 2019-2021 Axel Huebl, Luca Fedeli, Maxence Thevenet # # # This file is part of WarpX. @@ -34,11 +34,12 @@ cpp_string += '// Edit dev/Source/Utils/write_atomic_data_cpp.py instead!\n' cpp_string += '#ifndef WARPX_IONIZATION_TABLE_H_\n' cpp_string += '#define WARPX_IONIZATION_TABLE_H_\n\n' cpp_string += '#include <AMReX_AmrCore.H>\n' -cpp_string += '#include <AMReX_REAL.H>\n' -cpp_string += '#include <map>\n\n' +cpp_string += '#include <AMReX_REAL.H>\n\n' +cpp_string += '#include <map>\n' +cpp_string += '#include <string>\n\n' # Map each element to ID in table -cpp_string += 'std::map<std::string, int> ion_map_ids = {' +cpp_string += 'static std::map<std::string, int> const ion_map_ids = {' for count, name in enumerate(ion_names): cpp_string += '\n {"' + name + '", ' + str(count) + '},' cpp_string = cpp_string[:-1] |