Skip to content

Commit

Permalink
Fix last batch of core warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
blaisb committed Aug 20, 2024
1 parent 478c154 commit 881f23b
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 128 deletions.
2 changes: 1 addition & 1 deletion include/core/shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -2680,7 +2680,7 @@ class RBFShape : public Shape<dim>
* @param orientation the orientation of the shape with respect to each main
* axis
*/
RBFShape(const std::string shape_arguments_str,
RBFShape(const std::string &shape_arguments_str,
const Point<dim> &position,
const Tensor<1, 3> &orientation);

Expand Down
2 changes: 1 addition & 1 deletion include/core/solutions_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ write_boundaries_vtu(const DataOutFaces<dim> &data_out,
const double time,
const unsigned int iter,
const MPI_Comm &mpi_communicator,
const std::string file_prefix = std::string("boundaries"),
const std::string &file_prefix = std::string("boundaries"),
const unsigned int digits = 5);
#endif
2 changes: 1 addition & 1 deletion source/core/shape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ CompositeShape<dim>::set_layer_thickening(const double layer_thickening)
}

template <int dim>
RBFShape<dim>::RBFShape(const std::string shape_arguments_str,
RBFShape<dim>::RBFShape(const std::string &shape_arguments_str,
const Point<dim> &position,
const Tensor<1, 3> &orientation)
: Shape<dim>(1, position, orientation)
Expand Down
166 changes: 82 additions & 84 deletions source/core/shape_parsing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,104 +212,102 @@ ShapeGenerator::initialize_shape_from_file(const std::string &type,
std::vector<std::string> list_of_words_base =
Utilities::split_string_list(line, ";");
std::vector<std::string> list_of_words_clean;
for (unsigned int j = 0; j < list_of_words_base.size(); ++j)
for (const auto &word : list_of_words_base)
{
if (list_of_words_base[j] != "")
{
list_of_words_clean.push_back(list_of_words_base[j]);
}
list_of_words_clean.emplace_back(word);
}
if (parsing_shapes)
{
unsigned int identifier = stoi(list_of_words_clean[0]);
std::string type = list_of_words_clean[1];
std::string arguments_str = list_of_words_clean[2];
std::replace(arguments_str.begin(),
arguments_str.end(),
':',
';');
std::string position_str = list_of_words_clean[3];
std::string orientation_str = list_of_words_clean[4];
}
if (parsing_shapes)
{
unsigned int identifier = stoi(list_of_words_clean[0]);
std::string type = list_of_words_clean[1];
std::string arguments_str = list_of_words_clean[2];
std::replace(arguments_str.begin(),
arguments_str.end(),
':',
';');
std::string position_str = list_of_words_clean[3];
std::string orientation_str = list_of_words_clean[4];

std::vector<std::string> position_str_component =
Utilities::split_string_list(position_str, ":");
std::vector<std::string> orientation_str_component =
Utilities::split_string_list(orientation_str, ":");
std::vector<std::string> position_str_component =
Utilities::split_string_list(position_str, ":");
std::vector<std::string> orientation_str_component =
Utilities::split_string_list(orientation_str, ":");

std::vector<double> temp_position_vec =
Utilities::string_to_double(position_str_component);
std::vector<double> temp_orientation_vec =
Utilities::string_to_double(orientation_str_component);
std::vector<double> temp_position_vec =
Utilities::string_to_double(position_str_component);
std::vector<double> temp_orientation_vec =
Utilities::string_to_double(orientation_str_component);

Point<dim> temp_position;
Point<3> temp_orientation =
Point<3>({temp_orientation_vec[0],
temp_orientation_vec[1],
temp_orientation_vec[2]});
temp_position[0] = temp_position_vec[0];
temp_position[1] = temp_position_vec[1];
if constexpr (dim == 3)
temp_position[2] = temp_position_vec[2];
Point<dim> temp_position;
Point<3> temp_orientation =
Point<3>({temp_orientation_vec[0],
temp_orientation_vec[1],
temp_orientation_vec[2]});
temp_position[0] = temp_position_vec[0];
temp_position[1] = temp_position_vec[1];
if constexpr (dim == 3)
temp_position[2] = temp_position_vec[2];

std::shared_ptr<Shape<dim>> shape_temp;
shape_temp = ShapeGenerator::initialize_shape(type,
arguments_str,
Point<dim>(),
Tensor<1, 3>());
shape_temp->set_position(temp_position);
shape_temp->set_orientation(temp_orientation);
components[identifier] = shape_temp->static_copy();
}
else if (parsing_operations)
{
unsigned int identifier = stoi(list_of_words_clean[0]);
std::string type = list_of_words_clean[1];
std::string arguments_str = list_of_words_clean[2];
std::vector<std::string> arguments_str_component =
Utilities::split_string_list(arguments_str, ":");

std::shared_ptr<Shape<dim>> shape_temp;
shape_temp = ShapeGenerator::initialize_shape(
type, arguments_str, Point<dim>(), Tensor<1, 3>());
shape_temp->set_position(temp_position);
shape_temp->set_orientation(temp_orientation);
components[identifier] = shape_temp->static_copy();
unsigned int first_shape = stoi(arguments_str_component[0]);
unsigned int second_shape = stoi(arguments_str_component[1]);
if (type == "union")
{
operations[identifier] = std::make_tuple(
CompositeShape<dim>::BooleanOperation::Union,
first_shape,
second_shape);
}
else if (parsing_operations)
else if (type == "difference")
{
unsigned int identifier = stoi(list_of_words_clean[0]);
std::string type = list_of_words_clean[1];
std::string arguments_str = list_of_words_clean[2];
std::vector<std::string> arguments_str_component =
Utilities::split_string_list(arguments_str, ":");

unsigned int first_shape =
stoi(arguments_str_component[0]);
unsigned int second_shape =
stoi(arguments_str_component[1]);
if (type == "union")
{
operations[identifier] = std::make_tuple(
CompositeShape<dim>::BooleanOperation::Union,
first_shape,
second_shape);
}
else if (type == "difference")
{
operations[identifier] = std::make_tuple(
CompositeShape<dim>::BooleanOperation::Difference,
first_shape,
second_shape);
}
else if (type == "intersection")
{
operations[identifier] = std::make_tuple(
CompositeShape<dim>::BooleanOperation::Intersection,
first_shape,
second_shape);
}
operations[identifier] = std::make_tuple(
CompositeShape<dim>::BooleanOperation::Difference,
first_shape,
second_shape);
}
else if (type == "intersection")
{
operations[identifier] = std::make_tuple(
CompositeShape<dim>::BooleanOperation::Intersection,
first_shape,
second_shape);
}
}
}
myfile.close();
shape = std::make_shared<CompositeShape<dim>>(components,
operations,
position,
orientation);
}
else
throw std::invalid_argument(file_name);
}
else if (type == "opencascade")
{
shape = std::make_shared<OpenCascadeShape<dim>>(file_name,
position,
orientation);
myfile.close();
shape = std::make_shared<CompositeShape<dim>>(components,
operations,
position,
orientation);
}
return shape;
else
throw std::invalid_argument(file_name);
}
else if (type == "opencascade")
{
shape =
std::make_shared<OpenCascadeShape<dim>>(file_name, position, orientation);
}
return shape;
}

template std::shared_ptr<Shape<2>>
Expand Down
2 changes: 1 addition & 1 deletion source/core/solutions_output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ write_boundaries_vtu(const DataOutFaces<dim> &data_out_faces,
const double,
const unsigned int iter,
const MPI_Comm &mpi_communicator,
const std::string file_prefix,
const std::string &file_prefix,
const unsigned int digits)
{
const int my_id = Utilities::MPI::this_mpi_process(mpi_communicator);
Expand Down
24 changes: 11 additions & 13 deletions source/core/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ make_table_scalars_vectors(
if (display_scientific_notation)
{
table.set_scientific(independent_column_name, true);
for (unsigned int d = 0; d < dependent_column_names.size(); ++d)
table.set_scientific(dependent_column_names[d], true);
for (const auto &name : dependent_column_names)
table.set_scientific(name, true);
}
else
{
table.set_precision(independent_column_name, display_precision);
for (unsigned int d = 0; d < dependent_column_names.size(); ++d)
table.set_precision(dependent_column_names[d], display_precision);
for (const auto &name : dependent_column_names)
table.set_precision(name, display_precision);
}

return table;
Expand Down Expand Up @@ -235,7 +235,7 @@ fill_table_from_file(TableHandler &table,
{
if (word != "")
{
list_of_words_clean.push_back(word);
list_of_words_clean.emplace_back(word);
}
}
// If it's the first line, we only initialize the variable names.
Expand Down Expand Up @@ -282,7 +282,7 @@ fill_vectors_from_file(std::map<std::string, std::vector<double>> &map,
{
if (word != "")
{
list_of_words_clean.push_back(word);
list_of_words_clean.emplace_back(word);
}
}
// check if the line is contained words or numbers.
Expand All @@ -291,7 +291,7 @@ fill_vectors_from_file(std::map<std::string, std::vector<double>> &map,
line_of_data = Utilities::string_to_double(list_of_words_clean);
for (unsigned int i = 0; i < line_of_data.size(); ++i)
{
map[column_names[i]].push_back(line_of_data[i]);
map[column_names[i]].emplace_back(line_of_data[i]);
}
}
else
Expand Down Expand Up @@ -330,12 +330,10 @@ fill_string_vectors_from_file(
std::vector<std::string> list_of_words_base =
Utilities::split_string_list(line, delimiter);
std::vector<std::string> list_of_words_clean;
for (unsigned int i = 0; i < list_of_words_base.size(); ++i)
for (const auto &word : list_of_words_base)
{
if (list_of_words_base[i] != "")
{
list_of_words_clean.push_back(list_of_words_base[i]);
}
if (word != "")
list_of_words_clean.emplace_back(word);
}
// Check if it is the first line. If it is we assume it is the
// column name.
Expand All @@ -344,7 +342,7 @@ fill_string_vectors_from_file(
line_of_data = list_of_words_clean;
for (unsigned int i = 0; i < line_of_data.size(); ++i)
{
map[column_names[i]].push_back(line_of_data[i]);
map[column_names[i]].emplace_back(line_of_data[i]);
}
}
else
Expand Down
11 changes: 5 additions & 6 deletions tests/core/lethe_grid_tool_mesh_cut_by_flat_2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,12 @@ test()
});

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

// Printing the final position for all the vertices
Expand Down
13 changes: 6 additions & 7 deletions tests/core/lethe_grid_tool_mesh_cut_by_flat_3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@ test()
});


for (unsigned int i = 0; i < cells_cut.size(); ++i)
for (auto &cell : cells_cut)
{
cells_cut[i]->set_subdomain_id(1);
subdomain(cells_cut[i]->global_active_cell_index()) =
cells_cut[i]->global_active_cell_index();
deallog << "The cell with ID : "
<< cells_cut[i]->global_active_cell_index() << " is cut "
<< std::endl;
cell->set_subdomain_id(1);
subdomain(cell->global_active_cell_index()) =
cell->global_active_cell_index();
deallog << "The cell with ID : " << cell->global_active_cell_index()
<< " is cut " << std::endl;
}

// Printing the final position for all the vertices
Expand Down
13 changes: 4 additions & 9 deletions tests/core/table_read.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,11 @@ test()
std::map<std::string, std::vector<double>> vectors;
fill_vectors_from_file(vectors, table_file_name);

for (std::map<std::string, std::vector<double>>::iterator it =
vectors.begin();
it != vectors.end();
++it)
for (const auto &it : vectors)
{
deallog << it->first << std::endl;
for (unsigned int j = 0; j < it->second.size(); ++j)
{
deallog << it->second[j] << std::endl;
}
deallog << it.first << std::endl;
for (const auto &j : it.second)
deallog << j << std::endl;
}
}

Expand Down
8 changes: 3 additions & 5 deletions tests/core/vector_problem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,12 @@ test()

for (unsigned int d = 0; d < 3; ++d)
{
for (auto j = index_set_velocity[d].begin();
j != index_set_velocity[d].end();
j++)
for (const auto &j : index_set_velocity[d])
{
correction_norm += dummy_solution[*j] * dummy_solution[*j];
correction_norm += dummy_solution[j] * dummy_solution[j];

max_correction =
std::max(max_correction, std::abs(dummy_solution[*j]));
std::max(max_correction, std::abs(dummy_solution[j]));
}
}

Expand Down

0 comments on commit 881f23b

Please sign in to comment.