Skip to content

Commit 1f8eb28

Browse files
committed
Fix last batch of core warnings
1 parent 324ba5d commit 1f8eb28

File tree

10 files changed

+115
-128
lines changed

10 files changed

+115
-128
lines changed

include/core/shape.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2680,7 +2680,7 @@ class RBFShape : public Shape<dim>
26802680
* @param orientation the orientation of the shape with respect to each main
26812681
* axis
26822682
*/
2683-
RBFShape(const std::string shape_arguments_str,
2683+
RBFShape(const std::string &shape_arguments_str,
26842684
const Point<dim> &position,
26852685
const Tensor<1, 3> &orientation);
26862686

include/core/solutions_output.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ write_boundaries_vtu(const DataOutFaces<dim> &data_out,
8484
const double time,
8585
const unsigned int iter,
8686
const MPI_Comm &mpi_communicator,
87-
const std::string file_prefix = std::string("boundaries"),
87+
const std::string &file_prefix = std::string("boundaries"),
8888
const unsigned int digits = 5);
8989
#endif

source/core/shape.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ CompositeShape<dim>::set_layer_thickening(const double layer_thickening)
16381638
}
16391639

16401640
template <int dim>
1641-
RBFShape<dim>::RBFShape(const std::string shape_arguments_str,
1641+
RBFShape<dim>::RBFShape(const std::string &shape_arguments_str,
16421642
const Point<dim> &position,
16431643
const Tensor<1, 3> &orientation)
16441644
: Shape<dim>(1, position, orientation)

source/core/shape_parsing.cc

Lines changed: 82 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -212,104 +212,102 @@ ShapeGenerator::initialize_shape_from_file(const std::string &type,
212212
std::vector<std::string> list_of_words_base =
213213
Utilities::split_string_list(line, ";");
214214
std::vector<std::string> list_of_words_clean;
215-
for (unsigned int j = 0; j < list_of_words_base.size(); ++j)
215+
for (const auto &word : list_of_words_base)
216216
{
217217
if (list_of_words_base[j] != "")
218-
{
219-
list_of_words_clean.push_back(list_of_words_base[j]);
220-
}
218+
list_of_words_clean.emplace_back(word);
221219
}
222-
if (parsing_shapes)
223-
{
224-
unsigned int identifier = stoi(list_of_words_clean[0]);
225-
std::string type = list_of_words_clean[1];
226-
std::string arguments_str = list_of_words_clean[2];
227-
std::replace(arguments_str.begin(),
228-
arguments_str.end(),
229-
':',
230-
';');
231-
std::string position_str = list_of_words_clean[3];
232-
std::string orientation_str = list_of_words_clean[4];
220+
}
221+
if (parsing_shapes)
222+
{
223+
unsigned int identifier = stoi(list_of_words_clean[0]);
224+
std::string type = list_of_words_clean[1];
225+
std::string arguments_str = list_of_words_clean[2];
226+
std::replace(arguments_str.begin(),
227+
arguments_str.end(),
228+
':',
229+
';');
230+
std::string position_str = list_of_words_clean[3];
231+
std::string orientation_str = list_of_words_clean[4];
233232

234-
std::vector<std::string> position_str_component =
235-
Utilities::split_string_list(position_str, ":");
236-
std::vector<std::string> orientation_str_component =
237-
Utilities::split_string_list(orientation_str, ":");
233+
std::vector<std::string> position_str_component =
234+
Utilities::split_string_list(position_str, ":");
235+
std::vector<std::string> orientation_str_component =
236+
Utilities::split_string_list(orientation_str, ":");
238237

239-
std::vector<double> temp_position_vec =
240-
Utilities::string_to_double(position_str_component);
241-
std::vector<double> temp_orientation_vec =
242-
Utilities::string_to_double(orientation_str_component);
238+
std::vector<double> temp_position_vec =
239+
Utilities::string_to_double(position_str_component);
240+
std::vector<double> temp_orientation_vec =
241+
Utilities::string_to_double(orientation_str_component);
243242

244-
Point<dim> temp_position;
245-
Point<3> temp_orientation =
246-
Point<3>({temp_orientation_vec[0],
247-
temp_orientation_vec[1],
248-
temp_orientation_vec[2]});
249-
temp_position[0] = temp_position_vec[0];
250-
temp_position[1] = temp_position_vec[1];
251-
if constexpr (dim == 3)
252-
temp_position[2] = temp_position_vec[2];
243+
Point<dim> temp_position;
244+
Point<3> temp_orientation =
245+
Point<3>({temp_orientation_vec[0],
246+
temp_orientation_vec[1],
247+
temp_orientation_vec[2]});
248+
temp_position[0] = temp_position_vec[0];
249+
temp_position[1] = temp_position_vec[1];
250+
if constexpr (dim == 3)
251+
temp_position[2] = temp_position_vec[2];
252+
253+
std::shared_ptr<Shape<dim>> shape_temp;
254+
shape_temp = ShapeGenerator::initialize_shape(type,
255+
arguments_str,
256+
Point<dim>(),
257+
Tensor<1, 3>());
258+
shape_temp->set_position(temp_position);
259+
shape_temp->set_orientation(temp_orientation);
260+
components[identifier] = shape_temp->static_copy();
261+
}
262+
else if (parsing_operations)
263+
{
264+
unsigned int identifier = stoi(list_of_words_clean[0]);
265+
std::string type = list_of_words_clean[1];
266+
std::string arguments_str = list_of_words_clean[2];
267+
std::vector<std::string> arguments_str_component =
268+
Utilities::split_string_list(arguments_str, ":");
253269

254-
std::shared_ptr<Shape<dim>> shape_temp;
255-
shape_temp = ShapeGenerator::initialize_shape(
256-
type, arguments_str, Point<dim>(), Tensor<1, 3>());
257-
shape_temp->set_position(temp_position);
258-
shape_temp->set_orientation(temp_orientation);
259-
components[identifier] = shape_temp->static_copy();
270+
unsigned int first_shape = stoi(arguments_str_component[0]);
271+
unsigned int second_shape = stoi(arguments_str_component[1]);
272+
if (type == "union")
273+
{
274+
operations[identifier] = std::make_tuple(
275+
CompositeShape<dim>::BooleanOperation::Union,
276+
first_shape,
277+
second_shape);
260278
}
261-
else if (parsing_operations)
279+
else if (type == "difference")
262280
{
263-
unsigned int identifier = stoi(list_of_words_clean[0]);
264-
std::string type = list_of_words_clean[1];
265-
std::string arguments_str = list_of_words_clean[2];
266-
std::vector<std::string> arguments_str_component =
267-
Utilities::split_string_list(arguments_str, ":");
268-
269-
unsigned int first_shape =
270-
stoi(arguments_str_component[0]);
271-
unsigned int second_shape =
272-
stoi(arguments_str_component[1]);
273-
if (type == "union")
274-
{
275-
operations[identifier] = std::make_tuple(
276-
CompositeShape<dim>::BooleanOperation::Union,
277-
first_shape,
278-
second_shape);
279-
}
280-
else if (type == "difference")
281-
{
282-
operations[identifier] = std::make_tuple(
283-
CompositeShape<dim>::BooleanOperation::Difference,
284-
first_shape,
285-
second_shape);
286-
}
287-
else if (type == "intersection")
288-
{
289-
operations[identifier] = std::make_tuple(
290-
CompositeShape<dim>::BooleanOperation::Intersection,
291-
first_shape,
292-
second_shape);
293-
}
281+
operations[identifier] = std::make_tuple(
282+
CompositeShape<dim>::BooleanOperation::Difference,
283+
first_shape,
284+
second_shape);
285+
}
286+
else if (type == "intersection")
287+
{
288+
operations[identifier] = std::make_tuple(
289+
CompositeShape<dim>::BooleanOperation::Intersection,
290+
first_shape,
291+
second_shape);
294292
}
295293
}
296294
}
297-
myfile.close();
298-
shape = std::make_shared<CompositeShape<dim>>(components,
299-
operations,
300-
position,
301-
orientation);
302295
}
303-
else
304-
throw std::invalid_argument(file_name);
305-
}
306-
else if (type == "opencascade")
307-
{
308-
shape = std::make_shared<OpenCascadeShape<dim>>(file_name,
309-
position,
310-
orientation);
296+
myfile.close();
297+
shape = std::make_shared<CompositeShape<dim>>(components,
298+
operations,
299+
position,
300+
orientation);
311301
}
312-
return shape;
302+
else
303+
throw std::invalid_argument(file_name);
304+
}
305+
else if (type == "opencascade")
306+
{
307+
shape =
308+
std::make_shared<OpenCascadeShape<dim>>(file_name, position, orientation);
309+
}
310+
return shape;
313311
}
314312

315313
template std::shared_ptr<Shape<2>>

source/core/solutions_output.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ write_boundaries_vtu(const DataOutFaces<dim> &data_out_faces,
7777
const double,
7878
const unsigned int iter,
7979
const MPI_Comm &mpi_communicator,
80-
const std::string file_prefix,
80+
const std::string &file_prefix,
8181
const unsigned int digits)
8282
{
8383
const int my_id = Utilities::MPI::this_mpi_process(mpi_communicator);

source/core/utilities.cc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ make_table_scalars_vectors(
2929
if (display_scientific_notation)
3030
{
3131
table.set_scientific(independent_column_name, true);
32-
for (unsigned int d = 0; d < dependent_column_names.size(); ++d)
33-
table.set_scientific(dependent_column_names[d], true);
32+
for (const auto &name : dependent_column_names)
33+
table.set_scientific(name, true);
3434
}
3535
else
3636
{
3737
table.set_precision(independent_column_name, display_precision);
38-
for (unsigned int d = 0; d < dependent_column_names.size(); ++d)
39-
table.set_precision(dependent_column_names[d], display_precision);
38+
for (const auto &name : dependent_column_names)
39+
table.set_precision(name, display_precision);
4040
}
4141

4242
return table;
@@ -235,7 +235,7 @@ fill_table_from_file(TableHandler &table,
235235
{
236236
if (word != "")
237237
{
238-
list_of_words_clean.push_back(word);
238+
list_of_words_clean.emplace_back(word);
239239
}
240240
}
241241
// If it's the first line, we only initialize the variable names.
@@ -282,7 +282,7 @@ fill_vectors_from_file(std::map<std::string, std::vector<double>> &map,
282282
{
283283
if (word != "")
284284
{
285-
list_of_words_clean.push_back(word);
285+
list_of_words_clean.emplace_back(word);
286286
}
287287
}
288288
// check if the line is contained words or numbers.
@@ -291,7 +291,7 @@ fill_vectors_from_file(std::map<std::string, std::vector<double>> &map,
291291
line_of_data = Utilities::string_to_double(list_of_words_clean);
292292
for (unsigned int i = 0; i < line_of_data.size(); ++i)
293293
{
294-
map[column_names[i]].push_back(line_of_data[i]);
294+
map[column_names[i]].emplace_back(line_of_data[i]);
295295
}
296296
}
297297
else
@@ -330,12 +330,10 @@ fill_string_vectors_from_file(
330330
std::vector<std::string> list_of_words_base =
331331
Utilities::split_string_list(line, delimiter);
332332
std::vector<std::string> list_of_words_clean;
333-
for (unsigned int i = 0; i < list_of_words_base.size(); ++i)
333+
for (const auto &word : list_of_words_base)
334334
{
335-
if (list_of_words_base[i] != "")
336-
{
337-
list_of_words_clean.push_back(list_of_words_base[i]);
338-
}
335+
if (word != "")
336+
list_of_words_clean.emplace_back(word);
339337
}
340338
// Check if it is the first line. If it is we assume it is the
341339
// column name.
@@ -344,7 +342,7 @@ fill_string_vectors_from_file(
344342
line_of_data = list_of_words_clean;
345343
for (unsigned int i = 0; i < line_of_data.size(); ++i)
346344
{
347-
map[column_names[i]].push_back(line_of_data[i]);
345+
map[column_names[i]].emplace_back(line_of_data[i]);
348346
}
349347
}
350348
else

tests/core/lethe_grid_tool_mesh_cut_by_flat_2.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,12 @@ test()
102102
});
103103

104104
Vector<double> subdomain(triangulation.n_active_cells());
105-
for (unsigned int i = 0; i < cells_cut.size(); ++i)
105+
for (auto &cell : cells_cut)
106106
{
107-
cells_cut[i]->set_subdomain_id(1);
108-
subdomain(cells_cut[i]->global_active_cell_index()) = 1;
109-
deallog << "The cell with ID : "
110-
<< cells_cut[i]->global_active_cell_index() << " is cut "
111-
<< std::endl;
107+
cell->set_subdomain_id(1);
108+
subdomain(cell->global_active_cell_index()) = 1;
109+
deallog << "The cell with ID : " << cell->global_active_cell_index()
110+
<< " is cut " << std::endl;
112111
}
113112

114113
// Printing the final position for all the vertices

tests/core/lethe_grid_tool_mesh_cut_by_flat_3.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,13 @@ test()
100100
});
101101

102102

103-
for (unsigned int i = 0; i < cells_cut.size(); ++i)
103+
for (auto &cell : cells_cut)
104104
{
105-
cells_cut[i]->set_subdomain_id(1);
106-
subdomain(cells_cut[i]->global_active_cell_index()) =
107-
cells_cut[i]->global_active_cell_index();
108-
deallog << "The cell with ID : "
109-
<< cells_cut[i]->global_active_cell_index() << " is cut "
110-
<< std::endl;
105+
cell->set_subdomain_id(1);
106+
subdomain(cell->global_active_cell_index()) =
107+
cell->global_active_cell_index();
108+
deallog << "The cell with ID : " << cell->global_active_cell_index()
109+
<< " is cut " << std::endl;
111110
}
112111

113112
// Printing the final position for all the vertices

tests/core/table_read.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,11 @@ test()
5252
std::map<std::string, std::vector<double>> vectors;
5353
fill_vectors_from_file(vectors, table_file_name);
5454

55-
for (std::map<std::string, std::vector<double>>::iterator it =
56-
vectors.begin();
57-
it != vectors.end();
58-
++it)
55+
for (const auto &it : vectors)
5956
{
60-
deallog << it->first << std::endl;
61-
for (unsigned int j = 0; j < it->second.size(); ++j)
62-
{
63-
deallog << it->second[j] << std::endl;
64-
}
57+
deallog << it.first << std::endl;
58+
for (const auto &j : it.second)
59+
deallog << j << std::endl;
6560
}
6661
}
6762

tests/core/vector_problem.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,12 @@ test()
9999

100100
for (unsigned int d = 0; d < 3; ++d)
101101
{
102-
for (auto j = index_set_velocity[d].begin();
103-
j != index_set_velocity[d].end();
104-
j++)
102+
for (const auto &j : index_set_velocity[d])
105103
{
106-
correction_norm += dummy_solution[*j] * dummy_solution[*j];
104+
correction_norm += dummy_solution[j] * dummy_solution[j];
107105

108106
max_correction =
109-
std::max(max_correction, std::abs(dummy_solution[*j]));
107+
std::max(max_correction, std::abs(dummy_solution[j]));
110108
}
111109
}
112110

0 commit comments

Comments
 (0)