28 void ScaleRegionMap(std::map<
size_t, std::vector<HomogeneousRegion>>& region_map,
double factor);
31 ProcessedLayout::ProcessedLayout(
const ILayout& layout,
const std::vector<Slice>& slices,
32 double z_ref,
const IFresnelMap* p_fresnel_map,
bool polarized)
33 : mp_fresnel_map(p_fresnel_map), m_polarized(polarized)
35 m_n_slices = slices.size();
36 collectFormFactors(layout, slices, z_ref);
38 mP_iff.reset(p_iff->clone());
43 mp_fresnel_map = other.mp_fresnel_map;
44 m_polarized = other.m_polarized;
45 m_n_slices = other.m_n_slices;
46 m_surface_density = other.m_surface_density;
47 m_formfactors = std::move(other.m_formfactors);
48 mP_iff = std::move(other.mP_iff);
49 m_region_map = std::move(other.m_region_map);
52 size_t ProcessedLayout::numberOfSlices()
const
57 double ProcessedLayout::surfaceDensity()
const
59 return m_surface_density;
62 const std::vector<FormFactorCoherentSum>& ProcessedLayout::formFactorList()
const
72 std::map<size_t, std::vector<HomogeneousRegion>> ProcessedLayout::regionMap()
const
77 ProcessedLayout::~ProcessedLayout() =
default;
79 void ProcessedLayout::collectFormFactors(
const ILayout& layout,
const std::vector<Slice>& slices,
83 for (
auto p_particle : layout.
particles()) {
84 auto ff_coh = ProcessParticle(*p_particle, slices, z_ref);
85 ff_coh.scaleRelativeAbundance(layout_abundance);
86 m_formfactors.push_back(std::move(ff_coh));
88 double weight = layout.
weight();
90 double scale_factor = m_surface_density / layout_abundance;
91 ScaleRegionMap(m_region_map, scale_factor);
95 const std::vector<Slice>& slices,
98 double abundance = particle.abundance();
99 auto sliced_ffs = SlicedFormFactorList::createSlicedFormFactors(particle, slices, z_ref);
100 auto region_map = sliced_ffs.regionMap();
101 ScaleRegionMap(region_map, abundance);
102 mergeRegionMap(region_map);
104 for (
size_t i = 0; i < sliced_ffs.size(); ++i) {
105 auto ff_pair = sliced_ffs[i];
106 std::unique_ptr<IFormFactor> P_ff_framework;
107 if (slices.size() > 1) {
109 P_ff_framework = std::make_unique<FormFactorDWBAPol>(*ff_pair.first);
111 P_ff_framework = std::make_unique<FormFactorDWBA>(*ff_pair.first);
114 P_ff_framework = std::make_unique<FormFactorBAPol>(*ff_pair.first);
116 P_ff_framework.reset(ff_pair.first->clone());
119 size_t slice_index = ff_pair.second;
120 const Material slice_material = slices[slice_index].material();
121 P_ff_framework->setAmbientMaterial(slice_material);
124 part.setSpecularInfo(mp_fresnel_map, slice_index);
126 result.addCoherentPart(part);
131 void ProcessedLayout::mergeRegionMap(
132 const std::map<
size_t, std::vector<HomogeneousRegion>>& region_map)
134 for (
auto& entry : region_map) {
135 size_t layer_index = entry.first;
136 auto regions = entry.second;
137 m_region_map[layer_index].insert(m_region_map[layer_index].begin(), regions.begin(),
144 void ScaleRegionMap(std::map<
size_t, std::vector<HomogeneousRegion>>& region_map,
double factor)
146 for (
auto& entry : region_map) {
147 for (
auto& region : entry.second) {
148 region.m_volume *= factor;
Defines and implements the interface class IInterferenceFunction.
Defines and implements interface class ILayout.
Defines interface IParticle.
Defines class ProcessedLayout.
Holds the necessary information to calculate the radiation wavefunction in every layer for different ...
Pure virtual base class of interference functions.
Pure virtual interface class to equip a sample layer with scattering properties.
virtual const IInterferenceFunction * interferenceFunction() const =0
Returns the interference function.
virtual double getTotalAbundance() const =0
Get total abundance of all particles.
virtual SafePointerVector< IParticle > particles() const =0
Returns information on all particles (type and abundance) and generates new particles if an IAbstract...
virtual double totalParticleSurfaceDensity() const =0
Returns surface density of all particles.
double weight() const
Returns the relative weight of this layout.
Pure virtual base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal.
A wrapper for underlying material implementation.
Data structure that contains preprocessed data for a single layout.