Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion scripts/dev/fix_include_guards.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def fix_include_guards(filepath: Path, src_root: Path, project_name: str = "", d

if not ifndef_line:
print(f"⚠️ No include guard found in {filepath}")
return False
print(f" Add incluide guards in {filepath}")
return add_include_guards(filepath, src_root, project_name, dry_run)

# Extract current guard name
current_guard = re.search(r'#\s*ifndef\s+([A-Za-z0-9_]+)', ifndef_line).group(1)
Expand Down Expand Up @@ -193,6 +194,37 @@ def fix_include_guards(filepath: Path, src_root: Path, project_name: str = "", d
print(f"❌ Error writing {filepath}: {e}")
return False

def add_include_guards(filepath: Path, src_root: Path, project_name: str = "", dry_run: bool = False) -> bool:
"""
Add include guards to a file that doesn't have them.

Returns:
True if the file was modified, False otherwise
"""
try:
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
except Exception as e:
print(f"❌ Error reading {filepath}: {e}")
return False

guard_name = generate_guard_name(filepath, src_root, project_name)

print(f" {filepath.relative_to(src_root.parent)}:")
print(f" Adding guard: {guard_name}")

if dry_run:
return True

new_content = f"#ifndef {guard_name}\n#define {guard_name}\n\n{content.rstrip()}\n\n#endif // {guard_name}\n"

try:
with open(filepath, 'w', encoding='utf-8') as f:
f.write(new_content)
return True
except Exception as e:
print(f"❌ Error writing {filepath}: {e}")
return False

def main():
import argparse
Expand Down Expand Up @@ -228,6 +260,8 @@ def main():

extensions = [f".{ext.strip()}" for ext in args.extensions.split(',')]
exclude_dirs = args.exclude

exclude_dirs = [d.strip("/") for d in args.exclude]

print(f"🔍 Searching for header files in {src_root}")
print(f" Extensions: {', '.join(extensions)}")
Expand Down
7 changes: 3 additions & 4 deletions src/discretization/fd/abckernels/include/fd_abckernels.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef FDTD_PML_HPP
#define FDTD_PML_HPP

#ifndef FUNTIDES_DISCRETIZATION_FD_ABCKERNELS_INCLUDE_FD_ABCKERNELS_H_
#define FUNTIDES_DISCRETIZATION_FD_ABCKERNELS_INCLUDE_FD_ABCKERNELS_H_
#include "data_type.h"
#include "fd_macros.h"

Expand Down Expand Up @@ -233,4 +232,4 @@ struct FdtdAbcKernels

} // namespace abckernel
} // namespace fdtd
#endif // FDTD_PML_HPP
#endif // FUNTIDES_DISCRETIZATION_FD_ABCKERNELS_INCLUDE_FD_ABCKERNELS_H_
7 changes: 3 additions & 4 deletions src/discretization/fd/kernels/include/fd_kernels.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef FDTD_KERNEL_H
#define FDTD_KERNEL_H

#ifndef FUNTIDES_DISCRETIZATION_FD_KERNELS_INCLUDE_FD_KERNELS_H_
#define FUNTIDES_DISCRETIZATION_FD_KERNELS_INCLUDE_FD_KERNELS_H_
#include "data_type.h"
#include "fd_abckernels.h"
#include "fd_macros.h"
Expand Down Expand Up @@ -163,4 +162,4 @@ struct FdtdKernels

} // namespace kernel
} // namespace fdtd
#endif // FDTD_KERNEL_H
#endif // FUNTIDES_DISCRETIZATION_FD_KERNELS_INCLUDE_FD_KERNELS_H_
8 changes: 3 additions & 5 deletions src/discretization/fd/kernels/include/fd_macros.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef FDTD_MACROS_H
#define FDTD_MACROS_H

#ifndef FUNTIDES_DISCRETIZATION_FD_KERNELS_INCLUDE_FD_MACROS_H_
#define FUNTIDES_DISCRETIZATION_FD_KERNELS_INCLUDE_FD_MACROS_H_
#define POW2(x) ((x) * (x))
#define IDX3(i, j, k) (nz * ny * (i) + nz * (j) + (k))
#define IDX3_l(i, j, k) \
Expand Down Expand Up @@ -53,5 +52,4 @@
#else
#define FDFENCE
#endif

#endif // FDTD_MACROS_H
#endif // FUNTIDES_DISCRETIZATION_FD_KERNELS_INCLUDE_FD_MACROS_H_
8 changes: 3 additions & 5 deletions src/discretization/fd/stencils/include/fd_stencils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef FDTD_STENCILS_H
#define FDTD_STENCILS_H

#ifndef FUNTIDES_DISCRETIZATION_FD_STENCILS_INCLUDE_FD_STENCILS_H_
#define FUNTIDES_DISCRETIZATION_FD_STENCILS_INCLUDE_FD_STENCILS_H_
#include <data_type.h>

#include <cmath>
Expand Down Expand Up @@ -135,5 +134,4 @@ struct FdtdStencils

} // namespace stencils
} // namespace fdtd

#endif // FDTD_STENCILS_H
#endif // FUNTIDES_DISCRETIZATION_FD_STENCILS_INCLUDE_FD_STENCILS_H_
5 changes: 5 additions & 0 deletions src/discretization/fe/Integrals.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef FUNTIDES_DISCRETIZATION_FE_INTEGRALS_H_
#define FUNTIDES_DISCRETIZATION_FE_INTEGRALS_H_

#pragma once

#include "finiteElement/makutu/Qk_Hexahedron_Lagrange_GaussLobatto.hpp"
Expand All @@ -19,3 +22,5 @@ struct IntegralTypeSelector<ORDER, IntegralType::MAKUTU>
using type =
typename Qk_Hexahedron_Lagrange_GaussLobatto_Selector<ORDER>::type;
};

#endif // FUNTIDES_DISCRETIZATION_FE_INTEGRALS_H_
8 changes: 3 additions & 5 deletions src/main/fd/include/fd_io.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef FDTD_IO_H_
#define FDTD_IO_H_

#ifndef FUNTIDES_MAIN_FD_INCLUDE_FD_IO_H_
#define FUNTIDES_MAIN_FD_INCLUDE_FD_IO_H_
#include <cstdio>
#include <vector>

Expand Down Expand Up @@ -107,5 +106,4 @@ struct FdtdIo

} // namespace io
} // namespace fdtd

#endif // FDTD_IO.H_
#endif // FUNTIDES_MAIN_FD_INCLUDE_FD_IO_H_
9 changes: 3 additions & 6 deletions src/main/fd/include/fd_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
// boundary conditions, and output settings. It provides command-line
// argument binding and validation functionality.
//************************************************************************

#ifndef SRC_MAIN_FD_INCLUDE_FDTD_OPTIONS_HPP_
#define SRC_MAIN_FD_INCLUDE_FDTD_OPTIONS_HPP_

#ifndef FUNTIDES_MAIN_FD_INCLUDE_FD_OPTIONS_H_
#define FUNTIDES_MAIN_FD_INCLUDE_FD_OPTIONS_H_
#include <cxxopts.hpp>
#include <stdexcept>
#include <string>
Expand Down Expand Up @@ -334,5 +332,4 @@ class FdtdOptions

} // namespace options
} // namespace fdtd

#endif // SRC_MAIN_FD_INCLUDE_FDTD_OPTIONS_HPP_
#endif // FUNTIDES_MAIN_FD_INCLUDE_FD_OPTIONS_H_
8 changes: 3 additions & 5 deletions src/main/fd/include/fd_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
// Copyright (c) 2025
// License: [Specify license here]
//************************************************************************

#ifndef SRC_MAIN_FD_INCLUDE_FDTD_PROXY_HPP_
#define SRC_MAIN_FD_INCLUDE_FDTD_PROXY_HPP_

#ifndef FUNTIDES_MAIN_FD_INCLUDE_FD_PROXY_H_
#define FUNTIDES_MAIN_FD_INCLUDE_FD_PROXY_H_
#include <chrono>
#include <memory>

Expand Down Expand Up @@ -189,4 +187,4 @@ class FdtdProxy
};

} // namespace fdtd
#endif // SRC_MAIN_FD_INCLUDE_FDTD_PROXY_HPP_
#endif // FUNTIDES_MAIN_FD_INCLUDE_FD_PROXY_H_
5 changes: 5 additions & 0 deletions src/main/fe/include/sem_io_controller.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef FUNTIDES_MAIN_FE_INCLUDE_SEM_IO_CONTROLLER_H_
#define FUNTIDES_MAIN_FE_INCLUDE_SEM_IO_CONTROLLER_H_

#include <adios2.h>
#include <data_type.h>

Expand Down Expand Up @@ -122,3 +125,5 @@ class SemIOController
snaps_writer_.EndStep();
}
};

#endif // FUNTIDES_MAIN_FE_INCLUDE_SEM_IO_CONTROLLER_H_
6 changes: 3 additions & 3 deletions src/main/fe/include/sem_proxy.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef MAIN_FE_INCLUDE_SEM_PROXY_H_
#define MAIN_FE_INCLUDE_SEM_PROXY_H_
#ifndef FUNTIDES_MAIN_FE_INCLUDE_SEM_PROXY_H_
#define FUNTIDES_MAIN_FE_INCLUDE_SEM_PROXY_H_
#include <data_type.h>
#include <utils.h>

Expand Down Expand Up @@ -168,4 +168,4 @@ class SEMproxy
meshType getMesh(string meshArg);
model::AnisotropyType getAnisotropy(std::string anisotropyArg);
};
#endif // MAIN_FE_INCLUDE_SEM_PROXY_H_
#endif // FUNTIDES_MAIN_FE_INCLUDE_SEM_PROXY_H_
5 changes: 5 additions & 0 deletions src/main/fe/include/sem_proxy_options.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef FUNTIDES_MAIN_FE_INCLUDE_SEM_PROXY_OPTIONS_H_
#define FUNTIDES_MAIN_FE_INCLUDE_SEM_PROXY_OPTIONS_H_

#pragma once

#include <cxxopts.hpp>
Expand Down Expand Up @@ -88,3 +91,5 @@ class SemProxyOptions
cxxopts::value<std::string>(o.anisotropy));
}
};

#endif // FUNTIDES_MAIN_FE_INCLUDE_SEM_PROXY_OPTIONS_H_
8 changes: 3 additions & 5 deletions src/model/grid/include/fd_boundary.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
* @file fd_boundary.h
* @brief Absorbing boundary layer management
*/
#ifndef SRC_MODEL_GRID_INCLUDE_FDTD_BOUNDARY_H_
#define SRC_MODEL_GRID_INCLUDE_FDTD_BOUNDARY_H_

#ifndef FUNTIDES_MODEL_GRID_INCLUDE_FD_BOUNDARY_H_
#define FUNTIDES_MODEL_GRID_INCLUDE_FD_BOUNDARY_H_
namespace model
{
namespace fdgrid
Expand Down Expand Up @@ -121,5 +120,4 @@ class BoundaryLayers

} // namespace fdgrid
} // namespace model

#endif // SRC_MODEL_GRID_INCLUDE_FDTD_BOUNDARY_H_
#endif // FUNTIDES_MODEL_GRID_INCLUDE_FD_BOUNDARY_H_
8 changes: 3 additions & 5 deletions src/model/grid/include/fd_grid_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
* @file fdtd_grid_geometry.h
* @brief Grid geometry and indexing utilities
*/
#ifndef SRC_MODEL_GRID_INCLUDE_FDTD_GRID_GEOMETRY_H_
#define SRC_MODEL_GRID_INCLUDE_FDTD_GRID_GEOMETRY_H_

#ifndef FUNTIDES_MODEL_GRID_INCLUDE_FD_GRID_GEOMETRY_H_
#define FUNTIDES_MODEL_GRID_INCLUDE_FD_GRID_GEOMETRY_H_
#include <fd_options.h>

#include <cstddef>
Expand Down Expand Up @@ -117,5 +116,4 @@ class GridGeometry

} // namespace fdgrid
} // namespace model

#endif // SRC_MODEL_GRID_INCLUDE_FDTD_GRID_GEOMETRY_H_
#endif // FUNTIDES_MODEL_GRID_INCLUDE_FD_GRID_GEOMETRY_H_
8 changes: 3 additions & 5 deletions src/model/grid/include/fd_grids.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
* @file fdtd_grids.h
* @brief FDTD grid facade (backward compatibility wrapper)
*/
#ifndef SRC_MODEL_GRID_INCLUDE_FDTD_GRIDS_H_
#define SRC_MODEL_GRID_INCLUDE_FDTD_GRIDS_H_

#ifndef FUNTIDES_MODEL_GRID_INCLUDE_FD_GRIDS_H_
#define FUNTIDES_MODEL_GRID_INCLUDE_FD_GRIDS_H_
#include <fd_options.h>

#include "fd_boundary.h"
Expand Down Expand Up @@ -162,5 +161,4 @@ class FdtdGrids

} // namespace fdgrid
} // namespace model

#endif // SRC_MODEL_GRID_INCLUDE_FDTD_GRIDS_H_
#endif // FUNTIDES_MODEL_GRID_INCLUDE_FD_GRIDS_H_
8 changes: 3 additions & 5 deletions src/model/grid/include/fd_model_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
* @file fdtd_model_io.h
* @brief Model file I/O operations
*/
#ifndef SRC_MODEL_GRID_INCLUDE_FDTD_MODEL_IO_H_
#define SRC_MODEL_GRID_INCLUDE_FDTD_MODEL_IO_H_

#ifndef FUNTIDES_MODEL_GRID_INCLUDE_FD_MODEL_IO_H_
#define FUNTIDES_MODEL_GRID_INCLUDE_FD_MODEL_IO_H_
#include <fstream>
#include <stdexcept>
#include <string>
Expand Down Expand Up @@ -253,5 +252,4 @@ class ModelIO

} // namespace fdgrid
} // namespace model

#endif // SRC_MODEL_GRID_INCLUDE_FDTD_MODEL_IO_H_
#endif // FUNTIDES_MODEL_GRID_INCLUDE_FD_MODEL_IO_H_
8 changes: 3 additions & 5 deletions src/model/grid/include/fd_velocity_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
* @file fdtd_velocity_model.h
* @brief Velocity model storage and initialization
*/
#ifndef SRC_MODEL_GRID_INCLUDE_FDTD_VELOCITY_MODEL_H_
#define SRC_MODEL_GRID_INCLUDE_FDTD_VELOCITY_MODEL_H_

#ifndef FUNTIDES_MODEL_GRID_INCLUDE_FD_VELOCITY_MODEL_H_
#define FUNTIDES_MODEL_GRID_INCLUDE_FD_VELOCITY_MODEL_H_
#include <data_type.h>
#include <fd_options.h>

Expand Down Expand Up @@ -127,5 +126,4 @@ class VelocityModel

} // namespace fdgrid
} // namespace model

#endif // SRC_MODEL_GRID_INCLUDE_FDTD_VELOCITY_MODEL_H_
#endif // FUNTIDES_MODEL_GRID_INCLUDE_FD_VELOCITY_MODEL_H_
5 changes: 5 additions & 0 deletions src/model/mesh/api/include/builder.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef FUNTIDES_MODEL_MESH_API_INCLUDE_BUILDER_H_
#define FUNTIDES_MODEL_MESH_API_INCLUDE_BUILDER_H_

#pragma once

#include <model.h>
Expand All @@ -19,3 +22,5 @@ class ModelBuilderBase
const = 0;
};
} // namespace model

#endif // FUNTIDES_MODEL_MESH_API_INCLUDE_BUILDER_H_
8 changes: 3 additions & 5 deletions src/model/mesh/api/include/face_connectivity.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef SRC_MODEL_MESH_API_FACE_CONNECTIVITY_H_
#define SRC_MODEL_MESH_API_FACE_CONNECTIVITY_H_

#ifndef FUNTIDES_MODEL_MESH_API_INCLUDE_FACE_CONNECTIVITY_H_
#define FUNTIDES_MODEL_MESH_API_INCLUDE_FACE_CONNECTIVITY_H_
#include "model.h"

namespace model
Expand Down Expand Up @@ -83,5 +82,4 @@ class FaceConnectivityApi
};

} // namespace model

#endif // SRC_MODEL_MESH_API_FACE_CONNECTIVITY_H_
#endif // FUNTIDES_MODEL_MESH_API_INCLUDE_FACE_CONNECTIVITY_H_
7 changes: 3 additions & 4 deletions src/model/mesh/api/include/model.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef SRC_MODEL_MODELAPI_INCLUDE_MODEL_API_H_
#define SRC_MODEL_MODELAPI_INCLUDE_MODEL_API_H_

#ifndef FUNTIDES_MODEL_MESH_API_INCLUDE_MODEL_H_
#define FUNTIDES_MODEL_MESH_API_INCLUDE_MODEL_H_
#include "data_type.h"
#include "parallel_topology.h"
#include "sem_macros.h"
Expand Down Expand Up @@ -394,4 +393,4 @@ class ModelApi
};

} // namespace model
#endif // SRC_MODEL_MODELAPI_INCLUDE_MODEL_API_H_
#endif // FUNTIDES_MODEL_MESH_API_INCLUDE_MODEL_H_
8 changes: 3 additions & 5 deletions src/model/mesh/api/include/partitioning.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef SRC_MODEL_MESH_API_INCLUDE_PARTITIONING_H_
#define SRC_MODEL_MESH_API_INCLUDE_PARTITIONING_H_

#ifndef FUNTIDES_MODEL_MESH_API_INCLUDE_PARTITIONING_H_
#define FUNTIDES_MODEL_MESH_API_INCLUDE_PARTITIONING_H_
#include "cartesian_params.h"

namespace model
Expand Down Expand Up @@ -45,5 +44,4 @@ class PartitioningStrategy
};

} // namespace model

#endif // SRC_MODEL_MESH_API_INCLUDE_PARTITIONING_H_
#endif // FUNTIDES_MODEL_MESH_API_INCLUDE_PARTITIONING_H_
Loading
Loading