Skip to content

Commit

Permalink
Migrate include after ifdefs in core and solver h (chaos-polymtl#1170)
Browse files Browse the repository at this point in the history
Description
Everywhere throughout the include files of the core and the solver library, there were multiple includes that were defined before the #ifndef -> #define -> #endif statements. This is mostly aesthetics, but this can also have a small impact on compilation time, especially on systems with a slow filesystem (e.g. the clusters). See for example: https://stackoverflow.com/questions/20988705/is-an-include-before-ifdef-define-include-guard-okay

Additionally, some of the include guards were in capital letters, some were not. Heck, some were even missing. So I took the opportunity to uniformize thing. I limited myself to core/solver as a first step, but in a follow-up PR I could do it for the other parts of the library.

Testing
There are not tests required here. If the code compiles, everything will be fine.

Documentation
No documentation was modified in the making of this PR.

Co-authored-by: Audrey Collard-Daigneault <71884806+acdaigneault@users.noreply.github.com>
Co-authored-by: Amishga Alphonius <107414376+AmishgaAlphonius@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 13, 2024
1 parent dabcf1f commit eea049f
Show file tree
Hide file tree
Showing 48 changed files with 135 additions and 164 deletions.
13 changes: 7 additions & 6 deletions include/core/auxiliary_math_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
*
* ---------------------------------------------------------------------
*/
#include "core/parameters.h"

#include <cfloat>

#ifndef LETHE_AUXILIARY_MATH_FUNCTIONS_H
# define LETHE_AUXILIARY_MATH_FUNCTIONS_H
#ifndef lethe_auxiliary_math_functions_h
#define lethe_auxiliary_math_functions_h

#include <limits>

/**
* Carries out the calculation of the harmonic mean of two values.
Expand All @@ -31,7 +31,8 @@
inline double
harmonic_mean(const double &value_one, const double &value_two)
{
return (2 * value_one * value_two / (value_one + value_two + DBL_MIN));
return (2 * value_one * value_two /
(value_one + value_two + std::numeric_limits<double>::min()));
}

#endif // LETHE_AUXILIARY_MATH_FUNCTIONS_H
#endif
3 changes: 0 additions & 3 deletions include/core/boundary_conditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Bruno Blais, Polytechnique Montreal, 2019 -
*/

#ifndef lethe_boundary_conditions_h
Expand Down
15 changes: 6 additions & 9 deletions include/core/dem_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Bruno Blais, Polytechnique Montreal, 2020-
*/

#include <iostream>


#ifndef lethe_dem_properties_h
#define lethe_dem_properties_h

#include <string>
#include <tuple>
#include <vector>

#ifndef Lethe_DEM_properties_h
# define Lethe_DEM_properties_h

namespace DEM
{
/* This enum class is reponsible for the handling the specific indexes of the
/* This enum class is responsible for the handling the specific indexes of the
* particles properties within the property pool and also to generate
* the associative names for the properties
* This is the only part where we should use a classical enum because it is
Expand Down
1 change: 1 addition & 0 deletions include/core/evaporation_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* ---------------------------------------------------------------------
*/

#ifndef lethe_evaporation_model_h
#define lethe_evaporation_model_h

Expand Down
3 changes: 0 additions & 3 deletions include/core/grids.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Bruno Blais, Polytechnique Montreal, 2020 -
*/

#ifndef lethe_grids_h
Expand Down
9 changes: 5 additions & 4 deletions include/core/ib_particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
*
*/



#ifndef lethe_ib_particle_h
#define lethe_ib_particle_h

#include <core/dem_properties.h>
#include <core/shape.h>

#include <deal.II/base/auto_derivative_function.h>
#include <deal.II/base/function_signed_distance.h>
#include <deal.II/base/parsed_function.h>
#include <deal.II/base/point.h>
Expand All @@ -27,9 +31,6 @@

#include <vector>

#ifndef lethe_ib_particle_h
# define lethe_ib_particle_h

using namespace dealii;

/**
Expand Down
2 changes: 0 additions & 2 deletions include/core/ib_stencil.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Lucka Barbeau, Bruno Blais, Polytechnique Montreal, 2019 -
*/

#ifndef lethe_ib_stencil_h
Expand Down
4 changes: 2 additions & 2 deletions include/core/inexact_newton_non_linear_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* ---------------------------------------------------------------------
*/

#ifndef lethe_inexact_newton_iteration_non_linear_solver_h
#define lethe_inexact_newton_iteration_non_linear_solver_h
#ifndef lethe_inexact_newton_non_linear_solver_h
#define lethe_inexact_newton_non_linear_solver_h

#include <core/non_linear_solver.h>

Expand Down
4 changes: 2 additions & 2 deletions include/core/kinsol_newton_non_linear_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* ---------------------------------------------------------------------
*/

#ifndef kinsol_non_linear_solver_h
#define kinsol_non_linear_solver_h
#ifndef lethe_kinsol_non_linear_solver_h
#define lethe_kinsol_non_linear_solver_h

#include <core/non_linear_solver.h>
#include <core/parameters.h>
Expand Down
5 changes: 2 additions & 3 deletions include/core/lethe_grid_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
*
* -------------------------------------------------------------------*/

#ifndef lethe_lethegridtools_h
#define lethe_lethegridtools_h
#ifndef lethe_lethe_grid_tools_h
#define lethe_lethe_grid_tools_h

#include <core/serial_solid.h>

#include <deal.II/base/table_handler.h>
#include <deal.II/base/tensor.h>

#include <deal.II/dofs/dof_handler.h>
Expand Down
3 changes: 0 additions & 3 deletions include/core/manifolds.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Bruno Blais, Polytechnique Montreal, 2019 -
*/

#ifndef lethe_manifolds_h
Expand Down
7 changes: 2 additions & 5 deletions include/core/mesh_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
* ---------------------------------------------------------------------*/


#ifndef lethe_mesh_controler_h
#define lethe_mesh_controler_h

#include <iostream>

#ifndef lethe_mesh_controller_h
#define lethe_mesh_controller_h

/**
* @Class Controller that target a given number of elements in the mesh. This
Expand Down
3 changes: 0 additions & 3 deletions include/core/parameters_multiphysics.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Bruno Blais, Polytechnique Montreal, 2019-
*/

/*
Expand Down
4 changes: 0 additions & 4 deletions include/core/periodic_hills_grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Audrey Collard-Daigneault, Polytechnique Montreal, 2020 -
*/

#ifndef lethe_per_hills_grid_h
Expand All @@ -23,7 +20,6 @@
#include <deal.II/base/utilities.h>

#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/manifold_lib.h>
#include <deal.II/grid/tria.h>
Expand Down
4 changes: 2 additions & 2 deletions include/core/phase_change.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* ---------------------------------------------------------------------
*/

#ifndef phase_change_h
#define phase_change_h
#ifndef lethe_phase_change_h
#define lethe_phase_change_h

#include <core/physical_property_model.h>

Expand Down
4 changes: 2 additions & 2 deletions include/core/physics_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*
* ---------------------------------------------------------------------*/

#ifndef LETHE_PHYSICSSOLVER
#define LETHE_PHYSICSSOLVER
#ifndef lethe_physics_solver_h
#define lethe_physics_solver_h

#include <core/inexact_newton_non_linear_solver.h>
#include <core/kinsol_newton_non_linear_solver.h>
Expand Down
3 changes: 0 additions & 3 deletions include/core/simulation_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Bruno Blais, Polytechnique Montreal, 2020 -
*/

#ifndef lethe_simulation_control_h
Expand Down
4 changes: 0 additions & 4 deletions include/core/solid_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Authors: Carole-Anne Daunais, Valérie Bibeau, Polytechnique Montreal, 2020
* Jeanne Joachim, Polytechnique Montreal, 2020-
*/

#ifndef lethe_solid_base_h
Expand Down
7 changes: 2 additions & 5 deletions include/core/solid_objects_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Carole-Anne Daunais, Polytechnique Montreal, 2020 -
*/


#ifndef nitsche_h
#define nitsche_h
#ifndef lethe_solid_objects_parameters_h
#define lethe_solid_objects_parameters_h

#include <core/parameters.h>

Expand Down
3 changes: 0 additions & 3 deletions include/core/solutions_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Bruno Blais, Polytechnique Montreal, 2020 -
*/

#ifndef lethe_solutions_output_h
Expand Down
9 changes: 3 additions & 6 deletions include/core/tensors_and_points_dimension_manipulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Shahab Golshan, Polytechnique Montreal, 2019
*/

#ifndef lethe_tensors_and_points_dimension_manipulation_h
#define lethe_tensors_and_points_dimension_manipulation_h

#include <deal.II/base/point.h>
#include <deal.II/base/tensor.h>

using namespace dealii;

#ifndef tensors_and_points_dimension_manipulation_h
# define tensors_and_points_dimension_manipulation_h

/**
* Copies a two-dimensional tensor in a three-dimensional tensor. The third
* element of the three-dimensional tensor (in z direction) is set to zero.
Expand Down
3 changes: 0 additions & 3 deletions include/core/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
* the top level of the Lethe distribution.
*
* ---------------------------------------------------------------------
*
* Author: Bruno Blais, Polytechnique Montreal, 2020 -
*/

#ifndef lethe_utilities_h
Expand Down
4 changes: 2 additions & 2 deletions include/solvers/cahn_hilliard.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
* phase field parameter and the chemical potential.
*/

#ifndef cahn_hilliard_h
#define cahn_hilliard_h
#ifndef lethe_cahn_hilliard_h
#define lethe_cahn_hilliard_h

#include <core/bdf.h>
#include <core/simulation_control.h>
Expand Down
6 changes: 2 additions & 4 deletions include/solvers/cahn_hilliard_assemblers.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@
*
* ---------------------------------------------------------------------*/

#ifndef lethe_cahn_hilliard_assemblers_h
#define lethe_cahn_hilliard_assemblers_h

#include <core/simulation_control.h>

#include <solvers/cahn_hilliard_scratch_data.h>
#include <solvers/copy_data.h>
#include <solvers/multiphysics_interface.h>


#ifndef lethe_cahn_hilliard_assemblers_h
# define lethe_cahn_hilliard_assemblers_h

/**
* @brief A pure virtual class that serves as an interface for all
* of the assemblers for the Cahn-Hilliard equation
Expand Down
1 change: 0 additions & 1 deletion include/solvers/cahn_hilliard_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#ifndef lethe_cahn_hilliard_filter_h
#define lethe_cahn_hilliard_filter_h


#include <core/parameters_multiphysics.h>

/**
Expand Down
7 changes: 4 additions & 3 deletions include/solvers/cahn_hilliard_scratch_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* Scratch data for the CahnHilliard auxiliary physics
*/


#ifndef lethe_cahn_hilliard_scratch_data_h
#define lethe_cahn_hilliard_scratch_data_h

#include <core/multiphysics.h>

#include <solvers/multiphysics_interface.h>
Expand All @@ -33,9 +37,6 @@
#include <deal.II/numerics/vector_tools.h>


#ifndef lethe_cahn_hilliard_scratch_data_h
# define lethe_cahn_hilliard_scratch_data_h

using namespace dealii;


Expand Down
6 changes: 3 additions & 3 deletions include/solvers/copy_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
*/


#ifndef lethe_copy_data_h
#define lethe_copy_data_h

#include <deal.II/dofs/dof_handler.h>

#include <deal.II/lac/full_matrix.h>
#include <deal.II/lac/vector.h>

#include <vector>

#ifndef copy_data_navier_stokes_h
# define copy_data_navier_stokes_h

using namespace dealii;

/**
Expand Down
Loading

0 comments on commit eea049f

Please sign in to comment.