diff --git a/Sim/Computation/DWBAComputation.cpp b/Sim/Computation/DWBAComputation.cpp index 99d7ffe3a962c34e179e3bcdeb66b414ab075a47..23020a04a394479c08f4a4c74409fb6660eda97d 100644 --- a/Sim/Computation/DWBAComputation.cpp +++ b/Sim/Computation/DWBAComputation.cpp @@ -24,12 +24,8 @@ #include "Sim/Contrib/RoughMultiLayerContribution.h" DWBAComputation::DWBAComputation(const ReSample& re_sample, const SimulationOptions& options, - ProgressHandler& progress, - std::vector<DiffuseElement>::iterator begin_it, - std::vector<DiffuseElement>::iterator end_it) + ProgressHandler& progress) : IComputation(re_sample, options, progress) - , m_begin_it(begin_it) - , m_end_it(end_it) { } @@ -40,24 +36,20 @@ DWBAComputation::~DWBAComputation() = default; // For roughness: (scattering cross-section of area S)/S // For specular peak: |R|^2 * sin(alpha_i) / solid_angle // This allows them to be added and normalized together to the beam afterwards -void DWBAComputation::runProtected() +void DWBAComputation::run(DiffuseElement& ele) { - for (auto it = m_begin_it; it != m_end_it; ++it) { - DiffuseElement& ele = *it; + const Fluxes fluxes_in = m_re_sample.fluxesIn(ele.getKi()); + const Fluxes fluxes_out = m_re_sample.fluxesOut(ele.meanKf()); + ele.setFluxes(&fluxes_in, &fluxes_out); - const Fluxes fluxes_in = m_re_sample.fluxesIn(ele.getKi()); - const Fluxes fluxes_out = m_re_sample.fluxesOut(ele.meanKf()); - ele.setFluxes(&fluxes_in, &fluxes_out); + for (const ReLayout* relayout : m_re_sample.relayouts()) + compute::dwbaContribution(*relayout, ele); - for (const ReLayout* relayout : m_re_sample.relayouts()) - compute::dwbaContribution(*relayout, ele); + if (m_re_sample.hasRoughness()) + compute::roughMultiLayerContribution(m_re_sample, ele); - if (m_re_sample.hasRoughness()) - compute::roughMultiLayerContribution(m_re_sample, ele); + if (m_options.includeSpecular()) + compute::gisasSpecularContribution(ele); - if (m_options.includeSpecular()) - compute::gisasSpecularContribution(ele); - - stepProgress(); - } + stepProgress(); } diff --git a/Sim/Computation/DWBAComputation.h b/Sim/Computation/DWBAComputation.h index 48fd859af572782282aa8e84fde24ffe0f2755dd..91a39df47b3216163f4d6a16172d7e1db56ac0a0 100644 --- a/Sim/Computation/DWBAComputation.h +++ b/Sim/Computation/DWBAComputation.h @@ -37,14 +37,10 @@ class SimulationOptions; class DWBAComputation : public IComputation { public: DWBAComputation(const ReSample& re_sample, const SimulationOptions& options, - ProgressHandler& progress, std::vector<DiffuseElement>::iterator begin_it, - std::vector<DiffuseElement>::iterator end_it); + ProgressHandler& progress); ~DWBAComputation() override; - void runProtected() override; - -private: - std::vector<DiffuseElement>::iterator m_begin_it, m_end_it; + void run(DiffuseElement& ele); }; #endif // BORNAGAIN_SIM_COMPUTATION_DWBACOMPUTATION_H diff --git a/Sim/Simulation/OffspecSimulation.cpp b/Sim/Simulation/OffspecSimulation.cpp index 4cea6eb85523e1c577bfc7cc2fa85a134b3ff747..a0e71f9341093841bce010af35af93cef59f0bb4 100644 --- a/Sim/Simulation/OffspecSimulation.cpp +++ b/Sim/Simulation/OffspecSimulation.cpp @@ -147,9 +147,8 @@ void OffspecSimulation::initDistributionHandler() void OffspecSimulation::runComputation(const ReSample& re_sample, size_t iElement) { - const auto& begin = m_eles.begin() + static_cast<long>(iElement); - DWBAComputation(re_sample, options(), progress(), begin, begin + static_cast<long>(1)) - .runProtected(); + DiffuseElement& ele = *(m_eles.begin() + static_cast<long>(iElement)); + DWBAComputation(re_sample, options(), progress()).run(ele); } void OffspecSimulation::normalize(size_t start, size_t n_elements) diff --git a/Sim/Simulation/ScatteringSimulation.cpp b/Sim/Simulation/ScatteringSimulation.cpp index 8840cfd2b29c7fd6985c8832c7435e433d0a886c..c899bd2128a6c0354a308db2a0f852d81aa5b62d 100644 --- a/Sim/Simulation/ScatteringSimulation.cpp +++ b/Sim/Simulation/ScatteringSimulation.cpp @@ -120,9 +120,8 @@ void ScatteringSimulation::initElementVector() void ScatteringSimulation::runComputation(const ReSample& re_sample, size_t iElement) { - const auto& begin = m_eles.begin() + static_cast<long>(iElement); - DWBAComputation(re_sample, options(), progress(), begin, begin + static_cast<long>(1)) - .runProtected(); + DiffuseElement& ele = *(m_eles.begin() + static_cast<long>(iElement)); + DWBAComputation(re_sample, options(), progress()).run(ele); } void ScatteringSimulation::normalize(size_t start, size_t n_elements)