diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 591a61d7d9106000102140d401c00dad47c4623f..0c054a8404c163a1c51291d0af67209a8f0f68dc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,8 +27,10 @@ windows: tags: - Windows stage: build - variables: - GIT_DEPTH: "1" # shallow cloning + cache: + key: build-cache + paths: + - build/ script: - $OPT_DIR = "C:/opt/x64" - $FFTW3_INCLUDE_DIR = "$OPT_DIR/include" @@ -48,15 +50,17 @@ windows: - 'dir Env:' # make the CMake build directory - echo "----------------------------------------" - - mkdir -Force "$BUILD_DIR" - - cd "$BUILD_DIR" + - if($CI_PIPELINE_SOURCE -eq "schedule") { mkdir -Force $BUILD_DIR; echo "scheduled build" } + - if(!(Test-Path -path $BUILD_DIR)) { mkdir -Force $BUILD_DIR; echo "build from scratch" } + - cd $BUILD_DIR - pwd - echo "#--- CONFIGURE ---" - cmake --version - cmake -G "Visual Studio 16 2019" -A x64 -T host=x64 -DLIB_MAN=OFF -DQTDIR="$QT_MSVC_DIR" -DQt5_DIR="$QTCMake_DIR/Qt5" -DQt5Test_DIR="$QTCMake_DIR/Qt5Test" -DFFTW3_INCLUDE_DIR="$FFTW3_INCLUDE_DIR" -DFFTW3_LIBRARY="$FFTW3_LIB" -DCMAKE_INCLUDE_PATH="$OPT_DIR/include;$BOOST_INCLUDE_DIR" -DCMAKE_LIBRARY_PATH="$OPT_DIR/lib;$BOOST_LIB_DIR" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -B. .. - echo "#--- BUILD ---" - pwd - - cmake --build . --config Release --clean-first + - if($CI_PIPELINE_SOURCE -eq "schedule") { cmake --build . --target clean } + - cmake --build . --config Release - echo "#--- TEST ---" - ctest -C Release --parallel 8 --output-on-failure - echo "#--- PACKAGING ---" diff --git a/Fit/3rdparty/RootMinimizers/CMakeLists.txt b/Fit/3rdparty/RootMinimizers/CMakeLists.txt index 6ec53f2b4099b0fba27ba4220830abf310d4bb23..cad33ed305b680d2e69822c0162d8976140c50a0 100644 --- a/Fit/3rdparty/RootMinimizers/CMakeLists.txt +++ b/Fit/3rdparty/RootMinimizers/CMakeLists.txt @@ -26,7 +26,7 @@ if(NOT WIN32) string(APPEND CMAKE_CXX_FLAGS " -Wno-dangling-gsl") endif() else() - string(APPEND CMAKE_CXX_FLAGS " /wd4244 /wd4267") + string(APPEND CMAKE_CXX_FLAGS " /wd4244 /wd4267 /wd5033") endif() add_library(${library_name} STATIC ${source_files}) diff --git a/GUI/View/Job/JobPropertiesTableModel.cpp b/GUI/View/Job/JobPropertiesTableModel.cpp index e22964bf79205fbaf89df1bfb15eb937d7c8d471..1219458de0dcfd3c4806c342ad66d61a2930bf26 100644 --- a/GUI/View/Job/JobPropertiesTableModel.cpp +++ b/GUI/View/Job/JobPropertiesTableModel.cpp @@ -21,13 +21,13 @@ namespace Column { enum Columns { Name, Value }; } const QString ColumnNames[] = {"Name", "Value"}; -const int NumColumns = std::size(ColumnNames); +const int NumColumns = (int)std::size(ColumnNames); namespace Row { enum Rows { Name, Sample, Instrument, Status, Begin, End, Duration }; } const QString RowNames[] = {"Name", "Sample", "Instrument", "Status", "Begin", "End", "Duration"}; -const int NumRows = std::size(RowNames); +const int NumRows = (int)std::size(RowNames); const QString ModelDateShortFormat = "yyyy.MM.dd hh:mm:ss"; } // namespace diff --git a/GUI/View/Mask/MaskEditorPropertyPanel.cpp b/GUI/View/Mask/MaskEditorPropertyPanel.cpp index 516c549b3804651d2cb1786ecdd2c1b8bfdcc80d..6cb4c203af00911175ec91c62ae014fff53eac31 100644 --- a/GUI/View/Mask/MaskEditorPropertyPanel.cpp +++ b/GUI/View/Mask/MaskEditorPropertyPanel.cpp @@ -16,8 +16,7 @@ #include "GUI/Model/Data/IntensityDataItem.h" #include "GUI/Model/Session/SessionModel.h" #include "GUI/View/PropertyEditor/ComponentEditor.h" - -#include <qAccordion/contentpane.h> +#include "GUI/View/Tool/Accordion.h" #include <QListView> #include <QVBoxLayout> diff --git a/GUI/View/Tool/Accordion.h b/GUI/View/Tool/Accordion.h new file mode 100644 index 0000000000000000000000000000000000000000..3ffc0fa9629f62c61a7a6f77a5449744dcf6bb13 --- /dev/null +++ b/GUI/View/Tool/Accordion.h @@ -0,0 +1,22 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file GUI/View/Tool/Accordion.h +//! @brief Wraps include of headers from 3rdparty library qaccordion. +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2018 +//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) +// +// ************************************************************************************************ + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4267) +#endif +#include <qAccordion/contentpane.h> +#ifdef _MSC_VER +#pragma warning(pop) +#endif diff --git a/GUI/View/Toplevel/TestView.cpp b/GUI/View/Toplevel/TestView.cpp index a864c51c6784dbd49fd49997b771e0d0c645850b..ea8737948241b26799fe71fcc9757ec120e6ac7c 100644 --- a/GUI/View/Toplevel/TestView.cpp +++ b/GUI/View/Toplevel/TestView.cpp @@ -22,8 +22,7 @@ #include "GUI/View/Fit/MinimizerSettingsWidget.h" #include "GUI/View/PropertyEditor/TestComponentView.h" #include "GUI/View/SpecularData/Plot1DCanvas.h" - -#include <qAccordion/contentpane.h> +#include "GUI/View/Tool/Accordion.h" #include <QCheckBox> #include <QLineEdit> diff --git a/Resample/Specular/ComputeFluxMagnetic.cpp b/Resample/Specular/ComputeFluxMagnetic.cpp index 020339c653ebd09bbee26f67e40660aa5028c0a3..2e76fc737a8a365c05e36c419bc867eedd42e17d 100644 --- a/Resample/Specular/ComputeFluxMagnetic.cpp +++ b/Resample/Specular/ComputeFluxMagnetic.cpp @@ -67,34 +67,34 @@ void calculateUpwards(std::vector<MatrixFlux>& coeff, const SliceStack& slices, coeff.back().m_T = Eigen::Matrix2cd::Identity(); coeff.back().m_R = Eigen::Matrix2cd::Zero(); - for (signed long i = N - 2; i >= 0; --i) { + for (size_t i = N - 1; i > 0; --i) { double sigma = 0.; if (const auto roughness = slices.bottomRoughness(i)) sigma = roughness->getSigma(); // compute the 2x2 submatrices in the write-up denoted as P+, P- and delta - const auto [mp, mm] = computeBackwardsSubmatrices(coeff[i], coeff[i + 1], sigma, r_model); + const auto [mp, mm] = computeBackwardsSubmatrices(coeff[i-1], coeff[i], sigma, r_model); - const Eigen::Matrix2cd delta = coeff[i].computeDeltaMatrix(slices[i].thicknessOr0()); + const Eigen::Matrix2cd delta = coeff[i-1].computeDeltaMatrix(slices[i-1].thicknessOr0()); // compute the rotation matrix Eigen::Matrix2cd S, Si; - Si = mp + mm * coeff[i + 1].m_R; + Si = mp + mm * coeff[i].m_R; S << Si(1, 1), -Si(0, 1), -Si(1, 0), Si(0, 0); const complex_t norm = S(0, 0) * S(1, 1) - S(0, 1) * S(1, 0); S = S * delta; // store the rotation matrix and normalization constant in order to rotate // the coefficients for all lower slices at the end of the computation - SMatrices[i] = S; - Normalization[i] = norm; + SMatrices[i-1] = S; + Normalization[i-1] = norm; // compute the reflection matrix and // rotate the polarization such that we have pure incoming states (T = I) S /= norm; // T is always equal to the identity at this point, no need to store - coeff[i].m_R = delta * (mm + mp * coeff[i + 1].m_R) * S; + coeff[i-1].m_R = delta * (mm + mp * coeff[i].m_R) * S; } // now correct all amplitudes in forward direction by dividing with the remaining @@ -216,17 +216,17 @@ Eigen::Matrix2cd Compute::SpecularMagnetic::topLayerR(const SliceStack& slices, // bottom boundary condition c_i1.m_R = Eigen::Matrix2cd::Zero(); - for (signed long i = N - 2; i >= 0; --i) { - auto c_i = createCoeff(i); + for (size_t i = N - 1; i > 0; --i) { + auto c_i = createCoeff(i-1); double sigma = 0.; - if (const auto roughness = slices.bottomRoughness(i)) + if (const auto roughness = slices.bottomRoughness(i-1)) sigma = roughness->getSigma(); // compute the 2x2 submatrices in the write-up denoted as P+, P- and delta const auto [mp, mm] = computeBackwardsSubmatrices(c_i, c_i1, sigma, r_model); - const Eigen::Matrix2cd delta = c_i.computeDeltaMatrix(slices[i].thicknessOr0()); + const Eigen::Matrix2cd delta = c_i.computeDeltaMatrix(slices[i-1].thicknessOr0()); // compute the rotation matrix Eigen::Matrix2cd S, Si; diff --git a/Resample/Specular/ComputeFluxScalar.cpp b/Resample/Specular/ComputeFluxScalar.cpp index 8726a0dd44575750f5df6eb45ca61c551e09b5a6..599ce48eec336464c030a3fc2ad9916ce420deed 100644 --- a/Resample/Specular/ComputeFluxScalar.cpp +++ b/Resample/Specular/ComputeFluxScalar.cpp @@ -88,9 +88,9 @@ std::vector<Eigen::Vector2cd> computeTR(const SliceStack& slices, const std::vec // Calculate transmission/refraction coefficients t_r for each layer, from bottom to top. TR[X[N - 1]] = {1.0, 0.0}; std::vector<complex_t> factors(N - 1); - for (int i = N - 2; i >= 0; i--) { - size_t jthis = X[i]; - size_t jlast = X[i + 1]; + for (size_t i = N - 1; i > 0; i--) { + size_t jthis = X[i - 1]; + size_t jlast = X[i]; const auto roughness = slices.bottomRoughness(jthis); // TODO verify const double sigma = roughness ? roughness->getSigma() : 0.; @@ -99,7 +99,7 @@ std::vector<Eigen::Vector2cd> computeTR(const SliceStack& slices, const std::vec const complex_t delta = exp_I(kz[jthis] * slices[jthis].thicknessOr0()); complex_t S = delta / (mp + mm * TR[jlast](1)); - factors[i] = S; + factors[i-1] = S; TR[jthis](1) = delta * (mm + mp * TR[jlast](1)) * S; } @@ -151,14 +151,14 @@ complex_t Compute::SpecularScalar::topLayerR(const SliceStack& slices, complex_t R_i1 = 0.; - for (int i = N - 2; i >= 0; i--) { + for (size_t i = N - 1; i > 0; i--) { double sigma = 0.0; - if (const auto roughness = slices.bottomRoughness(i)) + if (const auto roughness = slices.bottomRoughness(i-1)) sigma = roughness->getSigma(); - const auto [mp, mm] = transition(kz[i], kz[i + 1], sigma, r_model); + const auto [mp, mm] = transition(kz[i-1], kz[i], sigma, r_model); - const complex_t delta = exp_I(kz[i] * slices[i].thicknessOr0()); + const complex_t delta = exp_I(kz[i-1] * slices[i-1].thicknessOr0()); R_i1 = pow(delta, 2) * (mm + mp * R_i1) / (mp + mm * R_i1); } diff --git a/Tests/Unit/Device/BeamFootprintTest.cpp b/Tests/Unit/Device/BeamFootprintTest.cpp index a4949a3dfc08ef9a19121e56b000b9e048d11897..fb09ee5f0775feb0e033f942e9c9eb7934d5186d 100644 --- a/Tests/Unit/Device/BeamFootprintTest.cpp +++ b/Tests/Unit/Device/BeamFootprintTest.cpp @@ -12,8 +12,8 @@ class BeamFootprintTest : public ::testing::Test { TEST_F(BeamFootprintTest, ErroneousArguments) { - EXPECT_THROW(std::make_unique<FootprintGauss>(-1.0), std::runtime_error); - EXPECT_THROW(std::make_unique<FootprintSquare>(-1.0), std::runtime_error); + EXPECT_THROW(FootprintGauss(-1.0), std::runtime_error); + EXPECT_THROW(FootprintSquare(-1.0), std::runtime_error); FootprintGauss gaussian_ff(std::numeric_limits<double>::infinity()); EXPECT_EQ(0.0, gaussian_ff.calculate(-90.0 * Units::deg));