From 274c4e0d6f1c09d072298211d1dde326d230993a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Dagand?= Date: Tue, 5 May 2026 09:47:48 +0200 Subject: [PATCH] Move sources to new src directory --- CMakeLists.txt | 47 +------------------ Doxyfile | 2 +- ci-tests/full_test.py | 4 +- src/CMakeLists.txt | 44 +++++++++++++++++ {algebra => src/algebra}/algebra.h | 0 {algebra => src/algebra}/algebraCore.h | 0 {algebra => src/algebra}/bicg.h | 0 {algebra => src/algebra}/cg.h | 0 {algebra => src/algebra}/iter.h | 0 {algebra => src/algebra}/sparseMat.h | 2 +- chronometer.cpp => src/chronometer.cpp | 0 chronometer.h => src/chronometer.h | 0 config.h.in => src/config.h.in | 0 .../default-settings.yml | 0 .../electrostatSolver.cpp | 0 .../electrostatSolver.h | 0 element.h => src/element.h | 0 energy.cpp => src/energy.cpp | 0 .../expression_parser.cpp | 0 .../expression_parser.h | 0 facette.cpp => src/facette.cpp | 0 facette.h => src/facette.h | 0 fem.h => src/fem.h | 0 fmm_demag.h => src/fmm_demag.h | 0 linear_algebra.cpp => src/linear_algebra.cpp | 0 linear_algebra.h => src/linear_algebra.h | 0 log-stats.h => src/log-stats.h | 0 main.cpp => src/main.cpp | 0 mesh.cpp => src/mesh.cpp | 0 mesh.h => src/mesh.h | 0 meshUtils.h => src/meshUtils.h | 0 node.h => src/node.h | 0 read.cpp => src/read.cpp | 0 recentering.cpp => src/recentering.cpp | 0 save.cpp => src/save.cpp | 0 settings.cpp => src/settings.cpp | 0 settings.h => src/settings.h | 0 solver.cpp => src/solver.cpp | 0 solver.h => src/solver.h | 0 .../spinAccumulationSolver.cpp | 0 .../spinAccumulationSolver.h | 0 tags.cpp => src/tags.cpp | 0 tags.h => src/tags.h | 0 tetra.cpp => src/tetra.cpp | 0 tetra.h => src/tetra.h | 0 .../time_integration.cpp | 0 time_integration.h => src/time_integration.h | 0 unit-tests/CMakeLists.txt | 22 ++++----- unit-tests/sparse_matrix.h | 2 +- unit-tests/ut_algebra.cpp | 6 +-- 50 files changed, 65 insertions(+), 64 deletions(-) create mode 100644 src/CMakeLists.txt rename {algebra => src/algebra}/algebra.h (100%) rename {algebra => src/algebra}/algebraCore.h (100%) rename {algebra => src/algebra}/bicg.h (100%) rename {algebra => src/algebra}/cg.h (100%) rename {algebra => src/algebra}/iter.h (100%) rename {algebra => src/algebra}/sparseMat.h (99%) rename chronometer.cpp => src/chronometer.cpp (100%) rename chronometer.h => src/chronometer.h (100%) rename config.h.in => src/config.h.in (100%) rename default-settings.yml => src/default-settings.yml (100%) rename electrostatSolver.cpp => src/electrostatSolver.cpp (100%) rename electrostatSolver.h => src/electrostatSolver.h (100%) rename element.h => src/element.h (100%) rename energy.cpp => src/energy.cpp (100%) rename expression_parser.cpp => src/expression_parser.cpp (100%) rename expression_parser.h => src/expression_parser.h (100%) rename facette.cpp => src/facette.cpp (100%) rename facette.h => src/facette.h (100%) rename fem.h => src/fem.h (100%) rename fmm_demag.h => src/fmm_demag.h (100%) rename linear_algebra.cpp => src/linear_algebra.cpp (100%) rename linear_algebra.h => src/linear_algebra.h (100%) rename log-stats.h => src/log-stats.h (100%) rename main.cpp => src/main.cpp (100%) rename mesh.cpp => src/mesh.cpp (100%) rename mesh.h => src/mesh.h (100%) rename meshUtils.h => src/meshUtils.h (100%) rename node.h => src/node.h (100%) rename read.cpp => src/read.cpp (100%) rename recentering.cpp => src/recentering.cpp (100%) rename save.cpp => src/save.cpp (100%) rename settings.cpp => src/settings.cpp (100%) rename settings.h => src/settings.h (100%) rename solver.cpp => src/solver.cpp (100%) rename solver.h => src/solver.h (100%) rename spinAccumulationSolver.cpp => src/spinAccumulationSolver.cpp (100%) rename spinAccumulationSolver.h => src/spinAccumulationSolver.h (100%) rename tags.cpp => src/tags.cpp (100%) rename tags.h => src/tags.h (100%) rename tetra.cpp => src/tetra.cpp (100%) rename tetra.h => src/tetra.h (100%) rename time_integration.cpp => src/time_integration.cpp (100%) rename time_integration.h => src/time_integration.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccf89080..cf315bd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,50 +109,7 @@ if(${ENABLE_LTO}) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) endif() -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fopenmp") - -SET(HEADERS config.h node.h expression_parser.h mesh.h electrostatSolver.h - spinAccumulationSolver.h time_integration.h settings.h tetra.h - facette.h linear_algebra.h log-stats.h tags.h chronometer.h element.h) - -SET(SOURCES settings.cpp time_integration.cpp solver.cpp electrostatSolver.cpp - spinAccumulationSolver.cpp read.cpp save.cpp linear_algebra.cpp recentering.cpp tetra.cpp - energy.cpp facette.cpp expression_parser.cpp chronometer.cpp - tags.cpp mesh.cpp) - -configure_file(config.h.in ./config.h) - -add_custom_command( - OUTPUT default-settings.o - COMMAND ld -r -b binary -z noexecstack default-settings.yml -o default-settings.o - DEPENDS default-settings.yml) - -#=========================================================================== -# Compiler options -#=========================================================================== -# -ffast-math -msse4.2 -mfpmath=sse (on X86 -mfpmath=sse set by default) or -mavx -# -fsanitize=address leak null undefined # both compiler and linker -#=========================================================================== - -include_directories (${CMAKE_SOURCE_DIR} ${GMSH_INC}) - -ADD_EXECUTABLE(feellgood main.cpp ${HEADERS} ${SOURCES} default-settings.o) -target_compile_options( feellgood PUBLIC -Wall -Wextra -O3 -march=native ${MKL_CFLAGS} ) -target_compile_definitions(feellgood PUBLIC - -DNDEBUG -DTBB_SUPPRESS_DEPRECATED_MESSAGES ${EIGEN_MKL_CFLAGS} ) - -if (MKL_FOUND) - #option --no-as-needed for mkl, see - # https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html - target_link_options(feellgood PUBLIC "-Wl,--no-as-needed" ) - # not sure we really need it since --no-as-needed is default value, though there might be - # a --as-needed before - TARGET_LINK_LIBRARIES(feellgood yaml-cpp duktape ann OpenMP::OpenMP_CXX ${TBB_LINK} - Eigen3::Eigen ${MKL_TARGET} ${GMSH_LIB}) -else() - TARGET_LINK_LIBRARIES(feellgood yaml-cpp duktape ann OpenMP::OpenMP_CXX ${TBB_LINK} - Eigen3::Eigen ${GMSH_LIB}) -endif() +add_subdirectory(src) #=========================================================================== # Find where to install the Python modules. @@ -226,7 +183,7 @@ else() endif() if(${ENABLE_UTESTS}) - configure_file(./unit-tests/ut_config.h.in ./unit-tests/ut_config.h) + configure_file(unit-tests/ut_config.h.in unit-tests/ut_config.h) include(CTest) add_subdirectory(unit-tests) endif() diff --git a/Doxyfile b/Doxyfile index 92400a91..da3354ce 100644 --- a/Doxyfile +++ b/Doxyfile @@ -765,7 +765,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = . algebra +INPUT = . src src/algebra # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/ci-tests/full_test.py b/ci-tests/full_test.py index 0cf9ef0d..f30601ec 100755 --- a/ci-tests/full_test.py +++ b/ci-tests/full_test.py @@ -43,7 +43,7 @@ def distance_R3(v1, v2): } # Expected outcome. It depends on whether feeLLGood was compiled in ONE_GAUSS_POINT mode. -val = subprocess.check_output(["../feellgood","--version"]) +val = subprocess.check_output(["../src/feellgood","--version"]) if b'ONE_GAUSS_POINT=ON' in val: expected = { "m": [0.307432, 0.476202, -0.823843], "E_tot": -4.446980e-19 } else: @@ -51,7 +51,7 @@ def distance_R3(v1, v2): # Run the simulation. sys.stdout.flush() -val = subprocess.run(["../feellgood", "--seed", "2", "-"], input=json.dumps(settings), text=True) +val = subprocess.run(["../src/feellgood", "--seed", "2", "-"], input=json.dumps(settings), text=True) #(devNote) to avoid -fsanitize=leak ASLR bug, we turn off address randomizer #val = subprocess.run(["setarch", "--addr-no-randomize", "../feellgood", "--seed", "2", "-"], diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..977cb045 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,44 @@ +SET(HEADERS config.h node.h expression_parser.h mesh.h electrostatSolver.h + spinAccumulationSolver.h time_integration.h settings.h tetra.h + facette.h linear_algebra.h log-stats.h tags.h chronometer.h element.h) + +SET(SOURCES settings.cpp time_integration.cpp solver.cpp electrostatSolver.cpp + spinAccumulationSolver.cpp read.cpp save.cpp linear_algebra.cpp recentering.cpp tetra.cpp + energy.cpp facette.cpp expression_parser.cpp chronometer.cpp + tags.cpp mesh.cpp) + +configure_file(config.h.in ./config.h) + +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fopenmp") + +add_custom_command( + OUTPUT default-settings.o + COMMAND ld -r -b binary -z noexecstack default-settings.yml -o default-settings.o + DEPENDS default-settings.yml) + +#=========================================================================== +# Compiler options +#=========================================================================== +# -ffast-math -msse4.2 -mfpmath=sse (on X86 -mfpmath=sse set by default) or -mavx +# -fsanitize=address leak null undefined # both compiler and linker +#=========================================================================== + +include_directories (${CMAKE_SOURCE_DIR} ${GMSH_INC}) + +ADD_EXECUTABLE(feellgood main.cpp ${HEADERS} ${SOURCES} default-settings.o) +target_compile_options( feellgood PUBLIC -Wall -Wextra -O3 -march=native ${MKL_CFLAGS} ) +target_compile_definitions(feellgood PUBLIC + -DNDEBUG -DTBB_SUPPRESS_DEPRECATED_MESSAGES ${EIGEN_MKL_CFLAGS} ) + +if (MKL_FOUND) + #option --no-as-needed for mkl, see + # https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html + target_link_options(feellgood PUBLIC "-Wl,--no-as-needed" ) + # not sure we really need it since --no-as-needed is default value, though there might be + # a --as-needed before + TARGET_LINK_LIBRARIES(feellgood yaml-cpp duktape ann OpenMP::OpenMP_CXX ${TBB_LINK} + Eigen3::Eigen ${MKL_TARGET} ${GMSH_LIB}) +else() + TARGET_LINK_LIBRARIES(feellgood yaml-cpp duktape ann OpenMP::OpenMP_CXX ${TBB_LINK} + Eigen3::Eigen ${GMSH_LIB}) +endif() diff --git a/algebra/algebra.h b/src/algebra/algebra.h similarity index 100% rename from algebra/algebra.h rename to src/algebra/algebra.h diff --git a/algebra/algebraCore.h b/src/algebra/algebraCore.h similarity index 100% rename from algebra/algebraCore.h rename to src/algebra/algebraCore.h diff --git a/algebra/bicg.h b/src/algebra/bicg.h similarity index 100% rename from algebra/bicg.h rename to src/algebra/bicg.h diff --git a/algebra/cg.h b/src/algebra/cg.h similarity index 100% rename from algebra/cg.h rename to src/algebra/cg.h diff --git a/algebra/iter.h b/src/algebra/iter.h similarity index 100% rename from algebra/iter.h rename to src/algebra/iter.h diff --git a/algebra/sparseMat.h b/src/algebra/sparseMat.h similarity index 99% rename from algebra/sparseMat.h rename to src/algebra/sparseMat.h index f68eedab..04630b00 100644 --- a/algebra/sparseMat.h +++ b/src/algebra/sparseMat.h @@ -25,7 +25,7 @@ reconstructing the matrix from scratch. #include #include -#include "config.h" +#include "../config.h" #include "algebraCore.h" namespace algebra diff --git a/chronometer.cpp b/src/chronometer.cpp similarity index 100% rename from chronometer.cpp rename to src/chronometer.cpp diff --git a/chronometer.h b/src/chronometer.h similarity index 100% rename from chronometer.h rename to src/chronometer.h diff --git a/config.h.in b/src/config.h.in similarity index 100% rename from config.h.in rename to src/config.h.in diff --git a/default-settings.yml b/src/default-settings.yml similarity index 100% rename from default-settings.yml rename to src/default-settings.yml diff --git a/electrostatSolver.cpp b/src/electrostatSolver.cpp similarity index 100% rename from electrostatSolver.cpp rename to src/electrostatSolver.cpp diff --git a/electrostatSolver.h b/src/electrostatSolver.h similarity index 100% rename from electrostatSolver.h rename to src/electrostatSolver.h diff --git a/element.h b/src/element.h similarity index 100% rename from element.h rename to src/element.h diff --git a/energy.cpp b/src/energy.cpp similarity index 100% rename from energy.cpp rename to src/energy.cpp diff --git a/expression_parser.cpp b/src/expression_parser.cpp similarity index 100% rename from expression_parser.cpp rename to src/expression_parser.cpp diff --git a/expression_parser.h b/src/expression_parser.h similarity index 100% rename from expression_parser.h rename to src/expression_parser.h diff --git a/facette.cpp b/src/facette.cpp similarity index 100% rename from facette.cpp rename to src/facette.cpp diff --git a/facette.h b/src/facette.h similarity index 100% rename from facette.h rename to src/facette.h diff --git a/fem.h b/src/fem.h similarity index 100% rename from fem.h rename to src/fem.h diff --git a/fmm_demag.h b/src/fmm_demag.h similarity index 100% rename from fmm_demag.h rename to src/fmm_demag.h diff --git a/linear_algebra.cpp b/src/linear_algebra.cpp similarity index 100% rename from linear_algebra.cpp rename to src/linear_algebra.cpp diff --git a/linear_algebra.h b/src/linear_algebra.h similarity index 100% rename from linear_algebra.h rename to src/linear_algebra.h diff --git a/log-stats.h b/src/log-stats.h similarity index 100% rename from log-stats.h rename to src/log-stats.h diff --git a/main.cpp b/src/main.cpp similarity index 100% rename from main.cpp rename to src/main.cpp diff --git a/mesh.cpp b/src/mesh.cpp similarity index 100% rename from mesh.cpp rename to src/mesh.cpp diff --git a/mesh.h b/src/mesh.h similarity index 100% rename from mesh.h rename to src/mesh.h diff --git a/meshUtils.h b/src/meshUtils.h similarity index 100% rename from meshUtils.h rename to src/meshUtils.h diff --git a/node.h b/src/node.h similarity index 100% rename from node.h rename to src/node.h diff --git a/read.cpp b/src/read.cpp similarity index 100% rename from read.cpp rename to src/read.cpp diff --git a/recentering.cpp b/src/recentering.cpp similarity index 100% rename from recentering.cpp rename to src/recentering.cpp diff --git a/save.cpp b/src/save.cpp similarity index 100% rename from save.cpp rename to src/save.cpp diff --git a/settings.cpp b/src/settings.cpp similarity index 100% rename from settings.cpp rename to src/settings.cpp diff --git a/settings.h b/src/settings.h similarity index 100% rename from settings.h rename to src/settings.h diff --git a/solver.cpp b/src/solver.cpp similarity index 100% rename from solver.cpp rename to src/solver.cpp diff --git a/solver.h b/src/solver.h similarity index 100% rename from solver.h rename to src/solver.h diff --git a/spinAccumulationSolver.cpp b/src/spinAccumulationSolver.cpp similarity index 100% rename from spinAccumulationSolver.cpp rename to src/spinAccumulationSolver.cpp diff --git a/spinAccumulationSolver.h b/src/spinAccumulationSolver.h similarity index 100% rename from spinAccumulationSolver.h rename to src/spinAccumulationSolver.h diff --git a/tags.cpp b/src/tags.cpp similarity index 100% rename from tags.cpp rename to src/tags.cpp diff --git a/tags.h b/src/tags.h similarity index 100% rename from tags.h rename to src/tags.h diff --git a/tetra.cpp b/src/tetra.cpp similarity index 100% rename from tetra.cpp rename to src/tetra.cpp diff --git a/tetra.h b/src/tetra.h similarity index 100% rename from tetra.h rename to src/tetra.h diff --git a/time_integration.cpp b/src/time_integration.cpp similarity index 100% rename from time_integration.cpp rename to src/time_integration.cpp diff --git a/time_integration.h b/src/time_integration.h similarity index 100% rename from time_integration.h rename to src/time_integration.h diff --git a/unit-tests/CMakeLists.txt b/unit-tests/CMakeLists.txt index 5fd389b9..b6a09933 100644 --- a/unit-tests/CMakeLists.txt +++ b/unit-tests/CMakeLists.txt @@ -16,7 +16,7 @@ if(NOT GMSH_INC) message(FATAL_ERROR "Could not find gmsh.h") endif() -include_directories (${CMAKE_SOURCE_DIR} ${Boost_INCLUDE_DIRS} ${GMSH_INC}) +include_directories (${CMAKE_SOURCE_DIR}/src ${Boost_INCLUDE_DIRS} ${GMSH_INC}) set( BOOST_TEST_LOG_LEVEL "all" ) @@ -32,39 +32,39 @@ add_executable (test_ut_algebra ut_algebra.cpp) add_executable (test_ut_OMP_solver ut_OMP_solver.cpp) -add_executable(test_ut_dukTapeParser ../expression_parser.cpp ut_dukTapeParser.cpp) +add_executable(test_ut_dukTapeParser ../src/expression_parser.cpp ut_dukTapeParser.cpp) add_executable (test_ut_node ut_node.cpp) add_executable (test_ut_index ut_index.cpp) -SET(SOURCES ../facette.cpp ../tetra.cpp ut_element.cpp) +SET(SOURCES ../src/facette.cpp ../src/tetra.cpp ut_element.cpp) add_executable (test_ut_element ${SOURCES}) -SET(SOURCES ../facette.cpp ut_facette.cpp) +SET(SOURCES ../src/facette.cpp ut_facette.cpp) add_executable (test_ut_facette ${SOURCES}) -SET(SOURCES ../facette.cpp ut_fac_charges.cpp) +SET(SOURCES ../src/facette.cpp ut_fac_charges.cpp) add_executable (test_ut_fac_charges ${SOURCES}) -SET(SOURCES ../tetra.cpp ut_tetra.cpp) +SET(SOURCES ../src/tetra.cpp ut_tetra.cpp) add_executable (test_ut_tetra ${SOURCES}) -SET(SOURCES ../tetra.cpp ut_tet_lumping.cpp) +SET(SOURCES ../src/tetra.cpp ut_tet_lumping.cpp) add_executable (test_ut_tet_lumping ${SOURCES}) -SET(SOURCES ../tetra.cpp ut_tet_charges.cpp) +SET(SOURCES ../src/tetra.cpp ut_tet_charges.cpp) add_executable (test_ut_tet_charges ${SOURCES}) -SET(SOURCES ../tetra.cpp ut_energy.cpp ../facette.cpp) +SET(SOURCES ../src/tetra.cpp ut_energy.cpp ../src/facette.cpp) add_executable (test_ut_energy ${SOURCES}) -SET(SOURCES ../tetra.cpp ut_anisotropy.cpp) +SET(SOURCES ../src/tetra.cpp ut_anisotropy.cpp) add_executable (test_ut_anisotropy ${SOURCES}) add_executable (test_ut_tiny ut_tiny.cpp) -set(SOURCES ../tetra.cpp ut_time_int.cpp) +set(SOURCES ../src/tetra.cpp ut_time_int.cpp) add_executable (test_ut_time_int ${SOURCES}) add_executable (test_ut_log-stats ut_log-stats.cpp) diff --git a/unit-tests/sparse_matrix.h b/unit-tests/sparse_matrix.h index 10a4603b..517e89d7 100644 --- a/unit-tests/sparse_matrix.h +++ b/unit-tests/sparse_matrix.h @@ -7,7 +7,7 @@ #include -#include "../algebra/sparseMat.h" +#include "algebra/sparseMat.h" using algebra::SparseMatrix; using algebra::MatrixShape; diff --git a/unit-tests/ut_algebra.cpp b/unit-tests/ut_algebra.cpp index de70f57e..6bbefe14 100644 --- a/unit-tests/ut_algebra.cpp +++ b/unit-tests/ut_algebra.cpp @@ -7,9 +7,9 @@ #include "ut_config.h" // for tolerance UT_TOL macro #include "sparse_matrix.h" -#include "../algebra/algebra.h" -#include "../algebra/cg.h" -#include "../algebra/bicg.h" +#include "algebra/algebra.h" +#include "algebra/cg.h" +#include "algebra/bicg.h" using namespace algebra;