Skip to content

Commit 7c9ca0d

Browse files
authored
Merge pull request #6765 from tjhei/tidy-fixes
fix some clang tidy warnings
2 parents 9a4ca81 + 20dfe4e commit 7c9ca0d

File tree

6 files changed

+37
-35
lines changed

6 files changed

+37
-35
lines changed

source/material_model/latent_heat.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,12 @@ namespace aspect
393393
// we have to scale them here so that they are relative factors in comparison to the product
394394
// of the prefactors of all phases above the current one
395395
unsigned int index = 0;
396-
for (unsigned int c=0; c<options.n_values_per_key.size(); ++c)
396+
for (const auto &n_phases : options.n_values_per_key)
397397
{
398398
double product = 1.;
399-
for (unsigned int phase=0; phase<options.n_values_per_key[c]; ++phase)
399+
for (unsigned int phase = 0; phase < n_phases; ++phase)
400400
{
401-
if (phase>0)
401+
if (phase > 0)
402402
phase_prefactors[index] /= product;
403403
product *= phase_prefactors[index];
404404
index += 1;

source/particle/property/composition_reaction.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ namespace aspect
242242
(Utilities::split_string_list(prm.get ("List of reaction times")));
243243

244244
if (this->convert_output_to_years() == true)
245-
for (unsigned int i=0; i<reaction_times.size(); ++i)
246-
reaction_times[i] *= year_in_seconds;
245+
for (double &time : reaction_times)
246+
time *= year_in_seconds;
247247

248248
AssertThrow ((reactants.size() == products.size()),
249249
ExcMessage ("The list of reactants and products need to have the "

source/particle/property/elastic_stress.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ namespace aspect
174174
old_solution_values.end());
175175

176176
EvaluationFlags::EvaluationFlags evaluation_flags_union = EvaluationFlags::nothing;
177-
for (unsigned int i=0; i<evaluation_flags.size(); ++i)
178-
evaluation_flags_union |= evaluation_flags[i];
177+
for (const auto flag : evaluation_flags)
178+
evaluation_flags_union |= flag;
179179

180180
// Update evaluators to the current cell
181181
if (evaluation_flags_union & (EvaluationFlags::values | EvaluationFlags::gradients))

source/postprocess/current_surface.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ namespace aspect
122122

123123
// Fill the coordinates with the x-values used for the data table.
124124
// This only works in 2D, and will need to be updated for 3D.
125-
coordinates[0].clear();
125+
coordinates[0].resize(temp_surface.size());
126126
for (unsigned int i=0; i<temp_surface.size(); ++i)
127-
coordinates[0].push_back(temp_surface[i][0]);
127+
coordinates[0][i] = temp_surface[i][0];
128128

129129
// Create a surface function for the elevations.
130130
surface_function = std::make_unique<Functions::InterpolatedTensorProductGridData<dim-1>>(coordinates, data_table);

source/postprocess/visualization/material_properties.cc

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -121,42 +121,42 @@ namespace aspect
121121
in.requested_properties
122122
= MaterialModel::MaterialProperties::uninitialized;
123123

124-
for (unsigned int i=0; i<property_names.size(); ++i)
124+
for (const auto &property_name : property_names)
125125
{
126-
if (property_names[i] == "viscosity")
126+
if (property_name == "viscosity")
127127
in.requested_properties = in.requested_properties | MaterialModel::MaterialProperties::viscosity;
128128

129-
else if (property_names[i] == "density")
129+
else if (property_name == "density")
130130
in.requested_properties = in.requested_properties | MaterialModel::MaterialProperties::density;
131131

132-
else if (property_names[i] == "thermal expansivity")
132+
else if (property_name == "thermal expansivity")
133133
in.requested_properties = in.requested_properties | MaterialModel::MaterialProperties::thermal_expansion_coefficient;
134134

135-
else if (property_names[i] == "specific heat")
135+
else if (property_name == "specific heat")
136136
in.requested_properties = in.requested_properties | MaterialModel::MaterialProperties::specific_heat;
137137

138-
else if (property_names[i] == "thermal conductivity")
138+
else if (property_name == "thermal conductivity")
139139
in.requested_properties = in.requested_properties | MaterialModel::MaterialProperties::thermal_conductivity;
140140

141-
else if (property_names[i] == "thermal diffusivity")
141+
else if (property_name == "thermal diffusivity")
142142
in.requested_properties = in.requested_properties | MaterialModel::MaterialProperties::density
143143
| MaterialModel::MaterialProperties::specific_heat
144144
| MaterialModel::MaterialProperties::thermal_conductivity;
145145

146-
else if (property_names[i] == "compressibility")
146+
else if (property_name == "compressibility")
147147
in.requested_properties = in.requested_properties | MaterialModel::MaterialProperties::compressibility;
148148

149-
else if (property_names[i] == "entropy derivative pressure")
149+
else if (property_name == "entropy derivative pressure")
150150
in.requested_properties = in.requested_properties | MaterialModel::MaterialProperties::entropy_derivative_pressure;
151151

152-
else if (property_names[i] == "entropy derivative temperature")
152+
else if (property_name == "entropy derivative temperature")
153153
in.requested_properties = in.requested_properties | MaterialModel::MaterialProperties::entropy_derivative_temperature;
154154

155-
else if (property_names[i] == "reaction terms")
155+
else if (property_name == "reaction terms")
156156
in.requested_properties = in.requested_properties | MaterialModel::MaterialProperties::reaction_terms;
157157

158158
// We don't know what a material model needs to compute the melt fraction.
159-
else if (property_names[i] == "melt fraction")
159+
else if (property_name == "melt fraction")
160160
in.requested_properties = MaterialModel::MaterialProperties::all_properties;
161161
}
162162

@@ -201,48 +201,50 @@ namespace aspect
201201
for (unsigned int q=0; q<n_quadrature_points; ++q)
202202
{
203203
unsigned output_index = 0;
204-
for (unsigned int i=0; i<property_names.size(); ++i, ++output_index)
204+
for (const auto &property_name : property_names)
205205
{
206-
if (property_names[i] == "viscosity")
206+
if (property_name == "viscosity")
207207
computed_quantities[q][output_index] = out.viscosities[q];
208208

209-
else if (property_names[i] == "density")
209+
else if (property_name == "density")
210210
computed_quantities[q][output_index] = out.densities[q];
211211

212-
else if (property_names[i] == "thermal expansivity")
212+
else if (property_name == "thermal expansivity")
213213
computed_quantities[q][output_index] = out.thermal_expansion_coefficients[q];
214214

215-
else if (property_names[i] == "specific heat")
215+
else if (property_name == "specific heat")
216216
computed_quantities[q][output_index] = out.specific_heat[q];
217217

218-
else if (property_names[i] == "thermal conductivity")
218+
else if (property_name == "thermal conductivity")
219219
computed_quantities[q][output_index] = out.thermal_conductivities[q];
220220

221-
else if (property_names[i] == "thermal diffusivity")
221+
else if (property_name == "thermal diffusivity")
222222
computed_quantities[q][output_index] = out.thermal_conductivities[q]/(out.densities[q]*out.specific_heat[q]);
223223

224-
else if (property_names[i] == "compressibility")
224+
else if (property_name == "compressibility")
225225
computed_quantities[q][output_index] = out.compressibilities[q];
226226

227-
else if (property_names[i] == "entropy derivative pressure")
227+
else if (property_name == "entropy derivative pressure")
228228
computed_quantities[q][output_index] = out.entropy_derivative_pressure[q];
229229

230-
else if (property_names[i] == "entropy derivative temperature")
230+
else if (property_name == "entropy derivative temperature")
231231
computed_quantities[q][output_index] = out.entropy_derivative_temperature[q];
232232

233-
else if (property_names[i] == "reaction terms")
233+
else if (property_name == "reaction terms")
234234
{
235235
for (unsigned int k=0; k<this->n_compositional_fields(); ++k, ++output_index)
236236
{
237237
computed_quantities[q][output_index] = out.reaction_terms[q][k];
238238
}
239239
--output_index;
240240
}
241-
else if (property_names[i] == "melt fraction")
241+
else if (property_name == "melt fraction")
242242
computed_quantities[q][output_index] = melt_fractions[q];
243243
else
244244
AssertThrow(false,
245245
ExcMessage("Material property not implemented for this postprocessor."));
246+
247+
++output_index;
246248
}
247249
}
248250
}

source/simulator/parameters.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,9 +2102,9 @@ namespace aspect
21022102
AssertThrow (normalized_fields.size() <= n_compositional_fields,
21032103
ExcMessage("Invalid input parameter file: Too many entries in List of normalized fields"));
21042104

2105-
for (unsigned int i_field = 0; i_field < normalized_fields.size(); ++i_field)
2105+
for (unsigned int field : normalized_fields)
21062106
{
2107-
AssertThrow(normalized_fields[i_field]<n_compositional_fields,
2107+
AssertThrow(field<n_compositional_fields,
21082108
ExcMessage("Invalid input parameter file: An entry in List of normalized fields is larger then the number of fields."));
21092109
}
21102110

0 commit comments

Comments
 (0)