From faff94370b834edf93d0043431674a3f38ce65b0 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Wed, 28 Jul 2021 16:56:37 +0200 Subject: [PATCH] ditto --- Core/Scan/AngularSpecScan.cpp | 6 +++--- Core/Scan/AngularSpecScan.h | 2 +- Core/Scan/ISpecularScan.h | 2 +- Core/Scan/QSpecScan.cpp | 6 +++--- Core/Scan/QSpecScan.h | 2 +- Core/Simulation/DepthProbeSimulation.cpp | 2 +- Core/Simulation/DepthProbeSimulation.h | 2 +- Core/Simulation/ISimulation.cpp | 2 +- Core/Simulation/ISimulation.h | 2 +- Core/Simulation/ISimulation2D.cpp | 8 ++++---- Core/Simulation/ISimulation2D.h | 2 +- Core/Simulation/OffSpecularSimulation.cpp | 4 ++-- Core/Simulation/OffSpecularSimulation.h | 2 +- Core/Simulation/SpecularSimulation.cpp | 4 ++-- Core/Simulation/SpecularSimulation.h | 2 +- Device/Detector/DetectorContext.cpp | 2 +- Device/Detector/DetectorContext.h | 2 +- Device/Detector/IDetector.cpp | 2 +- Device/Detector/IDetector.h | 2 +- Tests/Unit/Core/SpecularScanTest.cpp | 12 ++++++------ 20 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Core/Scan/AngularSpecScan.cpp b/Core/Scan/AngularSpecScan.cpp index ff125dfb4c1..fc1e1a252e6 100644 --- a/Core/Scan/AngularSpecScan.cpp +++ b/Core/Scan/AngularSpecScan.cpp @@ -89,7 +89,7 @@ AngularSpecScan::generateElements(const Instrument& instrument) const [](const ParameterSample& sample) { return sample.value; }); std::vector<SpecularElement> result; - result.reserve(numberOfDiffuseElements()); + result.reserve(numberOfElements()); for (size_t i = 0; i < m_inc_angle->size(); ++i) { for (size_t k = 0, size_incs = incs[i].size(); k < size_incs; ++k) { const double inc = incs[i][k]; @@ -182,7 +182,7 @@ void AngularSpecScan::setAbsoluteAngularResolution(const IRangedDistribution& di std::vector<double> AngularSpecScan::footprint(size_t start, size_t n_elements) const { - if (start + n_elements > numberOfDiffuseElements()) + if (start + n_elements > numberOfElements()) throw std::runtime_error("Error in AngularSpecScan::footprint: given index exceeds the " "number of simulation elements"); @@ -217,7 +217,7 @@ std::vector<double> AngularSpecScan::footprint(size_t start, size_t n_elements) return result; } -size_t AngularSpecScan::numberOfDiffuseElements() const +size_t AngularSpecScan::numberOfElements() const { return m_inc_angle->size() * m_wl_resolution->nSamples() * m_inc_resolution->nSamples(); } diff --git a/Core/Scan/AngularSpecScan.h b/Core/Scan/AngularSpecScan.h index 6c85e5c7ac7..ca5c499341e 100644 --- a/Core/Scan/AngularSpecScan.h +++ b/Core/Scan/AngularSpecScan.h @@ -53,7 +53,7 @@ public: std::vector<double> footprint(size_t i, size_t n_elements) const override; //! Returns the number of simulation elements - size_t numberOfDiffuseElements() const override; + size_t numberOfElements() const override; CoordSystem1D* createCoordSystem() const override; diff --git a/Core/Scan/ISpecularScan.h b/Core/Scan/ISpecularScan.h index 9dbedb9e676..40c4bf0f56c 100644 --- a/Core/Scan/ISpecularScan.h +++ b/Core/Scan/ISpecularScan.h @@ -50,7 +50,7 @@ public: virtual std::vector<double> footprint(size_t i, size_t n_elements) const = 0; //! Returns the number of simulation elements - virtual size_t numberOfDiffuseElements() const = 0; + virtual size_t numberOfElements() const = 0; virtual CoordSystem1D* createCoordSystem() const = 0; diff --git a/Core/Scan/QSpecScan.cpp b/Core/Scan/QSpecScan.cpp index ae43c992ad0..16ee20ec7f3 100644 --- a/Core/Scan/QSpecScan.cpp +++ b/Core/Scan/QSpecScan.cpp @@ -65,14 +65,14 @@ std::vector<SpecularElement> QSpecScan::generateElements(const Instrument& instr std::vector<double> QSpecScan::footprint(size_t i, size_t n_elements) const { - if (i + n_elements > numberOfDiffuseElements()) + if (i + n_elements > numberOfElements()) throw std::runtime_error("Error in QSpecScan::footprint: given index exceeds the " "number of simulation elements"); return std::vector<double>(n_elements, 1.0); } //! Returns the number of simulation elements -size_t QSpecScan::numberOfDiffuseElements() const +size_t QSpecScan::numberOfElements() const { return m_qs->size() * m_resolution->nSamples(); } @@ -152,7 +152,7 @@ std::vector<double> QSpecScan::generateQzVector() const const auto samples = applyQResolution(); std::vector<double> result; - result.reserve(numberOfDiffuseElements()); + result.reserve(numberOfElements()); for (size_t i = 0, size_out = samples.size(); i < size_out; ++i) for (size_t j = 0, size_in = samples[i].size(); j < size_in; ++j) result.push_back(samples[i][j].value); diff --git a/Core/Scan/QSpecScan.h b/Core/Scan/QSpecScan.h index 8fa6bb2951b..54402cb3f0f 100644 --- a/Core/Scan/QSpecScan.h +++ b/Core/Scan/QSpecScan.h @@ -57,7 +57,7 @@ public: std::vector<double> footprint(size_t i, size_t n_elements) const override; //! Returns the number of simulation elements - size_t numberOfDiffuseElements() const override; + size_t numberOfElements() const override; CoordSystem1D* createCoordSystem() const override; diff --git a/Core/Simulation/DepthProbeSimulation.cpp b/Core/Simulation/DepthProbeSimulation.cpp index c10d4ee9b85..af1fdcd10c6 100644 --- a/Core/Simulation/DepthProbeSimulation.cpp +++ b/Core/Simulation/DepthProbeSimulation.cpp @@ -38,7 +38,7 @@ DepthProbeSimulation::DepthProbeSimulation() : ISimulation() DepthProbeSimulation::~DepthProbeSimulation() = default; -size_t DepthProbeSimulation::numberOfDiffuseElements() const +size_t DepthProbeSimulation::numberOfElements() const { return getAlphaAxis()->size(); } diff --git a/Core/Simulation/DepthProbeSimulation.h b/Core/Simulation/DepthProbeSimulation.h index f1912ccfc61..58f90053b08 100644 --- a/Core/Simulation/DepthProbeSimulation.h +++ b/Core/Simulation/DepthProbeSimulation.h @@ -68,7 +68,7 @@ private: void initDiffuseElementVector() override; //! Gets the number of elements this simulation needs to calculate - size_t numberOfDiffuseElements() const override; + size_t numberOfElements() const override; //! Generate simulation elements for given beam std::vector<DepthProbeElement> generateElements(const Beam& beam); diff --git a/Core/Simulation/ISimulation.cpp b/Core/Simulation/ISimulation.cpp index f0ed66e8fb5..55d4de98fe3 100644 --- a/Core/Simulation/ISimulation.cpp +++ b/Core/Simulation/ISimulation.cpp @@ -162,7 +162,7 @@ void ISimulation::runSimulation() const auto re_sample = ProcessedSample::make(*sample(), options(), force_polarized); - const size_t total_size = numberOfDiffuseElements(); + const size_t total_size = numberOfElements(); size_t param_combinations = m_distribution_handler.getTotalNumberOfSamples(); m_progress.reset(); diff --git a/Core/Simulation/ISimulation.h b/Core/Simulation/ISimulation.h index 80e8dfa4675..69eb6616c87 100644 --- a/Core/Simulation/ISimulation.h +++ b/Core/Simulation/ISimulation.h @@ -112,7 +112,7 @@ protected: virtual void updateIntensityMap() {} //! Gets the number of elements this simulation needs to calculate - virtual size_t numberOfDiffuseElements() const = 0; + virtual size_t numberOfElements() const = 0; ProgressHandler& progress() { return m_progress; } diff --git a/Core/Simulation/ISimulation2D.cpp b/Core/Simulation/ISimulation2D.cpp index bcb38be0bd1..73e7a84eb42 100644 --- a/Core/Simulation/ISimulation2D.cpp +++ b/Core/Simulation/ISimulation2D.cpp @@ -71,11 +71,11 @@ void ISimulation2D::setRegionOfInterest(double xlow, double ylow, double xup, do detector2D().setRegionOfInterest(xlow, ylow, xup, yup); } -size_t ISimulation2D::numberOfDiffuseElements() const +size_t ISimulation2D::numberOfElements() const { if (!m_detector_context) - throw std::runtime_error("Error in numberOfDiffuseElements(): no detector context"); - return m_detector_context->numberOfDiffuseElements(); + throw std::runtime_error("Error in numberOfElements(): no detector context"); + return m_detector_context->numberOfElements(); } void ISimulation2D::setDetectorParameters(size_t n_x, double x_min, double x_max, size_t n_y, @@ -111,7 +111,7 @@ std::vector<DiffuseElement> ISimulation2D::generateElements(const Beam& beam) const Eigen::Matrix2cd analyzer_operator = detector.detectionProperties().analyzerOperator(); const size_t spec_index = detector.indexOfSpecular(beam); - const size_t N = m_detector_context->numberOfDiffuseElements(); + const size_t N = m_detector_context->numberOfElements(); std::vector<DiffuseElement> result; result.reserve(N); diff --git a/Core/Simulation/ISimulation2D.h b/Core/Simulation/ISimulation2D.h index 30cf682d109..666c2c6b857 100644 --- a/Core/Simulation/ISimulation2D.h +++ b/Core/Simulation/ISimulation2D.h @@ -69,7 +69,7 @@ protected: virtual void initCoordSystem() {} //! Gets the number of elements this simulation needs to calculate - size_t numberOfDiffuseElements() const override; + size_t numberOfElements() const override; //! Generate a single threaded computation for a given range of simulation elements //! @param start Index of the first element to include into computation diff --git a/Core/Simulation/OffSpecularSimulation.cpp b/Core/Simulation/OffSpecularSimulation.cpp index abbc60a6a24..f265b58755f 100644 --- a/Core/Simulation/OffSpecularSimulation.cpp +++ b/Core/Simulation/OffSpecularSimulation.cpp @@ -39,10 +39,10 @@ void OffSpecularSimulation::prepareSimulation() ISimulation2D::prepareSimulation(); } -size_t OffSpecularSimulation::numberOfDiffuseElements() const +size_t OffSpecularSimulation::numberOfElements() const { checkInitialization(); - return ISimulation2D::numberOfDiffuseElements() * m_alpha_i_axis->size(); + return ISimulation2D::numberOfElements() * m_alpha_i_axis->size(); } SimulationResult OffSpecularSimulation::result() const diff --git a/Core/Simulation/OffSpecularSimulation.h b/Core/Simulation/OffSpecularSimulation.h index 6f78a05fc6a..cf96d76f633 100644 --- a/Core/Simulation/OffSpecularSimulation.h +++ b/Core/Simulation/OffSpecularSimulation.h @@ -66,7 +66,7 @@ private: void updateIntensityMap() override; //! Gets the number of elements this simulation needs to calculate - size_t numberOfDiffuseElements() const override; + size_t numberOfElements() const override; //! Normalize, apply detector resolution and transfer detector image corresponding to //! alpha_i = m_alpha_i_axis->bin(index) diff --git a/Core/Simulation/SpecularSimulation.cpp b/Core/Simulation/SpecularSimulation.cpp index da64f9e64f5..51ce6723b61 100644 --- a/Core/Simulation/SpecularSimulation.cpp +++ b/Core/Simulation/SpecularSimulation.cpp @@ -77,9 +77,9 @@ void SpecularSimulation::prepareSimulation() ISimulation::prepareSimulation(); } -size_t SpecularSimulation::numberOfDiffuseElements() const +size_t SpecularSimulation::numberOfElements() const { - return m_scan->numberOfDiffuseElements(); + return m_scan->numberOfElements(); } SimulationResult SpecularSimulation::result() const diff --git a/Core/Simulation/SpecularSimulation.h b/Core/Simulation/SpecularSimulation.h index df66b84ba5c..5d57d850cf3 100644 --- a/Core/Simulation/SpecularSimulation.h +++ b/Core/Simulation/SpecularSimulation.h @@ -87,7 +87,7 @@ private: void moveDataFromCache() override; //! Gets the number of elements this simulation needs to calculate - size_t numberOfDiffuseElements() const override; + size_t numberOfElements() const override; std::vector<double> rawResults() const override; void setRawResults(const std::vector<double>& raw_data) override; diff --git a/Device/Detector/DetectorContext.cpp b/Device/Detector/DetectorContext.cpp index 6fb7d716d25..6786c71cf37 100644 --- a/Device/Detector/DetectorContext.cpp +++ b/Device/Detector/DetectorContext.cpp @@ -20,7 +20,7 @@ DetectorContext::DetectorContext(const IDetector2D* detector) setup_context(detector); } -size_t DetectorContext::numberOfDiffuseElements() const +size_t DetectorContext::numberOfElements() const { return m_active_indices.size(); } diff --git a/Device/Detector/DetectorContext.h b/Device/Detector/DetectorContext.h index b0a09330d5f..ad7f0bd0ca5 100644 --- a/Device/Detector/DetectorContext.h +++ b/Device/Detector/DetectorContext.h @@ -37,7 +37,7 @@ public: DetectorContext(const DetectorContext& other) = delete; DetectorContext& operator=(const DetectorContext& other) = delete; - size_t numberOfDiffuseElements() const; + size_t numberOfElements() const; std::unique_ptr<IPixel> createPixel(size_t element_index) const; diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp index 5bf26d3aba4..cce43130b1e 100644 --- a/Device/Detector/IDetector.cpp +++ b/Device/Detector/IDetector.cpp @@ -240,7 +240,7 @@ void IDetector::setDataToDetectorMap(OutputData<double>& detectorMap, detectorMap[it.roiIndex()] = elements[elementIndex++].intensity(); } -size_t IDetector::numberOfDiffuseElements() const +size_t IDetector::numberOfElements() const { size_t result(0); iterateOverNonMaskedPoints([&result](const_iterator) { ++result; }); diff --git a/Device/Detector/IDetector.h b/Device/Detector/IDetector.h index a9c4be11e49..1a8da686496 100644 --- a/Device/Detector/IDetector.h +++ b/Device/Detector/IDetector.h @@ -165,7 +165,7 @@ public: virtual Axes::Coords defaultCoords() const = 0; //! Returns number of simulation elements. - size_t numberOfDiffuseElements() const; + size_t numberOfElements() const; //! The lower and upper bound of the region of interest. If no region of interest is explicitly //! defined, then the whole detector is taken as "region of interest". diff --git a/Tests/Unit/Core/SpecularScanTest.cpp b/Tests/Unit/Core/SpecularScanTest.cpp index c6566c5d515..44dc339b243 100644 --- a/Tests/Unit/Core/SpecularScanTest.cpp +++ b/Tests/Unit/Core/SpecularScanTest.cpp @@ -20,7 +20,7 @@ TEST_F(SpecularScanTest, AngularScanInit) auto check = [](const AngularSpecScan& scan, const IAxis& axis) { EXPECT_EQ(scan.wavelength(), 0.1); EXPECT_EQ(axis, *scan.coordinateAxis()); - EXPECT_EQ(scan.numberOfDiffuseElements(), axis.size()); + EXPECT_EQ(scan.numberOfElements(), axis.size()); EXPECT_EQ(scan.footprintFactor(), nullptr); EXPECT_EQ(scan.footprint(0, 1), std::vector<double>{1.0}); EXPECT_THROW(scan.footprint(1, axis.size()), std::runtime_error); @@ -129,7 +129,7 @@ TEST_F(SpecularScanTest, QScanInit) { auto check = [](const QSpecScan& scan, const IAxis& axis) { EXPECT_EQ(axis, *scan.coordinateAxis()); - EXPECT_EQ(scan.numberOfDiffuseElements(), axis.size()); + EXPECT_EQ(scan.numberOfElements(), axis.size()); EXPECT_EQ(scan.footprintFactor(), nullptr); EXPECT_EQ(scan.footprint(0, 1), std::vector<double>{1.0}); EXPECT_EQ(scan.offset(), 0.); @@ -204,16 +204,16 @@ TEST_F(SpecularScanTest, GenerateSimElements) AngularSpecScan scan(0.1, std::vector<double>{0.0, 0.2, 0.3}); const Instrument instrument; std::vector<SpecularElement> eles = scan.generateElements(instrument); - EXPECT_EQ(eles.size(), scan.numberOfDiffuseElements()); - EXPECT_EQ(scan.numberOfDiffuseElements(), 3u); + EXPECT_EQ(eles.size(), scan.numberOfElements()); + EXPECT_EQ(scan.numberOfElements(), 3u); for (size_t i = 0; i < eles.size(); ++i) EXPECT_TRUE(eles[i].isCalculated()); const auto scan2_qvector = std::vector<double>{0.0, 0.2, 0.3}; QSpecScan scan2(scan2_qvector); std::vector<SpecularElement> eles2 = scan2.generateElements(instrument); - EXPECT_EQ(eles2.size(), scan2.numberOfDiffuseElements()); - EXPECT_EQ(scan2.numberOfDiffuseElements(), 3u); + EXPECT_EQ(eles2.size(), scan2.numberOfElements()); + EXPECT_EQ(scan2.numberOfElements(), 3u); for (size_t i = 0; i < eles2.size(); ++i) EXPECT_TRUE(eles2[i].isCalculated()); -- GitLab