BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DepthProbeElement.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Core/Computation/DepthProbeElement.cpp
6 //! @brief Implements class DepthProbeElement.
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/Axis/IAxis.h"
17 
18 const double phi_i_0 = 0.0;
19 
20 DepthProbeElement::DepthProbeElement(double wavelength, double alpha_i, const IAxis* z_positions)
21  : m_wavelength(wavelength), m_alpha_i(alpha_i), m_z_positions(z_positions),
22  m_calculation_flag(true)
23 {
24  if (!z_positions)
25  throw std::runtime_error(
26  "Error in DepthProbeElement::DepthProbeElement: z positions are not specified");
27  m_intensities.resize(z_positions->size(), 0.0);
28 }
29 
30 DepthProbeElement::DepthProbeElement(const DepthProbeElement& other)
31  : m_wavelength(other.m_wavelength), m_alpha_i(other.m_alpha_i),
32  m_intensities(other.m_intensities), m_z_positions(other.m_z_positions),
33  m_calculation_flag(other.m_calculation_flag)
34 {
35 }
36 
37 DepthProbeElement::DepthProbeElement(DepthProbeElement&& other) noexcept
38  : m_wavelength(other.m_wavelength), m_alpha_i(other.m_alpha_i),
39  m_intensities(std::move(other.m_intensities)), m_z_positions(other.m_z_positions),
40  m_calculation_flag(other.m_calculation_flag)
41 {
42 }
43 
44 DepthProbeElement::~DepthProbeElement() = default;
45 
46 DepthProbeElement& DepthProbeElement::operator=(const DepthProbeElement& other)
47 {
48  if (this != &other) {
49  DepthProbeElement tmp(other);
50  tmp.swapContent(*this);
51  }
52  return *this;
53 }
54 
55 kvector_t DepthProbeElement::getKi() const
56 {
57  return vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i, phi_i_0);
58 }
59 
60 void DepthProbeElement::swapContent(DepthProbeElement& other)
61 {
62  std::swap(m_wavelength, other.m_wavelength);
63  std::swap(m_alpha_i, other.m_alpha_i);
64  m_intensities.swap(other.m_intensities);
65  std::swap(m_z_positions, other.m_z_positions);
66  std::swap(m_calculation_flag, other.m_calculation_flag);
67 }
BasicVector3D< double > vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
Creates a vector<double> as a wavevector with given wavelength and angles.
Defines class DepthProbeElement.
Defines class IAxis.
void swap(OutputDataIterator< TValue, TContainer > &left, OutputDataIterator< TValue, TContainer > &right)
make Swappable
Interface for one-dimensional axes.
Definition: IAxis.h:25
virtual size_t size() const =0
retrieve the number of bins