Skip to content

Commit

Permalink
Remove all clang tidy warnings from the core library of Lethe (#1243)
Browse files Browse the repository at this point in the history
Description
Since I have deployed the new CI action, we are able to identify many more alerts using clang sanitizer. This PR aims at removing the alerts from the core library of Lethe. We still have warnings when we compile with clang, but this will need an additional CI instance check.

Testing
All units tests and application tests should pass before this is merged.
  • Loading branch information
blaisb authored Aug 20, 2024
1 parent 3aefa3a commit afe7dbb
Show file tree
Hide file tree
Showing 32 changed files with 242 additions and 238 deletions.
10 changes: 5 additions & 5 deletions include/core/bdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ using namespace dealii;
Vector<double>
calculate_bdf_coefficients(
const Parameters::SimulationControl::TimeSteppingMethod method,
const std::vector<double> time_steps);
const std::vector<double> &time_steps);


/**
Expand Down Expand Up @@ -78,10 +78,10 @@ calculate_bdf_coefficients(
* calculation of BDF coefficients.
*/
Vector<double>
delta(const unsigned int order,
const unsigned int n,
const unsigned int j,
const Vector<double> times);
delta(const unsigned int order,
const unsigned int n,
const unsigned int j,
const Vector<double> &times);



Expand Down
12 changes: 6 additions & 6 deletions include/core/manifolds.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,19 @@ attach_manifolds_to_triangulation(
*/
void
attach_cad_to_manifold(parallel::DistributedTriangulationBase<2> &triangulation,
std::string cad_name,
unsigned int manifold_id);
const std::string &cad_name,
const unsigned int manifold_id);

void
attach_cad_to_manifold(
parallel::DistributedTriangulationBase<2, 3> &triangulation,
std::string cad_name,
unsigned int manifold_id);
const std::string &cad_name,
const unsigned int manifold_id);

void
attach_cad_to_manifold(parallel::DistributedTriangulationBase<3> &triangulation,
std::string cad_name,
unsigned int manifold_id);
const std::string &cad_name,
const unsigned int manifold_id);



Expand Down
12 changes: 6 additions & 6 deletions include/core/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,12 @@ namespace Parameters
{}

void
declare_parameters(ParameterHandler &prm,
std::string material_prefix,
unsigned int id);
declare_parameters(ParameterHandler &prm,
const std::string &material_prefix,
unsigned int id);
void
parse_parameters(ParameterHandler &prm,
std::string material_prefix,
const std::string &material_prefix,
const unsigned int id,
const Dimensionality dimensions);

Expand Down Expand Up @@ -815,8 +815,8 @@ namespace Parameters
// z =2) value of the beam_orientation parameter
unsigned int beam_orientation_coordinate;

// beam_direction shows the direction of laser beam (either in positive (1)
// or negative (0) direction
// beam_direction shows the direction of laser beam (either in positive
// (true) or negative (false) direction
bool beam_direction;

// Based on the laser beam orientation, the integer values of a
Expand Down
6 changes: 3 additions & 3 deletions include/core/parsed_function_custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ class ParsedFunctionCustom
* @param[in] constants_list Constants used by the expressions
*/
void
initialize(const std::string vnames,
const std::string expression,
const std::string constants_list);
initialize(const std::string &vnames,
const std::string &expression,
const std::string &constants_list);

/**
* @brief Evaluate all components at the evaluation point
Expand Down
6 changes: 3 additions & 3 deletions include/core/pvd_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ class PVDHandler
* @param filename Name of the file to which the PVDHandler content is save
*/
void
save(std::string filename);
save(const std::string &filename);

/**
* @brief read Reads the content of a pvd times_and_names checpoint
*
* @param filename Name of the file frin which the PVDHandler content is read
*/
void
read(std::string filename);
read(const std::string &filename);

void
append(double time, std::string pvtu_filename)
append(double time, const std::string &pvtu_filename)
{
times_and_names.push_back(
std::pair<double, std::string>(time, pvtu_filename));
Expand Down
7 changes: 4 additions & 3 deletions include/core/serial_solid.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ class SerialSolid
* @param simulation_control The simulation control object
*/
void
write_output_results(std::shared_ptr<SimulationControl> simulation_control);
write_output_results(
const std::shared_ptr<SimulationControl> &simulation_control);

/**
* @brief read solid base triangulation checkpoint and replaces the
Expand All @@ -211,15 +212,15 @@ class SerialSolid
*
*/
void
read_checkpoint(std::string prefix_name);
read_checkpoint(const std::string &prefix_name);

/**
* @brief write solid base triangulation checkpoint
*
* @param prefix_name The prefix of the checkpoint of the simulation
*/
void
write_checkpoint(std::string prefix_name);
write_checkpoint(const std::string &prefix_name);


private:
Expand Down
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
16 changes: 8 additions & 8 deletions include/core/shape_parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace ShapeGenerator
*/
template <int dim>
std::shared_ptr<Shape<dim>>
initialize_shape(const std::string type,
const std::string shape_arguments_str,
initialize_shape(const std::string &type,
const std::string &shape_arguments_str,
const Point<dim> &position,
const Tensor<1, 3> &orientation);

Expand All @@ -47,10 +47,10 @@ namespace ShapeGenerator
*/
template <int dim>
std::shared_ptr<Shape<dim>>
initialize_shape_from_vector(const std::string type,
const std::vector<double> shape_arguments,
const Point<dim> &position,
const Tensor<1, 3> &orientation);
initialize_shape_from_vector(const std::string &type,
const std::vector<double> &shape_arguments,
const Point<dim> &position,
const Tensor<1, 3> &orientation);

/**
* Initializes the shape from its type and a text file that contains the real
Expand All @@ -62,8 +62,8 @@ namespace ShapeGenerator
*/
template <int dim>
std::shared_ptr<Shape<dim>>
initialize_shape_from_file(const std::string type,
const std::string file_name,
initialize_shape_from_file(const std::string &type,
const std::string &file_name,
const Point<dim> &position,
const Tensor<1, 3> &orientation);
} // namespace ShapeGenerator
Expand Down
29 changes: 19 additions & 10 deletions include/core/simulation_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class SimulationControl
*
**/

SimulationControl(const Parameters::SimulationControl param);
SimulationControl(const Parameters::SimulationControl &param);

/**
* @brief Pure virtual function to control the progression of the simulation.
Expand Down Expand Up @@ -472,23 +472,31 @@ class SimulationControl
return bdf_coefs;
}


/**
* @brief Save the simulation control information from the checkpoint file and updates the time step vector, the CFL value, the time and the iteration number.
*
* @param prefix The prefix of the checkpoint of the simulation
*/
void
save(std::string filename);
save(const std::string &prefix);

/**
* @brief Reads the simulation control information from the checkpoint file and updates the time step vector, the CFL value, the time and the iteration number.
*
* @param prefix The prefix of the checkpoint of the simulation
*/
void
read(std::string filename);
read(const std::string &prefix);

/**
* @brief Reads and returns the simulation control information from the checkpoint file filename without updating the simulation control information.
*
* @param prefix The prefix of the checkpoint of the simulation
*
* @return A vector containing the last checkpointed file and time step.
*/
std::vector<double>
get_checkpointed_simulation_control_info(std::string filename);
get_checkpointed_simulation_control_info(const std::string &prefix);
};


Expand Down Expand Up @@ -518,7 +526,7 @@ class SimulationControlTransient : public SimulationControl


public:
SimulationControlTransient(Parameters::SimulationControl param);
SimulationControlTransient(const Parameters::SimulationControl &param);

virtual void
print_progression(const ConditionalOStream &pcout) override;
Expand All @@ -543,7 +551,7 @@ class SimulationControlTransient : public SimulationControl
class SimulationControlTransientDEM : public SimulationControlTransient
{
public:
SimulationControlTransientDEM(Parameters::SimulationControl param);
SimulationControlTransientDEM(const Parameters::SimulationControl &param);

virtual void
print_progression(const ConditionalOStream &pcout) override;
Expand Down Expand Up @@ -571,7 +579,8 @@ class SimulationControlTransientDynamicOutput
calculate_time_step() override;

public:
SimulationControlTransientDynamicOutput(Parameters::SimulationControl param);
SimulationControlTransientDynamicOutput(
const Parameters::SimulationControl &param);


/**
Expand All @@ -585,7 +594,7 @@ class SimulationControlTransientDynamicOutput
class SimulationControlSteady : public SimulationControl
{
public:
SimulationControlSteady(Parameters::SimulationControl param);
SimulationControlSteady(const Parameters::SimulationControl &param);

virtual void
print_progression(const ConditionalOStream &pcout) override;
Expand All @@ -606,7 +615,7 @@ class SimulationControlSteady : public SimulationControl
class SimulationControlAdjointSteady : public SimulationControlTransient
{
public:
SimulationControlAdjointSteady(Parameters::SimulationControl param);
SimulationControlAdjointSteady(const Parameters::SimulationControl &param);

virtual void
print_progression(const ConditionalOStream &pcout) override;
Expand Down
8 changes: 4 additions & 4 deletions include/core/solid_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ class SolidBase
* @brief Loads a solid triangulation from a restart file
*/
void
load_triangulation(const std::string filename_tria);
load_triangulation(const std::string &filename_tria);

/**
* @brief Loads a particle handler in the fluid triangulation domain that holds the particles of the solid
* according to a specific quadrature, and sets up dofs
*/
void
load_particles(const std::string filename_part);
load_particles(const std::string &filename_part);

/**
* @return the reference to the std::shared_ptr of a Particles::ParticleHandler<spacedim> that contains the solid particle handler
Expand Down Expand Up @@ -220,13 +220,13 @@ class SolidBase
* @brief read solid base triangulation checkpoint
*/
void
read_checkpoint(std::string prefix_name);
read_checkpoint(const std::string &prefix_name);

/**
* @brief write solid base triangulation checkpoint
*/
void
write_checkpoint(std::string prefix_name);
write_checkpoint(const std::string &prefix_name);


private:
Expand Down
8 changes: 4 additions & 4 deletions include/core/solutions_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ template <int dim, int spacedim = dim>
void
write_vtu_and_pvd(PVDHandler &pvd_handler,
const DataOutInterface<dim, spacedim> &data_out,
const std::string folder,
const std::string file_prefix,
const std::string &folder,
const std::string &file_prefix,
const double time,
const unsigned int iter,
const unsigned int group_files,
Expand All @@ -80,10 +80,10 @@ write_vtu_and_pvd(PVDHandler &pvd_handler,
template <int dim>
void
write_boundaries_vtu(const DataOutFaces<dim> &data_out,
const std::string folder,
const std::string &folder,
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
14 changes: 7 additions & 7 deletions include/core/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ calculate_point_property_cahn_hilliard(const double phase_cahn_hilliard,
* @param delimiter The delimiter used to read the table.
*/
void
fill_table_from_file(TableHandler &table,
const std::string file_name,
const std::string delimiter = " ");
fill_table_from_file(TableHandler &table,
const std::string &file_name,
const std::string &delimiter = " ");

/**
* @brief function that read a file that was build from a dealii table and fill 2 vectors.
Expand All @@ -379,8 +379,8 @@ fill_table_from_file(TableHandler &table,
*/
void
fill_vectors_from_file(std::map<std::string, std::vector<double>> &map,
const std::string file_name,
const std::string delimiter = " ");
const std::string &file_name,
const std::string &delimiter = " ");

/**
* @brief Function that read a file that was build from a dealii table and create a map with the key being the column name and the variable the vectors of data.
Expand All @@ -393,8 +393,8 @@ fill_vectors_from_file(std::map<std::string, std::vector<double>> &map,
void
fill_string_vectors_from_file(
std::map<std::string, std::vector<std::string>> &map,
const std::string file_name,
const std::string delimiter = " ");
const std::string &file_name,
const std::string &delimiter = " ");

/**
* @brief Creates the simulation output folder
Expand Down
Loading

0 comments on commit afe7dbb

Please sign in to comment.