From 711a17c2b789beb0a38a00811717f3c7a0f441c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= Date: Thu, 4 May 2023 16:18:51 +0200 Subject: [PATCH 1/2] core: Use consistent types in Lees-Edwards code --- src/core/io/writer/h5md_core.cpp | 6 ++-- src/core/lees_edwards/LeesEdwardsBC.hpp | 5 ++-- .../lees_edwards/LeesEdwards.hpp | 28 ++++++++++--------- src/utils/include/utils/Vector.hpp | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/core/io/writer/h5md_core.cpp b/src/core/io/writer/h5md_core.cpp index 1aec1030a39..73a83366dcd 100644 --- a/src/core/io/writer/h5md_core.cpp +++ b/src/core/io/writer/h5md_core.cpp @@ -338,16 +338,18 @@ static void write_le_off(LeesEdwardsBC const &lebc, h5xx::dataset &dataset) { } static void write_le_dir(LeesEdwardsBC const &lebc, h5xx::dataset &dataset) { + auto const shear_direction = static_cast(lebc.shear_direction); auto const extents = static_cast(dataset).extents(); extend_dataset(dataset, Vector2hs{1, 0}); - h5xx::write_dataset(dataset, Utils::Vector{lebc.shear_direction}, + h5xx::write_dataset(dataset, Utils::Vector{shear_direction}, h5xx::slice(Vector2hs{extents[0], 0}, Vector2hs{1, 1})); } static void write_le_normal(LeesEdwardsBC const &lebc, h5xx::dataset &dataset) { + auto const shear_plane_normal = static_cast(lebc.shear_plane_normal); auto const extents = static_cast(dataset).extents(); extend_dataset(dataset, Vector2hs{1, 0}); - h5xx::write_dataset(dataset, Utils::Vector{lebc.shear_plane_normal}, + h5xx::write_dataset(dataset, Utils::Vector{shear_plane_normal}, h5xx::slice(Vector2hs{extents[0], 0}, Vector2hs{1, 1})); } diff --git a/src/core/lees_edwards/LeesEdwardsBC.hpp b/src/core/lees_edwards/LeesEdwardsBC.hpp index 2b450fd5074..916eb31e491 100644 --- a/src/core/lees_edwards/LeesEdwardsBC.hpp +++ b/src/core/lees_edwards/LeesEdwardsBC.hpp @@ -26,10 +26,11 @@ #include struct LeesEdwardsBC { + static auto constexpr invalid_dir = 3u; double pos_offset = 0.; double shear_velocity = 0.; - int shear_direction = -1; - int shear_plane_normal = -1; + unsigned int shear_direction = invalid_dir; + unsigned int shear_plane_normal = invalid_dir; Utils::Vector3d distance(Utils::Vector3d const &d, Utils::Vector3d const &l, Utils::Vector3d const &hal_l, Utils::Vector3d const &l_inv, diff --git a/src/script_interface/lees_edwards/LeesEdwards.hpp b/src/script_interface/lees_edwards/LeesEdwards.hpp index 76a1688dade..01bf9b3f96f 100644 --- a/src/script_interface/lees_edwards/LeesEdwards.hpp +++ b/src/script_interface/lees_edwards/LeesEdwards.hpp @@ -22,6 +22,7 @@ #include "Protocol.hpp" #include "core/grid.hpp" +#include "core/lees_edwards/LeesEdwardsBC.hpp" #include "core/lees_edwards/lees_edwards.hpp" #include "script_interface/ScriptInterface.hpp" @@ -35,7 +36,7 @@ namespace LeesEdwards { class LeesEdwards : public AutoParameters { std::shared_ptr m_protocol; - LeesEdwardsBC const &m_lebc = box_geo.lees_edwards_bc(); + LeesEdwardsBC const &m_lebc = ::box_geo.lees_edwards_bc(); public: LeesEdwards() : m_protocol{nullptr} { @@ -44,13 +45,14 @@ class LeesEdwards : public AutoParameters { [this](Variant const &value) { if (is_none(value)) { m_protocol = nullptr; - box_geo.set_lees_edwards_bc(LeesEdwardsBC{0., 0., -1, -1}); + ::box_geo.set_lees_edwards_bc(LeesEdwardsBC{}); ::LeesEdwards::unset_protocol(); return; } context()->parallel_try_catch([this]() { - if (m_lebc.shear_direction == -1 or - m_lebc.shear_plane_normal == -1) { + auto constexpr invalid_dir = LeesEdwardsBC::invalid_dir; + if (m_lebc.shear_direction == invalid_dir or + m_lebc.shear_plane_normal == invalid_dir) { throw std::runtime_error( "Parameters 'shear_plane_normal' and 'shear_direction' " "must be initialized together with 'protocol' on first " @@ -94,7 +96,7 @@ class LeesEdwards : public AutoParameters { "'shear_plane_normal' must differ"); } // update box geometry and cell structure - box_geo.set_lees_edwards_bc( + ::box_geo.set_lees_edwards_bc( LeesEdwardsBC{0., 0., shear_direction, shear_plane_normal}); ::LeesEdwards::set_protocol(m_protocol->protocol()); }); @@ -109,28 +111,28 @@ class LeesEdwards : public AutoParameters { } private: - int get_shear_axis(VariantMap const ¶ms, std::string name) { + unsigned int get_shear_axis(VariantMap const ¶ms, std::string name) { auto const value = get_value(params, name); if (value == "x") { - return 0; + return 0u; } if (value == "y") { - return 1; + return 1u; } if (value == "z") { - return 2; + return 2u; } throw std::invalid_argument("Parameter '" + name + "' is invalid"); } - Variant get_shear_name(int axis) { - if (axis == 0) { + Variant get_shear_name(unsigned int axis) { + if (axis == 0u) { return {std::string("x")}; } - if (axis == 1) { + if (axis == 1u) { return {std::string("y")}; } - if (axis == 2) { + if (axis == 2u) { return {std::string("z")}; } return {none}; diff --git a/src/utils/include/utils/Vector.hpp b/src/utils/include/utils/Vector.hpp index 5ddd0f1cc43..9f12e6d7a05 100644 --- a/src/utils/include/utils/Vector.hpp +++ b/src/utils/include/utils/Vector.hpp @@ -448,7 +448,7 @@ auto hadamard_division(T const &a, U const &b) { return a / b; } -template Vector unit_vector(int i) { +template Vector unit_vector(unsigned int i) { if (i == 0) return {T{1}, T{0}, T{0}}; if (i == 1) From 47b95a014d6f55d846ae00e39b4b880f8ac61302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= Date: Thu, 4 May 2023 16:20:47 +0200 Subject: [PATCH 2/2] DevOps: Bump version requirements Require CMake 3.20. Use new ScaFaCoS build. Handle known Doxygen bug. On the espressomd/espresso repository, only write a CI cache file on push from the main branch. --- .github/workflows/push_pull.yml | 10 +++++----- .gitlab-ci.yml | 4 ++-- CMakeLists.txt | 5 ++--- cmake/FindClangTidy.cmake | 2 +- cmake/FindCython.cmake | 5 +++-- maintainer/CI/dox_warnings.py | 3 +++ 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/push_pull.yml b/.github/workflows/push_pull.yml index 53e8673c393..9044cd67cce 100644 --- a/.github/workflows/push_pull.yml +++ b/.github/workflows/push_pull.yml @@ -18,7 +18,7 @@ jobs: uses: hendrikmuhs/ccache-action@v1.2 with: key: macos - save: ${{ ! startsWith(github.ref, 'refs/pull') }} + save: ${{ github.ref == 'refs/heads/python' }} - name: Setup Python environment uses: actions/setup-python@v4.3.1 with: @@ -35,7 +35,7 @@ jobs: debian: runs-on: ubuntu-latest container: - image: ghcr.io/espressomd/docker/debian:f6cf74049a2521b2b5580d23d42c8290c5f7611e-base-layer + image: ghcr.io/espressomd/docker/debian:fbdf2f2f9d76b761c0aa1308f17fb17e38501850-base-layer credentials: username: ${{ github.actor }} password: ${{ secrets.github_token }} @@ -47,7 +47,7 @@ jobs: uses: hendrikmuhs/ccache-action@v1.2 with: key: debian - save: ${{ ! startsWith(github.ref, 'refs/pull') }} + save: ${{ github.ref == 'refs/heads/python' || ( github.repository != 'espressomd/espresso' && ! startsWith(github.ref, 'refs/pull') ) }} - name: Setup Git environment run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Get runner specifications @@ -74,7 +74,7 @@ jobs: runs-on: ubuntu-latest if: ${{ github.repository == 'espressomd/espresso' }} container: - image: ghcr.io/espressomd/docker/ubuntu-wo-dependencies:f6cf74049a2521b2b5580d23d42c8290c5f7611e-base-layer + image: ghcr.io/espressomd/docker/ubuntu-wo-dependencies:fbdf2f2f9d76b761c0aa1308f17fb17e38501850-base-layer credentials: username: ${{ github.actor }} password: ${{ secrets.github_token }} @@ -86,7 +86,7 @@ jobs: uses: hendrikmuhs/ccache-action@v1.2 with: key: ubuntu - save: ${{ ! startsWith(github.ref, 'refs/pull') }} + save: ${{ github.ref == 'refs/heads/python' }} - name: Setup Git environment run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Get runner specifications diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 82e34d3c135..4217ff87b07 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: ghcr.io/espressomd/docker/ubuntu-22.04:cb0a2886ebd6a4fbd372503d7b46fc05fb1da5d5 +image: ghcr.io/espressomd/docker/ubuntu-22.04:fbdf2f2f9d76b761c0aa1308f17fb17e38501850 stages: - prepare @@ -139,7 +139,7 @@ no_rotation: fedora:36: <<: *global_job_definition stage: build - image: ghcr.io/espressomd/docker/fedora:3fd42369f84239b8c4f5d77067d404789c55ff44 + image: ghcr.io/espressomd/docker/fedora:fbdf2f2f9d76b761c0aa1308f17fb17e38501850 variables: with_cuda: 'false' with_gsl: 'false' diff --git a/CMakeLists.txt b/CMakeLists.txt index cab20603aff..70c01263d12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ # along with this program. If not, see . # -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) message(STATUS "CMake version: ${CMAKE_VERSION}") if(POLICY CMP0076) # make target_sources() convert relative paths to absolute @@ -234,8 +234,7 @@ endif() # Python interpreter and Cython interface library if(ESPRESSO_BUILD_WITH_PYTHON) find_package(Python 3.9 REQUIRED COMPONENTS Interpreter Development NumPy) - # use version range 0.29.21...<3.0.0 in CMake 3.19 - find_package(Cython 0.29.21 REQUIRED) + find_package(Cython 0.29.21...<3.0 REQUIRED) find_program(IPYTHON_EXECUTABLE NAMES jupyter ipython3 ipython) endif() diff --git a/cmake/FindClangTidy.cmake b/cmake/FindClangTidy.cmake index 39b48f96c87..a4ce027764c 100644 --- a/cmake/FindClangTidy.cmake +++ b/cmake/FindClangTidy.cmake @@ -44,5 +44,5 @@ if(CLANG_TIDY_EXE) endif() include( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( ClangTidy REQUIRED_VARS CLANG_TIDY_EXE +find_package_handle_standard_args( ClangTidy REQUIRED_VARS CLANG_TIDY_EXE VERSION_VAR CLANG_TIDY_VERSION) diff --git a/cmake/FindCython.cmake b/cmake/FindCython.cmake index 894c3b392fc..f0373c6217e 100644 --- a/cmake/FindCython.cmake +++ b/cmake/FindCython.cmake @@ -79,7 +79,8 @@ if(CYTHON_EXECUTABLE) endif() include(FindPackageHandleStandardArgs) -# add HANDLE_VERSION_RANGE in CMake 3.19 -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cython REQUIRED_VARS CYTHON_EXECUTABLE VERSION_VAR CYTHON_VERSION) +find_package_handle_standard_args( + Cython REQUIRED_VARS CYTHON_EXECUTABLE VERSION_VAR CYTHON_VERSION + HANDLE_VERSION_RANGE) mark_as_advanced(CYTHON_EXECUTABLE) diff --git a/maintainer/CI/dox_warnings.py b/maintainer/CI/dox_warnings.py index 7b4d02aa61e..6a26b44c0f8 100644 --- a/maintainer/CI/dox_warnings.py +++ b/maintainer/CI/dox_warnings.py @@ -70,6 +70,9 @@ if re.search('^no uniquely matching class member found for $', warning): # known bug, not fixed yet continue + if re.search('^no matching (class|file) member found for $', warning): + # known bug, not fixed yet + continue if re.search( '^The following parameters? of .+ (is|are) not documented:$', warning): # non-critical warning, enforcing it would encourage bad behavior, i.e.