BornAgain  1.19.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 reflection and scattering
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 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_SAMPLE_FRESNEL_MATRIXFRESNELMAP_H
21 #define BORNAGAIN_SAMPLE_FRESNEL_MATRIXFRESNELMAP_H
22 
24 #include <cstddef>
25 #include <memory>
26 #include <unordered_map>
27 #include <utility>
28 #include <vector>
29 
31 class Slice;
32 class SimulationElement;
33 
34 //! Implementation of IFresnelMap for matrix valued reflection/transmission coefficients.
35 //! @ingroup algorithms_internal
36 
37 class MatrixFresnelMap : public IFresnelMap {
38 public:
39  MatrixFresnelMap(std::unique_ptr<ISpecularStrategy> strategy);
40  ~MatrixFresnelMap() override;
41 
42  MatrixFresnelMap(const MatrixFresnelMap& other) = delete;
43  MatrixFresnelMap& operator=(const MatrixFresnelMap& other) = delete;
44 
45  std::unique_ptr<const ILayerRTCoefficients>
46  getOutCoefficients(const SimulationElement& sim_element, size_t layer_index) const final;
47 
48  void setSlices(const std::vector<Slice>& slices) final;
49 
50 private:
51  //! Provides a hash function for a 3-vector of doubles, for use in MatrixFresnelMap.
52  class HashKVector {
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_SAMPLE_FRESNEL_MATRIXFRESNELMAP_H
75 #endif // USER_API
Defines interface IFresnelMap.
Holds the necessary information to calculate the radiation wavefunction in every layer for different ...
Definition: IFresnelMap.h:34
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
void setSlices(const std::vector< Slice > &slices) final
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
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
MatrixFresnelMap(std::unique_ptr< ISpecularStrategy > strategy)
CoefficientHash m_hash_table_out
std::unique_ptr< const ILayerRTCoefficients > getOutCoefficients(const SimulationElement &sim_element, size_t layer_index) const final
Retrieves the amplitude coefficients for a (time-reversed) outgoing wavevector.
~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:32