BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
LayoutStrategyBuilder.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Core/Computation/LayoutStrategyBuilder.cpp
6 //! @brief Implements class LayoutStrategyBuilder.
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 
16 #include "Base/Types/Exceptions.h"
21 
23  const SimulationOptions& sim_params, bool polarized)
24  : mp_layout(p_layout), m_sim_params(sim_params), m_polarized(polarized)
25 {
27 }
28 
29 // needs class definitions => don't move to .h
31 
33 {
34  return mP_strategy.release();
35 }
36 
37 //! Returns a new strategy object that is able to calculate the scattering for fixed k_f.
39 {
41  if (p_iff && mp_layout->numberOfSlices() > 1 && !p_iff->supportsMultilayer())
42  throw std::runtime_error("LayoutStrategyBuilder::checkInterferenceFunction: "
43  "interference function does not support multiple layers");
44 
45  auto p_radial_para = dynamic_cast<const InterferenceFunctionRadialParaCrystal*>(p_iff);
46  if (p_radial_para && p_radial_para->kappa() > 0.0) {
47  double kappa = p_radial_para->kappa();
48  mP_strategy = std::make_unique<SSCApproximationStrategy>(m_sim_params, kappa, m_polarized);
49  } else {
50  mP_strategy = std::make_unique<DecouplingApproximationStrategy>(m_sim_params, m_polarized);
51  }
52  if (!mP_strategy)
53  throw Exceptions::ClassInitializationException("Could not create appropriate strategy");
54  mP_strategy->init(mp_layout->formFactorList(), p_iff);
55 }
Defines class DecouplingApproximationStrategy.
Defines many exception classes in namespace Exceptionss.
Defines class InterferenceFunctionRadialParaCrystal.
Defines class LayoutStrategyBuilder.
Defines class ProcessedLayout.
Defines class SSCApproximationStrategy.
Base class of all interference function strategy classes.
Pure virtual base class of interference functions.
virtual bool supportsMultilayer() const
Indicates if this interference function can be used with a multilayer (DWBA mode)
Interference function of radial paracrystal.
bool m_polarized
polarized computation required?
IInterferenceFunctionStrategy * releaseStrategy()
const ProcessedLayout * mp_layout
LayoutStrategyBuilder(const ProcessedLayout *p_layout, const SimulationOptions &sim_params, bool polarized)
void createStrategy()
Returns a new strategy object that is able to calculate the scattering for fixed k_f.
SimulationOptions m_sim_params
std::unique_ptr< IInterferenceFunctionStrategy > mP_strategy
Data structure that contains preprocessed data for a single layout.
size_t numberOfSlices() const
const std::vector< FormFactorCoherentSum > & formFactorList() const
const IInterferenceFunction * interferenceFunction() const
Collect the different options for simulation.