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

move map<.. HomogeneousRegion> to utils

parent 47f1007c
No related branches found
No related tags found
1 merge request!154further simplification of ProcessedSample
......@@ -18,8 +18,10 @@
#include "Sample/Material/MaterialUtils.h"
#include "Sample/Material/RefractiveMaterialImpl.h"
#include "Sample/Particle/HomogeneousRegion.h"
#include "Sample/Processed/ProcessedLayout.h"
#include "Sample/Slice/Slice.h"
#include "Sample/Slice/SliceStack.h"
#include <map>
namespace {
......@@ -95,9 +97,18 @@ void checkRegions(const std::vector<HomogeneousRegion>& regions)
} // namespace
void SampleUtils::Preprocessor::regionalAverage(
SliceStack& stack, const std::map<size_t, std::vector<HomogeneousRegion>>& region_map)
void SampleUtils::Preprocessor::regionalAverage(SliceStack& stack,
const std::vector<ProcessedLayout>& layouts)
{
std::map<size_t, std::vector<HomogeneousRegion>> region_map;
for (const ProcessedLayout& layout : layouts) {
for (const auto& entry : layout.regionMap()) {
const size_t i = entry.first;
const auto& regions = entry.second;
region_map[i].insert(region_map[i].cbegin(), regions.cbegin(), regions.cend());
}
}
const size_t last_slice_index = stack.size() - 1;
for (const auto& entry : region_map) {
const size_t i_slice = entry.first;
......
......@@ -20,16 +20,14 @@
#ifndef BORNAGAIN_SAMPLE_PROCESSED_MATERIALSLICER_H
#define BORNAGAIN_SAMPLE_PROCESSED_MATERIALSLICER_H
#include <map>
#include <vector>
struct HomogeneousRegion;
class ProcessedLayout;
class SliceStack;
namespace SampleUtils::Preprocessor {
void regionalAverage(SliceStack& slices,
const std::map<size_t, std::vector<HomogeneousRegion>>& region_map);
void regionalAverage(SliceStack& stack, const std::vector<ProcessedLayout>& layouts);
} // namespace SampleUtils::Preprocessor
......
......@@ -20,7 +20,6 @@
#include "Sample/Multilayer/Layer.h"
#include "Sample/Multilayer/MultiLayer.h"
#include "Sample/Multilayer/MultilayerUtils.h"
#include "Sample/Particle/HomogeneousRegion.h"
#include "Sample/Processed/MaterialSlicer.h"
#include "Sample/Processed/ParticleRegions.h"
#include "Sample/Processed/ProcessedLayout.h"
......@@ -30,7 +29,6 @@
#include "Sample/Slice/Slice.h"
#include "Sample/Slice/SliceStack.h"
#include "Sample/Specular/SpecularStrategyBuilder.h"
#include <functional>
//! Returns a SliceStack that refines the layer structure of sample,
//! taking into account the average SLD of layer material and particle decoration.
......@@ -99,7 +97,7 @@ SliceStack slicify(const MultiLayer& sample, const SimulationOptions& options)
//! Returns collection of all ProcessedLayout%s
std::vector<ProcessedLayout> collectLayouts(const MultiLayer& sample, const SliceStack& slices,
bool polarized)
bool polarized)
{
std::vector<ProcessedLayout> result;
......@@ -126,17 +124,8 @@ ProcessedSample::ProcessedSample(const MultiLayer& sample, const SimulationOptio
, m_layouts{collectLayouts(sample, m_slices, m_polarized)}
{
SliceStack fresnelStack = m_slices;
if (options.useAvgMaterials()) { // modify fresnelStack
std::map<size_t, std::vector<HomogeneousRegion>> region_map;
for (const ProcessedLayout& layout: m_layouts) {
for (const auto& entry : layout.regionMap()) {
const size_t i = entry.first;
const auto& regions = entry.second;
region_map[i].insert(region_map[i].cbegin(), regions.cbegin(), regions.cend());
}
}
SampleUtils::Preprocessor::regionalAverage(fresnelStack, region_map);
}
if (options.useAvgMaterials()) // modify fresnelStack
SampleUtils::Preprocessor::regionalAverage(fresnelStack, m_layouts);
const bool useCache = !options.isIntegrate();
if (m_slices.containsMagneticMaterial())
m_fresnel_map = std::make_unique<MatrixFresnelMap>(
......
......@@ -22,11 +22,9 @@
#include "Base/Vector/Vectors3D.h"
#include "Sample/Slice/SliceStack.h"
#include <map>
#include <memory>
#include <vector>
struct HomogeneousRegion;
class IFresnelMap;
class LayerRoughness;
class Material;
......
......@@ -57,7 +57,7 @@ SliceStack SliceStack::setBField(const kvector_t& externalField)
return *this;
const double M_z0 = this->at(0).material().magnetization().z();
const double H_z = externalField.z() + M_z0;
for (Slice& slice: *this)
for (Slice& slice : *this)
slice.initBField(externalField, H_z);
return *this;
}
......
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