From 8db71598243914fdab76dbae93d520ecea967e07 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Wed, 29 Jul 2026 08:23:28 +0200 Subject: [PATCH 01/44] ci: add first version clangd-tidy checks --- .clang-tidy | 587 +++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 62 ++++ .vscode/tasks.json | 63 ++++ scripts/clang_tidy.sh | 35 +++ 4 files changed, 747 insertions(+) create mode 100644 .clang-tidy create mode 100644 .github/workflows/lint.yml create mode 100644 .vscode/tasks.json create mode 100755 scripts/clang_tidy.sh diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..f057bea9e --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,587 @@ +--- +Checks: + ' + abseil-cleanup-ctad + ' +WarningsAsErrors: '' +HeaderFileExtensions: + - h + - hh + - hpp + - hxx + - tpp +ImplementationFileExtensions: + - c + - cc + - cpp + - tpp + - cxx +HeaderFilterRegex: '.*/PQ/src/.*' +SystemHeaders: false +FormatStyle: google +# CheckOptions: +# - key: llvmlibc-restrict-system-libc-headers.Includes +# value: 'cstdint' + +# ### allow short variable names +# - key: readability-identifier-length.IgnoredParameterNames +# value: '^(id|it|db|x|y|z|tx)$' +# - key: readability-identifier-length.IgnoredVariableNames +# value: '^(id|it|db|x|y|z|tx)$' + +# ### special member functions +# - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor +# value: true +# - key: hicpp-special-member-functions.AllowSoleDefaultDtor +# value: true + +# ### short line statements +# - key: readability-braces-around-statements.ShortStatementLines +# value: 4 +# - key: google-readability-braces-around-statements.ShortStatementLines +# value: 4 +# - key: hicpp-braces-around-statements.ShortStatementLines +# value: 4 + +# ### necessary for POD-structs! +# - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic +# value: true +... + +### TO BE INCLUDED IN THE FUTURE +# abseil-duration-addition, + # abseil-duration-comparison, + # abseil-duration-conversion-cast, + # abseil-duration-division, + # abseil-duration-factory-float, + # abseil-duration-factory-scale, + # abseil-duration-subtraction, + # abseil-duration-unnecessary-conversion, + # abseil-faster-strsplit-delimiter, + # abseil-no-internal-dependencies, + # abseil-no-namespace, + # abseil-redundant-strcat-calls, + # abseil-str-cat-append, + # abseil-string-find-startswith, + # abseil-string-find-str-contains, + # abseil-time-comparison, + # abseil-time-subtraction, + # abseil-upgrade-duration-conversions, + # altera-id-dependent-backward-branch, + # altera-kernel-name-restriction, + # altera-single-work-item-barrier, + # altera-struct-pack-align, + # altera-unroll-loops, + # android-cloexec-accept, + # android-cloexec-accept4, + # android-cloexec-creat, + # android-cloexec-dup, + # android-cloexec-epoll-create, + # android-cloexec-epoll-create1, + # android-cloexec-fopen, + # android-cloexec-inotify-init, + # android-cloexec-inotify-init1, + # android-cloexec-memfd-create, + # android-cloexec-open, + # android-cloexec-pipe, + # android-cloexec-pipe2, + # android-cloexec-socket, + # android-comparison-in-temp-failure-retry, + # boost-use-to-string, + # bugprone-argument-comment, + # bugprone-assert-side-effect, + # bugprone-assignment-in-if-condition, + # bugprone-bad-signal-to-kill-thread, + # bugprone-bool-pointer-implicit-conversion, + # bugprone-branch-clone, + # bugprone-casting-through-void, + # bugprone-chained-comparison, + # bugprone-compare-pointer-to-member-virtual-function, + # bugprone-copy-constructor-init, + # bugprone-dangling-handle, + # bugprone-dynamic-static-initializers, + # bugprone-easily-swappable-parameters, + # bugprone-empty-catch, + # bugprone-exception-escape, + # bugprone-fold-init-type, + # bugprone-forward-declaration-namespace, + # bugprone-forwarding-reference-overload, + # bugprone-implicit-widening-of-multiplication-result, + # bugprone-inaccurate-erase, + # bugprone-inc-dec-in-conditions, + # bugprone-incorrect-enable-if, + # bugprone-incorrect-roundings, + # bugprone-infinite-loop, + # bugprone-integer-division, + # bugprone-lambda-function-name, + # bugprone-macro-parentheses, + # bugprone-macro-repeated-side-effects, + # bugprone-misplaced-operator-in-strlen-in-alloc, + # bugprone-misplaced-pointer-arithmetic-in-alloc, + # bugprone-misplaced-widening-cast, + # bugprone-move-forwarding-reference, + # bugprone-multi-level-implicit-pointer-conversion, + # bugprone-multiple-new-in-one-expression, + # bugprone-multiple-statement-macro, + # bugprone-narrowing-conversions, + # bugprone-no-escape, + # bugprone-non-zero-enum-to-bool-conversion, + # bugprone-not-null-terminated-result, + # bugprone-optional-value-conversion, + # bugprone-parent-virtual-call, + # bugprone-posix-return, + # bugprone-redundant-branch-condition, + # bugprone-reserved-identifier, + # bugprone-shared-ptr-array-mismatch, + # bugprone-signal-handler, + # bugprone-signed-char-misuse, + # bugprone-sizeof-container, + # bugprone-sizeof-expression, + # bugprone-spuriously-wake-up-functions, + # bugprone-standalone-empty, + # bugprone-string-constructor, + # bugprone-string-integer-assignment, + # bugprone-string-literal-with-embedded-nul, + # bugprone-stringview-nullptr, + # bugprone-suspicious-enum-usage, + # bugprone-suspicious-include, + # bugprone-suspicious-memory-comparison, + # bugprone-suspicious-memset-usage, + # bugprone-suspicious-missing-comma, + # bugprone-suspicious-realloc-usage, + # bugprone-suspicious-semicolon, + # bugprone-suspicious-string-compare, + # bugprone-swapped-arguments, + # bugprone-switch-missing-default-case, + # bugprone-terminating-continue, + # bugprone-throw-keyword-missing, + # bugprone-too-small-loop-variable, + # bugprone-unchecked-optional-access, + # bugprone-undefined-memory-manipulation, + # bugprone-undelegated-constructor, + # bugprone-unhandled-exception-at-new, + # bugprone-unhandled-self-assignment, + # bugprone-unique-ptr-array-mismatch, + # bugprone-unsafe-functions, + # bugprone-unused-local-non-trivial-variable, + # bugprone-unused-raii, + # bugprone-unused-return-value, + # bugprone-use-after-move, + # bugprone-virtual-near-miss, + # cert-con36-c, + # cert-con54-cpp, + # cert-dcl03-c, + # cert-dcl16-c, + # cert-dcl21-cpp, + # cert-dcl37-c, + # cert-dcl50-cpp, + # cert-dcl51-cpp, + # cert-dcl54-cpp, + # cert-dcl58-cpp, + # cert-dcl59-cpp, + # cert-env33-c, + # cert-err09-cpp, + # cert-err33-c, + # cert-err34-c, + # cert-err52-cpp, + # cert-err58-cpp, + # cert-err60-cpp, + # cert-err61-cpp, + # cert-exp42-c, + # cert-fio38-c, + # cert-flp30-c, + # cert-flp37-c, + # cert-mem57-cpp, + # cert-msc24-c, + # cert-msc30-c, + # cert-msc32-c, + # cert-msc33-c, + # cert-msc50-cpp, + # cert-msc51-cpp, + # cert-msc54-cpp, + # cert-oop11-cpp, + # cert-oop54-cpp, + # cert-oop57-cpp, + # cert-oop58-cpp, + # cert-pos44-c, + # cert-pos47-c, + # cert-sig30-c, + # cert-str34-c, + # clang-analyzer-apiModeling.Errno, + # clang-analyzer-apiModeling.TrustNonnull, + # clang-analyzer-apiModeling.TrustReturnsNonnull, + # clang-analyzer-apiModeling.google.GTest, + # clang-analyzer-apiModeling.llvm.CastValue, + # clang-analyzer-apiModeling.llvm.ReturnValue, + # clang-analyzer-core.BitwiseShift, + # clang-analyzer-core.CallAndMessage, + # clang-analyzer-core.CallAndMessageModeling, + # clang-analyzer-core.DivideZero, + # clang-analyzer-core.DynamicTypePropagation, + # clang-analyzer-core.NonNullParamChecker, + # clang-analyzer-core.NonnilStringConstants, + # clang-analyzer-core.NullDereference, + # clang-analyzer-core.StackAddrEscapeBase, + # clang-analyzer-core.StackAddressEscape, + # clang-analyzer-core.UndefinedBinaryOperatorResult, + # clang-analyzer-core.VLASize, + # clang-analyzer-core.builtin.BuiltinFunctions, + # clang-analyzer-core.builtin.NoReturnFunctions, + # clang-analyzer-core.uninitialized.ArraySubscript, + # clang-analyzer-core.uninitialized.Assign, + # clang-analyzer-core.uninitialized.Branch, + # clang-analyzer-core.uninitialized.CapturedBlockVariable, + # clang-analyzer-core.uninitialized.NewArraySize, + # clang-analyzer-core.uninitialized.UndefReturn, + # clang-analyzer-cplusplus.InnerPointer, + # clang-analyzer-cplusplus.Move, + # clang-analyzer-cplusplus.NewDelete, + # clang-analyzer-cplusplus.NewDeleteLeaks, + # clang-analyzer-cplusplus.PlacementNew, + # clang-analyzer-cplusplus.PureVirtualCall, + # clang-analyzer-cplusplus.SelfAssignment, + # clang-analyzer-cplusplus.SmartPtrModeling, + # clang-analyzer-cplusplus.StringChecker, + # clang-analyzer-cplusplus.VirtualCallModeling, + # clang-analyzer-deadcode.DeadStores, + # clang-analyzer-fuchsia.HandleChecker, + # clang-analyzer-nullability.NullPassedToNonnull, + # clang-analyzer-nullability.NullReturnedFromNonnull, + # clang-analyzer-nullability.NullabilityBase, + # clang-analyzer-nullability.NullableDereferenced, + # clang-analyzer-nullability.NullablePassedToNonnull, + # clang-analyzer-nullability.NullableReturnedFromNonnull, + # clang-analyzer-optin.core.EnumCastOutOfRange, + # clang-analyzer-optin.cplusplus.UninitializedObject, + # clang-analyzer-optin.cplusplus.VirtualCall, + # clang-analyzer-optin.mpi.MPI-Checker, + # clang-analyzer-optin.osx.OSObjectCStyleCast, + # clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker, + # clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker, + # clang-analyzer-optin.performance.GCDAntipattern, + # clang-analyzer-optin.performance.Padding, + # clang-analyzer-optin.portability.UnixAPI, + # clang-analyzer-osx.API, + # clang-analyzer-osx.MIG, + # clang-analyzer-osx.NSOrCFErrorDerefChecker, + # clang-analyzer-osx.NumberObjectConversion, + # clang-analyzer-osx.OSObjectRetainCount, + # clang-analyzer-osx.ObjCProperty, + # clang-analyzer-osx.SecKeychainAPI, + # clang-analyzer-osx.cocoa.AtSync, + # clang-analyzer-osx.cocoa.AutoreleaseWrite, + # clang-analyzer-osx.cocoa.ClassRelease, + # clang-analyzer-osx.cocoa.Dealloc, + # clang-analyzer-osx.cocoa.IncompatibleMethodTypes, + # clang-analyzer-osx.cocoa.Loops, + # clang-analyzer-osx.cocoa.MissingSuperCall, + # clang-analyzer-osx.cocoa.NSAutoreleasePool, + # clang-analyzer-osx.cocoa.NSError, + # clang-analyzer-osx.cocoa.NilArg, + # clang-analyzer-osx.cocoa.NonNilReturnValue, + # clang-analyzer-osx.cocoa.ObjCGenerics, + # clang-analyzer-osx.cocoa.RetainCount, + # clang-analyzer-osx.cocoa.RetainCountBase, + # clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak, + # clang-analyzer-osx.cocoa.SelfInit, + # clang-analyzer-osx.cocoa.SuperDealloc, + # clang-analyzer-osx.cocoa.UnusedIvars, + # clang-analyzer-osx.cocoa.VariadicMethodTypes, + # clang-analyzer-osx.coreFoundation.CFError, + # clang-analyzer-osx.coreFoundation.CFNumber, + # clang-analyzer-osx.coreFoundation.CFRetainRelease, + # clang-analyzer-osx.coreFoundation.containers.OutOfBounds, + # clang-analyzer-osx.coreFoundation.containers.PointerSizedValues, + # clang-analyzer-security.FloatLoopCounter, + # clang-analyzer-security.cert.env.InvalidPtr, + # clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, + # clang-analyzer-security.insecureAPI.SecuritySyntaxChecker, + # clang-analyzer-security.insecureAPI.UncheckedReturn, + # clang-analyzer-security.insecureAPI.bcmp, + # clang-analyzer-security.insecureAPI.bcopy, + # clang-analyzer-security.insecureAPI.bzero, + # clang-analyzer-security.insecureAPI.decodeValueOfObjCType, + # clang-analyzer-security.insecureAPI.getpw, + # clang-analyzer-security.insecureAPI.gets, + # clang-analyzer-security.insecureAPI.mkstemp, + # clang-analyzer-security.insecureAPI.mktemp, + # clang-analyzer-security.insecureAPI.rand, + # clang-analyzer-security.insecureAPI.strcpy, + # clang-analyzer-security.insecureAPI.vfork, + # clang-analyzer-unix.API, + # clang-analyzer-unix.DynamicMemoryModeling, + # clang-analyzer-unix.Errno, + # clang-analyzer-unix.Malloc, + # clang-analyzer-unix.MallocSizeof, + # clang-analyzer-unix.MismatchedDeallocator, + # clang-analyzer-unix.StdCLibraryFunctions, + # clang-analyzer-unix.Vfork, + # clang-analyzer-unix.cstring.BadSizeArg, + # clang-analyzer-unix.cstring.CStringModeling, + # clang-analyzer-unix.cstring.NullArg, + # clang-analyzer-valist.CopyToSelf, + # clang-analyzer-valist.Uninitialized, + # clang-analyzer-valist.Unterminated, + # clang-analyzer-valist.ValistBase, + # clang-analyzer-webkit.NoUncountedMemberChecker, + # clang-analyzer-webkit.RefCntblBaseVirtualDtor, + # clang-analyzer-webkit.UncountedLambdaCapturesChecker, + # concurrency-mt-unsafe, + # concurrency-thread-canceltype-asynchronous, + # cppcoreguidelines-avoid-c-arrays, + # cppcoreguidelines-avoid-capturing-lambda-coroutines, + # cppcoreguidelines-avoid-const-or-ref-data-members, + # cppcoreguidelines-avoid-do-while, + # cppcoreguidelines-avoid-goto, + # cppcoreguidelines-avoid-magic-numbers, + # cppcoreguidelines-avoid-non-const-global-variables, + # cppcoreguidelines-avoid-reference-coroutine-parameters, + # cppcoreguidelines-c-copy-assignment-signature, + # cppcoreguidelines-explicit-virtual-functions, + # cppcoreguidelines-init-variables, + # cppcoreguidelines-interfaces-global-init, + # cppcoreguidelines-macro-to-enum, + # cppcoreguidelines-macro-usage, + # cppcoreguidelines-misleading-capture-default-by-value, + # cppcoreguidelines-missing-std-forward, + # cppcoreguidelines-narrowing-conversions, + # cppcoreguidelines-no-malloc, + # cppcoreguidelines-no-suspend-with-lock, + # cppcoreguidelines-noexcept-destructor, + # cppcoreguidelines-noexcept-move-operations, + # cppcoreguidelines-noexcept-swap, + # cppcoreguidelines-non-private-member-variables-in-classes, + # cppcoreguidelines-owning-memory, + # cppcoreguidelines-prefer-member-initializer, + # cppcoreguidelines-pro-bounds-array-to-pointer-decay, + # cppcoreguidelines-pro-bounds-constant-array-index, + # cppcoreguidelines-pro-bounds-pointer-arithmetic, + # cppcoreguidelines-pro-type-const-cast, + # cppcoreguidelines-pro-type-cstyle-cast, + # cppcoreguidelines-pro-type-member-init, + # cppcoreguidelines-pro-type-reinterpret-cast, + # cppcoreguidelines-pro-type-static-cast-downcast, + # cppcoreguidelines-pro-type-union-access, + # cppcoreguidelines-pro-type-vararg, + # cppcoreguidelines-rvalue-reference-param-not-moved, + # cppcoreguidelines-slicing, + # cppcoreguidelines-special-member-functions, + # cppcoreguidelines-use-default-member-init, + # cppcoreguidelines-virtual-class-destructor, + # darwin-avoid-spinlock, + # darwin-dispatch-once-nonstatic, + # fuchsia-default-arguments-calls, + # fuchsia-default-arguments-declarations, + # fuchsia-header-anon-namespaces, + # fuchsia-multiple-inheritance, + # fuchsia-overloaded-operator, + # fuchsia-statically-constructed-objects, + # fuchsia-trailing-return, + # fuchsia-virtual-inheritance, + # google-build-explicit-make-pair, + # google-build-namespaces, + # google-build-using-namespace, + # google-default-arguments, + # google-explicit-constructor, + # google-global-names-in-headers, + # google-objc-avoid-nsobject-new, + # google-objc-avoid-throwing-exception, + # google-objc-function-naming, + # google-objc-global-variable-declaration, + # google-readability-avoid-underscore-in-googletest-name, + # google-readability-braces-around-statements, + # google-readability-casting, + # google-readability-function-size, + # google-readability-namespace-comments, + # google-readability-todo, + # google-runtime-int, + # google-runtime-operator, + # google-upgrade-googletest-case, + # hicpp-avoid-c-arrays, + # hicpp-avoid-goto, + # hicpp-braces-around-statements, + # hicpp-deprecated-headers, + # hicpp-exception-baseclass, + # hicpp-explicit-conversions, + # hicpp-function-size, + # hicpp-ignored-remove-result, + # hicpp-invalid-access-moved, + # hicpp-member-init, + # hicpp-move-const-arg, + # hicpp-multiway-paths-covered, + # hicpp-named-parameter, + # hicpp-new-delete-operators, + # hicpp-no-array-decay, + # hicpp-no-assembler, + # hicpp-no-malloc, + # hicpp-noexcept-move, + # hicpp-signed-bitwise, + # hicpp-special-member-functions, + # hicpp-static-assert, + # hicpp-undelegated-constructor, + # hicpp-uppercase-literal-suffix, + # hicpp-use-auto, + # hicpp-use-emplace, + # hicpp-use-equals-default, + # hicpp-use-equals-delete, + # hicpp-use-noexcept, + # hicpp-use-nullptr, + # hicpp-use-override, + # hicpp-vararg, + # linuxkernel-must-check-errs, + # llvm-else-after-return, + # llvm-header-guard, + # llvm-include-order, + # llvm-namespace-comment, + # llvm-prefer-isa-or-dyn-cast-in-conditionals, + # llvm-prefer-register-over-unsigned, + # llvm-qualified-auto, + # llvm-twine-local, + # llvmlibc-callee-namespace, + # llvmlibc-implementation-in-namespace, + # llvmlibc-inline-function-decl, + # llvmlibc-restrict-system-libc-headers, + # misc-confusable-identifiers, + # misc-const-correctness, + # misc-coroutine-hostile-raii, + # misc-definitions-in-headers, + # misc-header-include-cycle, + # misc-include-cleaner, + # misc-misleading-bidirectional, + # misc-misleading-identifier, + # misc-misplaced-const, + # misc-new-delete-overloads, + # misc-no-recursion, + # misc-non-copyable-objects, + # misc-non-private-member-variables-in-classes, + # misc-redundant-expression, + # misc-static-assert, + # misc-throw-by-value-catch-by-reference, + # misc-unconventional-assign-operator, + # misc-uniqueptr-reset-release, + # misc-unused-alias-decls, + # misc-unused-parameters, + # misc-unused-using-decls, + # misc-use-anonymous-namespace, + # modernize-avoid-bind, + # modernize-avoid-c-arrays, + # modernize-concat-nested-namespaces, + # modernize-deprecated-headers, + # modernize-deprecated-ios-base-aliases, + # modernize-loop-convert, + # modernize-macro-to-enum, + # modernize-make-shared, + # modernize-make-unique, + # modernize-pass-by-value, + # modernize-raw-string-literal, + # modernize-redundant-void-arg, + # modernize-replace-auto-ptr, + # modernize-replace-disallow-copy-and-assign-macro, + # modernize-replace-random-shuffle, + # modernize-return-braced-init-list, + # modernize-shrink-to-fit, + # modernize-type-traits, + # modernize-unary-static-assert, + # modernize-use-auto, + # modernize-use-bool-literals, + # modernize-use-constraints, + # modernize-use-default-member-init, + # modernize-use-emplace, + # modernize-use-equals-default, + # modernize-use-equals-delete, + # modernize-use-nodiscard, + # modernize-use-noexcept, + # modernize-use-nullptr, + # modernize-use-override, + # modernize-use-starts-ends-with, + # modernize-use-std-numbers, + # modernize-use-std-print, + # modernize-use-trailing-return-type, + # modernize-use-transparent-functors, + # modernize-use-uncaught-exceptions, + # modernize-use-using, + # mpi-buffer-deref, + # mpi-type-mismatch, + # objc-assert-equals, + # objc-avoid-nserror-init, + # objc-dealloc-in-category, + # objc-forbidden-subclassing, + # objc-missing-hash, + # objc-nsdate-formatter, + # objc-nsinvocation-argument-lifetime, + # objc-property-declaration, + # objc-super-self, + # openmp-exception-escape, + # openmp-use-default-none, + # performance-avoid-endl, + # performance-enum-size, + # performance-faster-string-find, + # performance-for-range-copy, + # performance-implicit-conversion-in-loop, + # performance-inefficient-algorithm, + # performance-inefficient-string-concatenation, + # performance-inefficient-vector-operation, + # performance-move-const-arg, + # performance-move-constructor-init, + # performance-no-automatic-move, + # performance-no-int-to-ptr, + # performance-noexcept-destructor, + # performance-noexcept-move-constructor, + # performance-noexcept-swap, + # performance-trivially-destructible, + # performance-type-promotion-in-math-fn, + # performance-unnecessary-copy-initialization, + # performance-unnecessary-value-param, + # portability-restrict-system-includes, + # portability-simd-intrinsics, + # portability-std-allocator-const, + # readability-avoid-const-params-in-decls, + # readability-avoid-nested-conditional-operator, + # readability-avoid-return-with-void-value, + # readability-avoid-unconditional-preprocessor-if, + # readability-braces-around-statements, + # readability-const-return-type, + # readability-container-contains, + # readability-container-data-pointer, + # readability-container-size-empty, + # readability-convert-member-functions-to-static, + # readability-delete-null-pointer, + # readability-duplicate-include, + # readability-else-after-return, + # readability-function-cognitive-complexity, + # readability-function-size, + # readability-identifier-length, + # readability-identifier-naming, + # readability-implicit-bool-conversion, + # readability-inconsistent-declaration-parameter-name, + # readability-isolate-declaration, + # readability-magic-numbers, + # readability-make-member-function-const, + # readability-misleading-indentation, + # readability-misplaced-array-index, + # readability-named-parameter, + # readability-non-const-parameter, + # readability-operators-representation, + # readability-qualified-auto, + # readability-redundant-access-specifiers, + # readability-redundant-casting, + # readability-redundant-control-flow, + # readability-redundant-declaration, + # readability-redundant-function-ptr-dereference, + # readability-redundant-inline-specifier, + # readability-redundant-member-init, + # readability-redundant-preprocessor, + # readability-redundant-smartptr-get, + # readability-redundant-string-cstr, + # readability-redundant-string-init, + # readability-reference-to-constructed-temporary, + # readability-simplify-boolean-expr, + # readability-simplify-subscript-expr, + # readability-static-accessed-through-instance, + # readability-static-definition-in-anonymous-namespace, + # readability-string-compare, + # readability-suspicious-call-argument, + # readability-uniqueptr-delete-release, + # readability-uppercase-literal-suffix, + # readability-use-anyofallof, + # zircon-temporary-objects, \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..dc2e51cca --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,62 @@ +name: LINT + +on: + pull_request: + branches: + - '*' + paths: + - '.github/workflows/ci_lint.yml' + - '.cmake/**' + - 'apps/**' + - 'include/**' + - 'src/**' + - 'CMakeLists.txt' + push: + branches: + - dev + - main + paths: + - '.github/workflows/ci_lint.yml' + - '.cmake/**' + - 'apps/**' + - 'include/**' + - 'src/**' + - 'CMakeLists.txt' + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + + - name: Install build tools + run: | + sudo apt update + sudo apt install -y gcc-13 g++-13 mold ninja-build clangd-20 + sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-20 100 + shell: bash + + - name: Setup python + uses: actions/setup-python@v3 + with: + python-version: '3.12' + + - name: Install clangd-tidy + run: python -m pip install clangd-tidy + shell: bash + + - name: Configure (generate compile_commands.json) + run: | + cmake -S . -B build -G Ninja \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DBUILD_WITH_NATIVE=Off + env: + CC: gcc-13 + CXX: g++-13 + + - name: Run clangd-tidy + run: | + clangd-tidy $(find src/ apps/ include/ -name "*.cpp" ! -name "moc_*.cpp" 2>/dev/null) -p=build \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..b354ccf9b --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,63 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "clangd-tidy (changed)", + "type": "shell", + "command": "bash", + "args": [ + "-c", + "scripts/clang_tidy.sh" + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [ + { + "owner": "clangd-tidy", + "fileLocation": [ + "absolute" + ], + "pattern": { + "regexp": "^(.*?):(\\d+):(\\d+):\\s*(warning|error|note):\\s*(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + } + ], + "group": "build" + }, + { + "label": "clangd-tidy (all)", + "type": "shell", + "command": "bash", + "args": [ + "-c", + "scripts/clang_tidy.sh --all" + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [ + { + "owner": "clangd-tidy", + "fileLocation": [ + "absolute" + ], + "pattern": { + "regexp": "^(.*?):(\\d+):(\\d+):\\s*(warning|error|note):\\s*(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + } + ], + "group": "build" + } + ] +} \ No newline at end of file diff --git a/scripts/clang_tidy.sh b/scripts/clang_tidy.sh new file mode 100755 index 000000000..6831ebb2b --- /dev/null +++ b/scripts/clang_tidy.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -euo pipefail + +# scripts/clangd_tidy.sh +# +# Runs clangd-tidy either on all source files, or only on files changed +# relative to HEAD. +# +# Usage: +# scripts/clangd_tidy.sh # only changed .cpp files +# scripts/clangd_tidy.sh --all # all .cpp files under src/ + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" +BUILD_DIR="${ROOT_DIR}/.build" + +cd "${ROOT_DIR}" + +MODE="changed" +if [[ "${1:-}" == "--all" ]]; then + MODE="all" +fi + +if [[ "${MODE}" == "all" ]]; then + mapfile -t FILES < <(find "${ROOT_DIR}/src" -name '*.cpp' ! -name 'moc_*.cpp') +else + mapfile -t FILES < <(git diff --name-only --diff-filter=ACMR HEAD -- '*.cpp' ':!*moc_*.cpp') +fi + +if [[ ${#FILES[@]} -eq 0 ]]; then + echo "No files to lint." + exit 0 +fi + +clangd-tidy "${FILES[@]}" -p="${BUILD_DIR}" --tqdm From 82bfc6fdedc31c582fedcb3f0e99a63fca491ac0 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Wed, 29 Jul 2026 23:09:44 +0200 Subject: [PATCH 02/44] cleanup: remove unused header --- apps/PQ.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/PQ.cpp b/apps/PQ.cpp index efccffcc9..2aec6011e 100644 --- a/apps/PQ.cpp +++ b/apps/PQ.cpp @@ -20,13 +20,12 @@ ******************************************************************************/ -#include // for EXIT_SUCCESS -#include // for exception -#include // for remove_all -#include // for operator<< -#include // for unique_ptr -#include // for string, char_traits -#include // for vector +#include // for EXIT_SUCCESS +#include // for exception +#include // for operator<< +#include // for unique_ptr +#include // for string, char_traits +#include // for vector #include "commandLineArgs.hpp" // for CommandLineArgs #include "engine.hpp" // for Engine From 976653b2e51395b2480d9e946c934d0494f4dc8a Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Wed, 29 Jul 2026 23:14:14 +0200 Subject: [PATCH 03/44] cleanup: export intrinsic headers in linearAlgebra lib --- include/linearAlgebra/staticMatrix.hpp | 5 +++-- include/linearAlgebra/vector3d.hpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/linearAlgebra/staticMatrix.hpp b/include/linearAlgebra/staticMatrix.hpp index eda4cae7a..ce77346a7 100644 --- a/include/linearAlgebra/staticMatrix.hpp +++ b/include/linearAlgebra/staticMatrix.hpp @@ -24,6 +24,7 @@ #define _STATIC_MATRIX_INTERFACE_HPP_ -#include "staticMatrix/staticMatrix3x3.hpp" // IWYU pragma: export +#include "staticMatrix/staticMatrix3x3.hpp" // IWYU pragma: export +#include "staticMatrix/staticMatrix3x3Class.hpp" // IWYU pragma: export -#endif // _STATIC_MATRIX_INTERFACE_HPP_ \ No newline at end of file +#endif // _STATIC_MATRIX_INTERFACE_HPP_ diff --git a/include/linearAlgebra/vector3d.hpp b/include/linearAlgebra/vector3d.hpp index d3a79f95c..608b31064 100644 --- a/include/linearAlgebra/vector3d.hpp +++ b/include/linearAlgebra/vector3d.hpp @@ -24,6 +24,7 @@ #define _VECTOR3D_INTERFACE_HPP_ -#include "vector3d/vector3d.hpp" // IWYU pragma: export +#include "vector3d/vector3d.hpp" // IWYU pragma: export +#include "vector3d/vector3dClass.hpp" // IWYU pragma: export -#endif // _VECTOR3D_INTERFACE_HPP_ \ No newline at end of file +#endif // _VECTOR3D_INTERFACE_HPP_ From 054157a022d6e1bf1eec6e8768f1b7bdce384070 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 10:37:12 +0200 Subject: [PATCH 04/44] cleanup: final call on dstr is prohibited -- make full class final --- include/opt/optimizer/adam.hpp | 14 +++++++------- include/opt/optimizer/steepestDescent.hpp | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/opt/optimizer/adam.hpp b/include/opt/optimizer/adam.hpp index d5a4b7e2f..1586a9281 100644 --- a/include/opt/optimizer/adam.hpp +++ b/include/opt/optimizer/adam.hpp @@ -34,7 +34,7 @@ namespace opt * @class Adam * */ - class Adam : public Optimizer + class Adam final : public Optimizer { private: constexpr static size_t _maxHistoryLength = 2; @@ -49,14 +49,14 @@ namespace opt explicit Adam(const size_t nEpochs, const size_t nAtoms); explicit Adam(const size_t, const double, const double, const size_t); - Adam() = default; - ~Adam() final = default; + Adam() = default; + ~Adam() = default; - [[nodiscard]] pq::SharedOptimizer clone() const final; - [[nodiscard]] size_t maxHistoryLength() const final; + [[nodiscard]] pq::SharedOptimizer clone() const; + [[nodiscard]] size_t maxHistoryLength() const; - void update(const double learningRate, const size_t step) final; + void update(const double learningRate, const size_t step); }; } // namespace opt -#endif // _ADAM_HPP_ \ No newline at end of file +#endif // _ADAM_HPP_ diff --git a/include/opt/optimizer/steepestDescent.hpp b/include/opt/optimizer/steepestDescent.hpp index 6cdd965f6..505cbe9cf 100644 --- a/include/opt/optimizer/steepestDescent.hpp +++ b/include/opt/optimizer/steepestDescent.hpp @@ -34,7 +34,7 @@ namespace opt * @brief Steepest Descent optimizer * */ - class SteepestDescent : public Optimizer + class SteepestDescent final : public Optimizer { private: constexpr static size_t _maxHistoryLength = 2; @@ -42,15 +42,15 @@ namespace opt public: explicit SteepestDescent(const size_t nEpochs); - SteepestDescent() = default; - ~SteepestDescent() final = default; + SteepestDescent() = default; + ~SteepestDescent() = default; - [[nodiscard]] pq::SharedOptimizer clone() const final; - [[nodiscard]] size_t maxHistoryLength() const final; + [[nodiscard]] pq::SharedOptimizer clone() const; + [[nodiscard]] size_t maxHistoryLength() const; - void update(const double learningRate, const size_t step) final; + void update(const double learningRate, const size_t step); }; } // namespace opt -#endif // _STEEPEST_DESCENT_HPP_ \ No newline at end of file +#endif // _STEEPEST_DESCENT_HPP_ From 2443255b94681c5b2c37e0221287e126ef5d8e8b Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 10:54:16 +0200 Subject: [PATCH 05/44] cleanup: wrap Kokkos-related code in conditional compilation directives --- .../coulomb_kokkos/coulombWolf_kokkos.hpp | 12 ++++++++-- .../nonCoulomb_kokkos/lennardJones_kokkos.hpp | 24 +++++++++++++------ .../simulationBox/simulationBox_kokkos.hpp | 12 ++++++++-- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/include/potential/coulomb_kokkos/coulombWolf_kokkos.hpp b/include/potential/coulomb_kokkos/coulombWolf_kokkos.hpp index cba8d0d80..ace0c79b5 100644 --- a/include/potential/coulomb_kokkos/coulombWolf_kokkos.hpp +++ b/include/potential/coulomb_kokkos/coulombWolf_kokkos.hpp @@ -24,6 +24,8 @@ #define _KOKKOS_COULOMB_WOLF_HPP_ +#ifdef WITH_KOKKOS + #include namespace potential @@ -60,12 +62,18 @@ namespace potential KokkosCoulombWolf() = default; ~KokkosCoulombWolf() = default; - KOKKOS_FUNCTION double calculate(const double, const double, const double, double&) - const; + KOKKOS_FUNCTION double calculate( + const double, + const double, + const double, + double& + ) const; [[nodiscard]] Kokkos::View getCoulombRadiusCutOff() const; }; } // namespace potential +#endif // WITH_KOKKOS + #endif // _KOKKOS_COULOMB_WOLF_HPP_ diff --git a/include/potential/nonCoulomb_kokkos/lennardJones_kokkos.hpp b/include/potential/nonCoulomb_kokkos/lennardJones_kokkos.hpp index 8bb4ddb8f..ea6b3d8fa 100644 --- a/include/potential/nonCoulomb_kokkos/lennardJones_kokkos.hpp +++ b/include/potential/nonCoulomb_kokkos/lennardJones_kokkos.hpp @@ -24,6 +24,8 @@ #define _KOKKOS_LENNARD_JONES_PAIR_HPP_ +#ifdef WITH_KOKKOS + #include #include "typeAliases.hpp" @@ -73,13 +75,21 @@ namespace potential [[nodiscard]] Kokkos::DualView &getC12(); [[nodiscard]] double getC12(const size_t i, const size_t j) const; - KOKKOS_FUNCTION double getRadialCutoff(const size_t, const size_t) - const; - [[nodiscard]] double getEnergyCutoff(const size_t i, const size_t j) - const; - [[nodiscard]] double getForceCutoff(const size_t i, const size_t j) - const; + KOKKOS_FUNCTION double getRadialCutoff( + const size_t, + const size_t + ) const; + [[nodiscard]] double getEnergyCutoff( + const size_t i, + const size_t j + ) const; + [[nodiscard]] double getForceCutoff( + const size_t i, + const size_t j + ) const; }; } // namespace potential -#endif // _KOKKOS_LENNARD_JONES_PAIR_HPP_ \ No newline at end of file +#endif // WITH_KOKKOS + +#endif // _KOKKOS_LENNARD_JONES_PAIR_HPP_ diff --git a/include/simulationBox/simulationBox_kokkos.hpp b/include/simulationBox/simulationBox_kokkos.hpp index a59a8026c..73f535b6c 100644 --- a/include/simulationBox/simulationBox_kokkos.hpp +++ b/include/simulationBox/simulationBox_kokkos.hpp @@ -24,6 +24,8 @@ #define _KOKKOS_SIMULATION_BOX_HPP_ +#ifdef WITH_KOKKOS + #include #include "typeAliases.hpp" @@ -61,7 +63,11 @@ namespace simulationBox KokkosSimulationBox() = default; ~KokkosSimulationBox() = default; - KOKKOS_FUNCTION static void calcShiftVector(const double*, Kokkos::View, double*); + KOKKOS_FUNCTION static void calcShiftVector( + const double*, + Kokkos::View, + double* + ); void initKokkosSimulationBox(pq::SimBox& simBox); void initForces(); @@ -103,4 +109,6 @@ namespace simulationBox }; } // namespace simulationBox -#endif // _KOKKOS_SIMULATION_BOX_HPP_ \ No newline at end of file +#endif // WITH_KOKKOS + +#endif // _KOKKOS_SIMULATION_BOX_HPP_ From dc5805a6a0ef2a46b62ae3858dd9a131a4e418c7 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 10:55:21 +0200 Subject: [PATCH 06/44] cleanup: another kokkos PP cleanup --- src/engine/engine_kokkos.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/engine_kokkos.cpp b/src/engine/engine_kokkos.cpp index d36de02e8..4a9a02f18 100644 --- a/src/engine/engine_kokkos.cpp +++ b/src/engine/engine_kokkos.cpp @@ -20,14 +20,14 @@ ******************************************************************************/ +#ifdef WITH_KOKKOS + #include "engine.hpp" using namespace engine; using namespace simulationBox; using namespace potential; -#ifdef WITH_KOKKOS - /** * @brief get reference to KokkosSimulationBox * @@ -116,4 +116,4 @@ void Engine::initKokkosCoulombWolf( */ void Engine::initKokkosPotential() { _kokkosPotential = KokkosPotential(); } -#endif \ No newline at end of file +#endif From 41be66fe3620953ca0122ce7aad0437174039d74 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 10:56:45 +0200 Subject: [PATCH 07/44] cleanup: remove some unused headers --- benchmarks/perf/perfBenchSetup.hpp | 25 +++- benchmarks/perf/perfBoxTransforms.cpp | 1 - benchmarks/perf/perfConstraints.cpp | 12 +- benchmarks/perf/perfForceKernel.cpp | 3 +- benchmarks/perf/perfKinetics.cpp | 1 - benchmarks/perf/perfShiftVector.cpp | 2 +- include/integrator/integrator_kokkos.hpp | 85 ------------ src/QM/ase/aseMaceRunner.cpp | 4 +- src/engine/hessianEngine.cpp | 65 +++++----- src/integrator/integrator_kokkos.cpp | 157 ----------------------- 10 files changed, 65 insertions(+), 290 deletions(-) delete mode 100644 include/integrator/integrator_kokkos.hpp delete mode 100644 src/integrator/integrator_kokkos.cpp diff --git a/benchmarks/perf/perfBenchSetup.hpp b/benchmarks/perf/perfBenchSetup.hpp index 1976f7da2..82c3647b4 100644 --- a/benchmarks/perf/perfBenchSetup.hpp +++ b/benchmarks/perf/perfBenchSetup.hpp @@ -37,7 +37,6 @@ #include "matrix.hpp" #include "molecule.hpp" #include "simulationBox.hpp" -#include "vector3d.hpp" namespace potential { @@ -72,7 +71,9 @@ namespace benchSetup 0.25 * d }; atom->setPosition(pos); - atom->setPositionOld(pos); // at-rest start (stable for constraints) + atom->setPositionOld( + pos + ); // at-rest start (stable for constraints) atom->setVelocity({0.01 * (d + 1.0), -0.015, 0.02}); atom->setForce({0.1, -0.2, 0.05}); atom->setShiftForce({0.0, 0.0, 0.0}); @@ -94,11 +95,19 @@ namespace benchSetup { auto nonCoulomb = potential::ForceFieldNonCoulomb(); nonCoulomb.setNonCoulombPairsMatrix( - linearAlgebra::Matrix>(2, 2) + linearAlgebra::Matrix>( + 2, + 2 + ) ); - auto pair = - potential::LennardJonesPair(std::size_t(0), std::size_t(1), 12.0, 2.0, 3.0); + auto pair = potential::LennardJonesPair( + std::size_t(0), + std::size_t(1), + 12.0, + 2.0, + 3.0 + ); nonCoulomb.setNonCoulombPairsMatrix(0, 1, pair); nonCoulomb.setNonCoulombPairsMatrix(1, 0, pair); @@ -118,10 +127,12 @@ namespace benchSetup for (std::size_t m = 0; m < nMolecules; ++m) { - auto molecule = makeMolecule(nAtomsPerMol, 3.0 * static_cast(m)); + auto molecule = + makeMolecule(nAtomsPerMol, 3.0 * static_cast(m)); for (std::size_t i = 0; i < nAtomsPerMol; ++i) - box.addAtom(molecule.getAtoms()[i]); // share the atom pointers + box.addAtom(molecule.getAtoms()[i] + ); // share the atom pointers box.addMolecule(molecule); } diff --git a/benchmarks/perf/perfBoxTransforms.cpp b/benchmarks/perf/perfBoxTransforms.cpp index 7f919dab8..3f5f005a3 100644 --- a/benchmarks/perf/perfBoxTransforms.cpp +++ b/benchmarks/perf/perfBoxTransforms.cpp @@ -33,7 +33,6 @@ #include "orthorhombicBox.hpp" #include "triclinicBox.hpp" -#include "vector3d.hpp" static constexpr long ITERATIONS = 20000; diff --git a/benchmarks/perf/perfConstraints.cpp b/benchmarks/perf/perfConstraints.cpp index ab420a176..f85460395 100644 --- a/benchmarks/perf/perfConstraints.cpp +++ b/benchmarks/perf/perfConstraints.cpp @@ -33,13 +33,11 @@ #define CALLGRIND_ZERO_STATS #endif -#include "perfBenchSetup.hpp" #include "bondConstraint.hpp" #include "constraints.hpp" -#include "molecule.hpp" +#include "perfBenchSetup.hpp" #include "simulationBox.hpp" #include "timingsSettings.hpp" -#include "vector3d.hpp" static constexpr long ITERATIONS = 1000; @@ -59,7 +57,13 @@ int main() for (std::size_t m = 0; m < molecules.size(); ++m) constr.addBondConstraint( - constraints::BondConstraint(&molecules[m], &molecules[m], 0, 1, 0.85) + constraints::BondConstraint( + &molecules[m], + &molecules[m], + 0, + 1, + 0.85 + ) ); constr.calculateConstraintBondRefs(box); diff --git a/benchmarks/perf/perfForceKernel.cpp b/benchmarks/perf/perfForceKernel.cpp index bb5bf140e..d989428c5 100644 --- a/benchmarks/perf/perfForceKernel.cpp +++ b/benchmarks/perf/perfForceKernel.cpp @@ -24,7 +24,6 @@ // (Coulomb + non-Coulomb pair evaluation, the per-pair getNonCoulPair lookup // and force accumulation), so callgrind yields a stable instruction count. -#include #include #ifdef PQ_WITH_CALLGRIND @@ -33,10 +32,10 @@ #define CALLGRIND_ZERO_STATS #endif -#include "perfBenchSetup.hpp" #include "coulombShiftedPotential.hpp" #include "intraNonBondedContainer.hpp" #include "intraNonBondedMap.hpp" +#include "perfBenchSetup.hpp" #include "physicalData.hpp" #include "potentialSettings.hpp" #include "simulationBox.hpp" diff --git a/benchmarks/perf/perfKinetics.cpp b/benchmarks/perf/perfKinetics.cpp index 20128ab76..6697839f8 100644 --- a/benchmarks/perf/perfKinetics.cpp +++ b/benchmarks/perf/perfKinetics.cpp @@ -32,7 +32,6 @@ #endif #include "perfBenchSetup.hpp" -#include "vector3d.hpp" static constexpr long ITERATIONS = 1000; diff --git a/benchmarks/perf/perfShiftVector.cpp b/benchmarks/perf/perfShiftVector.cpp index ff8473178..f28b079eb 100644 --- a/benchmarks/perf/perfShiftVector.cpp +++ b/benchmarks/perf/perfShiftVector.cpp @@ -51,7 +51,7 @@ int main() double sink = 0.0; for (long i = 0; i < ITERATIONS; ++i) { - const double x = (i & 127) * 0.3 - 19.0; + const double x = (i & 127) * 0.3 - 19.0; const linearAlgebra::Vec3D v(x, 0.5 * x, -x); sink += norm(ortho.calcShiftVector(v)); diff --git a/include/integrator/integrator_kokkos.hpp b/include/integrator/integrator_kokkos.hpp deleted file mode 100644 index 3c9898808..000000000 --- a/include/integrator/integrator_kokkos.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/***************************************************************************** - - - PQ - Copyright (C) 2023-now Jakob Gamper - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - - -******************************************************************************/ - -#ifndef _KOKKOS_INTEGRATOR_HPP_ - -#define _KOKKOS_INTEGRATOR_HPP_ - -#include // for DualView - -#include "simulationBox.hpp" // for SimulationBox -#include "simulationBox_kokkos.hpp" // for KokkosSimulationBox -#include "timer.hpp" // for Timer - -namespace integrator -{ - /** - * @class KokkosVelocityVerlet - * - * @brief KokkosVelocityVerlet is a class for the velocity Verlet integrator - * - */ - class KokkosVelocityVerlet : public timings::Timer - { - private: - Kokkos::DualView _dt; - Kokkos::DualView _velocityFactor; - Kokkos::DualView _timeFactor; - - public: - explicit KokkosVelocityVerlet( - const double dt, - const double velocityFactor, - const double timeFactor - ); - - KokkosVelocityVerlet() = default; - ~KokkosVelocityVerlet() = default; - - void firstStep( - simulationBox::SimulationBox &simBox, - simulationBox::KokkosSimulationBox &kokkosSimBox - ); - - void secondStep( - simulationBox::SimulationBox &simBox, - simulationBox::KokkosSimulationBox &kokkosSimBox - ); - - KOKKOS_INLINE_FUNCTION - void integrate_velocities( - double *velocities, - double *forces, - double mass - ) - { - const auto dt = _dt.d_view(); - const auto velocityFactor = _velocityFactor.d_view(); - - velocities[0] += dt * forces[0] / mass * velocityFactor; - velocities[1] += dt * forces[1] / mass * velocityFactor; - velocities[2] += dt * forces[2] / mass * velocityFactor; - } - }; -} // namespace integrator - -#endif // _KOKKOS_INTEGRATOR_HPP_ \ No newline at end of file diff --git a/src/QM/ase/aseMaceRunner.cpp b/src/QM/ase/aseMaceRunner.cpp index cde852239..f0bed9e63 100644 --- a/src/QM/ase/aseMaceRunner.cpp +++ b/src/QM/ase/aseMaceRunner.cpp @@ -22,9 +22,7 @@ #include "aseMaceRunner.hpp" -#include // for fprintf, stderr - -#include "pybind11/embed.h" +#include using QM::AseMaceRunner; diff --git a/src/engine/hessianEngine.cpp b/src/engine/hessianEngine.cpp index 6c319680f..c9b28d0da 100644 --- a/src/engine/hessianEngine.cpp +++ b/src/engine/hessianEngine.cpp @@ -44,10 +44,9 @@ #include "progressbar.hpp" #include "referencesOutput.hpp" #include "settings.hpp" -#include "steepestDescent.hpp" #include "stdoutOutput.hpp" +#include "steepestDescent.hpp" #include "timingsSettings.hpp" -#include "timingsOutput.hpp" using namespace engine; using namespace opt; @@ -66,7 +65,7 @@ void HessianEngine::run() runOptimization(); } - auto builder = setupHessianBuilder(); + auto builder = setupHessianBuilder(); const auto hessian = builder->build(*evaluator, *_simulationBox); @@ -121,7 +120,7 @@ pq::SharedHessianBuilder HessianEngine::setupHessianBuilder() const void HessianEngine::setupOptimization(const pq::SharedEvaluator &evaluator) { - _evaluator = evaluator; + _evaluator = evaluator; _learningRateStrategy = setupLearningRateStrategy(); _optimizer = setupEmptyOptimizer(); @@ -162,10 +161,12 @@ void HessianEngine::runOptimization() } if (!_converged) - throw OptException(std::format( - "Optimizer did not converge after {} epochs.", - _optimizer->getNEpochs() - )); + throw OptException( + std::format( + "Optimizer did not converge after {} epochs.", + _optimizer->getNEpochs() + ) + ); if (_optStopped) { @@ -420,12 +421,14 @@ void HessianEngine::setupMinMaxLearningRate( const auto maxLR = OptimizerSettings::getMaxLearningRate(); if (maxLR.has_value() && minLR >= maxLR.value()) - throw UserInputException(std::format( - "The minimum learning rate {} is greater or equal to the " - "maximum learning rate {}, which is not allowed.", - minLR, - maxLR.value() - )); + throw UserInputException( + std::format( + "The minimum learning rate {} is greater or equal to the " + "maximum learning rate {}, which is not allowed.", + minLR, + maxLR.value() + ) + ); learningRate->setMinLearningRate(minLR); learningRate->setMaxLearningRate(maxLR); @@ -433,18 +436,24 @@ void HessianEngine::setupMinMaxLearningRate( void HessianEngine::writeOptimizationSetupInfo() { - _engineOutput.getLogOutput().writeSetupInfo(std::format( - "Optimize before Hessian: {}", - HessianSettings::optimizeBeforeHessian() ? "true" : "false" - )); - _engineOutput.getLogOutput().writeSetupInfo(std::format( - "Optimizer: {}", - string(OptimizerSettings::getOptimizer()) - )); - _engineOutput.getLogOutput().writeSetupInfo(std::format( - "Learning rate strategy: {}", - string(OptimizerSettings::getLearningRateStrategy()) - )); + _engineOutput.getLogOutput().writeSetupInfo( + std::format( + "Optimize before Hessian: {}", + HessianSettings::optimizeBeforeHessian() ? "true" : "false" + ) + ); + _engineOutput.getLogOutput().writeSetupInfo( + std::format( + "Optimizer: {}", + string(OptimizerSettings::getOptimizer()) + ) + ); + _engineOutput.getLogOutput().writeSetupInfo( + std::format( + "Learning rate strategy: {}", + string(OptimizerSettings::getLearningRateStrategy()) + ) + ); _engineOutput.getLogOutput().writeEmptyLine(); } @@ -453,9 +462,7 @@ void HessianEngine::writeHessian(const pq::HessianMatrix &hessian) const std::ofstream file(HessianSettings::getHessianFile()); if (file.fail()) - throw UserInputException( - "Could not open Hessian file for writing." - ); + throw UserInputException("Could not open Hessian file for writing."); file << std::scientific << std::setprecision(16); diff --git a/src/integrator/integrator_kokkos.cpp b/src/integrator/integrator_kokkos.cpp deleted file mode 100644 index 0c5742885..000000000 --- a/src/integrator/integrator_kokkos.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/***************************************************************************** - - - PQ - Copyright (C) 2023-now Jakob Gamper - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - - -******************************************************************************/ - -#include "integrator_kokkos.hpp" - -using namespace integrator; - -/** - * @brief constructor - * - * @param dt time step - * @param velocityFactor velocity factor - * @param timeFactor time factor - */ -KokkosVelocityVerlet::KokkosVelocityVerlet( - const double dt, - const double velocityFactor, - const double timeFactor -) - : _dt("dt", 1), - _velocityFactor("velocityFactor", 1), - _timeFactor("timeFactor", 1) -{ - _dt.h_view() = dt; - _velocityFactor.h_view() = velocityFactor; - _timeFactor.h_view() = timeFactor; - - Kokkos::deep_copy(_dt.d_view, _dt.h_view); - Kokkos::deep_copy(_velocityFactor.d_view, _velocityFactor.h_view); - Kokkos::deep_copy(_timeFactor.d_view, _timeFactor.h_view); -} - -/** - * @brief first step of the velocity Verlet integrator - * - * @param simBox simulation box - * @param kokkosSimBox Kokkos simulation box - */ -void KokkosVelocityVerlet::firstStep( - simulationBox::SimulationBox &simBox, - simulationBox::KokkosSimulationBox &kokkosSimBox -) -{ - startTimingsSection("Velocity Verlet - first step"); - - kokkosSimBox.transferPositionsFromSimulationBox(simBox); - kokkosSimBox.transferForcesFromSimulationBox(simBox); - kokkosSimBox.transferVelocitiesFromSimulationBox(simBox); - kokkosSimBox.transferBoxDimensionsFromSimulationBox(simBox); - - auto velocities = kokkosSimBox.getVelocities().d_view; - auto forces = kokkosSimBox.getForces().d_view; - auto masses = kokkosSimBox.getMasses().d_view; - auto positions = kokkosSimBox.getPositions().d_view; - const auto boxDimensions = kokkosSimBox.getBoxDimensions().d_view; - - const auto dt = _dt.d_view; - const auto timeFactor = _timeFactor.d_view; - const auto velocityFactor = _velocityFactor.d_view; - - Kokkos::parallel_for( - simBox.getNumberOfAtoms(), - KOKKOS_LAMBDA(const size_t i) { - double pos[3] = {positions(i, 0), positions(i, 1), positions(i, 2)}; - - // integrate_velocities(&velocities(i, 0), &forces(i, 0), - // masses(i)); - - for (size_t j = 0; j < 3; ++j) - { - velocities(i, j) += - forces(i, j) / masses(i) * dt() * velocityFactor(); - - pos[j] += dt() * velocities(i, j) * timeFactor(); - } - - double txyz[3] = {0.0, 0.0, 0.0}; - - simulationBox::KokkosSimulationBox::calcShiftVector( - pos, - boxDimensions, - txyz - ); - - for (size_t j = 0; j < 3; ++j) - { - positions(i, j) += pos[j] + txyz[j]; - } - } - ); // TODO: calculate new center of mass - - kokkosSimBox.transferVelocitiesToSimulationBox(simBox); - kokkosSimBox.transferPositionsToSimulationBox(simBox); - - stopTimingsSection("Velocity Verlet - first step"); -} - -/** - * @brief second step of the velocity Verlet integrator - * - * @param simBox simulation box - * @param kokkosSimBox Kokkos simulation box - */ -void KokkosVelocityVerlet::secondStep( - simulationBox::SimulationBox &simBox, - simulationBox::KokkosSimulationBox &kokkosSimBox -) -{ - startTimingsSection("Velocity Verlet - second step"); - - kokkosSimBox.transferForcesFromSimulationBox(simBox); - kokkosSimBox.transferVelocitiesFromSimulationBox(simBox); - - auto forces = kokkosSimBox.getForces().d_view; - auto velocities = kokkosSimBox.getVelocities().d_view; - auto masses = kokkosSimBox.getMasses().d_view; - - const auto dt = _dt.d_view; - const auto velocityFactor = _velocityFactor.d_view; - - Kokkos::parallel_for( - simBox.getNumberOfAtoms(), - KOKKOS_LAMBDA(const size_t i) { - // integrate_velocities(&velocities(i, 0), &forces(i, 0), - // masses(i)); - - for (size_t j = 0; j < 3; ++j) - { - velocities(i, j) += - forces(i, j) / masses(i) * dt() * velocityFactor(); - } - } - ); - - kokkosSimBox.transferVelocitiesToSimulationBox(simBox); - - stopTimingsSection("Velocity Verlet - second step"); -} \ No newline at end of file From e3f4d538d9aff77f7399ffd9660bf6c929a43e9b Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 11:45:11 +0200 Subject: [PATCH 08/44] cleanup: guard mpi approach with correct PP directive --- src/mpi/mpi.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mpi/mpi.cpp b/src/mpi/mpi.cpp index 193f1aee4..d4650b656 100644 --- a/src/mpi/mpi.cpp +++ b/src/mpi/mpi.cpp @@ -20,6 +20,8 @@ ******************************************************************************/ +#ifdef WITH_MPI + #include "mpi.hpp" #include // for MPI_Comm_rank, MPI_Comm_size, MPI_Init, MPI_Finalize @@ -145,4 +147,6 @@ size_t MPI::getRank() { return _rank; } * * @return size_t */ -size_t MPI::getSize() { return _size; } \ No newline at end of file +size_t MPI::getSize() { return _size; } + +#endif // WITH_MPI From c69bffef090b93fb7d111cae911a87b592f7efae Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 11:45:40 +0200 Subject: [PATCH 09/44] cleanup: remove some more unused headers --- src/manostat/manostat.cpp | 7 ++-- src/opt/evaluator/hessianBuilder.cpp | 52 +++++++++++++--------------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/manostat/manostat.cpp b/src/manostat/manostat.cpp index 789b10055..afaacaa65 100644 --- a/src/manostat/manostat.cpp +++ b/src/manostat/manostat.cpp @@ -22,8 +22,6 @@ #include "manostat.hpp" -#include // for function - #include "constants/internalConversionFactors.hpp" // for _PRESSURE_FACTOR_ #include "manostatSettings.hpp" // for ManostatType, Isotropy #include "physicalData.hpp" // for PhysicalData @@ -72,7 +70,8 @@ void Manostat::calculatePressure(const SimulationBox &box, PhysicalData &data) * @brief rotate mu back into upper diagonal space * * @details first order approximation of mu rotation according to gromacs - * @link https://manual.gromacs.org/current/reference-manual/algorithms/molecular-dynamics.html + * @link + * https://manual.gromacs.org/current/reference-manual/algorithms/molecular-dynamics.html * * @param mu */ @@ -113,4 +112,4 @@ ManostatType Manostat::getManostatType() const { return ManostatType::NONE; } * * @return Isotropy */ -Isotropy Manostat::getIsotropy() const { return Isotropy::NONE; } \ No newline at end of file +Isotropy Manostat::getIsotropy() const { return Isotropy::NONE; } diff --git a/src/opt/evaluator/hessianBuilder.cpp b/src/opt/evaluator/hessianBuilder.cpp index ff5238888..83519dee1 100644 --- a/src/opt/evaluator/hessianBuilder.cpp +++ b/src/opt/evaluator/hessianBuilder.cpp @@ -27,7 +27,6 @@ #include "atom.hpp" #include "evaluator.hpp" #include "exceptions.hpp" -#include "simulationBox.hpp" using namespace opt; using namespace settings; @@ -41,10 +40,10 @@ ForceDifferenceHessianBuilder::ForceDifferenceHessianBuilder( } std::vector ForceDifferenceHessianBuilder::evaluateForces( - Evaluator &evaluator, - pq::SimBox &simulationBox, - const size_t coordinateIndex, - const double displacement + Evaluator &evaluator, + pq::SimBox &simulationBox, + const size_t coordinateIndex, + const double displacement ) const { displaceCoordinate(simulationBox, coordinateIndex, displacement); @@ -65,15 +64,15 @@ void ForceDifferenceHessianBuilder::restorePositions( } void ForceDifferenceHessianBuilder::displaceCoordinate( - pq::SimBox &simulationBox, - const size_t coordinateIndex, - const double displacement + pq::SimBox &simulationBox, + const size_t coordinateIndex, + const double displacement ) { const auto atomIndex = coordinateIndex / 3; const auto dimension = coordinateIndex % 3; - auto position = simulationBox.getAtom(atomIndex).getPosition(); + auto position = simulationBox.getAtom(atomIndex).getPosition(); position[dimension] += displacement; simulationBox.getAtom(atomIndex).setPosition(position); @@ -101,19 +100,19 @@ void ForceDifferenceHessianBuilder::symmetrize(pq::HessianMatrix &hessian) for (size_t row = 0; row < hessian.size(); ++row) for (size_t col = row + 1; col < hessian.size(); ++col) { - const auto value = 0.5 * (hessian[row][col] + hessian[col][row]); + const auto value = 0.5 * (hessian[row][col] + hessian[col][row]); hessian[row][col] = value; hessian[col][row] = value; } } pq::HessianMatrix CentralForceDifferenceHessianBuilder::build( - Evaluator &evaluator, - pq::SimBox &simulationBox + Evaluator &evaluator, + pq::SimBox &simulationBox ) const { const auto numberOfCoordinates = 3 * simulationBox.getNumberOfAtoms(); - auto hessian = pq::HessianMatrix( + auto hessian = pq::HessianMatrix( numberOfCoordinates, std::vector(numberOfCoordinates, 0.0) ); @@ -128,8 +127,8 @@ pq::HessianMatrix CentralForceDifferenceHessianBuilder::build( evaluateForces(evaluator, simulationBox, col, -_displacement); for (size_t row = 0; row < numberOfCoordinates; ++row) - hessian[row][col] = -(fPlus[row] - fMinus[row]) / - (2.0 * _displacement); + hessian[row][col] = + -(fPlus[row] - fMinus[row]) / (2.0 * _displacement); restorePositions(simulationBox, originalPositions); } @@ -141,12 +140,12 @@ pq::HessianMatrix CentralForceDifferenceHessianBuilder::build( } pq::HessianMatrix ForwardForceDifferenceHessianBuilder::build( - Evaluator &evaluator, - pq::SimBox &simulationBox + Evaluator &evaluator, + pq::SimBox &simulationBox ) const { const auto numberOfCoordinates = 3 * simulationBox.getNumberOfAtoms(); - auto hessian = pq::HessianMatrix( + auto hessian = pq::HessianMatrix( numberOfCoordinates, std::vector(numberOfCoordinates, 0.0) ); @@ -173,12 +172,12 @@ pq::HessianMatrix ForwardForceDifferenceHessianBuilder::build( } pq::HessianMatrix FivePointForceDifferenceHessianBuilder::build( - Evaluator &evaluator, - pq::SimBox &simulationBox + Evaluator &evaluator, + pq::SimBox &simulationBox ) const { const auto numberOfCoordinates = 3 * simulationBox.getNumberOfAtoms(); - auto hessian = pq::HessianMatrix( + auto hessian = pq::HessianMatrix( numberOfCoordinates, std::vector(numberOfCoordinates, 0.0) ); @@ -198,10 +197,9 @@ pq::HessianMatrix FivePointForceDifferenceHessianBuilder::build( for (size_t row = 0; row < numberOfCoordinates; ++row) { - const auto derivative = ( - -fPlus2[row] + 8.0 * fPlus[row] - 8.0 * fMinus[row] + - fMinus2[row] - ) / (12.0 * _displacement); + const auto derivative = (-fPlus2[row] + 8.0 * fPlus[row] - + 8.0 * fMinus[row] + fMinus2[row]) / + (12.0 * _displacement); hessian[row][col] = -derivative; } @@ -216,8 +214,8 @@ pq::HessianMatrix FivePointForceDifferenceHessianBuilder::build( } pq::HessianMatrix AnalyticHessianBuilder::build( - Evaluator &evaluator, - pq::SimBox & + Evaluator &evaluator, + pq::SimBox & ) const { if (!evaluator.supportsAnalyticHessian()) From 37f9a5ca8919d205fc66099f53f3c9a2f305595e Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 11:46:04 +0200 Subject: [PATCH 10/44] cleanup: comment out unused function params --- src/forceField/forceFieldClass.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/forceField/forceFieldClass.cpp b/src/forceField/forceFieldClass.cpp index b2df967cc..535b6f72e 100644 --- a/src/forceField/forceFieldClass.cpp +++ b/src/forceField/forceFieldClass.cpp @@ -23,7 +23,7 @@ #include "forceFieldClass.hpp" #include -#include // for format +#include // for format #include "exceptions.hpp" @@ -298,8 +298,8 @@ void ForceField::calculateImproperDihedralInteractions( * @param physicalData */ void ForceField::calculateJCouplingInteractions( - const SimulationBox &box, - PhysicalData &physicalData + const SimulationBox & /*box*/, + PhysicalData & /*physicalData*/ ) { if (!_jCouplings.empty()) @@ -618,4 +618,4 @@ const std::vector &ForceField::getImproperTypes() const const std::vector &ForceField::getJCouplTypes() const { return _jCouplingTypes; -} \ No newline at end of file +} From ac4e18857503f414d176f8a775d3891b255c7be7 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 11:48:05 +0200 Subject: [PATCH 11/44] cleanup: guard kokkos impl files with correct PP directive --- src/potential/coulomb_kokkos/coulombWolf_kokkos.cpp | 6 +++++- src/potential/nonCoulomb_kokkos/lennardJones_kokkos.cpp | 6 +++++- src/potential/potential_kokkos.cpp | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/potential/coulomb_kokkos/coulombWolf_kokkos.cpp b/src/potential/coulomb_kokkos/coulombWolf_kokkos.cpp index d36489e50..8a7a0127e 100644 --- a/src/potential/coulomb_kokkos/coulombWolf_kokkos.cpp +++ b/src/potential/coulomb_kokkos/coulombWolf_kokkos.cpp @@ -20,6 +20,8 @@ ******************************************************************************/ +#ifdef WITH_KOKKOS + #include "coulombWolf_kokkos.hpp" using namespace potential; @@ -120,4 +122,6 @@ double KokkosCoulombWolf::calculate( View KokkosCoulombWolf::getCoulombRadiusCutOff() const { return _coulombRadiusCutOff.d_view; -} \ No newline at end of file +} + +#endif // WITH_KOKKOS diff --git a/src/potential/nonCoulomb_kokkos/lennardJones_kokkos.cpp b/src/potential/nonCoulomb_kokkos/lennardJones_kokkos.cpp index 015ae51ec..d7acf6372 100644 --- a/src/potential/nonCoulomb_kokkos/lennardJones_kokkos.cpp +++ b/src/potential/nonCoulomb_kokkos/lennardJones_kokkos.cpp @@ -20,6 +20,8 @@ ******************************************************************************/ +#ifdef WITH_KOKKOS + #include "lennardJones_kokkos.hpp" #include "lennardJonesPair.hpp" @@ -225,4 +227,6 @@ double KokkosLennardJones::getC6(const size_t i, const size_t j) const double KokkosLennardJones::getC12(const size_t i, const size_t j) const { return _c12.d_view(i, j); -} \ No newline at end of file +} + +#endif // WITH_KOKKOS diff --git a/src/potential/potential_kokkos.cpp b/src/potential/potential_kokkos.cpp index 22f7cbb69..4a51944c4 100644 --- a/src/potential/potential_kokkos.cpp +++ b/src/potential/potential_kokkos.cpp @@ -20,6 +20,8 @@ ******************************************************************************/ +#ifdef WITH_KOKKOS + #include "potential_kokkos.hpp" #include // for size_t @@ -189,3 +191,5 @@ void KokkosPotential::calculateForces( stopTimingsSection("InterNonBonded - Transfer"); } + +#endif // WITH_KOKKOS From 4b8f56b816b6b2581863705fb6c30d41f0970e40 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 11:56:23 +0200 Subject: [PATCH 12/44] fix: remove error flags when compiling with benchmarking --- .cmake/benchmarking.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cmake/benchmarking.cmake b/.cmake/benchmarking.cmake index d52413811..cc9eef14d 100644 --- a/.cmake/benchmarking.cmake +++ b/.cmake/benchmarking.cmake @@ -13,7 +13,7 @@ FetchContent_Declare( # Keep project warning policy from being applied to third-party sources. set(_CMAKE_CXX_FLAGS_BACKUP "${CMAKE_CXX_FLAGS}") -foreach(flag IN ITEMS "-Wswitch-enum" "-Werror=switch-enum") +foreach(flag IN ITEMS "-Wswitch-enum" "-Werror=switch-enum" "-Werror" "-Wundef") string(REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endforeach() From 9c4eef8caf63743da4580527a70a78661185b60a Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:04:28 +0200 Subject: [PATCH 13/44] cleanup: guard selection impl file with PP guards --- src/CMakeLists.txt | 3 ++- src/python/selection.cpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6fcb6b553..177cabb58 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,9 +28,10 @@ add_subdirectory(opt) add_subdirectory(randomNumberGenerator) if(BUILD_WITH_PYTHON_BINDINGS) + add_definitions(-DWITH_WITH_PYTHON_BINDINGS) add_subdirectory(python) endif() if(BUILD_WITH_MPI) add_subdirectory(mpi) -endif() \ No newline at end of file +endif() diff --git a/src/python/selection.cpp b/src/python/selection.cpp index 7838d7d24..c06cb89ee 100644 --- a/src/python/selection.cpp +++ b/src/python/selection.cpp @@ -20,6 +20,8 @@ ******************************************************************************/ +#ifdef WITH_WITH_PYTHON_BINDINGS + #include "selection.hpp" #include @@ -135,4 +137,6 @@ std::vector pq_python::select( ::Py_Finalize(); return result; -} \ No newline at end of file +} + +#endif // WITH_WITH_PYTHON_BINDINGS From 08b66d24cb2a87e93753e9b4ae9ee7cdb7d53d8c Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:04:41 +0200 Subject: [PATCH 14/44] cleanup: more kokkos PP guards --- src/setup/kokkosSetup.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/setup/kokkosSetup.cpp b/src/setup/kokkosSetup.cpp index a9934a242..7e545b703 100644 --- a/src/setup/kokkosSetup.cpp +++ b/src/setup/kokkosSetup.cpp @@ -20,6 +20,8 @@ ******************************************************************************/ +#ifdef WITH_KOKKOS + #include "kokkosSetup.hpp" #include @@ -58,7 +60,7 @@ void setup::setupKokkos(Engine &engine) * * @param engine */ -KokkosSetup::KokkosSetup(Engine &engine) : _engine(engine){}; +KokkosSetup::KokkosSetup(Engine &engine) : _engine(engine) {} /** * @brief setup Kokkos @@ -135,4 +137,6 @@ void KokkosSetup::setup() wolfPotential.getWolfParameter3(), _COULOMB_PREFACTOR_ ); -} \ No newline at end of file +} + +#endif // WITH_KOKKOS From 1f4d9af0109807c575b2c9b532a09775ec70940f Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:06:16 +0200 Subject: [PATCH 15/44] cleanup: fix reusing same variable twice --- src/setup/outputFilesSetup.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/setup/outputFilesSetup.cpp b/src/setup/outputFilesSetup.cpp index 66ea7b119..c2281cc41 100644 --- a/src/setup/outputFilesSetup.cpp +++ b/src/setup/outputFilesSetup.cpp @@ -123,19 +123,21 @@ void OutputFilesSetup::setup() if (Settings::isRingPolymerMDActivated()) { - const auto RstFile = OutputFileSettings::getRPMDRestartFileName(); - const auto xyzFile = OutputFileSettings::getRPMDTrajFileName(); - const auto velFile = OutputFileSettings::getRPMDVelocityFileName(); - const auto forceFile = OutputFileSettings::getRPMDForceFileName(); - const auto chargeFile = OutputFileSettings::getRPMDChargeFileName(); - const auto energyFile = OutputFileSettings::getRPMDEnergyFileName(); - - mdEngine.getRingPolymerRstFileOutput().setFilename(RstFile); - mdEngine.getRingPolymerXyzOutput().setFilename(xyzFile); - mdEngine.getRingPolymerVelOutput().setFilename(velFile); - mdEngine.getRingPolymerForceOutput().setFilename(forceFile); - mdEngine.getRingPolymerChargeOutput().setFilename(chargeFile); - mdEngine.getRingPolymerEnergyOutput().setFilename(energyFile); + const auto rstFile_ = OutputFileSettings::getRPMDRestartFileName(); + const auto xyzFile_ = OutputFileSettings::getRPMDTrajFileName(); + const auto velFile_ = OutputFileSettings::getRPMDVelocityFileName(); + const auto forceFile_ = OutputFileSettings::getRPMDForceFileName(); + const auto chargeFile_ = + OutputFileSettings::getRPMDChargeFileName(); + const auto energyFile_ = + OutputFileSettings::getRPMDEnergyFileName(); + + mdEngine.getRingPolymerRstFileOutput().setFilename(rstFile_); + mdEngine.getRingPolymerXyzOutput().setFilename(xyzFile_); + mdEngine.getRingPolymerVelOutput().setFilename(velFile_); + mdEngine.getRingPolymerForceOutput().setFilename(forceFile_); + mdEngine.getRingPolymerChargeOutput().setFilename(chargeFile_); + mdEngine.getRingPolymerEnergyOutput().setFilename(energyFile_); } } From fa504eef97262d987f9f97b2920ba9bd0aa15348 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:21:35 +0200 Subject: [PATCH 16/44] cleanup: more kokkos PP directives --- src/setup/setup.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/setup/setup.cpp b/src/setup/setup.cpp index f601b0791..a32f587cb 100644 --- a/src/setup/setup.cpp +++ b/src/setup/setup.cpp @@ -32,7 +32,6 @@ #include "inputFileReader.hpp" // for readInputFile #include "intraNonBondedReader.hpp" // for readIntraNonBondedFile #include "intraNonBondedSetup.hpp" // for setupIntraNonBonded -#include "kokkosSetup.hpp" // for setupKokkos #include "manostatSetup.hpp" // for setupManostat #include "moldescriptorReader.hpp" // for readMolDescriptor #include "optimizerSetup.hpp" // for setupOptimizer @@ -50,6 +49,10 @@ #include "timer.hpp" // for Timings #include "topologyReader.hpp" // for readTopologyFile +#ifdef WITH_KOKKOS +#include "kokkosSetup.hpp" // for setupKokkos +#endif + using namespace engine; using namespace input; using namespace timings; From 76a4022ab2cf35fe646b29c50a475a246597db85 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:21:50 +0200 Subject: [PATCH 17/44] cleanup: remove unused header --- src/setup/ringPolymerSetup.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/setup/ringPolymerSetup.cpp b/src/setup/ringPolymerSetup.cpp index b6df636ca..34186c2ef 100644 --- a/src/setup/ringPolymerSetup.cpp +++ b/src/setup/ringPolymerSetup.cpp @@ -22,11 +22,9 @@ #include "ringPolymerSetup.hpp" -#include // for __for_each_fn, for_each -#include // for size_t -#include // for string_view +#include // for __for_each_fn, for_each +#include // for size_t -#include "exceptions.hpp" // for InputFileException #include "fileSettings.hpp" // for FileSettings #include "maxwellBoltzmann.hpp" // for MaxwellBoltzmann #include "ringPolymerEngine.hpp" // for RingPolymerEngine @@ -78,8 +76,9 @@ void setup::setupRingPolymer(Engine &engine) * * @param engine */ -RingPolymerSetup::RingPolymerSetup(RingPolymerEngine &engine) - : _engine(engine){}; +RingPolymerSetup::RingPolymerSetup(RingPolymerEngine &engine) : _engine(engine) +{ +} /** * @brief setup a ring polymer simulation From eaa92e05cfd8c4d10b082c15b7578cd6a7570fa3 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:22:41 +0200 Subject: [PATCH 18/44] cleanup: remove this argument from lambdas as it is not used --- src/setup/simulationBoxSetup.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/setup/simulationBoxSetup.cpp b/src/setup/simulationBoxSetup.cpp index cfcf2f6d0..11651bec2 100644 --- a/src/setup/simulationBoxSetup.cpp +++ b/src/setup/simulationBoxSetup.cpp @@ -118,7 +118,7 @@ void SimulationBoxSetup::setAtomNames() { auto &simBox = _engine.getSimulationBox(); - auto setAtomNamesOfMolecule = [this, &simBox](auto &molecule) + auto setAtomNamesOfMolecule = [&simBox](auto &molecule) { const auto &molType = molecule.getMoltype(); if (molType == 0) @@ -149,7 +149,7 @@ void SimulationBoxSetup::setAtomTypes() { auto &simBox = _engine.getSimulationBox(); - auto setAtomTypesOfMolecule = [this, &simBox](auto &molecule) + auto setAtomTypesOfMolecule = [&simBox](auto &molecule) { const auto &molType = molecule.getMoltype(); @@ -178,7 +178,7 @@ void SimulationBoxSetup::setExternalVDWTypes() { auto &simBox = _engine.getSimulationBox(); - auto setExternalVDWTypesOfMolecule = [this, &simBox](auto &molecule) + auto setExternalVDWTypesOfMolecule = [&simBox](auto &molecule) { const auto &molType = molecule.getMoltype(); @@ -223,7 +223,7 @@ void SimulationBoxSetup::setPartialCharges() { auto &simBox = _engine.getSimulationBox(); - auto setPartialChargesOfMolecule = [this, &simBox](auto &molecule) + auto setPartialChargesOfMolecule = [&simBox](auto &molecule) { const auto &molType = molecule.getMoltype(); From 17ce6dbad5840c1a2c61c1b05a4bac642324c4f3 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:26:44 +0200 Subject: [PATCH 19/44] cleanup: add explicit destructor for private unique ptr --- include/input/parameterFileReader/parameterFileReader.hpp | 3 ++- src/input/parameterFileReader/parameterFileReader.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/input/parameterFileReader/parameterFileReader.hpp b/include/input/parameterFileReader/parameterFileReader.hpp index 257626e09..bab66a76e 100644 --- a/include/input/parameterFileReader/parameterFileReader.hpp +++ b/include/input/parameterFileReader/parameterFileReader.hpp @@ -52,6 +52,7 @@ namespace input::parameterFile public: ParameterFileReader(const std::string &filename, pq::Engine &engine); + ~ParameterFileReader(); void read(); void deleteSection(const pq::ParamFileSection *section); @@ -72,4 +73,4 @@ namespace input::parameterFile } // namespace input::parameterFile -#endif // _PARAMETER_FILE_READER_HPP_ \ No newline at end of file +#endif // _PARAMETER_FILE_READER_HPP_ diff --git a/src/input/parameterFileReader/parameterFileReader.cpp b/src/input/parameterFileReader/parameterFileReader.cpp index 116132157..65bdb797b 100644 --- a/src/input/parameterFileReader/parameterFileReader.cpp +++ b/src/input/parameterFileReader/parameterFileReader.cpp @@ -68,6 +68,8 @@ ParameterFileReader::ParameterFileReader( _parameterFileSections.push_back(make_unique()); } +ParameterFileReader::~ParameterFileReader() = default; + /** * @brief determines which section of the parameter file the header line belongs * to @@ -86,7 +88,8 @@ ParameterFileSection *ParameterFileReader::determineSection( const auto iterEnd = _parameterFileSections.end(); for (auto section = iterStart; section != iterEnd; ++section) - if ((*section)->keyword() == toLowerAndReplaceDashesCopy(lineElements[0])) + if ((*section)->keyword() == + toLowerAndReplaceDashesCopy(lineElements[0])) return (*section).get(); throw ParameterFileException( @@ -219,4 +222,4 @@ std::vector> &ParameterFileReader:: const std::string &ParameterFileReader::getFilename() const { return _fileName; -} \ No newline at end of file +} From 577a990f97d2a40decc8617f164a622770c55882 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:26:56 +0200 Subject: [PATCH 20/44] cleanup: more kokkos PP --- src/simulationBox/simulationBox_kokkos.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/simulationBox/simulationBox_kokkos.cpp b/src/simulationBox/simulationBox_kokkos.cpp index 3254647ca..639363e3e 100644 --- a/src/simulationBox/simulationBox_kokkos.cpp +++ b/src/simulationBox/simulationBox_kokkos.cpp @@ -20,6 +20,8 @@ ******************************************************************************/ +#ifdef WITH_KOKKOS + #include "simulationBox_kokkos.hpp" #include "simulationBox.hpp" // for SimulationBox @@ -298,7 +300,8 @@ void KokkosSimulationBox::transferBoxDimensionsFromSimulationBox( /** * @brief transfer positions to simulation box */ -void KokkosSimulationBox::transferPositionsToSimulationBox(SimulationBox& simBox +void KokkosSimulationBox::transferPositionsToSimulationBox( + SimulationBox& simBox ) { // copy positions back to host @@ -493,4 +496,6 @@ DualView& KokkosSimulationBox::getPartialCharges() DualView KokkosSimulationBox::getBoxDimensions() { return _boxDimensions; -} \ No newline at end of file +} + +#endif // WITH_KOKKOS From e3aae943c873a42460975ac2b7890e409274d3ed Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:30:30 +0200 Subject: [PATCH 21/44] fix: add missing cmake dependency to benchmark lib --- benchmarks/src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/benchmarks/src/CMakeLists.txt b/benchmarks/src/CMakeLists.txt index 019d109c7..b5c5ae5e7 100644 --- a/benchmarks/src/CMakeLists.txt +++ b/benchmarks/src/CMakeLists.txt @@ -7,6 +7,7 @@ function(add_pq_benchmark target source) target_link_libraries(${target} PRIVATE benchmark::benchmark_main + simulationBox ${ARGN} ) From 716e70b8a47304b5f480a5e74f79d710fe733dee Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:30:57 +0200 Subject: [PATCH 22/44] cleanup: correct include paths according to cmake approach --- tests/include/input/testRestartFileSection.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/include/input/testRestartFileSection.hpp b/tests/include/input/testRestartFileSection.hpp index 202ccaf35..92a490836 100644 --- a/tests/include/input/testRestartFileSection.hpp +++ b/tests/include/input/testRestartFileSection.hpp @@ -22,12 +22,12 @@ #include -#include "atomSection.hpp" -#include "boxSection.hpp" #include "mmmdEngine.hpp" -#include "noseHooverSection.hpp" -#include "restartFileSection.hpp" -#include "stepCountSection.hpp" +#include "restartFileReader/atomSection.hpp" +#include "restartFileReader/boxSection.hpp" +#include "restartFileReader/noseHooverSection.hpp" +#include "restartFileReader/restartFileSection.hpp" +#include "restartFileReader/stepCountSection.hpp" /** * @class TestBoxSection @@ -127,4 +127,4 @@ class TestAtomSection : public ::testing::Test input::restartFile::RestartFileSection *_section; engine::Engine *_engine; -}; \ No newline at end of file +}; From 5f4c87455412ce116a170a4f77408f0ca39bc760 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:44:38 +0200 Subject: [PATCH 23/44] cleanup: remove unused step param --- include/output/ringPolymerRestartFileOutput.hpp | 4 ++-- src/output/ringPolymerRestartFileOutput.cpp | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/include/output/ringPolymerRestartFileOutput.hpp b/include/output/ringPolymerRestartFileOutput.hpp index a8d98c90c..d82e20280 100644 --- a/include/output/ringPolymerRestartFileOutput.hpp +++ b/include/output/ringPolymerRestartFileOutput.hpp @@ -43,9 +43,9 @@ namespace output public: using Output::Output; - void write(std::vector &, const size_t); + void write(std::vector &); }; } // namespace output -#endif // _RST_FILE_OUTPUT_HPP_ \ No newline at end of file +#endif // _RST_FILE_OUTPUT_HPP_ diff --git a/src/output/ringPolymerRestartFileOutput.cpp b/src/output/ringPolymerRestartFileOutput.cpp index 03074ba92..95afc1ebf 100644 --- a/src/output/ringPolymerRestartFileOutput.cpp +++ b/src/output/ringPolymerRestartFileOutput.cpp @@ -41,10 +41,7 @@ using namespace settings; * @param simBox * @param step */ -void RingPolymerRestartFileOutput::write( - std::vector &beads, - const size_t step -) +void RingPolymerRestartFileOutput::write(std::vector &beads) { std::ostringstream buffer; @@ -88,4 +85,4 @@ void RingPolymerRestartFileOutput::write( // Write the buffer to the file _fp << buffer.str(); _fp << std::flush; -} \ No newline at end of file +} From 5b6eada5d3c6e51d42b2465380cad720963ec531 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:46:29 +0200 Subject: [PATCH 24/44] cleanup: remove unused includes --- tests/src/constraints/testBondConstraint.cpp | 4 +--- tests/src/constraints/testConstraints.cpp | 4 +--- tests/src/forceField/testAngleType.cpp | 4 +--- tests/src/forceField/testBondType.cpp | 4 +--- tests/src/forceField/testDihedralType.cpp | 4 +--- tests/src/input/inputFileParsing/testConvergenceParser.cpp | 4 +--- .../src/input/inputFileParsing/testCoulombLongRangeParser.cpp | 4 +--- 7 files changed, 7 insertions(+), 21 deletions(-) diff --git a/tests/src/constraints/testBondConstraint.cpp b/tests/src/constraints/testBondConstraint.cpp index b3e87a110..d3c2fb5ff 100644 --- a/tests/src/constraints/testBondConstraint.cpp +++ b/tests/src/constraints/testBondConstraint.cpp @@ -22,8 +22,6 @@ #include "testBondConstraint.hpp" -#include // for string - #include "constants/conversionFactors.hpp" #include "gtest/gtest.h" // for AssertionResult, Message, TestPartResult #include "timingsSettings.hpp" @@ -131,4 +129,4 @@ TEST_F(TestBondConstraint, applyRattle) ); EXPECT_TRUE(_bondConstraint->applyRattle(1000.0)); -} \ No newline at end of file +} diff --git a/tests/src/constraints/testConstraints.cpp b/tests/src/constraints/testConstraints.cpp index f51325fb2..ee9cb1b81 100644 --- a/tests/src/constraints/testConstraints.cpp +++ b/tests/src/constraints/testConstraints.cpp @@ -22,8 +22,6 @@ #include "testConstraints.hpp" -#include // for basic_string - #include "exceptions.hpp" // for ShakeException #include "gmock/gmock.h" // for DoubleNear, ElementsAre, MakePredica... #include "gtest/gtest.h" // for Message, TestPartResult, InitGoogleTest @@ -228,4 +226,4 @@ TEST_F(TestConstraints, isActivated) _constraints->activateDistanceConstraints(); EXPECT_TRUE(_constraints->isActive()); EXPECT_TRUE(_constraints->isDistanceConstraintsActive()); -} \ No newline at end of file +} diff --git a/tests/src/forceField/testAngleType.cpp b/tests/src/forceField/testAngleType.cpp index 73e7be698..85721f164 100644 --- a/tests/src/forceField/testAngleType.cpp +++ b/tests/src/forceField/testAngleType.cpp @@ -22,8 +22,6 @@ #include // for Test, EXPECT_FALSE, InitGoogleTest, RUN_ALL... -#include // for allocator, string - #include "angleType.hpp" // for AngleType #include "gtest/gtest.h" // for AssertionResult, Message, TestPartResult @@ -43,4 +41,4 @@ TEST(TestAngleType, operatorEqual) EXPECT_FALSE(angleType1 == angleType3); EXPECT_FALSE(angleType1 == angleType4); EXPECT_FALSE(angleType1 == angleType5); -} \ No newline at end of file +} diff --git a/tests/src/forceField/testBondType.cpp b/tests/src/forceField/testBondType.cpp index 10773a875..1a9ed45eb 100644 --- a/tests/src/forceField/testBondType.cpp +++ b/tests/src/forceField/testBondType.cpp @@ -22,8 +22,6 @@ #include // for Test, EXPECT_FALSE, InitGoogleTest, RUN_ALL... -#include // for allocator, string - #include "bondType.hpp" // for BondType #include "gtest/gtest.h" // for AssertionResult, Message, TestPartResult @@ -43,4 +41,4 @@ TEST(TestBondType, operatorEqual) EXPECT_FALSE(bondType1 == bondType3); EXPECT_FALSE(bondType1 == bondType4); EXPECT_FALSE(bondType1 == bondType5); -} \ No newline at end of file +} diff --git a/tests/src/forceField/testDihedralType.cpp b/tests/src/forceField/testDihedralType.cpp index 065369010..db61280b7 100644 --- a/tests/src/forceField/testDihedralType.cpp +++ b/tests/src/forceField/testDihedralType.cpp @@ -22,8 +22,6 @@ #include // for Test, EXPECT_FALSE, InitGoogleTest, RUN_... -#include // for allocator, string - #include "dihedralType.hpp" // for DihedralType #include "gtest/gtest.h" // for AssertionResult, Message, TestPartResult @@ -45,4 +43,4 @@ TEST(TestDihedralType, operatorEqual) EXPECT_FALSE(dihedralType1 == dihedralType4); EXPECT_FALSE(dihedralType1 == dihedralType5); EXPECT_FALSE(dihedralType1 == dihedralType6); -} \ No newline at end of file +} diff --git a/tests/src/input/inputFileParsing/testConvergenceParser.cpp b/tests/src/input/inputFileParsing/testConvergenceParser.cpp index 7cf4c036e..d34fae655 100644 --- a/tests/src/input/inputFileParsing/testConvergenceParser.cpp +++ b/tests/src/input/inputFileParsing/testConvergenceParser.cpp @@ -22,8 +22,6 @@ #include // for TEST_F, EXPECT_EQ, RUN_ALL_TESTS -#include // for string, allocator - #include "convergenceInputParser.hpp" // for InputFileParserOptimizer #include "convergenceSettings.hpp" // for ConvSettings #include "exceptions.hpp" // for InputFileException, customException @@ -285,4 +283,4 @@ TEST_F(TestInputFileReader, parserRMSForceConvergence) "RMS force convergence must be greater than 0.0 in input file at " "line 0." ) -} \ No newline at end of file +} diff --git a/tests/src/input/inputFileParsing/testCoulombLongRangeParser.cpp b/tests/src/input/inputFileParsing/testCoulombLongRangeParser.cpp index 14ffc3f61..19e6dd4bb 100644 --- a/tests/src/input/inputFileParsing/testCoulombLongRangeParser.cpp +++ b/tests/src/input/inputFileParsing/testCoulombLongRangeParser.cpp @@ -22,8 +22,6 @@ #include // for TestInfo (ptr only) -#include // for string, allocator - #include "coulombLongRangeInputParser.hpp" #include "exceptions.hpp" // for InputFileException #include "gtest/gtest.h" // for Message, TestPartResult @@ -120,4 +118,4 @@ TEST_F(TestInputFileReader, testParseReactionFieldEpsilon) "Static relative permittivity \"rf_epsilon\" cannot be lower than " "1.0" ); -} \ No newline at end of file +} From 107e27ac0fe5c700787855909b19c07a56403827 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:52:11 +0200 Subject: [PATCH 25/44] fix: add missing step in rst file for rpmd --- include/engine/engineOutput.hpp | 19 ++++++++++++++----- .../output/ringPolymerRestartFileOutput.hpp | 2 +- src/output/ringPolymerRestartFileOutput.cpp | 7 ++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/engine/engineOutput.hpp b/include/engine/engineOutput.hpp index 3f46782d3..eaa14ff4f 100644 --- a/include/engine/engineOutput.hpp +++ b/include/engine/engineOutput.hpp @@ -90,12 +90,18 @@ namespace engine EngineOutput(); void writeEnergyFile(const size_t step, const pq::PhysicalData &); - void writeInstantEnergyFile(const size_t step, const pq::PhysicalData &); + void writeInstantEnergyFile( + const size_t step, + const pq::PhysicalData & + ); void writeXyzFile(pq::SimBox &); void writeVelFile(pq::SimBox &); void writeForceFile(pq::SimBox &); void writeChargeFile(pq::SimBox &); - void writeInfoFile(const double simulationTime, const pq::PhysicalData &); + void writeInfoFile( + const double simulationTime, + const pq::PhysicalData & + ); void writeRstFile(pq::SimBox &, const pq::Thermostat &, const size_t); void writeOptRstFile(pq::SimBox &, const size_t); @@ -105,12 +111,15 @@ namespace engine void writeBoxFile(const size_t, const pq::Box &); void writeOptFile(const size_t, const pq::Optimizer &); - void writeRingPolymerRstFile(std::vector &, const size_t); + void writeRingPolymerRstFile(std::vector &); void writeRingPolymerXyzFile(std::vector &); void writeRingPolymerVelFile(std::vector &); void writeRingPolymerForceFile(std::vector &); void writeRingPolymerChargeFile(std::vector &); - void writeRingPolymerEnergyFile(const size_t, const std::vector &); + void writeRingPolymerEnergyFile( + const size_t, + const std::vector & + ); void writeTimingsFile(timings::GlobalTimer &); @@ -151,4 +160,4 @@ namespace engine } // namespace engine -#endif // _ENGINE_OUTPUT_HPP_ \ No newline at end of file +#endif // _ENGINE_OUTPUT_HPP_ diff --git a/include/output/ringPolymerRestartFileOutput.hpp b/include/output/ringPolymerRestartFileOutput.hpp index d82e20280..e92db6c5a 100644 --- a/include/output/ringPolymerRestartFileOutput.hpp +++ b/include/output/ringPolymerRestartFileOutput.hpp @@ -43,7 +43,7 @@ namespace output public: using Output::Output; - void write(std::vector &); + void write(std::vector &, const size_t); }; } // namespace output diff --git a/src/output/ringPolymerRestartFileOutput.cpp b/src/output/ringPolymerRestartFileOutput.cpp index 95afc1ebf..5ab5f9312 100644 --- a/src/output/ringPolymerRestartFileOutput.cpp +++ b/src/output/ringPolymerRestartFileOutput.cpp @@ -41,13 +41,18 @@ using namespace settings; * @param simBox * @param step */ -void RingPolymerRestartFileOutput::write(std::vector &beads) +void RingPolymerRestartFileOutput::write( + std::vector &beads, + const size_t step +) { std::ostringstream buffer; _fp.close(); _fp.open(_fileName); + buffer << "Step " << step << '\n'; + const auto nBeads = RingPolymerSettings::getNumberOfBeads(); for (size_t i = 0; i < nBeads; ++i) From d0b594c1e0e1d266c976d927f2d35c3b960447c0 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 12:52:38 +0200 Subject: [PATCH 26/44] fix: make check of typeid in tests for engine safer --- .../inputFileParsing/testGeneralParser.cpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/src/input/inputFileParsing/testGeneralParser.cpp b/tests/src/input/inputFileParsing/testGeneralParser.cpp index ff41185a4..f94f40c47 100644 --- a/tests/src/input/inputFileParsing/testGeneralParser.cpp +++ b/tests/src/input/inputFileParsing/testGeneralParser.cpp @@ -42,6 +42,19 @@ using namespace input; using namespace settings; +namespace +{ + void checkEngineType( + const std::unique_ptr& engine, + const std::type_info& expectedType + ) + { + ASSERT_NE(engine, nullptr) << "Engine pointer is null"; + const auto& engineRef = *engine; + EXPECT_EQ(typeid(engineRef), expectedType); + } +} // namespace + /** * @brief tests parsing the "jobtype" command * @@ -57,33 +70,33 @@ TEST_F(TestInputFileReader, JobType) parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::MM_MD); EXPECT_EQ(Settings::isMMActivated(), true); - EXPECT_EQ(typeid(*engine), typeid(engine::MMMDEngine)); + checkEngineType(engine, typeid(engine::MMMDEngine)); lineElements = {"jobtype", "=", "qm-md"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::QM_MD); EXPECT_EQ(Settings::isQMActivated(), true); - EXPECT_EQ(typeid(*engine), typeid(engine::QMMDEngine)); + checkEngineType(engine, typeid(engine::QMMDEngine)); lineElements = {"jobtype", "=", "qm-rpmd"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::RING_POLYMER_QM_MD); EXPECT_EQ(Settings::isQMActivated(), true); EXPECT_EQ(Settings::isRingPolymerMDActivated(), true); - EXPECT_EQ(typeid(*engine), typeid(engine::RingPolymerQMMDEngine)); + checkEngineType(engine, typeid(engine::RingPolymerQMMDEngine)); lineElements = {"jobtype", "=", "mm-opt"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::MM_OPT); EXPECT_EQ(Settings::isOptJobType(), true); EXPECT_EQ(Settings::isMMActivated(), true); - EXPECT_EQ(typeid(*engine), typeid(engine::OptEngine)); + checkEngineType(engine, typeid(engine::OptEngine)); lineElements = {"jobtype", "=", "mm-hessian"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::MM_HESSIAN); EXPECT_EQ(Settings::isMMActivated(), true); - EXPECT_EQ(typeid(*engine), typeid(engine::HessianEngine)); + checkEngineType(engine, typeid(engine::HessianEngine)); lineElements = {"jobtype", "=", "notValid"}; EXPECT_THROW_MSG( From cb79f6a2fb9b455ca36db8f6e5960a0f5b26017c Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 13:04:36 +0200 Subject: [PATCH 27/44] chore: fix some rework bugs --- include/engine/engineOutput.hpp | 2 +- tests/src/input/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/engine/engineOutput.hpp b/include/engine/engineOutput.hpp index eaa14ff4f..79f00bc30 100644 --- a/include/engine/engineOutput.hpp +++ b/include/engine/engineOutput.hpp @@ -111,7 +111,7 @@ namespace engine void writeBoxFile(const size_t, const pq::Box &); void writeOptFile(const size_t, const pq::Optimizer &); - void writeRingPolymerRstFile(std::vector &); + void writeRingPolymerRstFile(std::vector &, const size_t); void writeRingPolymerXyzFile(std::vector &); void writeRingPolymerVelFile(std::vector &); void writeRingPolymerForceFile(std::vector &); diff --git a/tests/src/input/CMakeLists.txt b/tests/src/input/CMakeLists.txt index 1132c4694..ed014b631 100644 --- a/tests/src/input/CMakeLists.txt +++ b/tests/src/input/CMakeLists.txt @@ -15,6 +15,7 @@ foreach(source_file ${source_files}) target_include_directories(${test_name} PRIVATE ${PROJECT_SOURCE_DIR}/tests/include/input + ${PROJECT_SOURCE_DIR}/include/input/ ${PROJECT_SOURCE_DIR}/tests/include/macros ) target_link_libraries(${test_name} From 7d4ba9e9af8753b84a6c6a782b612d447b08ead7 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 13:10:10 +0200 Subject: [PATCH 28/44] chore: cmake fix after rework --- tests/src/input/CMakeLists.txt | 2 +- tests/src/input/restartFileSection/CMakeLists.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/src/input/CMakeLists.txt b/tests/src/input/CMakeLists.txt index ed014b631..3bfb7a4c9 100644 --- a/tests/src/input/CMakeLists.txt +++ b/tests/src/input/CMakeLists.txt @@ -14,8 +14,8 @@ foreach(source_file ${source_files}) add_executable(${test_name} ${source_file}) target_include_directories(${test_name} PRIVATE - ${PROJECT_SOURCE_DIR}/tests/include/input ${PROJECT_SOURCE_DIR}/include/input/ + ${PROJECT_SOURCE_DIR}/tests/include/input ${PROJECT_SOURCE_DIR}/tests/include/macros ) target_link_libraries(${test_name} diff --git a/tests/src/input/restartFileSection/CMakeLists.txt b/tests/src/input/restartFileSection/CMakeLists.txt index 55b1efe7d..745f77d26 100644 --- a/tests/src/input/restartFileSection/CMakeLists.txt +++ b/tests/src/input/restartFileSection/CMakeLists.txt @@ -10,6 +10,7 @@ foreach(source_file ${source_files}) add_executable(${test_name} ${source_file}) target_include_directories(${test_name} PRIVATE + ${PROJECT_SOURCE_DIR}/include/input/ ${PROJECT_SOURCE_DIR}/tests/include/input ${PROJECT_SOURCE_DIR}/tests/include/macros ) @@ -39,4 +40,4 @@ if(${BUILD_WITH_GCOVR}) EXECUTABLE_ARGS "-L;restartFileSection" OUTPUT_PATH "coverage" ) -endif() \ No newline at end of file +endif() From cf68a0fc1ac9d829b442c9e5ff6b8a3d7c049d56 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 13:15:25 +0200 Subject: [PATCH 29/44] cleanup: use bindMember in tests also --- .../inputFileParsing/testInputFileParser.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/src/input/inputFileParsing/testInputFileParser.cpp b/tests/src/input/inputFileParsing/testInputFileParser.cpp index cb283803f..27b85640d 100644 --- a/tests/src/input/inputFileParsing/testInputFileParser.cpp +++ b/tests/src/input/inputFileParsing/testInputFileParser.cpp @@ -22,15 +22,15 @@ #include // for TestInfo (ptr only), EXPECT_EQ -#include // for _Bind_front_t, bind_front -#include // for map -#include // for string, allocator, basic_string -#include // for vector - -#include "exceptions.hpp" // for InputFileException -#include "generalInputParser.hpp" // for InputFileParserGeneral -#include "gtest/gtest.h" // for Message, TestPartResult -#include "inputFileParser.hpp" // for ParseFunc, checkCommand +#include // for map +#include // for string, allocator, basic_string +#include // for vector + +#include "exceptions.hpp" // for InputFileException +#include "generalInputParser.hpp" // for InputFileParserGeneral +#include "gtest/gtest.h" // for Message, TestPartResult +#include "inputFileParser.hpp" // for ParseFunc, checkCommand +#include "parserUtils.hpp" #include "testInputFileReader.hpp" // for TestInputFileReader #include "throwWithMessage.hpp" // for ASSERT_THROW_MSG @@ -114,7 +114,7 @@ TEST_F(TestInputFileReader, addKeyword) parser.addKeyword( "test", - bind_front(&GeneralInputParser::parseJobType, parser), + input::bindMember(&GeneralInputParser::parseJobType, &parser), true ); @@ -126,4 +126,4 @@ TEST_F(TestInputFileReader, addKeyword) EXPECT_EQ(parser.getKeywordRequiredMap().size(), 1 + initialSizeOfMaps); EXPECT_EQ(parser.getKeywordRequiredMap().at("test"), true); -} \ No newline at end of file +} From 6fbb7ed650172bc0768b6da073c45d34c20dd890 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 13:19:22 +0200 Subject: [PATCH 30/44] cleanup: remove unused param for rpmd rst output --- include/engine/engineOutput.hpp | 2 +- include/output/ringPolymerRestartFileOutput.hpp | 5 ++--- src/engine/engineOutput.cpp | 9 +++------ src/engine/ringPolymerEngine.cpp | 2 +- src/output/ringPolymerRestartFileOutput.cpp | 7 +------ tests/src/output/testRingPolymerRestartFileOutput.cpp | 4 ++-- 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/include/engine/engineOutput.hpp b/include/engine/engineOutput.hpp index 79f00bc30..eaa14ff4f 100644 --- a/include/engine/engineOutput.hpp +++ b/include/engine/engineOutput.hpp @@ -111,7 +111,7 @@ namespace engine void writeBoxFile(const size_t, const pq::Box &); void writeOptFile(const size_t, const pq::Optimizer &); - void writeRingPolymerRstFile(std::vector &, const size_t); + void writeRingPolymerRstFile(std::vector &); void writeRingPolymerXyzFile(std::vector &); void writeRingPolymerVelFile(std::vector &); void writeRingPolymerForceFile(std::vector &); diff --git a/include/output/ringPolymerRestartFileOutput.hpp b/include/output/ringPolymerRestartFileOutput.hpp index e92db6c5a..b55042c02 100644 --- a/include/output/ringPolymerRestartFileOutput.hpp +++ b/include/output/ringPolymerRestartFileOutput.hpp @@ -24,8 +24,7 @@ #define _RING_POLYMER_RESTART_FILE_OUTPUT_HPP_ -#include // for size_t -#include // for vector +#include // for vector #include "output.hpp" #include "typeAliases.hpp" @@ -43,7 +42,7 @@ namespace output public: using Output::Output; - void write(std::vector &, const size_t); + void write(std::vector &); }; } // namespace output diff --git a/src/engine/engineOutput.cpp b/src/engine/engineOutput.cpp index be0bba083..c8e519d91 100644 --- a/src/engine/engineOutput.cpp +++ b/src/engine/engineOutput.cpp @@ -299,13 +299,10 @@ void EngineOutput::writeOptFile( * @param simulationBox * @param step */ -void EngineOutput::writeRingPolymerRstFile( - std::vector &beads, - const size_t step -) +void EngineOutput::writeRingPolymerRstFile(std::vector &beads) { startTimingsSection("RingPolymerRestartFileOutput"); - _rpmdRstFileOutput->write(beads, step); + _rpmdRstFileOutput->write(beads); stopTimingsSection("RingPolymerRestartFileOutput"); } @@ -565,4 +562,4 @@ RingPolymerEnergyOutput &EngineOutput::getRingPolymerEnergyOutput() * * @return TimingsOutput */ -TimingsOutput &EngineOutput::getTimingsOutput() { return *_timingsOutput; } \ No newline at end of file +TimingsOutput &EngineOutput::getTimingsOutput() { return *_timingsOutput; } diff --git a/src/engine/ringPolymerEngine.cpp b/src/engine/ringPolymerEngine.cpp index 3acd13cf1..67590260a 100644 --- a/src/engine/ringPolymerEngine.cpp +++ b/src/engine/ringPolymerEngine.cpp @@ -75,7 +75,7 @@ void RingPolymerEngine::writeOutput() _engineOutput.writeChargeFile(*_simulationBox); _engineOutput.writeRstFile(*_simulationBox, *_thermostat, effStep); - _engineOutput.writeRingPolymerRstFile(_ringPolymerBeads, effStep); + _engineOutput.writeRingPolymerRstFile(_ringPolymerBeads); _engineOutput.writeRingPolymerXyzFile(_ringPolymerBeads); _engineOutput.writeRingPolymerVelFile(_ringPolymerBeads); _engineOutput.writeRingPolymerForceFile(_ringPolymerBeads); diff --git a/src/output/ringPolymerRestartFileOutput.cpp b/src/output/ringPolymerRestartFileOutput.cpp index 5ab5f9312..95afc1ebf 100644 --- a/src/output/ringPolymerRestartFileOutput.cpp +++ b/src/output/ringPolymerRestartFileOutput.cpp @@ -41,18 +41,13 @@ using namespace settings; * @param simBox * @param step */ -void RingPolymerRestartFileOutput::write( - std::vector &beads, - const size_t step -) +void RingPolymerRestartFileOutput::write(std::vector &beads) { std::ostringstream buffer; _fp.close(); _fp.open(_fileName); - buffer << "Step " << step << '\n'; - const auto nBeads = RingPolymerSettings::getNumberOfBeads(); for (size_t i = 0; i < nBeads; ++i) diff --git a/tests/src/output/testRingPolymerRestartFileOutput.cpp b/tests/src/output/testRingPolymerRestartFileOutput.cpp index f95f373af..1d4dae426 100644 --- a/tests/src/output/testRingPolymerRestartFileOutput.cpp +++ b/tests/src/output/testRingPolymerRestartFileOutput.cpp @@ -39,7 +39,7 @@ TEST_F(TestRingPolymerRestartFileOutput, write) settings::RingPolymerSettings::setNumberOfBeads(_beads.size()); _rstFileOutput->setFilename("default.rpmd.rst"); - _rstFileOutput->write(_beads, 10); + _rstFileOutput->write(_beads); _rstFileOutput->close(); std::ifstream file("default.rpmd.rst"); std::string line; @@ -93,4 +93,4 @@ TEST_F(TestRingPolymerRestartFileOutput, write) "2.00000000e+00\t 2.00000000e+00\t 2.00000000\t " "2.00000000\t 2.00000000" ); -} \ No newline at end of file +} From ccfee3d8ef4fb2b761a8cb8dd2d3f5d9eed7bb22 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 13:20:13 +0200 Subject: [PATCH 31/44] cleanup: remove unused header --- tests/src/input/inputFileParsing/testOptParser.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/src/input/inputFileParsing/testOptParser.cpp b/tests/src/input/inputFileParsing/testOptParser.cpp index 88cee5a9a..e2e6bc0db 100644 --- a/tests/src/input/inputFileParsing/testOptParser.cpp +++ b/tests/src/input/inputFileParsing/testOptParser.cpp @@ -22,8 +22,6 @@ #include // for TEST_F, EXPECT_EQ, RUN_ALL_TESTS -#include // for string, allocator - #include "exceptions.hpp" // for InputFileException, customException #include "gtest/gtest.h" // for Message, TestPartResult #include "optInputParser.hpp" // for InputFileParserOptimizer @@ -258,4 +256,4 @@ TEST_F(TestInputFileReader, parserMinLearningRate) "Minimum learning rate must be greater than 0.0 in input file at line " "0." ) -} \ No newline at end of file +} From 8c905dbce7a3ac1384bef14fd2ba738562a400f1 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 13:21:55 +0200 Subject: [PATCH 32/44] cleanup: silence unused result warning --- .../testNonCoulombicTypesSection.cpp | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/src/input/parameterFileReader/testNonCoulombicTypesSection.cpp b/tests/src/input/parameterFileReader/testNonCoulombicTypesSection.cpp index 08a83c042..ba61a61bd 100644 --- a/tests/src/input/parameterFileReader/testNonCoulombicTypesSection.cpp +++ b/tests/src/input/parameterFileReader/testNonCoulombicTypesSection.cpp @@ -22,8 +22,6 @@ #include // for EXPECT_EQ, TestInfo (ptr only) -#include // for string, basic_string - #include "buckinghamPair.hpp" // for BuckinghamPair #include "engine.hpp" // for Engine #include "exceptions.hpp" // for ParameterFileException @@ -203,27 +201,33 @@ TEST_F(TestParameterFileSection, processSectionNonCoulombics) PotentialSettings::setNonCoulombType(NonCoulombType::LJ); nonCoulombicsSection.processSection(lineElements, *_engine); EXPECT_EQ(potential.getNonCoulombPairsVector().size(), 1); - EXPECT_NO_THROW(dynamic_cast( - potential.getNonCoulombPairsVector()[0].get() - )); + EXPECT_NO_THROW( + [[maybe_unused]] auto ret = dynamic_cast( + potential.getNonCoulombPairsVector()[0].get() + ) + ); lineElements = {"0", "1", "1.22", "234.3", "324.3"}; PotentialSettings::setNonCoulombType(NonCoulombType::BUCKINGHAM); EXPECT_NO_THROW(nonCoulombicsSection.processSection(lineElements, *_engine) ); EXPECT_EQ(potential.getNonCoulombPairsVector().size(), 2); - EXPECT_NO_THROW(dynamic_cast( - potential.getNonCoulombPairsVector()[0].get() - )); + EXPECT_NO_THROW( + [[maybe_unused]] auto ret = dynamic_cast( + potential.getNonCoulombPairsVector()[0].get() + ) + ); lineElements = {"0", "1", "1.22", "234.3", "324.3"}; PotentialSettings::setNonCoulombType(NonCoulombType::MORSE); EXPECT_NO_THROW(nonCoulombicsSection.processSection(lineElements, *_engine) ); EXPECT_EQ(potential.getNonCoulombPairsVector().size(), 3); - EXPECT_NO_THROW(dynamic_cast( - potential.getNonCoulombPairsVector()[0].get() - )); + EXPECT_NO_THROW( + [[maybe_unused]] auto ret = dynamic_cast( + potential.getNonCoulombPairsVector()[0].get() + ) + ); lineElements = {"0", "1", "1.22", "234.3", "324.3"}; PotentialSettings::setNonCoulombType(NonCoulombType::LJ_9_12); @@ -243,4 +247,4 @@ TEST_F(TestParameterFileSection, endedNormallyNonCoulombic) ParameterFileException, "Parameter file noncoulombics section ended abnormally!" ); -} \ No newline at end of file +} From ed0d3a556c1bd4eab8439bb72753a10af9a3711a Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 13:24:39 +0200 Subject: [PATCH 33/44] chore: fix header in tests to be compliant with cmake approach --- .../restartFileSection/testAtomSection.cpp | 20 +++--- .../restartFileSection/testBoxSection.cpp | 63 +++++++++++++------ .../testNoseHooverSection.cpp | 17 +---- .../testStepCountSection.cpp | 8 +-- 4 files changed, 59 insertions(+), 49 deletions(-) diff --git a/tests/src/input/restartFileSection/testAtomSection.cpp b/tests/src/input/restartFileSection/testAtomSection.cpp index cf443df55..6855f1676 100644 --- a/tests/src/input/restartFileSection/testAtomSection.cpp +++ b/tests/src/input/restartFileSection/testAtomSection.cpp @@ -27,15 +27,15 @@ #include // for string, stod, allocator, basic_string #include // for vector -#include "atom.hpp" // for Atom -#include "atomSection.hpp" // for AtomSection -#include "engine.hpp" // for Engine -#include "exceptions.hpp" // for RstFileException, customException -#include "gmock/gmock.h" // for ElementsAre, MakePredicateFormatter -#include "gtest/gtest.h" // for Message, TestPartResult -#include "molecule.hpp" // for Molecule -#include "moleculeType.hpp" // for MoleculeType -#include "restartFileSection.hpp" // for RstFileSection, AtomSection +#include "atom.hpp" // for Atom +#include "engine.hpp" // for Engine +#include "exceptions.hpp" // for RstFileException, customException +#include "gmock/gmock.h" // for ElementsAre, MakePredicateFormatter +#include "gtest/gtest.h" // for Message, TestPartResult +#include "molecule.hpp" // for Molecule +#include "moleculeType.hpp" // for MoleculeType +#include "restartFileReader/atomSection.hpp" +#include "restartFileReader/restartFileSection.hpp" #include "testRestartFileSection.hpp" // for TestAtomSection #include "throwWithMessage.hpp" // for ASSERT_THROW_MSG @@ -261,4 +261,4 @@ TEST_F(TestAtomSection, testProcessQMAtomLine) ); ASSERT_EQ(atoms[0]->getAtomTypeName(), line[0]); -} \ No newline at end of file +} diff --git a/tests/src/input/restartFileSection/testBoxSection.cpp b/tests/src/input/restartFileSection/testBoxSection.cpp index 476e3f9b9..c98169b1e 100644 --- a/tests/src/input/restartFileSection/testBoxSection.cpp +++ b/tests/src/input/restartFileSection/testBoxSection.cpp @@ -20,20 +20,21 @@ ******************************************************************************/ -#include "engine.hpp" // for Engine -#include "exceptions.hpp" // for RstFileException, customException -#include "restartFileSection.hpp" // for RstFileSection, readInput +#include // for TestInfo (ptr only), ASSERT_THROW + +#include // for size_t, std +#include // for string, allocator, basic_string +#include // for vector + +#include "engine.hpp" // for Engine +#include "exceptions.hpp" // for RstFileException, customException +#include "gmock/gmock.h" // for ElementsAre, MakePredicateForma... +#include "gtest/gtest.h" // for Message, TestPartResult, Assert... +#include "restartFileReader/restartFileSection.hpp" #include "settings.hpp" // for Settings #include "simulationBoxSettings.hpp" // for SimulationBoxSettings #include "testRestartFileSection.hpp" // for TestBoxSection -#include "gmock/gmock.h" // for ElementsAre, MakePredicateForma... -#include "gtest/gtest.h" // for Message, TestPartResult, Assert... -#include // for size_t, std -#include // for TestInfo (ptr only), ASSERT_THROW -#include // for string, allocator, basic_string -#include // for vector - using namespace input; TEST_F(TestBoxSection, testKeyword) { EXPECT_EQ(_section->keyword(), "box"); } @@ -46,7 +47,10 @@ TEST_F(TestBoxSection, testNumberOfArguments) if (i != 4 && i != 7) { auto line = std::vector(i); - ASSERT_THROW(_section->process(line, *_engine), customException::RstFileException); + ASSERT_THROW( + _section->process(line, *_engine), + customException::RstFileException + ); } } @@ -58,22 +62,43 @@ TEST_F(TestBoxSection, testProcess) std::vector line = {"box", "1.0", "2.0", "3.0"}; _section->process(line, *_engine); - ASSERT_THAT(_engine->getSimulationBox().getBoxDimensions(), testing::ElementsAre(1.0, 2.0, 3.0)); - ASSERT_THAT(_engine->getSimulationBox().getBoxAngles(), testing::ElementsAre(90.0, 90.0, 90.0)); + ASSERT_THAT( + _engine->getSimulationBox().getBoxDimensions(), + testing::ElementsAre(1.0, 2.0, 3.0) + ); + ASSERT_THAT( + _engine->getSimulationBox().getBoxAngles(), + testing::ElementsAre(90.0, 90.0, 90.0) + ); line = {"box", "1.0", "2.0", "3.0", "90.0", "90.0", "70.0"}; _section->process(line, *_engine); - ASSERT_THAT(_engine->getSimulationBox().getBoxDimensions(), testing::ElementsAre(1.0, 2.0, 3.0)); - ASSERT_THAT(_engine->getSimulationBox().getBoxAngles(), testing::ElementsAre(90.0, 90.0, 70.0)); + ASSERT_THAT( + _engine->getSimulationBox().getBoxDimensions(), + testing::ElementsAre(1.0, 2.0, 3.0) + ); + ASSERT_THAT( + _engine->getSimulationBox().getBoxAngles(), + testing::ElementsAre(90.0, 90.0, 70.0) + ); line = {"box", "1.0", "2.0", "-3.0", "90.0", "90.0", "90.0"}; - ASSERT_THROW(_section->process(line, *_engine), customException::RstFileException); + ASSERT_THROW( + _section->process(line, *_engine), + customException::RstFileException + ); line = {"box", "1.0", "2.0", "3.0", "90.0", "90.0", "190.0"}; - ASSERT_THROW(_section->process(line, *_engine), customException::RstFileException); + ASSERT_THROW( + _section->process(line, *_engine), + customException::RstFileException + ); line = {"box", "1.0", "2.0", "3.0", "90.0", "90.0", "-90.0"}; - ASSERT_THROW(_section->process(line, *_engine), customException::RstFileException); + ASSERT_THROW( + _section->process(line, *_engine), + customException::RstFileException + ); EXPECT_EQ(settings::SimulationBoxSettings::getBoxSet(), true); -} \ No newline at end of file +} diff --git a/tests/src/input/restartFileSection/testNoseHooverSection.cpp b/tests/src/input/restartFileSection/testNoseHooverSection.cpp index 35e135aba..2acbf8ee3 100644 --- a/tests/src/input/restartFileSection/testNoseHooverSection.cpp +++ b/tests/src/input/restartFileSection/testNoseHooverSection.cpp @@ -20,19 +20,4 @@ ******************************************************************************/ -#include // for TestInfo (ptr only), TEST_F, InitG... - -// TEST_F(TestNoseHooverSection, testKeyword) { EXPECT_EQ(_section->keyword(), -// "chi"); } - -// TEST_F(TestNoseHooverSection, testIsHeader) { -// EXPECT_TRUE(_section->isHeader()); } - -// TEST_F(TestNoseHooverSection, testNumberOfArguments) { GTEST_SKIP(); } - -// TEST_F(TestNoseHooverSection, testProcess) -// { -// auto line = std::vector(0); -// ASSERT_THROW(_section->process(line, *_engine), -// customException::RstFileException); -// } \ No newline at end of file +#include diff --git a/tests/src/input/restartFileSection/testStepCountSection.cpp b/tests/src/input/restartFileSection/testStepCountSection.cpp index a1ab24831..efe692b71 100644 --- a/tests/src/input/restartFileSection/testStepCountSection.cpp +++ b/tests/src/input/restartFileSection/testStepCountSection.cpp @@ -26,9 +26,9 @@ #include // for string, allocator, basic_string #include // for vector -#include "exceptions.hpp" // for RstFileException, customException -#include "gtest/gtest.h" // for AssertionResult, Message, TestPart... -#include "restartFileSection.hpp" // for RstFileSection, readInput +#include "exceptions.hpp" // for RstFileException, customException +#include "gtest/gtest.h" // for AssertionResult, Message, TestPart... +#include "restartFileReader/restartFileSection.hpp" // for RstFileSection, readInput #include "testRestartFileSection.hpp" // for TestStepCountSection #include "timingsSettings.hpp" // for TimingsSettings @@ -73,4 +73,4 @@ TEST_F(TestStepCountSection, testProcess) line[1] = "1000"; _section->process(line, *_engine); EXPECT_EQ(settings::TimingsSettings::getStepCount(), 1000); -} \ No newline at end of file +} From 3cbfd3082432ef7889fc4aedf8b5855a42cb4e1b Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 13:48:40 +0200 Subject: [PATCH 34/44] cleanup: generalize engine type check --- tests/include/testUtils/testUtils.hpp | 42 +++++++++++++++++ tests/src/CMakeLists.txt | 3 +- tests/src/input/CMakeLists.txt | 1 + .../src/input/inputFileParsing/CMakeLists.txt | 1 + .../inputFileParsing/testGeneralParser.cpp | 24 +++------- tests/src/input/testInputFileReader.cpp | 5 +- tests/src/testUtils/CMakeLists.txt | 18 ++++++++ tests/src/testUtils/testUtils.cpp | 46 +++++++++++++++++++ 8 files changed, 119 insertions(+), 21 deletions(-) create mode 100644 tests/include/testUtils/testUtils.hpp create mode 100644 tests/src/testUtils/CMakeLists.txt create mode 100644 tests/src/testUtils/testUtils.cpp diff --git a/tests/include/testUtils/testUtils.hpp b/tests/include/testUtils/testUtils.hpp new file mode 100644 index 000000000..90eecc8a3 --- /dev/null +++ b/tests/include/testUtils/testUtils.hpp @@ -0,0 +1,42 @@ +/***************************************************************************** + + + PQ + Copyright (C) 2023-now Jakob Gamper + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + +******************************************************************************/ + +#ifndef _TEST_UTILS_HPP_ + +#define _TEST_UTILS_HPP_ + +#include + +#include +#include + +#include "typeAliases.hpp" + +namespace test +{ + void checkEngineType( + const std::unique_ptr& engine, + const std::type_info& expectedType + ); +} // namespace test + +#endif // _TEST_UTILS_HPP_ diff --git a/tests/src/CMakeLists.txt b/tests/src/CMakeLists.txt index 8eed268f8..fdd7b280d 100644 --- a/tests/src/CMakeLists.txt +++ b/tests/src/CMakeLists.txt @@ -21,4 +21,5 @@ add_subdirectory(box) add_subdirectory(kernels) add_subdirectory(opt) add_subdirectory(main) -add_subdirectory(randomNumberGenerator) \ No newline at end of file +add_subdirectory(randomNumberGenerator) +add_subdirectory(testUtils) diff --git a/tests/src/input/CMakeLists.txt b/tests/src/input/CMakeLists.txt index 3bfb7a4c9..9a1c60e14 100644 --- a/tests/src/input/CMakeLists.txt +++ b/tests/src/input/CMakeLists.txt @@ -27,6 +27,7 @@ foreach(source_file ${source_files}) gtest gmock pq_test_main + testUtils ) add_test( NAME ${test_name} diff --git a/tests/src/input/inputFileParsing/CMakeLists.txt b/tests/src/input/inputFileParsing/CMakeLists.txt index cdb9c8268..c40961192 100644 --- a/tests/src/input/inputFileParsing/CMakeLists.txt +++ b/tests/src/input/inputFileParsing/CMakeLists.txt @@ -38,6 +38,7 @@ foreach(source_file ${source_files}) gtest gmock pq_test_main + testUtils ) add_test( NAME ${test_name} diff --git a/tests/src/input/inputFileParsing/testGeneralParser.cpp b/tests/src/input/inputFileParsing/testGeneralParser.cpp index f94f40c47..e22643cf2 100644 --- a/tests/src/input/inputFileParsing/testGeneralParser.cpp +++ b/tests/src/input/inputFileParsing/testGeneralParser.cpp @@ -37,24 +37,12 @@ #include "ringPolymerqmmdEngine.hpp" // for RingPolymerQMMDEngine #include "settings.hpp" // for Settings #include "testInputFileReader.hpp" // for TestInputFileReader +#include "testUtils.hpp" // for checkEngineType #include "throwWithMessage.hpp" // for EXPECT_THROW_MSG using namespace input; using namespace settings; -namespace -{ - void checkEngineType( - const std::unique_ptr& engine, - const std::type_info& expectedType - ) - { - ASSERT_NE(engine, nullptr) << "Engine pointer is null"; - const auto& engineRef = *engine; - EXPECT_EQ(typeid(engineRef), expectedType); - } -} // namespace - /** * @brief tests parsing the "jobtype" command * @@ -70,33 +58,33 @@ TEST_F(TestInputFileReader, JobType) parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::MM_MD); EXPECT_EQ(Settings::isMMActivated(), true); - checkEngineType(engine, typeid(engine::MMMDEngine)); + test::checkEngineType(engine, typeid(engine::MMMDEngine)); lineElements = {"jobtype", "=", "qm-md"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::QM_MD); EXPECT_EQ(Settings::isQMActivated(), true); - checkEngineType(engine, typeid(engine::QMMDEngine)); + test::checkEngineType(engine, typeid(engine::QMMDEngine)); lineElements = {"jobtype", "=", "qm-rpmd"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::RING_POLYMER_QM_MD); EXPECT_EQ(Settings::isQMActivated(), true); EXPECT_EQ(Settings::isRingPolymerMDActivated(), true); - checkEngineType(engine, typeid(engine::RingPolymerQMMDEngine)); + test::checkEngineType(engine, typeid(engine::RingPolymerQMMDEngine)); lineElements = {"jobtype", "=", "mm-opt"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::MM_OPT); EXPECT_EQ(Settings::isOptJobType(), true); EXPECT_EQ(Settings::isMMActivated(), true); - checkEngineType(engine, typeid(engine::OptEngine)); + test::checkEngineType(engine, typeid(engine::OptEngine)); lineElements = {"jobtype", "=", "mm-hessian"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::MM_HESSIAN); EXPECT_EQ(Settings::isMMActivated(), true); - checkEngineType(engine, typeid(engine::HessianEngine)); + test::checkEngineType(engine, typeid(engine::HessianEngine)); lineElements = {"jobtype", "=", "notValid"}; EXPECT_THROW_MSG( diff --git a/tests/src/input/testInputFileReader.cpp b/tests/src/input/testInputFileReader.cpp index 90a0b34cc..f6a8faac0 100644 --- a/tests/src/input/testInputFileReader.cpp +++ b/tests/src/input/testInputFileReader.cpp @@ -35,6 +35,7 @@ #include "mmmdEngine.hpp" #include "potentialSettings.hpp" #include "settings.hpp" +#include "testUtils.hpp" #include "throwWithMessage.hpp" using namespace input; @@ -302,7 +303,7 @@ TEST_F(TestInputFileReader, testReadJobType) auto engine = std::unique_ptr(); ASSERT_NO_THROW(input::readJobType(filename, engine)); EXPECT_EQ(settings::Settings::getJobtype(), settings::JobType::MM_MD); - EXPECT_EQ(typeid(*engine), typeid(engine::MMMDEngine)); + test::checkEngineType(engine, typeid(engine::MMMDEngine)); filename = "fileNotFound"; ASSERT_THROW_MSG( @@ -317,4 +318,4 @@ TEST_F(TestInputFileReader, testReadJobType) customException::InputFileException, "Missing keyword \"jobtype\" in input file" ); -} \ No newline at end of file +} diff --git a/tests/src/testUtils/CMakeLists.txt b/tests/src/testUtils/CMakeLists.txt new file mode 100644 index 000000000..fd5de5859 --- /dev/null +++ b/tests/src/testUtils/CMakeLists.txt @@ -0,0 +1,18 @@ +add_library(testUtils + testUtils.cpp +) + +target_include_directories(testUtils + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/tests/include/testUtils/ +) + +target_link_libraries(testUtils + PUBLIC + engine +) + +install(TARGETS testUtils + DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/ +) diff --git a/tests/src/testUtils/testUtils.cpp b/tests/src/testUtils/testUtils.cpp new file mode 100644 index 000000000..b994500e2 --- /dev/null +++ b/tests/src/testUtils/testUtils.cpp @@ -0,0 +1,46 @@ +/***************************************************************************** + + + PQ + Copyright (C) 2023-now Jakob Gamper + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + +******************************************************************************/ + +#include "testUtils.hpp" + +#include + +#include "engine.hpp" + +namespace test +{ + /** + * @brief check if engine is of expected type + * + * @param engine + * @param expectedType + */ + void checkEngineType( + const std::unique_ptr& engine, + const std::type_info& expectedType + ) + { + ASSERT_NE(engine, nullptr); + const auto& engineRef = *engine; + EXPECT_EQ(typeid(engineRef), expectedType); + } +} // namespace test From bef34c5967c33e80cb2144ae709a6b19e58d11ed Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 13:50:47 +0200 Subject: [PATCH 35/44] cleanup: remove unused headers --- tests/src/input/testMoldescriptorReader.cpp | 95 +++++++++++++------ tests/src/integrator/testIntegrator.cpp | 7 +- .../src/intraNonBonded/testIntraNonBonded.cpp | 3 +- tests/src/manostat/testManostat.cpp | 1 - .../nonCoulomb/testBuckinghamPair.cpp | 3 +- .../nonCoulomb/testLennardJonesPair.cpp | 3 +- .../potential/nonCoulomb/testMorsePair.cpp | 7 +- tests/src/setup/testCelllistSetup.cpp | 2 - 8 files changed, 77 insertions(+), 44 deletions(-) diff --git a/tests/src/input/testMoldescriptorReader.cpp b/tests/src/input/testMoldescriptorReader.cpp index 1c4841aa4..58d5b6db3 100644 --- a/tests/src/input/testMoldescriptorReader.cpp +++ b/tests/src/input/testMoldescriptorReader.cpp @@ -20,17 +20,16 @@ ******************************************************************************/ +#include // for TestInfo (ptr only), TEST_F + #include "engine.hpp" // for Engine #include "exceptions.hpp" // for MolDescriptorException #include "fileSettings.hpp" // for FileSettings +#include "gtest/gtest.h" // for Message, TestPartResult, testing #include "moldescriptorReader.hpp" // for MoldescriptorReader #include "testMoldesctripotReader.hpp" // for TestMoldescriptorReader #include "throwWithMessage.hpp" // for ASSERT_THROW_MSG -#include "gtest/gtest.h" // for Message, TestPartResult, testing -#include // for TestInfo (ptr only), TEST_F -#include // for allocator, basic_string - using namespace std; using namespace ::testing; using namespace input::molDescriptor; @@ -42,7 +41,9 @@ using namespace customException; */ TEST_F(TestMoldescriptorReader, constructor) { - settings::FileSettings::setMolDescriptorFileName("data/moldescriptorReader/moldescriptor.dat"); + settings::FileSettings::setMolDescriptorFileName( + "data/moldescriptorReader/moldescriptor.dat" + ); ASSERT_NO_THROW(MoldescriptorReader reader(*_engine)); } @@ -52,9 +53,15 @@ TEST_F(TestMoldescriptorReader, constructor) */ TEST_F(TestMoldescriptorReader, argumentsInMoldescriptor) { - settings::FileSettings::setMolDescriptorFileName("data/moldescriptorReader/moldescriptorWithOneWordLine.dat"); + settings::FileSettings::setMolDescriptorFileName( + "data/moldescriptorReader/moldescriptorWithOneWordLine.dat" + ); MoldescriptorReader reader(*_engine); - ASSERT_THROW_MSG(reader.read(), MolDescriptorException, "Error in moldescriptor file at line 1"); + ASSERT_THROW_MSG( + reader.read(), + MolDescriptorException, + "Error in moldescriptor file at line 1" + ); } /** @@ -63,19 +70,35 @@ TEST_F(TestMoldescriptorReader, argumentsInMoldescriptor) */ TEST_F(TestMoldescriptorReader, argumentsInMoleculeSection) { - settings::FileSettings::setMolDescriptorFileName("data/moldescriptorReader/moldescriptorWithErrorInAtomArguments.dat"); + settings::FileSettings::setMolDescriptorFileName( + "data/moldescriptorReader/moldescriptorWithErrorInAtomArguments.dat" + ); MoldescriptorReader reader(*_engine); ASSERT_THROW_MSG( - reader.read(), MolDescriptorException, "Atom line in moldescriptor file at line 4 has to have 3 or 4 elements"); - - settings::FileSettings::setMolDescriptorFileName("data/moldescriptorReader/moldescriptorWithErrorInAtomArguments2.dat"); + reader.read(), + MolDescriptorException, + "Atom line in moldescriptor file at line 4 has to have 3 or 4 elements" + ); + + settings::FileSettings::setMolDescriptorFileName( + "data/moldescriptorReader/moldescriptorWithErrorInAtomArguments2.dat" + ); MoldescriptorReader reader2(*_engine); ASSERT_THROW_MSG( - reader2.read(), MolDescriptorException, "Atom line in moldescriptor file at line 5 has to have 3 or 4 elements"); - - settings::FileSettings::setMolDescriptorFileName("data/moldescriptorReader/moldescriptorWithErrorInMolArguments.dat"); + reader2.read(), + MolDescriptorException, + "Atom line in moldescriptor file at line 5 has to have 3 or 4 elements" + ); + + settings::FileSettings::setMolDescriptorFileName( + "data/moldescriptorReader/moldescriptorWithErrorInMolArguments.dat" + ); MoldescriptorReader reader3(*_engine); - ASSERT_THROW_MSG(reader3.read(), MolDescriptorException, "Not enough arguments in moldescriptor file at line 3"); + ASSERT_THROW_MSG( + reader3.read(), + MolDescriptorException, + "Not enough arguments in moldescriptor file at line 3" + ); } /** @@ -84,7 +107,9 @@ TEST_F(TestMoldescriptorReader, argumentsInMoleculeSection) */ TEST_F(TestMoldescriptorReader, moldescriptorReader) { - settings::FileSettings::setMolDescriptorFileName("examples/setup/moldescriptor.dat"); + settings::FileSettings::setMolDescriptorFileName( + "examples/setup/moldescriptor.dat" + ); MoldescriptorReader reader(*_engine); ASSERT_NO_THROW(reader.read()); } @@ -95,7 +120,9 @@ TEST_F(TestMoldescriptorReader, moldescriptorReader) */ TEST_F(TestMoldescriptorReader, specialTypes) { - settings::FileSettings::setMolDescriptorFileName("examples/setup/moldescriptor.dat"); + settings::FileSettings::setMolDescriptorFileName( + "examples/setup/moldescriptor.dat" + ); readMolDescriptor(*_engine); ASSERT_EQ(_engine->getSimulationBox().getWaterType(), 1); ASSERT_EQ(_engine->getSimulationBox().getAmmoniaType(), 2); @@ -107,26 +134,40 @@ TEST_F(TestMoldescriptorReader, specialTypes) */ TEST_F(TestMoldescriptorReader, toManyAtomsPerMoltype) { - settings::FileSettings::setMolDescriptorFileName("data/moldescriptorReader/moldescriptorTooManyAtomsPerMoltype.dat"); + settings::FileSettings::setMolDescriptorFileName( + "data/moldescriptorReader/moldescriptorTooManyAtomsPerMoltype.dat" + ); MoldescriptorReader reader2(*_engine); ASSERT_THROW_MSG( - reader2.read(), MolDescriptorException, "Error reading of moldescriptor stopped before last molecule was finished"); + reader2.read(), + MolDescriptorException, + "Error reading of moldescriptor stopped before last molecule was " + "finished" + ); } /** - * @brief tests if non coulombic force field is activated but no global can der Waals parameter given + * @brief tests if non coulombic force field is activated but no global can der + * Waals parameter given * */ TEST_F(TestMoldescriptorReader, globalVdwTypes) { _engine->getForceFieldPtr()->activateNonCoulombic(); - settings::FileSettings::setMolDescriptorFileName("data/moldescriptorReader/moldescriptor_withGlobalVdwTypes.dat"); + settings::FileSettings::setMolDescriptorFileName( + "data/moldescriptorReader/moldescriptor_withGlobalVdwTypes.dat" + ); EXPECT_NO_THROW(readMolDescriptor(*_engine)); - settings::FileSettings::setMolDescriptorFileName("data/moldescriptorReader/moldescriptor_withMissingGlobalVdwTypes.dat"); - EXPECT_THROW_MSG(readMolDescriptor(*_engine), - MolDescriptorException, - "Error in moldescriptor file at line 6 - force field noncoulombics is activated but no global van der Waals " - "parameter given"); -} \ No newline at end of file + settings::FileSettings::setMolDescriptorFileName( + "data/moldescriptorReader/moldescriptor_withMissingGlobalVdwTypes.dat" + ); + EXPECT_THROW_MSG( + readMolDescriptor(*_engine), + MolDescriptorException, + "Error in moldescriptor file at line 6 - force field noncoulombics is " + "activated but no global van der Waals " + "parameter given" + ); +} diff --git a/tests/src/integrator/testIntegrator.cpp b/tests/src/integrator/testIntegrator.cpp index 21f008981..e3a7b6001 100644 --- a/tests/src/integrator/testIntegrator.cpp +++ b/tests/src/integrator/testIntegrator.cpp @@ -22,12 +22,11 @@ #include "testIntegrator.hpp" -#include // for string #include // for vector -#include "constants/conversionFactors.hpp" // for _FS_TO_S_ -#include "constants/internalConversionFactors.hpp" // for _V_VERLET_VELOCITY_FACTOR_ -#include "gtest/gtest.h" // for CmpHelperFloatingPointEQ, Message, Test, TestPartResult, EXPECT_EQ, EXPECT_DOUBLE_EQ, EXPECT_TRUE, TestPartResultArray, InitGoogleTest, RUN_ALL_TESTS +#include "constants/conversionFactors.hpp" +#include "constants/internalConversionFactors.hpp" +#include "gtest/gtest.h" /** * @brief tests function integrate velocities of velocity verlet integrator diff --git a/tests/src/intraNonBonded/testIntraNonBonded.cpp b/tests/src/intraNonBonded/testIntraNonBonded.cpp index 2f1610e6b..9235fe3af 100644 --- a/tests/src/intraNonBonded/testIntraNonBonded.cpp +++ b/tests/src/intraNonBonded/testIntraNonBonded.cpp @@ -25,7 +25,6 @@ #include // for size_t #include // for format #include // for shared_ptr, allocator, make_shared -#include // for basic_string #include // for vector #include "atom.hpp" // for Atom @@ -222,4 +221,4 @@ TEST(TestIntraNonBonded, calculate) std::make_shared(nonCoulombPotential) ); EXPECT_NO_THROW(intraNonBonded.calculate(simulationBox, physicalData)); -} \ No newline at end of file +} diff --git a/tests/src/manostat/testManostat.cpp b/tests/src/manostat/testManostat.cpp index be8034523..8a964478e 100644 --- a/tests/src/manostat/testManostat.cpp +++ b/tests/src/manostat/testManostat.cpp @@ -24,7 +24,6 @@ #include // for pow #include // for make_shared, __shared_ptr_access -#include // for string, allocator #include "atom.hpp" // for Atom #include "berendsenManostat.hpp" // for BerendsenManostat diff --git a/tests/src/potential/nonCoulomb/testBuckinghamPair.cpp b/tests/src/potential/nonCoulomb/testBuckinghamPair.cpp index b85e9ff65..f5b225a06 100644 --- a/tests/src/potential/nonCoulomb/testBuckinghamPair.cpp +++ b/tests/src/potential/nonCoulomb/testBuckinghamPair.cpp @@ -24,7 +24,6 @@ #include // for pow, exp #include // for size_t -#include // for string #include // for vector #include "buckinghamPair.hpp" // for BuckinghamPair @@ -108,4 +107,4 @@ TEST(TestBuckinghamPair, calculateEnergyAndForces) -helper * coefficients[1] + 6.0 * coefficients[2] / ::pow(distance, 7) - forceCutoff ); -} \ No newline at end of file +} diff --git a/tests/src/potential/nonCoulomb/testLennardJonesPair.cpp b/tests/src/potential/nonCoulomb/testLennardJonesPair.cpp index 34b2cedb4..f733cce35 100644 --- a/tests/src/potential/nonCoulomb/testLennardJonesPair.cpp +++ b/tests/src/potential/nonCoulomb/testLennardJonesPair.cpp @@ -24,7 +24,6 @@ #include // for pow #include // for size_t -#include // for string #include // for vector #include "gtest/gtest.h" // for AssertionResult, Message, TestPartResult @@ -102,4 +101,4 @@ TEST(TestLennardJonesPair, calculateEnergyAndForces) 6 * coefficients[0] / ::pow(distance, 7) + 12 * coefficients[1] / ::pow(distance, 13) - forceCutoff ); -} \ No newline at end of file +} diff --git a/tests/src/potential/nonCoulomb/testMorsePair.cpp b/tests/src/potential/nonCoulomb/testMorsePair.cpp index 1abbb8aee..fa317471e 100644 --- a/tests/src/potential/nonCoulomb/testMorsePair.cpp +++ b/tests/src/potential/nonCoulomb/testMorsePair.cpp @@ -24,11 +24,10 @@ #include // for exp, pow #include // for size_t -#include // for string #include // for vector -#include "gtest/gtest.h" // for AssertionResult, Message, TestPartResult -#include "morsePair.hpp" // for MorsePair +#include "gtest/gtest.h" // for AssertionResult, Message, TestPartResult +#include "morsePair.hpp" // for MorsePair using namespace potential; @@ -108,4 +107,4 @@ TEST(TestMorsePair, calculateEnergyAndForces) -2 * coefficients[0] * coefficients[1] * (1 - expTerm) * expTerm - forceCutoff ); -} \ No newline at end of file +} diff --git a/tests/src/setup/testCelllistSetup.cpp b/tests/src/setup/testCelllistSetup.cpp index ce1ce6261..d1523b383 100644 --- a/tests/src/setup/testCelllistSetup.cpp +++ b/tests/src/setup/testCelllistSetup.cpp @@ -22,8 +22,6 @@ #include // for InitGoogleTest, RUN_ALL_TESTS, EXPECT_EQ -#include // for allocator, basic_string - #include "celllistSetup.hpp" // for CellListSetup, setupCellList, setup #include "engine.hpp" // for Engine #include "gtest/gtest.h" // for Message, TestPartResult From c8f8d89e7603313231de209401eb163aa1bb265b Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 13:54:44 +0200 Subject: [PATCH 36/44] cleanup: add type checking approach in tests also for potential types --- tests/include/testUtils/testUtils.hpp | 5 +++++ tests/src/setup/CMakeLists.txt | 3 ++- tests/src/setup/testCelllistSetup.cpp | 9 +++++---- tests/src/testUtils/testUtils.cpp | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/include/testUtils/testUtils.hpp b/tests/include/testUtils/testUtils.hpp index 90eecc8a3..ea7b94cd8 100644 --- a/tests/include/testUtils/testUtils.hpp +++ b/tests/include/testUtils/testUtils.hpp @@ -37,6 +37,11 @@ namespace test const std::unique_ptr& engine, const std::type_info& expectedType ); + + void checkPotentialType( + const potential::Potential* potential, + const std::type_info& expectedType + ); } // namespace test #endif // _TEST_UTILS_HPP_ diff --git a/tests/src/setup/CMakeLists.txt b/tests/src/setup/CMakeLists.txt index e78caf8fb..5936e455a 100644 --- a/tests/src/setup/CMakeLists.txt +++ b/tests/src/setup/CMakeLists.txt @@ -33,6 +33,7 @@ foreach(source_file ${source_files}) gtest gmock pq_test_main + testUtils ) add_test( NAME ${test_name} @@ -54,4 +55,4 @@ if(${BUILD_WITH_GCOVR}) EXECUTABLE_ARGS "-L;setup" OUTPUT_PATH "coverage" ) -endif() \ No newline at end of file +endif() diff --git a/tests/src/setup/testCelllistSetup.cpp b/tests/src/setup/testCelllistSetup.cpp index d1523b383..f34d01a7e 100644 --- a/tests/src/setup/testCelllistSetup.cpp +++ b/tests/src/setup/testCelllistSetup.cpp @@ -29,6 +29,7 @@ #include "potentialCellList.hpp" // for PotentialCellList #include "potentialSettings.hpp" #include "testSetup.hpp" // for TestSetup +#include "testUtils.hpp" // for checkPotentialType using namespace setup; @@ -41,8 +42,8 @@ TEST_F(TestSetup, setupCellList) CellListSetup cellListSetup(*_engine); cellListSetup.setup(); - EXPECT_EQ( - typeid((_engine->getPotential())), + test::checkPotentialType( + &_engine->getPotential(), typeid(potential::PotentialBruteForce) ); @@ -52,8 +53,8 @@ TEST_F(TestSetup, setupCellList) _engine->getCellList().activate(); cellListSetup.setup(); - EXPECT_EQ( - typeid((_engine->getPotential())), + test::checkPotentialType( + &_engine->getPotential(), typeid(potential::PotentialCellList) ); diff --git a/tests/src/testUtils/testUtils.cpp b/tests/src/testUtils/testUtils.cpp index b994500e2..4e7567aec 100644 --- a/tests/src/testUtils/testUtils.cpp +++ b/tests/src/testUtils/testUtils.cpp @@ -43,4 +43,19 @@ namespace test const auto& engineRef = *engine; EXPECT_EQ(typeid(engineRef), expectedType); } + + /** + * @brief check if potential is of expected type + * + * @param potential + * @param expectedType + */ + void checkPotentialType( + const potential::Potential* potential, + const std::type_info& expectedType + ) + { + ASSERT_NE(potential, nullptr); + EXPECT_EQ(typeid(*potential), expectedType); + } } // namespace test From 319b3541817407634c42a8db047b26b8be5ee77b Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 14:29:24 +0200 Subject: [PATCH 37/44] cleanup: generalize template approach for type checking --- tests/include/testUtils/testUtils.hpp | 14 +---- .../inputFileParsing/testGeneralParser.cpp | 14 ++--- tests/src/input/testInputFileReader.cpp | 2 +- tests/src/setup/testCelllistSetup.cpp | 6 +- tests/src/setup/testConstraintsSetup.cpp | 4 +- tests/src/setup/testManostatSetup.cpp | 6 +- tests/src/setup/testPotentialSetup.cpp | 24 +++---- tests/src/setup/testQMSetup.cpp | 34 ++++------ tests/src/testUtils/CMakeLists.txt | 3 + tests/src/testUtils/testUtils.cpp | 62 ++++++++++++------- 10 files changed, 83 insertions(+), 86 deletions(-) diff --git a/tests/include/testUtils/testUtils.hpp b/tests/include/testUtils/testUtils.hpp index ea7b94cd8..1e2468f53 100644 --- a/tests/include/testUtils/testUtils.hpp +++ b/tests/include/testUtils/testUtils.hpp @@ -26,22 +26,12 @@ #include -#include #include -#include "typeAliases.hpp" - namespace test { - void checkEngineType( - const std::unique_ptr& engine, - const std::type_info& expectedType - ); - - void checkPotentialType( - const potential::Potential* potential, - const std::type_info& expectedType - ); + template + void checkType(const T& obj, const std::type_info& expectedType); } // namespace test #endif // _TEST_UTILS_HPP_ diff --git a/tests/src/input/inputFileParsing/testGeneralParser.cpp b/tests/src/input/inputFileParsing/testGeneralParser.cpp index e22643cf2..7e8f53696 100644 --- a/tests/src/input/inputFileParsing/testGeneralParser.cpp +++ b/tests/src/input/inputFileParsing/testGeneralParser.cpp @@ -37,8 +37,8 @@ #include "ringPolymerqmmdEngine.hpp" // for RingPolymerQMMDEngine #include "settings.hpp" // for Settings #include "testInputFileReader.hpp" // for TestInputFileReader -#include "testUtils.hpp" // for checkEngineType -#include "throwWithMessage.hpp" // for EXPECT_THROW_MSG +#include "testUtils.hpp" +#include "throwWithMessage.hpp" // for EXPECT_THROW_MSG using namespace input; using namespace settings; @@ -58,33 +58,33 @@ TEST_F(TestInputFileReader, JobType) parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::MM_MD); EXPECT_EQ(Settings::isMMActivated(), true); - test::checkEngineType(engine, typeid(engine::MMMDEngine)); + test::checkType(engine, typeid(engine::MMMDEngine)); lineElements = {"jobtype", "=", "qm-md"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::QM_MD); EXPECT_EQ(Settings::isQMActivated(), true); - test::checkEngineType(engine, typeid(engine::QMMDEngine)); + test::checkType(engine, typeid(engine::QMMDEngine)); lineElements = {"jobtype", "=", "qm-rpmd"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::RING_POLYMER_QM_MD); EXPECT_EQ(Settings::isQMActivated(), true); EXPECT_EQ(Settings::isRingPolymerMDActivated(), true); - test::checkEngineType(engine, typeid(engine::RingPolymerQMMDEngine)); + test::checkType(engine, typeid(engine::RingPolymerQMMDEngine)); lineElements = {"jobtype", "=", "mm-opt"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::MM_OPT); EXPECT_EQ(Settings::isOptJobType(), true); EXPECT_EQ(Settings::isMMActivated(), true); - test::checkEngineType(engine, typeid(engine::OptEngine)); + test::checkType(engine, typeid(engine::OptEngine)); lineElements = {"jobtype", "=", "mm-hessian"}; parser.parseJobTypeForEngine(lineElements, 0, engine); EXPECT_EQ(Settings::getJobtype(), JobType::MM_HESSIAN); EXPECT_EQ(Settings::isMMActivated(), true); - test::checkEngineType(engine, typeid(engine::HessianEngine)); + test::checkType(engine, typeid(engine::HessianEngine)); lineElements = {"jobtype", "=", "notValid"}; EXPECT_THROW_MSG( diff --git a/tests/src/input/testInputFileReader.cpp b/tests/src/input/testInputFileReader.cpp index f6a8faac0..721a9e21a 100644 --- a/tests/src/input/testInputFileReader.cpp +++ b/tests/src/input/testInputFileReader.cpp @@ -303,7 +303,7 @@ TEST_F(TestInputFileReader, testReadJobType) auto engine = std::unique_ptr(); ASSERT_NO_THROW(input::readJobType(filename, engine)); EXPECT_EQ(settings::Settings::getJobtype(), settings::JobType::MM_MD); - test::checkEngineType(engine, typeid(engine::MMMDEngine)); + test::checkType(engine, typeid(engine::MMMDEngine)); filename = "fileNotFound"; ASSERT_THROW_MSG( diff --git a/tests/src/setup/testCelllistSetup.cpp b/tests/src/setup/testCelllistSetup.cpp index f34d01a7e..425d642a1 100644 --- a/tests/src/setup/testCelllistSetup.cpp +++ b/tests/src/setup/testCelllistSetup.cpp @@ -29,7 +29,7 @@ #include "potentialCellList.hpp" // for PotentialCellList #include "potentialSettings.hpp" #include "testSetup.hpp" // for TestSetup -#include "testUtils.hpp" // for checkPotentialType +#include "testUtils.hpp" using namespace setup; @@ -42,7 +42,7 @@ TEST_F(TestSetup, setupCellList) CellListSetup cellListSetup(*_engine); cellListSetup.setup(); - test::checkPotentialType( + test::checkType( &_engine->getPotential(), typeid(potential::PotentialBruteForce) ); @@ -53,7 +53,7 @@ TEST_F(TestSetup, setupCellList) _engine->getCellList().activate(); cellListSetup.setup(); - test::checkPotentialType( + test::checkType( &_engine->getPotential(), typeid(potential::PotentialCellList) ); diff --git a/tests/src/setup/testConstraintsSetup.cpp b/tests/src/setup/testConstraintsSetup.cpp index b4f0dd1b0..7b5b52a5a 100644 --- a/tests/src/setup/testConstraintsSetup.cpp +++ b/tests/src/setup/testConstraintsSetup.cpp @@ -22,8 +22,6 @@ #include // for TestInfo (ptr only), EXPECT_EQ, Init... -#include // for allocator, basic_string - #include "constraintSettings.hpp" // for getShakeMaxIter, getShakeTolerance, getRattleMaxIter, getRattleTolerance #include "constraintsSetup.hpp" // for ConstraintsSetup, setupConstraints #include "engine.hpp" // for Engine @@ -87,4 +85,4 @@ TEST_F(TestSetup, setupConstraints) _engine->getConstraints().getShakeTolerance(); EXPECT_NE(shakeToleranceDeactivated, shakeToleranceActivated); -} \ No newline at end of file +} diff --git a/tests/src/setup/testManostatSetup.cpp b/tests/src/setup/testManostatSetup.cpp index 9d2c3acae..67c4dd154 100644 --- a/tests/src/setup/testManostatSetup.cpp +++ b/tests/src/setup/testManostatSetup.cpp @@ -22,8 +22,6 @@ #include // for EXPECT_EQ, EXPECT_NO_THROW, InitGoog... -#include // for allocator, basic_string - #include "berendsenManostat.hpp" // for BerendsenManostat #include "gtest/gtest.h" // for Message, TestPartResult #include "manostat.hpp" // for BerendsenManostat, Manostat @@ -88,8 +86,8 @@ TEST_F(TestSetup, setupManostatNoneIsotropyDefaultsToIsotropic) ManostatSetup manostatSetup(*_mdEngine); EXPECT_NO_THROW(manostatSetup.setup()); - const auto &manostat = _mdEngine->getManostat(); - const auto berendsen = dynamic_cast(manostat); + const auto &manostat = _mdEngine->getManostat(); + const auto berendsen = dynamic_cast(manostat); EXPECT_EQ(berendsen.getIsotropy(), Isotropy::ISOTROPIC); } diff --git a/tests/src/setup/testPotentialSetup.cpp b/tests/src/setup/testPotentialSetup.cpp index b43e2b8aa..2102b85d2 100644 --- a/tests/src/setup/testPotentialSetup.cpp +++ b/tests/src/setup/testPotentialSetup.cpp @@ -24,7 +24,6 @@ #include // for size_t #include // for make_shared -#include // for allocator, basic_string #include "coulombReactionField.hpp" // for CoulombReactionField #include "coulombShiftedPotential.hpp" // for CoulombShiftedPotential @@ -39,7 +38,8 @@ #include "potentialSettings.hpp" // for PotentialSettings #include "potentialSetup.hpp" // for PotentialSetup, setupPotential #include "testSetup.hpp" // for TestSetup -#include "throwWithMessage.hpp" // for EXPECT_THROW_MSG +#include "testUtils.hpp" +#include "throwWithMessage.hpp" // for EXPECT_THROW_MSG using namespace setup; using namespace settings; @@ -55,8 +55,8 @@ TEST_F(TestSetup, setupReactionFieldPotential) PotentialSettings::setReactionFieldEpsilon(80.0); EXPECT_NO_THROW(potentialSetup.setup()); - EXPECT_EQ( - typeid(_engine->getPotential().getCoulombPotential()), + test::checkType( + &(_engine->getPotential().getCoulombPotential()), typeid(CoulombReactionField) ); @@ -72,8 +72,8 @@ TEST_F(TestSetup, setupCoulombPotential) PotentialSetup potentialSetup(*_engine); potentialSetup.setupCoulomb(); - EXPECT_EQ( - typeid(_engine->getPotential().getCoulombPotential()), + test::checkType( + &_engine->getPotential().getCoulombPotential(), typeid(CoulombShiftedPotential) ); @@ -81,8 +81,8 @@ TEST_F(TestSetup, setupCoulombPotential) PotentialSetup potentialSetup2(*_engine); potentialSetup2.setup(); - EXPECT_EQ( - typeid(_engine->getPotential().getCoulombPotential()), + test::checkType( + &_engine->getPotential().getCoulombPotential(), typeid(CoulombWolf) ); const auto &wolfCoulomb = dynamic_cast( @@ -101,8 +101,8 @@ TEST_F(TestSetup, setupNonCoulombPotential) PotentialSetup potentialSetup(*_engine); potentialSetup.setupNonCoulomb(); - EXPECT_EQ( - typeid(_engine->getPotential().getNonCoulombPotential()), + test::checkType( + &_engine->getPotential().getNonCoulombPotential(), typeid(ForceFieldNonCoulomb) ); @@ -110,8 +110,8 @@ TEST_F(TestSetup, setupNonCoulombPotential) PotentialSetup potentialSetup2(*_engine); potentialSetup2.setupNonCoulomb(); - EXPECT_EQ( - typeid(_engine->getPotential().getNonCoulombPotential()), + test::checkType( + &_engine->getPotential().getNonCoulombPotential(), typeid(GuffNonCoulomb) ); } diff --git a/tests/src/setup/testQMSetup.cpp b/tests/src/setup/testQMSetup.cpp index 6844ef999..258407021 100644 --- a/tests/src/setup/testQMSetup.cpp +++ b/tests/src/setup/testQMSetup.cpp @@ -25,15 +25,16 @@ #include // for allocator, basic_string #include // for string_view -#include "dftbplusRunner.hpp" // for DFTBPlusRunner -#include "exceptions.hpp" // for InputFileException -#include "gtest/gtest.h" // for Message, TestPartResult -#include "pyscfRunner.hpp" // for PySCFRunner -#include "qmSettings.hpp" // for QMMethod, QMSettings -#include "qmSetup.hpp" // for QMSetup, setupQM -#include "qmSetup.hpp" // for QMSetup -#include "qmmdEngine.hpp" // for QMMDEngine -#include "settings.hpp" // for Settings +#include "dftbplusRunner.hpp" // for DFTBPlusRunner +#include "exceptions.hpp" // for InputFileException +#include "gtest/gtest.h" // for Message, TestPartResult +#include "pyscfRunner.hpp" // for PySCFRunner +#include "qmSettings.hpp" // for QMMethod, QMSettings +#include "qmSetup.hpp" // for QMSetup, setupQM +#include "qmSetup.hpp" // for QMSetup +#include "qmmdEngine.hpp" // for QMMDEngine +#include "settings.hpp" // for Settings +#include "testUtils.hpp" #include "throwWithMessage.hpp" // for ASSERT_THROW_MSG #include "turbomoleRunner.hpp" // for TurbomoleRunner @@ -64,10 +65,7 @@ TEST(TestQMSetup, setupDftbplus) setBuildCompatibleQMScript(); setupQM.setup(); - EXPECT_EQ( - typeid(dynamic_cast(*engine.getQMRunner())), - typeid(QM::DFTBPlusRunner) - ); + test::checkType(engine.getQMRunner(), typeid(QM::DFTBPlusRunner)); settings::QMSettings::setQMMethod(settings::QMMethod::NONE); @@ -88,10 +86,7 @@ TEST(TestQMSetup, setupPySCF) setBuildCompatibleQMScript(); setupQM.setup(); - EXPECT_EQ( - typeid(dynamic_cast(*engine.getQMRunner())), - typeid(QM::PySCFRunner) - ); + test::checkType(engine.getQMRunner(), typeid(QM::PySCFRunner)); settings::QMSettings::setQMMethod(settings::QMMethod::NONE); @@ -112,10 +107,7 @@ TEST(TestQMSetup, setupTurbomoleRunner) setBuildCompatibleQMScript(); setupQM.setup(); - EXPECT_EQ( - typeid(dynamic_cast(*engine.getQMRunner())), - typeid(QM::TurbomoleRunner) - ); + test::checkType(engine.getQMRunner(), typeid(QM::TurbomoleRunner)); settings::QMSettings::setQMMethod(settings::QMMethod::NONE); diff --git a/tests/src/testUtils/CMakeLists.txt b/tests/src/testUtils/CMakeLists.txt index fd5de5859..dc8dda4d9 100644 --- a/tests/src/testUtils/CMakeLists.txt +++ b/tests/src/testUtils/CMakeLists.txt @@ -11,6 +11,9 @@ target_include_directories(testUtils target_link_libraries(testUtils PUBLIC engine + potential + coulombPotential + nonCoulombPotential ) install(TARGETS testUtils diff --git a/tests/src/testUtils/testUtils.cpp b/tests/src/testUtils/testUtils.cpp index 4e7567aec..f0ba8cdc0 100644 --- a/tests/src/testUtils/testUtils.cpp +++ b/tests/src/testUtils/testUtils.cpp @@ -24,38 +24,54 @@ #include +#include "coulombPotential.hpp" #include "engine.hpp" +#include "nonCoulombPotential.hpp" +#include "qmRunner.hpp" namespace test { /** - * @brief check if engine is of expected type + * @brief check that the dynamic type of obj matches expectedType * - * @param engine - * @param expectedType - */ - void checkEngineType( - const std::unique_ptr& engine, - const std::type_info& expectedType - ) - { - ASSERT_NE(engine, nullptr); - const auto& engineRef = *engine; - EXPECT_EQ(typeid(engineRef), expectedType); - } - - /** - * @brief check if potential is of expected type + * @details Works for raw pointers, smart pointers, and plain + * references alike — dereferences anything pointer-like before + * comparing typeid, so typeid always reflects the pointee's + * actual (polymorphic) type rather than the pointer/wrapper type. * - * @param potential + * @tparam T + * @param obj * @param expectedType */ - void checkPotentialType( - const potential::Potential* potential, - const std::type_info& expectedType - ) + template + void checkType(const T& obj, const std::type_info& expectedType) { - ASSERT_NE(potential, nullptr); - EXPECT_EQ(typeid(*potential), expectedType); + if constexpr (requires { *obj; }) + EXPECT_EQ(typeid(*obj), expectedType); + else + EXPECT_EQ(typeid(obj), expectedType); } + + // explicit instantiations + template void checkType>( + const std::unique_ptr& engine, + const std::type_info& expectedType + ); + template void checkType( + potential::Potential* const& potential, + const std::type_info& expectedType + ); + template void checkType( + potential::CoulombPotential* const& potential, + const std::type_info& expectedType + ); + template void checkType( + potential::NonCoulombPotential* const& potential, + const std::type_info& expectedType + ); + template void checkType( + QM::QMRunner* const& runner, + const std::type_info& expectedType + ); + } // namespace test From a2c997d22654cb6596aea98854affa773bb11e87 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 14:32:14 +0200 Subject: [PATCH 38/44] chore: some more cleanups and header removals --- tests/src/setup/testThermostatSetup.cpp | 21 +++++++++------------ tests/src/simulationBox/testCelllist.cpp | 7 +++---- tests/src/utilities/testMathUtilities.cpp | 3 +-- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/tests/src/setup/testThermostatSetup.cpp b/tests/src/setup/testThermostatSetup.cpp index 16e377f0b..6fc33739b 100644 --- a/tests/src/setup/testThermostatSetup.cpp +++ b/tests/src/setup/testThermostatSetup.cpp @@ -22,19 +22,18 @@ #include // for EXPECT_EQ, EXPECT_NO_THROW, InitGo... -#include // for sqrt -#include // for allocator, basic_string +#include // for sqrt #include "berendsenThermostat.hpp" // for BerendsenThermostat #include "constants/conversionFactors.hpp" // for _FS_TO_S_, _KG_TO_GRAM_ #include "constants/natureConstants.hpp" // for _UNIVERSAL_GAS_CONSTANT_ -#include "gtest/gtest.h" // for Message, TestPartResult -#include "langevinThermostat.hpp" // for LangevinThermostat -#include "noseHooverThermostat.hpp" // for NoseHooverThermostat -#include "testSetup.hpp" // for TestSetup -#include "thermostatSettings.hpp" // for ThermostatSettings -#include "thermostatSetup.hpp" // for ThermostatSetup, setupThermostat -#include "timingsSettings.hpp" // for TimingsSettings +#include "gtest/gtest.h" // for Message, TestPartResult +#include "langevinThermostat.hpp" // for LangevinThermostat +#include "noseHooverThermostat.hpp" // for NoseHooverThermostat +#include "testSetup.hpp" // for TestSetup +#include "thermostatSettings.hpp" // for ThermostatSettings +#include "thermostatSetup.hpp" // for ThermostatSetup, setupThermostat +#include "timingsSettings.hpp" // for TimingsSettings #include "velocityRescalingThermostat.hpp" // for VelocityRescalingThermostat using namespace setup; @@ -99,7 +98,6 @@ TEST_F(TestSetup, setupThermostat_temp_ramping) thermostatSetup.getEngine().getThermostat().getRampingFrequency(), 2 ); - } TEST_F(TestSetup, setupThermostat_only_end_temp_defined) @@ -188,8 +186,7 @@ TEST_F(TestSetup, setupThermostat_langevin) EXPECT_EQ(langevinThermostat.getFriction(), 1.0e11); const auto conversionFactor = - constants::_UNIVERSAL_GAS_CONSTANT_ * - constants::_M2_TO_ANGSTROM2_ * + constants::_UNIVERSAL_GAS_CONSTANT_ * constants::_M2_TO_ANGSTROM2_ * constants::_KG_TO_GRAM_ / constants::_FS_TO_S_; const auto sigma = std::sqrt( 4.0 * langevinThermostat.getFriction() * conversionFactor * diff --git a/tests/src/simulationBox/testCelllist.cpp b/tests/src/simulationBox/testCelllist.cpp index 56e929b69..94a1e06a1 100644 --- a/tests/src/simulationBox/testCelllist.cpp +++ b/tests/src/simulationBox/testCelllist.cpp @@ -23,7 +23,6 @@ #include "testCelllist.hpp" #include // for make_shared, __shared_ptr_access -#include // for allocator, basic_string #include // for vector #include "atom.hpp" // for Atom @@ -34,7 +33,7 @@ #include "potentialSettings.hpp" // for PotentialSettings #include "simulationBox.hpp" // for SimulationBox #include "throwWithMessage.hpp" // for EXPECT_THROW_MSG -#include "vector3d.hpp" // IWYU pragma: keep - for Vec3Dul, Vec3D, Vector3D +#include "vector3d.hpp" // IWYU pragma: keep - for Vec3Dul, Vec3D, Vector3D TEST_F(TestCellList, determineCellSize) { @@ -242,10 +241,10 @@ TEST_F(TestCellList, checkCoulombCutoff) { _simulationBox->setBoxDimensions(linearAlgebra::Vec3D(50.0, 50.0, 50.0)); _cellList->determineCellSize(_simulationBox->getBoxDimensions()); - EXPECT_NO_THROW(_cellList->checkCoulombCutoff({200.0})); + EXPECT_NO_THROW(_cellList->checkCoulombCutoff(200.0)); EXPECT_THROW_MSG( - _cellList->checkCoulombCutoff({0.1}), + _cellList->checkCoulombCutoff(0.1), customException::CellListException, "Coulomb cutoff is smaller than half of the largest cell size." ); diff --git a/tests/src/utilities/testMathUtilities.cpp b/tests/src/utilities/testMathUtilities.cpp index 8de8cbbbf..a76cfd29d 100644 --- a/tests/src/utilities/testMathUtilities.cpp +++ b/tests/src/utilities/testMathUtilities.cpp @@ -23,7 +23,6 @@ #include // for Test, TestInfo (ptr only), EXPECT_EQ #include // for numeric_limits -#include // for allocator, string #include "gtest/gtest.h" // for AssertionResult, Message, TestPartResult #include "mathUtilities.hpp" // for compare, sign, utilities @@ -113,4 +112,4 @@ TEST(TestMathUtilities, isZero) EXPECT_FALSE(isZero(1.0)); EXPECT_FALSE(isZero(std::numeric_limits::epsilon())); EXPECT_FALSE(isZero(std::numeric_limits::min())); -} \ No newline at end of file +} From 9dea215ea4e552b38951c4acf471bd840fde62f1 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 17:21:12 +0200 Subject: [PATCH 39/44] cleanup: finish implementing first version of clangd and clang_tidy checks --- .github/notworkingworkflows/ci_cuda.yml | 58 -------------------- .gitignore | 9 +++- .vscode/settings.json | 7 ++- .vscode/tasks.json | 13 ++++- scripts/clang_tidy.sh | 71 ++++++++++++++++--------- tests/src/testUtils/testUtils.cpp | 8 +-- 6 files changed, 77 insertions(+), 89 deletions(-) delete mode 100644 .github/notworkingworkflows/ci_cuda.yml diff --git a/.github/notworkingworkflows/ci_cuda.yml b/.github/notworkingworkflows/ci_cuda.yml deleted file mode 100644 index d5fddcb7e..000000000 --- a/.github/notworkingworkflows/ci_cuda.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: C/C++ CI - -on: - push: - branches: - - '*' - pull_request: - branches: - - '*' - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-24.04 - - steps: - - uses: actions/checkout@v3 - - uses: Jimver/cuda-toolkit@v0.2.15 - id: cuda-toolkit - with: - cuda: '12.4.1' - - - name: install gcc13 - run: | - sudo apt update - sudo apt install gcc-13 g++-13 - shell: bash - - - name: setup python - uses: actions/setup-python@v2 - with: - python-version: '3.12' - - - name: install coverage - run: | - python -m pip install coverage - python -m pip install gcovr - shell: bash - - - name: Build and Test Project - run: | - mkdir build - cd build - cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_GCOVR=ON -DBUILD_WITH_KOKKOS=ON -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_TURING75=ON .. - make -j20 - make coverage_xml - env: - CC: gcc-13 - CXX: g++-13 - - # - name: Upload coverage to Codecov - # uses: codecov/codecov-action@v3 - # with: - # fail_ci_if_error: true # optional (default = false) - # gcov: true - # gcov_executable: gcov-13 - # env: - # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index ea4adab52..d93c9dd9c 100644 --- a/.gitignore +++ b/.gitignore @@ -64,7 +64,6 @@ examples/**/tm.out examples/**/traj2box examples/**/*.cao - *.gcov googletest @@ -77,3 +76,11 @@ venv .venv env .env + +# local clangd output for checks for ci -- not to be committed +clangd-tidy-report.log + +# sometimes useful to make a syslink into the main dir from the build dir, but not to be committed +compile_commands.json + +CMakePresets.json diff --git a/.vscode/settings.json b/.vscode/settings.json index d4ccad7b4..e118037b5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -143,11 +143,15 @@ "coulombic", "Coulombics", "Coupl", + "Cueq", + "cuequivariance", "datapoints", + "Derivs", "DFTD", "dxyz", "ekin", "equil", + "Fennol", "filterwarnings", "forcexyz", "freset", @@ -214,6 +218,7 @@ "RSTFILEEXCEPTION", "RSTFILEOUTPUT", "SHAKEEXCEPTION", + "Slakos", "sonarlint", "STDOUTOUTPUT", "STREQ", @@ -241,4 +246,4 @@ "esbonio.sphinx.confDir": "", "workbench.colorTheme": "Visual Studio Dark - C++", "sonarlint.pathToCompileCommands": "${workspaceFolder}/.build/compile_commands.json" -} \ No newline at end of file +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b354ccf9b..d022e0c6c 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -58,6 +58,17 @@ } ], "group": "build" + }, + { + "type": "cmake", + "label": "CMake: build", + "command": "build", + "targets": [ + "all" + ], + "group": "build", + "problemMatcher": [], + "detail": "CMake template build task" } ] -} \ No newline at end of file +} diff --git a/scripts/clang_tidy.sh b/scripts/clang_tidy.sh index 6831ebb2b..c9d4d63ba 100755 --- a/scripts/clang_tidy.sh +++ b/scripts/clang_tidy.sh @@ -1,35 +1,58 @@ #!/usr/bin/env bash -set -euo pipefail +set -o pipefail -# scripts/clangd_tidy.sh -# -# Runs clangd-tidy either on all source files, or only on files changed -# relative to HEAD. -# -# Usage: -# scripts/clangd_tidy.sh # only changed .cpp files -# scripts/clangd_tidy.sh --all # all .cpp files under src/ +LOGFILE="clangd-tidy-report.log" +# Only stdout goes to the log file; stderr (where --tqdm draws its +# progress bar via carriage returns) stays on the terminal only, so +# the log file doesn't fill up with \r-based redraw noise. +exec > >(tee "$LOGFILE") -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" -BUILD_DIR="${ROOT_DIR}/.build" +echo "Clangd-Tidy:" -cd "${ROOT_DIR}" +all_files=false +while [[ $# -gt 0 ]]; do + case "$1" in + --all) + all_files=true + shift + ;; + *) + echo "Unknown option: $1" + exit 1 + ;; + esac +done -MODE="changed" -if [[ "${1:-}" == "--all" ]]; then - MODE="all" -fi - -if [[ "${MODE}" == "all" ]]; then - mapfile -t FILES < <(find "${ROOT_DIR}/src" -name '*.cpp' ! -name 'moc_*.cpp') +files=() +if $all_files; then + echo " Mode: all tracked C++ files" + while IFS= read -r f; do + [[ -f "$f" ]] && files+=("$f") + done < <(git ls-files '*.cpp' '*.cxx' '*.cc' '*.c' '*.h' '*.hpp' '*.hxx' -- ':!external') else - mapfile -t FILES < <(git diff --name-only --diff-filter=ACMR HEAD -- '*.cpp' ':!*moc_*.cpp') + echo " Mode: changed files since origin/dev" + while IFS=$'\t' read -r status old new; do + case "$status" in + D) ;; + R*) [[ -f "$new" ]] && files+=("$new") ;; + *) [[ -f "$old" ]] && files+=("$old") ;; + esac + done < <(git diff --name-status "$(git merge-base HEAD origin/dev)") + + # Filter to C++ files only (changed mode may include non-source files) + # and exclude anything under external/ + cpp_files=() + for f in "${files[@]}"; do + [[ "$f" == external/* ]] && continue + [[ "$f" =~ \.(cpp|cxx|cc|c|h|hpp|hxx)$ ]] && cpp_files+=("$f") + done + files=("${cpp_files[@]}") fi -if [[ ${#FILES[@]} -eq 0 ]]; then - echo "No files to lint." +if [[ ${#files[@]} -eq 0 ]]; then + echo " No files to check." exit 0 fi -clangd-tidy "${FILES[@]}" -p="${BUILD_DIR}" --tqdm +echo " Files: ${#files[@]}" +clangd-tidy "${files[@]}" -p=. --tqdm -j3 diff --git a/tests/src/testUtils/testUtils.cpp b/tests/src/testUtils/testUtils.cpp index f0ba8cdc0..dd91d53b1 100644 --- a/tests/src/testUtils/testUtils.cpp +++ b/tests/src/testUtils/testUtils.cpp @@ -24,10 +24,10 @@ #include -#include "coulombPotential.hpp" -#include "engine.hpp" -#include "nonCoulombPotential.hpp" -#include "qmRunner.hpp" +#include "coulombPotential.hpp" // IWYU pragma: keep -- needed for explicit template instantiation +#include "engine.hpp" // IWYU pragma: keep -- needed for explicit template instantiation +#include "nonCoulombPotential.hpp" // IWYU pragma: keep -- needed for explicit template instantiation +#include "qmRunner.hpp" // IWYU pragma: keep -- needed for explicit template instantiation namespace test { From 4c04e9c7127ce766b945e469322f99656fb5d37a Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 17:24:47 +0200 Subject: [PATCH 40/44] chore: add changelog update --- changes/clang.developer.internal.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/clang.developer.internal.md diff --git a/changes/clang.developer.internal.md b/changes/clang.developer.internal.md new file mode 100644 index 000000000..746bbb684 --- /dev/null +++ b/changes/clang.developer.internal.md @@ -0,0 +1 @@ +- Add first version of CI for static analysis via clangd and clang-tidy (all clangd-tidy checks for now disabled apart a test check) From 9d6fa6d472dd8eb0eaf673ee7e1a9fc3faf7b052 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 17:29:20 +0200 Subject: [PATCH 41/44] chore: add numpy to lint ci --- .github/workflows/lint.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dc2e51cca..a3a408950 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -43,6 +43,11 @@ jobs: with: python-version: '3.12' + - name: install python dependencies + run: | + python -m pip install numpy + shell: bash + - name: Install clangd-tidy run: python -m pip install clangd-tidy shell: bash @@ -59,4 +64,4 @@ jobs: - name: Run clangd-tidy run: | - clangd-tidy $(find src/ apps/ include/ -name "*.cpp" ! -name "moc_*.cpp" 2>/dev/null) -p=build \ No newline at end of file + clangd-tidy $(find src/ apps/ include/ -name "*.cpp" ! -name "moc_*.cpp" 2>/dev/null) -p=build From 5d858ef312f1d54f71c68150676007f717999d32 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Thu, 30 Jul 2026 17:30:01 +0200 Subject: [PATCH 42/44] chore: add same on settings as for build workflow --- .github/workflows/lint.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a3a408950..cb653f1b7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,22 +5,30 @@ on: branches: - '*' paths: - - '.github/workflows/ci_lint.yml' + - '.github/workflows/ci_build.yml' - '.cmake/**' - 'apps/**' - 'include/**' - 'src/**' + - 'integration_tests/**' + - 'tests/**' + - 'benchmarks/CMakeLists.txt' + - 'benchmarks/src/**' - 'CMakeLists.txt' push: branches: - dev - main paths: - - '.github/workflows/ci_lint.yml' + - '.github/workflows/ci_build.yml' - '.cmake/**' - 'apps/**' - 'include/**' - 'src/**' + - 'integration_tests/**' + - 'tests/**' + - 'benchmarks/CMakeLists.txt' + - 'benchmarks/src/**' - 'CMakeLists.txt' workflow_dispatch: From 6eb4d8baa60aa8eb43671e50b8c6268c69d53e9f Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Fri, 31 Jul 2026 19:50:03 +0200 Subject: [PATCH 43/44] chore: fix problems in lint.yml ci --- .github/workflows/lint.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cb653f1b7..ea03c8beb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,6 +15,9 @@ on: - 'benchmarks/CMakeLists.txt' - 'benchmarks/src/**' - 'CMakeLists.txt' + - '.clang-tidy' + - 'scripts/clang_tidy.sh' + - '.github/workflows/lint.yml' push: branches: - dev @@ -26,8 +29,10 @@ on: - 'include/**' - 'src/**' - 'integration_tests/**' - - 'tests/**' - - 'benchmarks/CMakeLists.txt' + - 'CMakeLists.txt' + - '.clang-tidy' + - 'scripts/clang_tidy.sh' + - '.github/workflows/lint.yml' - 'benchmarks/src/**' - 'CMakeLists.txt' workflow_dispatch: @@ -72,4 +77,4 @@ jobs: - name: Run clangd-tidy run: | - clangd-tidy $(find src/ apps/ include/ -name "*.cpp" ! -name "moc_*.cpp" 2>/dev/null) -p=build + clangd-tidy $(find src/ apps/ include/ -name "*.cpp" -o -name "*.hpp" -o -name "*.tpp" 2>/dev/null) -p=build From 8fffe7b50140d4e707f398ec02d7dec361bed2c9 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Fri, 31 Jul 2026 20:31:05 +0200 Subject: [PATCH 44/44] chore: remove some more kokkos include via PP directive --- include/potential/potential_kokkos.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/potential/potential_kokkos.hpp b/include/potential/potential_kokkos.hpp index afc99dbff..9fca4a589 100644 --- a/include/potential/potential_kokkos.hpp +++ b/include/potential/potential_kokkos.hpp @@ -24,6 +24,8 @@ #define _KOKKOS_POTENTIAL_HPP_ +#ifdef WITH_KOKKOS + #include "timer.hpp" // for Timer #include "typeAliases.hpp" @@ -49,4 +51,6 @@ namespace potential } // namespace potential -#endif // _KOKKOS_POTENTIAL_HPP_ \ No newline at end of file +#endif // WITH_KOKKOS + +#endif // _KOKKOS_POTENTIAL_HPP_