1919#include " ../external/json.hxx"
2020
2121#include < algorithm>
22+ #include < cstddef>
2223#include < fstream>
2324#include < iterator>
2425
25- OpenADASRateCoefficient::OpenADASRateCoefficient (const std::string& filename, int level) {
26+ OpenADASRateCoefficient::OpenADASRateCoefficient (const std::string& filename, std:: size_t level) {
2627 AUTO_TRACE ();
2728
2829 // Read the rate file
@@ -54,7 +55,7 @@ OpenADASRateCoefficient::OpenADASRateCoefficient(const std::string& filename, in
5455
5556namespace {
5657
57- int get_high_index (const std::vector<BoutReal>& vec, BoutReal value) {
58+ auto get_high_index (const std::vector<BoutReal>& vec, BoutReal value) {
5859 ASSERT2 (vec.size () > 1 ); // Need at least two elements
5960
6061 // Iterator pointing to the first element greater than or equal to log10T
@@ -64,10 +65,10 @@ int get_high_index(const std::vector<BoutReal>& vec, BoutReal value) {
6465 } else if (high_it == vec.begin ()) {
6566 ++high_it; // Shift to the second element
6667 }
67- int high_index = std::distance (vec.begin (), high_it);
68+ const auto high_index = std::distance (vec.begin (), high_it);
6869
69- ASSERT2 ((high_index > 0 ) and (high_index < static_cast <int >( vec.size () )));
70- return high_index;
70+ ASSERT2 ((high_index > 0 ) and (static_cast <std:: size_t >(high_index) < vec.size ()));
71+ return static_cast <std:: size_t >( high_index) ;
7172}
7273
7374} // namespace
@@ -80,8 +81,8 @@ BoutReal OpenADASRateCoefficient::evaluate(BoutReal T, BoutReal n) {
8081 BoutReal log10n = log10 (std::clamp (n, nmin, nmax));
8182
8283 // Get the upper index. Between 1 and size-1 inclusive
83- int high_T_index = get_high_index (log_temperature, log10T);
84- int high_n_index = get_high_index (log_density, log10n);
84+ const auto high_T_index = get_high_index (log_temperature, log10T);
85+ const auto high_n_index = get_high_index (log_density, log10n);
8586
8687 // Construct the simple interpolation grid
8788 // Find weightings based on linear distance
@@ -91,12 +92,13 @@ BoutReal OpenADASRateCoefficient::evaluate(BoutReal T, BoutReal n) {
9192 // | / \ | |
9293 // w00 ------ w10
9394
94- int low_T_index = high_T_index - 1 ;
95+ // This is ok because high_T_index is >= 1
96+ const auto low_T_index = high_T_index - 1 ;
9597
9698 BoutReal x = (log10T - log_temperature[low_T_index])
9799 / (log_temperature[high_T_index] - log_temperature[low_T_index]);
98100
99- int low_n_index = high_n_index - 1 ;
101+ const auto low_n_index = high_n_index - 1 ;
100102
101103 BoutReal y = (log10n - log_density[low_n_index])
102104 / (log_density[high_n_index] - log_density[low_n_index]);
0 commit comments