Skip to content
Snippets Groups Projects

Prepare for ISimulation w/o Instrument

Merged Wuttke, Joachim requested to merge rz8 into develop
5 files
+ 34
14
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -13,12 +13,14 @@
// ************************************************************************************************
#include "Core/Simulation/ISimulation.h"
#include "Base/Element/PolarizerPair.h"
#include "Base/Utils/Assert.h"
#include "Base/Utils/StringUtils.h"
#include "Core/Background/IBackground.h"
#include "Core/Computation/IComputation.h"
#include "Core/Simulation/MPISimulation.h"
#include "Device/Beam/Beam.h"
#include "Resample/Options/SimulationOptions.h"
#include "Resample/Processed/ProcessedSample.h"
#include "Sample/Multilayer/MultilayerUtils.h"
#include "Sample/SampleBuilderEngine/ISampleBuilder.h"
@@ -105,20 +107,24 @@ void runComputations(std::vector<std::unique_ptr<IComputation>>& computations)
// ************************************************************************************************
ISimulation::ISimulation(const Beam& beam, const MultiLayer& sample, const IDetector& detector)
: m_instrument(beam, detector)
: m_options(std::make_unique<SimulationOptions>())
, m_instrument(beam, detector)
{
setSample(sample);
initialize();
}
#ifndef SWIG
ISimulation::ISimulation(const Beam& beam, const IDetector& detector) : m_instrument(beam, detector)
ISimulation::ISimulation(const Beam& beam, const IDetector& detector)
: m_options(std::make_unique<SimulationOptions>())
, m_instrument(beam, detector)
{
initialize();
}
#endif // SWIG
ISimulation::ISimulation()
: m_options(std::make_unique<SimulationOptions>())
{
initialize();
}
@@ -131,6 +137,19 @@ void ISimulation::initialize()
registerChild(&m_sample_provider);
}
void ISimulation::setOptions(const SimulationOptions& options) {
ASSERT(m_options);
*m_options = options;
}
const SimulationOptions& ISimulation::options() const {
ASSERT(m_options);
return *m_options; }
SimulationOptions& ISimulation::options() {
ASSERT(m_options);
return *m_options; }
//! Initializes a progress monitor that prints to stdout.
void ISimulation::setTerminalProgressMonitor()
{
@@ -170,8 +189,8 @@ void ISimulation::runSimulation()
m_progress.setExpectedNTicks(param_combinations * total_size);
// restrict calculation to current batch
const size_t n_batches = m_options.getNumberOfBatches();
const size_t current_batch = m_options.getCurrentBatch();
const size_t n_batches = m_options->getNumberOfBatches();
const size_t current_batch = m_options->getCurrentBatch();
const size_t batch_start = startIndex(n_batches, current_batch, total_size);
const size_t batch_size = batchSize(n_batches, current_batch, total_size);
@@ -235,6 +254,12 @@ void ISimulation::setSampleBuilder(const std::shared_ptr<class ISampleBuilder>&
m_sample_provider.setBuilder(sample_builder);
}
PolarizerPair ISimulation::polarizerPair() const
{
return {m_instrument.beam().getPolarization(),
m_instrument.detector().detectionProperties().analyzerOperator()};
}
void ISimulation::setBackground(const IBackground& bg)
{
m_background.reset(bg.clone());
@@ -293,7 +318,7 @@ void ISimulation::runSingleSimulation(const ProcessedSample& re_sample, size_t b
{
initElementVector();
const size_t n_threads = m_options.getNumberOfThreads();
const size_t n_threads = m_options->getNumberOfThreads();
ASSERT(n_threads > 0);
std::vector<std::unique_ptr<IComputation>> computations;
Loading