BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ParticleLayoutComputation.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Core/Computation/ParticleLayoutComputation.cpp
6 //! @brief Implements class ParticleLayoutComputation.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
20 
22  const SimulationOptions& options,
23  bool polarized)
24  : mp_layout(p_layout)
25 {
26  LayoutStrategyBuilder builder(p_layout, options, polarized);
27  mP_strategy.reset(builder.releaseStrategy());
28  m_region_map = p_layout->regionMap();
29  m_surface_density = p_layout->surfaceDensity();
30 }
31 
33 
35 {
36  double alpha_f = elem.getAlphaMean();
37  size_t n_layers = mp_layout->numberOfSlices();
38  if (n_layers > 1 && alpha_f < 0) {
39  return; // zero for transmission with multilayers (n>1)
40  } else {
41  elem.addIntensity(mP_strategy->evaluate(elem) * m_surface_density);
42  }
43 }
44 
46  std::map<size_t, std::vector<HomogeneousRegion>>& region_map) const
47 {
48  for (auto& entry : m_region_map) {
49  size_t i = entry.first;
50  auto& regions = entry.second;
51  region_map[i].insert(region_map[i].begin(), regions.begin(), regions.end());
52  }
53 }
Defines class IInterferenceFunctionStrategy.
Defines class LayoutStrategyBuilder.
Defines class ParticleLayoutComputation.
Defines class ProcessedLayout.
Defines class SimulationElement.
Methods to generate a simulation strategy for a ParticleLayoutComputation.
IInterferenceFunctionStrategy * releaseStrategy()
const ProcessedLayout * mp_layout
std::map< size_t, std::vector< HomogeneousRegion > > m_region_map
ParticleLayoutComputation(const ProcessedLayout *p_layout, const SimulationOptions &options, bool polarized)
std::unique_ptr< const IInterferenceFunctionStrategy > mP_strategy
void compute(SimulationElement &elem) const
void mergeRegionMap(std::map< size_t, std::vector< HomogeneousRegion >> &region_map) const
Merges its region map into the given one (notice non-const reference parameter)
Data structure that contains preprocessed data for a single layout.
size_t numberOfSlices() const
std::map< size_t, std::vector< HomogeneousRegion > > regionMap() const
double surfaceDensity() const
Data stucture containing both input and output of a single detector cell.
void addIntensity(double intensity)
double getAlphaMean() const
Collect the different options for simulation.