BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MatrixFresnelMap.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Fresnel/MatrixFresnelMap.h
6 //! @brief Defines class MatrixFresnelMap.
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 
15 #ifndef BORNAGAIN_CORE_MULTILAYER_MATRIXFRESNELMAP_H
16 #define BORNAGAIN_CORE_MULTILAYER_MATRIXFRESNELMAP_H
17 
21 #include <cstddef>
22 #include <memory>
23 #include <unordered_map>
24 #include <utility>
25 #include <vector>
26 
28 class Slice;
29 class SimulationElement;
30 
31 //! Implementation of IFresnelMap for matrix valued reflection/transmission coefficients.
32 //! @ingroup algorithms_internal
33 
35 {
36 public:
37  MatrixFresnelMap(std::unique_ptr<ISpecularStrategy> strategy);
38  ~MatrixFresnelMap() override;
39 
40  MatrixFresnelMap(const MatrixFresnelMap& other) = delete;
41  MatrixFresnelMap& operator=(const MatrixFresnelMap& other) = delete;
42 
43  std::unique_ptr<const ILayerRTCoefficients>
44  getOutCoefficients(const SimulationElement& sim_element,
45  size_t layer_index) const final override;
46 
47  void setSlices(const std::vector<Slice>& slices) final override;
48 
49 private:
50  //! Provides a hash function for a 3-vector of doubles, for use in MatrixFresnelMap.
52  {
53  public:
54  size_t operator()(const kvector_t& kvec) const noexcept;
55  };
56 
57  using CoefficientHash = std::unordered_map<kvector_t, ISpecularStrategy::coeffs_t, HashKVector>;
58 
59  std::unique_ptr<const ILayerRTCoefficients> getCoefficients(const kvector_t& kvec,
60  size_t layer_index) const override;
61  std::unique_ptr<const ILayerRTCoefficients> getCoefficients(const kvector_t& kvec,
62  size_t layer_index,
63  const std::vector<Slice>& slices,
64  CoefficientHash& hash_table) const;
65  std::vector<Slice> m_inverted_slices;
68 
70  const std::vector<Slice>& slices,
71  CoefficientHash& hash_table) const;
72 };
73 
74 #endif // BORNAGAIN_CORE_MULTILAYER_MATRIXFRESNELMAP_H
Defines class IFresnelMap.
Defines class MatrixRTCoefficients.
Defines class SpecularMagneticStrategy.
Holds the necessary information to calculate the radiation wavefunction in every layer for different ...
Definition: IFresnelMap.h:30
const std::vector< Slice > & slices() const
Definition: IFresnelMap.cpp:28
Interface to access reflection/transmission coefficients.
std::vector< std::unique_ptr< const ILayerRTCoefficients > > coeffs_t
Provides a hash function for a 3-vector of doubles, for use in MatrixFresnelMap.
size_t operator()(const kvector_t &kvec) const noexcept
Returns hash value of a 3-vector, computed by exclusive-or of the component hash values.
Implementation of IFresnelMap for matrix valued reflection/transmission coefficients.
std::vector< Slice > m_inverted_slices
CoefficientHash m_hash_table_in
std::unordered_map< kvector_t, ISpecularStrategy::coeffs_t, HashKVector > CoefficientHash
std::unique_ptr< const ILayerRTCoefficients > getCoefficients(const kvector_t &kvec, size_t layer_index) const override
void setSlices(const std::vector< Slice > &slices) final override
MatrixFresnelMap & operator=(const MatrixFresnelMap &other)=delete
const ISpecularStrategy::coeffs_t & getCoefficientsFromCache(kvector_t kvec, const std::vector< Slice > &slices, CoefficientHash &hash_table) const
MatrixFresnelMap(const MatrixFresnelMap &other)=delete
std::unique_ptr< const ILayerRTCoefficients > getOutCoefficients(const SimulationElement &sim_element, size_t layer_index) const final override
Retrieves the amplitude coefficients for a (time-reversed) outgoing wavevector.
MatrixFresnelMap(std::unique_ptr< ISpecularStrategy > strategy)
CoefficientHash m_hash_table_out
~MatrixFresnelMap() override
Data stucture containing both input and output of a single detector cell.
Data structure containing the data of a single slice, for calculating the Fresnel coefficients.
Definition: Slice.h:28