Skip to content
Snippets Groups Projects
Commit 7e858c5b authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

looks worse, but prepares for removal of ISimulation inheritance

parent 16095645
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "LayerStrategyBuilder.h" #include "LayerStrategyBuilder.h"
#include "Logger.h" #include "Logger.h"
#include "MultiLayer.h" #include "MultiLayer.h"
#include "Simulation.h"
#include "SimulationElement.h" #include "SimulationElement.h"
DecoratedLayerComputation::DecoratedLayerComputation(const Layer* p_layer, size_t layout_index) DecoratedLayerComputation::DecoratedLayerComputation(const Layer* p_layer, size_t layout_index)
...@@ -36,14 +35,19 @@ DecoratedLayerComputation::~DecoratedLayerComputation() ...@@ -36,14 +35,19 @@ DecoratedLayerComputation::~DecoratedLayerComputation()
delete mp_specular_info; delete mp_specular_info;
} }
void DecoratedLayerComputation::run() void DecoratedLayerComputation::eval(
bool polarized,
const MultiLayer& sample,
std::vector<SimulationElement>::iterator begin_it,
std::vector<SimulationElement>::iterator end_it)
{ {
const std::unique_ptr<const IInterferenceFunctionStrategy> LayerStrategyBuilder builder(*mp_layer, sample, m_sim_options, m_layout_index);
p_strategy(createAndInitStrategy()); assert(mp_specular_info);
builder.setRTInfo(*mp_specular_info);
const std::unique_ptr<const IInterferenceFunctionStrategy> p_strategy(builder.createStrategy());
double total_surface_density = mp_layer->getTotalParticleSurfaceDensity(m_layout_index); double total_surface_density = mp_layer->getTotalParticleSurfaceDensity(m_layout_index);
bool polarization_present = mp_simulation->getSample()->containsMagneticMaterial();
for (std::vector<SimulationElement>::iterator it = m_begin_it; it != m_end_it; ++it) { for (std::vector<SimulationElement>::iterator it = begin_it; it != end_it; ++it) {
if (!m_progress.update()) if (!m_progress.update())
break; break;
double alpha_f = it->getAlphaMean(); double alpha_f = it->getAlphaMean();
...@@ -51,7 +55,7 @@ void DecoratedLayerComputation::run() ...@@ -51,7 +55,7 @@ void DecoratedLayerComputation::run()
if (n_layers > 1 && alpha_f < 0) if (n_layers > 1 && alpha_f < 0)
continue; continue;
// each ffdwba: one call to getOutCoeffs // each ffdwba: one call to getOutCoeffs
if (polarization_present) if (polarized)
it->setIntensity(p_strategy->evaluatePol(*it) * total_surface_density); it->setIntensity(p_strategy->evaluatePol(*it) * total_surface_density);
else else
it->setIntensity(p_strategy->evaluate(*it) * total_surface_density); it->setIntensity(p_strategy->evaluate(*it) * total_surface_density);
...@@ -59,16 +63,6 @@ void DecoratedLayerComputation::run() ...@@ -59,16 +63,6 @@ void DecoratedLayerComputation::run()
m_progress.finished(); m_progress.finished();
} }
IInterferenceFunctionStrategy* DecoratedLayerComputation::createAndInitStrategy() const
{
LayerStrategyBuilder builder(*mp_layer, *mp_simulation->getSample(),
m_sim_options, m_layout_index);
assert(mp_specular_info);
builder.setRTInfo(*mp_specular_info);
IInterferenceFunctionStrategy* p_strategy = builder.createStrategy();
return p_strategy;
}
void DecoratedLayerComputation::setSpecularInfo(const LayerSpecularInfo& specular_info) void DecoratedLayerComputation::setSpecularInfo(const LayerSpecularInfo& specular_info)
{ {
if (mp_specular_info != &specular_info) { if (mp_specular_info != &specular_info) {
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
class IInterferenceFunctionStrategy; class IInterferenceFunctionStrategy;
class Layer; class Layer;
class LayerSpecularInfo; class LayerSpecularInfo;
class MultiLayer;
//! Computes the scattering contribution from one layer with particles in/on it. //! Computes the scattering contribution from one layer with particles in/on it.
//! Controlled by MainComputation. //! Controlled by MainComputation.
...@@ -32,12 +33,13 @@ public: ...@@ -32,12 +33,13 @@ public:
DecoratedLayerComputation(const Layer* p_layer, size_t layout_index=0); DecoratedLayerComputation(const Layer* p_layer, size_t layout_index=0);
~DecoratedLayerComputation() final; ~DecoratedLayerComputation() final;
void run() final; void eval(bool polarized,
const MultiLayer& sample,
std::vector<SimulationElement>::iterator begin_it,
std::vector<SimulationElement>::iterator end_it);
void setSpecularInfo(const LayerSpecularInfo& specular_info); void setSpecularInfo(const LayerSpecularInfo& specular_info);
private: private:
IInterferenceFunctionStrategy* createAndInitStrategy() const;
Layer* mp_layer; Layer* mp_layer;
LayerSpecularInfo* mp_specular_info; LayerSpecularInfo* mp_specular_info;
size_t m_layout_index; size_t m_layout_index;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "MultiLayer.h" #include "MultiLayer.h"
#include "RoughMultiLayerComputation.h" #include "RoughMultiLayerComputation.h"
#include "ScalarSpecularInfoMap.h" #include "ScalarSpecularInfoMap.h"
#include "Simulation.h"
#include "SimulationElement.h" #include "SimulationElement.h"
#include "SpecularMagnetic.h" #include "SpecularMagnetic.h"
#include "SpecularMatrix.h" #include "SpecularMatrix.h"
...@@ -96,10 +97,12 @@ void MainComputation::runProtected() ...@@ -96,10 +97,12 @@ void MainComputation::runProtected()
// run through layers and run layer simulations // run through layers and run layer simulations
std::vector<SimulationElement> layer_elements; std::vector<SimulationElement> layer_elements;
std::copy(m_begin_it, m_end_it, std::back_inserter(layer_elements)); std::copy(m_begin_it, m_end_it, std::back_inserter(layer_elements));
bool polarized = mp_simulation->getSample()->containsMagneticMaterial();
for (auto& layer_comp: m_layer_computation) { for (auto& layer_comp: m_layer_computation) {
for (DecoratedLayerComputation* comp: layer_comp) { for (DecoratedLayerComputation* comp: layer_comp) {
comp->init(m_sim_options, *mp_simulation, layer_elements.begin(), layer_elements.end()); comp->init(m_sim_options, *mp_simulation, layer_elements.begin(), layer_elements.end());
comp->run(); comp->eval(polarized, *mp_simulation->getSample(),
layer_elements.begin(), layer_elements.end());
addElementsWithWeight(layer_elements.begin(), layer_elements.end(), m_begin_it, 1.0); addElementsWithWeight(layer_elements.begin(), layer_elements.end(), m_begin_it, 1.0);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment