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

Merge branch 'rv4b' into 'develop'

trivial cleanup

See merge request !195
parents 70f86402 e558393b
No related branches found
No related tags found
1 merge request!195trivial cleanup
Pipeline #41284 passed
......@@ -166,13 +166,14 @@ std::vector<DepthProbeElement> DepthProbeSimulation::generateDiffuseElements(con
return result;
}
std::unique_ptr<IComputation> DepthProbeSimulation::createComputation(
const ProcessedSample& re_sample, size_t start, size_t n_elements)
std::unique_ptr<IComputation>
DepthProbeSimulation::createComputation(const ProcessedSample& re_sample, size_t start,
size_t n_elements)
{
ASSERT(start < m_sim_elements.size() && start + n_elements <= m_sim_elements.size());
const auto& begin = m_sim_elements.begin() + static_cast<long>(start);
return std::make_unique<DepthProbeComputation>(re_sample, options(), progress(),
begin, begin + static_cast<long>(n_elements));
return std::make_unique<DepthProbeComputation>(re_sample, options(), progress(), begin,
begin + static_cast<long>(n_elements));
}
void DepthProbeSimulation::validityCheck() const
......
......@@ -83,9 +83,8 @@ private:
//! Generate a single threaded computation for a given range of simulation elements
//! @param start Index of the first element to include into computation
//! @param n_elements Number of elements to process
std::unique_ptr<IComputation>
createComputation(const ProcessedSample& re_sample,
size_t start, size_t n_elements) override;
std::unique_ptr<IComputation> createComputation(const ProcessedSample& re_sample, size_t start,
size_t n_elements) override;
//! Checks if simulation data is ready for retrieval.
void validityCheck() const;
......
......@@ -21,8 +21,8 @@
#include "Sample/Multilayer/MultilayerUtils.h"
#include "Sample/SampleBuilderEngine/ISampleBuilder.h"
#include <gsl/gsl_errno.h>
#include <thread>
#include <iostream>
#include <thread>
namespace {
......@@ -302,8 +302,8 @@ void ISimulation::addParameterDistribution(const ParameterDistribution& par_dist
//! Runs a single simulation with fixed parameter values.
//! If desired, the simulation is run in several threads.
void ISimulation::runSingleSimulation(const ProcessedSample& re_sample,
size_t batch_start, size_t batch_size, double weight)
void ISimulation::runSingleSimulation(const ProcessedSample& re_sample, size_t batch_start,
size_t batch_size, double weight)
{
initDiffuseElementVector();
......@@ -318,8 +318,7 @@ void ISimulation::runSingleSimulation(const ProcessedSample& re_sample,
const size_t thread_size = getNumberOfElements(n_threads, i_thread, batch_size);
if (thread_size == 0)
break;
computations.emplace_back(
createComputation(re_sample, thread_start, thread_size));
computations.emplace_back(createComputation(re_sample, thread_start, thread_size));
}
runComputations(computations);
......
......@@ -123,8 +123,8 @@ protected:
private:
void initialize();
void runSingleSimulation(const ProcessedSample& re_sample,
size_t batch_start, size_t batch_size, double weight = 1.0);
void runSingleSimulation(const ProcessedSample& re_sample, size_t batch_start,
size_t batch_size, double weight = 1.0);
//! Generate a single threaded computation for a given range of simulation elements
//! @param start Index of the first element to include into computation
......
......@@ -13,14 +13,11 @@
// ************************************************************************************************
#include "Resample/Fresnel/IFresnelMap.h"
#include "Base/Pixel/DiffuseElement.h"
#include "Resample/Flux/IFlux.h"
#include "Resample/Slice/Slice.h"
#include "Resample/Slice/SliceStack.h"
#include "Resample/Specular/ISpecularStrategy.h"
IFresnelMap::IFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy,
bool /*useCache*/)
IFresnelMap::IFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy)
: m_slices(stack), m_strategy(std::move(strategy))
{
}
......
......@@ -33,8 +33,7 @@ class DiffuseElement;
class IFresnelMap {
public:
IFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy,
bool useCache);
IFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy);
virtual ~IFresnelMap();
//! Retrieves the amplitude coefficients for given wavevector and layer.
......
......@@ -19,8 +19,8 @@
#include "Resample/Slice/SliceStack.h"
MatrixFresnelMap::MatrixFresnelMap(const SliceStack& stack,
std::unique_ptr<ISpecularStrategy>&& strategy, bool useCache)
: IFresnelMap(stack, std::move(strategy), useCache)
std::unique_ptr<ISpecularStrategy>&& strategy)
: IFresnelMap(stack, std::move(strategy))
{
m_inverted_slices.clear();
for (Slice slice : m_slices) {
......
......@@ -33,8 +33,7 @@ class DiffuseElement;
class MatrixFresnelMap : public IFresnelMap {
public:
MatrixFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy,
bool useCache);
MatrixFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy);
~MatrixFresnelMap() override;
MatrixFresnelMap(const MatrixFresnelMap& other) = delete;
......
......@@ -17,8 +17,8 @@
#include "Resample/Flux/IFlux.h"
ScalarFresnelMap::ScalarFresnelMap(const SliceStack& stack,
std::unique_ptr<ISpecularStrategy>&& strategy, bool useCache)
: IFresnelMap(stack, std::move(strategy), useCache)
std::unique_ptr<ISpecularStrategy>&& strategy)
: IFresnelMap(stack, std::move(strategy))
{
}
......
......@@ -33,8 +33,7 @@ class DiffuseElement;
class ScalarFresnelMap : public IFresnelMap {
public:
ScalarFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy,
bool useCache);
ScalarFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy);
~ScalarFresnelMap() override;
ScalarFresnelMap(const ScalarFresnelMap& other) = delete;
......
......@@ -101,18 +101,20 @@ void checkVolumeFractions(const Admixtures& admixtures)
"total volumetric fraction of particles exceeds 1!");
}
void setAvgMatsInStack(SliceStack& stack, const std::vector<ProcessedLayout>& layouts)
SliceStack refineStack(const SliceStack& stack, const std::vector<ProcessedLayout>& layouts)
{
SliceStack result = stack;
for (const ProcessedLayout& layout : layouts) {
for (const auto& entry : layout.regionMap()) {
const size_t i_slice = entry.first;
if (i_slice == 0 || i_slice == stack.size() - 1)
if (i_slice == 0 || i_slice == result.size() - 1)
continue; // skip semi-infinite layers
const auto slice_mat = stack[i_slice].material();
const auto slice_mat = result[i_slice].material();
checkVolumeFractions(entry.second);
stack[i_slice].setMaterial(createAveragedMaterial(slice_mat, entry.second));
result[i_slice].setMaterial(createAveragedMaterial(slice_mat, entry.second));
}
}
return result;
}
//! Returns a SliceStack that refines the layer structure of sample,
......@@ -203,18 +205,14 @@ std::unique_ptr<IFresnelMap> fresnelify(const MultiLayer& sample, const SliceSta
const std::vector<ProcessedLayout>& layouts,
const SimulationOptions& options)
{
SliceStack fresnelStack = slices;
bool useCache = !options.isIntegrate();
if (options.useAvgMaterials()) // modify fresnelStack
setAvgMatsInStack(fresnelStack, layouts);
SliceStack fresnelStack = options.useAvgMaterials() ? refineStack(slices, layouts) : slices;
if (slices.containsMagneticMaterial())
return std::make_unique<MatrixFresnelMap>(
fresnelStack,
SampleUtils::SpecularStrategyBuilder::buildMagnetic(sample.roughnessModel()), useCache);
SampleUtils::SpecularStrategyBuilder::buildMagnetic(sample.roughnessModel()));
return std::make_unique<ScalarFresnelMap>(
fresnelStack, SampleUtils::SpecularStrategyBuilder::buildScalar(sample.roughnessModel()),
useCache);
fresnelStack, SampleUtils::SpecularStrategyBuilder::buildScalar(sample.roughnessModel()));
}
} // namespace
......
......@@ -129,12 +129,6 @@ C++ includes: DecouplingApproximationStrategy.h
";
// File: classScalarFresnelMap_1_1Hash2Doubles.xml
// File: classMatrixFresnelMap_1_1HashKVector.xml
// File: classIComputeFF.xml
%feature("docstring") IComputeFF "
......@@ -262,7 +256,7 @@ Holds all information that is needed to compute the IFlux that characterize an
C++ includes: IFresnelMap.h
";
%feature("docstring") IFresnelMap::IFresnelMap "IFresnelMap::IFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy, bool useCache)
%feature("docstring") IFresnelMap::IFresnelMap "IFresnelMap::IFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy)
";
%feature("docstring") IFresnelMap::~IFresnelMap "IFresnelMap::~IFresnelMap()
......@@ -428,7 +422,7 @@ Implementation of IFresnelMap for matrix valued reflection/transmission coeffic
C++ includes: MatrixFresnelMap.h
";
%feature("docstring") MatrixFresnelMap::MatrixFresnelMap "MatrixFresnelMap::MatrixFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy, bool useCache)
%feature("docstring") MatrixFresnelMap::MatrixFresnelMap "MatrixFresnelMap::MatrixFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy)
";
%feature("docstring") MatrixFresnelMap::~MatrixFresnelMap "MatrixFresnelMap::~MatrixFresnelMap() override
......@@ -619,7 +613,7 @@ Implementation of IFresnelMap for scalar valued reflection/transmission coeffic
C++ includes: ScalarFresnelMap.h
";
%feature("docstring") ScalarFresnelMap::ScalarFresnelMap "ScalarFresnelMap::ScalarFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy, bool useCache)
%feature("docstring") ScalarFresnelMap::ScalarFresnelMap "ScalarFresnelMap::ScalarFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy)
";
%feature("docstring") ScalarFresnelMap::~ScalarFresnelMap "ScalarFresnelMap::~ScalarFresnelMap() override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment