diff --git a/Sim/Simulation/DepthprobeSimulation.cpp b/Sim/Simulation/DepthprobeSimulation.cpp index 4783193537835dcd8ac201dd14ab1684be6c2f92..f211c36172234988c38cec43300427edf6321267 100644 --- a/Sim/Simulation/DepthprobeSimulation.cpp +++ b/Sim/Simulation/DepthprobeSimulation.cpp @@ -136,8 +136,6 @@ void DepthprobeSimulation::initElementVector() m_depth_eles.emplace_back(wavelength, -result_angle, zAxis(), alpha_limits.isInRange(result_angle)); } - - m_cache.resize(m_depth_eles.size() * zAxis()->size(), 0.); } std::unique_ptr<IComputation> @@ -201,6 +199,11 @@ size_t DepthprobeSimulation::numberOfElements() const return alphaAxis()->size(); } +size_t DepthprobeSimulation::nOutChannels() const +{ + return numberOfElements() * zAxis()->size(); +} + SimulationResult DepthprobeSimulation::packResult() { const std::vector<const IAxis*> axes{alphaAxis()->clone(), zAxis()->clone()}; diff --git a/Sim/Simulation/DepthprobeSimulation.h b/Sim/Simulation/DepthprobeSimulation.h index 5bf6adf4da443ae46ace27b1dc7f233c438959b6..26269d7e398f5017f6b589d4f59720bb9093f02b 100644 --- a/Sim/Simulation/DepthprobeSimulation.h +++ b/Sim/Simulation/DepthprobeSimulation.h @@ -86,6 +86,8 @@ private: //! Returns the number of elements this simulation needs to calculate size_t numberOfElements() const override; + size_t nOutChannels() const override; + SimulationResult packResult() override; //! Checks the distribution validity for simulation. diff --git a/Sim/Simulation/ISimulation.cpp b/Sim/Simulation/ISimulation.cpp index 1809d28eb0fc6ce515899aa051a56f5c4746c3b0..72491a6709f6f78fe6b73402830094f17c32743f 100644 --- a/Sim/Simulation/ISimulation.cpp +++ b/Sim/Simulation/ISimulation.cpp @@ -130,6 +130,7 @@ SimulationResult ISimulation::simulate() gsl_set_error_handler_off(); prepareSimulation(); + m_cache = std::vector<double>(nOutChannels(), 0.); const ReSample re_sample = ReSample::make(*m_sample, options(), force_polarized()); diff --git a/Sim/Simulation/ISimulation.h b/Sim/Simulation/ISimulation.h index f731c8bae10746dfec0033abb9b15936420ff79b..eada5e6032f3c577d487cd69347a97174065f314 100644 --- a/Sim/Simulation/ISimulation.h +++ b/Sim/Simulation/ISimulation.h @@ -118,9 +118,12 @@ private: //! Force polarized computation even in absence of sample magnetization or external fields virtual bool force_polarized() const = 0; - //! Gets the number of elements this simulation needs to calculate. + //! Returns the number of elements this simulation needs to calculate. virtual size_t numberOfElements() const = 0; + //! Returns the number of output channels to be computed. Determines size of m_cache. + virtual size_t nOutChannels() const = 0; + //! Returns simulation result, based on intensity held in elements vector. virtual SimulationResult packResult() = 0; diff --git a/Sim/Simulation/OffspecSimulation.h b/Sim/Simulation/OffspecSimulation.h index 33440508ad2dfe5905fe2b65b10d0cb8719bc14f..ca62a55f02f0aea97285486cf6f90fbb5fe86060 100644 --- a/Sim/Simulation/OffspecSimulation.h +++ b/Sim/Simulation/OffspecSimulation.h @@ -87,9 +87,13 @@ private: //... Overridden getters: bool force_polarized() const override; - //! Returns the number of elements this simulation needs to calculate size_t numberOfElements() const override; + size_t nOutChannels() const override + { + return numberOfElements(); + } + SimulationResult packResult() override; //! Checks the distribution validity for simulation. diff --git a/Sim/Simulation/ScatteringSimulation.cpp b/Sim/Simulation/ScatteringSimulation.cpp index 36b62d0635ce8749d5d4e9d3bd283ea7c02e9eff..3638908277c6fa234900042de21c5ddd0052e55e 100644 --- a/Sim/Simulation/ScatteringSimulation.cpp +++ b/Sim/Simulation/ScatteringSimulation.cpp @@ -117,8 +117,6 @@ void ScatteringSimulation::prepareSimulation() void ScatteringSimulation::initElementVector() { m_eles = generateElements(beam()); - - m_cache.resize(m_eles.size(), 0.0); } std::unique_ptr<IComputation> diff --git a/Sim/Simulation/ScatteringSimulation.h b/Sim/Simulation/ScatteringSimulation.h index 23405ddbf06220cd275e1e7cd5997fcadb037586..bcdb4cb74c1521959ca343e31feb2736fefa28ae 100644 --- a/Sim/Simulation/ScatteringSimulation.h +++ b/Sim/Simulation/ScatteringSimulation.h @@ -94,6 +94,11 @@ private: //! Returns the number of elements this simulation needs to calculate size_t numberOfElements() const override; + size_t nOutChannels() const override + { + return numberOfElements(); + } + SimulationResult packResult() override; //... Local function: diff --git a/Sim/Simulation/SpecularSimulation.cpp b/Sim/Simulation/SpecularSimulation.cpp index 20476b8664803ccbe2738a44c823c6a2fcfd18dc..28202b1eaebf209a9cbe1ef5b0f7bec3be01d86a 100644 --- a/Sim/Simulation/SpecularSimulation.cpp +++ b/Sim/Simulation/SpecularSimulation.cpp @@ -48,8 +48,6 @@ const ICoordSystem* SpecularSimulation::simCoordSystem() const void SpecularSimulation::initElementVector() { m_eles = m_scan->generateElements(); - - m_cache.resize(m_eles.size(), 0); } std::unique_ptr<IComputation> SpecularSimulation::createComputation(const ReSample& re_sample, diff --git a/Sim/Simulation/SpecularSimulation.h b/Sim/Simulation/SpecularSimulation.h index bb375cd2b9155b03006b485b54f00be0393dadb4..328ae45c6573486b87b08148e6a38a6f27575616 100644 --- a/Sim/Simulation/SpecularSimulation.h +++ b/Sim/Simulation/SpecularSimulation.h @@ -64,6 +64,11 @@ private: //! Returns the number of elements this simulation needs to calculate size_t numberOfElements() const override; + size_t nOutChannels() const override + { + return numberOfElements(); + } + SimulationResult packResult() override; //! Checks the distribution validity for simulation.