BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ScalarFresnelMap.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Fresnel/ScalarFresnelMap.h
6 //! @brief Defines class ScalarFresnelMap.
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_SCALARFRESNELMAP_H
21 #define BORNAGAIN_SAMPLE_FRESNEL_SCALARFRESNELMAP_H
22 
25 #include <cstddef>
26 #include <unordered_map>
27 #include <utility>
28 #include <vector>
29 
31 class SimulationElement;
32 class Slice;
33 
34 //! Implementation of IFresnelMap for scalar valued reflection/transmission coefficients.
35 //! @ingroup algorithms_internal
36 
37 class ScalarFresnelMap : public IFresnelMap {
38 public:
39  ScalarFresnelMap(std::unique_ptr<ISpecularStrategy> strategy);
40  ~ScalarFresnelMap() override;
41 
42  ScalarFresnelMap(const ScalarFresnelMap& other) = delete;
43  ScalarFresnelMap& operator=(const ScalarFresnelMap& other) = delete;
44 
45  std::unique_ptr<const ILayerRTCoefficients>
46  getOutCoefficients(const SimulationElement& sim_element, size_t layer_index) const override;
47 
48 private:
49  //! Provides a hash function for a pair of doubles.
50  class Hash2Doubles {
51  public:
52  size_t operator()(const std::pair<double, double>& doubles) const noexcept;
53  };
54 
55  std::unique_ptr<const ILayerRTCoefficients> getCoefficients(const kvector_t& kvec,
56  size_t layer_index) const override;
58  mutable std::unordered_map<std::pair<double, double>, ISpecularStrategy::coeffs_t, Hash2Doubles>
60 };
61 
62 #endif // BORNAGAIN_SAMPLE_FRESNEL_SCALARFRESNELMAP_H
63 #endif // USER_API
Defines interface IFresnelMap.
Defines class ScalarRTCoefficients.
Holds the necessary information to calculate the radiation wavefunction in every layer for different ...
Definition: IFresnelMap.h:34
Interface to access reflection/transmission coefficients.
std::vector< std::unique_ptr< const ILayerRTCoefficients > > coeffs_t
Provides a hash function for a pair of doubles.
size_t operator()(const std::pair< double, double > &doubles) const noexcept
Returns hash value of a pair of doubles, computed by exclusive-or of the component hash values.
Implementation of IFresnelMap for scalar valued reflection/transmission coefficients.
std::unique_ptr< const ILayerRTCoefficients > getOutCoefficients(const SimulationElement &sim_element, size_t layer_index) const override
Retrieves the amplitude coefficients for a (time-reversed) outgoing wavevector.
ScalarFresnelMap(std::unique_ptr< ISpecularStrategy > strategy)
const ISpecularStrategy::coeffs_t & getCoefficientsFromCache(kvector_t kvec) const
std::unique_ptr< const ILayerRTCoefficients > getCoefficients(const kvector_t &kvec, size_t layer_index) const override
~ScalarFresnelMap() override
ScalarFresnelMap(const ScalarFresnelMap &other)=delete
ScalarFresnelMap & operator=(const ScalarFresnelMap &other)=delete
std::unordered_map< std::pair< double, double >, ISpecularStrategy::coeffs_t, Hash2Doubles > m_cache
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