BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SpecularSimulationElement.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Slice/SpecularSimulationElement.cpp
6 //! @brief Implements the class SpecularSimulationElement.
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 
17 
18 SpecularSimulationElement::SpecularSimulationElement(double kz, bool computable)
19  : m_intensity(0.0), m_computable(computable),
20  m_kz_computation([kz](const std::vector<Slice>& slices) {
21  return KzComputation::computeKzFromSLDs(slices, kz);
22  })
23 {
24 }
25 
26 SpecularSimulationElement::SpecularSimulationElement(double wavelength, double alpha,
27  bool computable)
28  : m_intensity(0.0), m_computable(computable),
29  m_kz_computation(
30  [k = vecOfLambdaAlphaPhi(wavelength, alpha, 0.0)](const std::vector<Slice>& slices) {
31  return KzComputation::computeKzFromRefIndices(slices, k);
32  })
33 {
34 }
35 
36 SpecularSimulationElement::SpecularSimulationElement(const SpecularSimulationElement& other)
37  : m_polarization(other.m_polarization), m_intensity(other.m_intensity),
38  m_computable(other.m_computable), m_kz_computation(other.m_kz_computation)
39 {
40 }
41 
42 SpecularSimulationElement::SpecularSimulationElement(SpecularSimulationElement&& other) noexcept
43  : m_polarization(std::move(other.m_polarization)), m_intensity(other.m_intensity),
44  m_computable(other.m_computable), m_kz_computation(std::move(other.m_kz_computation))
45 {
46 }
47 
48 SpecularSimulationElement::~SpecularSimulationElement() = default;
49 
51 SpecularSimulationElement::operator=(const SpecularSimulationElement& other)
52 {
53  if (this != &other) {
54  SpecularSimulationElement tmp(other);
55  tmp.swapContent(*this);
56  }
57  return *this;
58 }
59 
61 {
62  m_polarization = handler;
63 }
64 
65 std::vector<complex_t> SpecularSimulationElement::produceKz(const std::vector<Slice>& slices)
66 {
67  return m_kz_computation(slices);
68 }
69 
70 void SpecularSimulationElement::swapContent(SpecularSimulationElement& other)
71 {
72  m_polarization.swapContent(other.m_polarization);
73  std::swap(m_intensity, other.m_intensity);
74  m_kz_computation.swap(other.m_kz_computation);
75 }
BasicVector3D< double > vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
Creates a vector<double> as a wavevector with given wavelength and angles.
Declares functions in namespace KzComputation.
void swap(OutputDataIterator< TValue, TContainer > &left, OutputDataIterator< TValue, TContainer > &right)
make Swappable
Declares the class SpecularSimulationElement.
Convenience class for handling polarization density matrix and polarization analyzer operator.
Data structure containing the data of a single slice, for calculating the Fresnel coefficients.
Definition: Slice.h:28
Data stucture containing both input and output of a single image pixel for specular simulation.
std::vector< complex_t > produceKz(const std::vector< Slice > &slices)
Returns kz values for Abeles computation of reflection/transition coefficients.
void setPolarizationHandler(const PolarizationHandler &handler)
Assigns PolarizationHandler.