Skip to content
Snippets Groups Projects
Commit fbe53934 authored by Beerwerth, Randolf's avatar Beerwerth, Randolf
Browse files

Hide concrete type returned by SpecularScalarStrategy

parent b150525e
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,6 @@
#include "ScalarRTCoefficients.h"
#include "SimulationElement.h"
#include "Slice.h"
#include "SpecularScalarStrategy.h"
#include "Vectors3D.h"
#include <functional>
......@@ -41,13 +40,13 @@ ScalarFresnelMap::getCoefficients(const kvector_t& kvec, size_t layer_index) con
{
if (!m_use_cache) {
auto coeffs = std::make_unique<SpecularScalarStrategy>()->Execute(m_slices, kvec);
return std::unique_ptr<const ScalarRTCoefficients>(coeffs[layer_index]->clone());
return SpecularScalarStrategy::single_coeff_t(coeffs[layer_index]->clone());
}
const auto& coef_vector = getCoefficientsFromCache(kvec);
return std::unique_ptr<const ScalarRTCoefficients>(coef_vector[layer_index]->clone());
return SpecularScalarStrategy::single_coeff_t(coef_vector[layer_index]->clone());
}
const std::vector<std::unique_ptr<ScalarRTCoefficients>>&
const SpecularScalarStrategy::coeffs_t&
ScalarFresnelMap::getCoefficientsFromCache(kvector_t kvec) const
{
std::pair<double, double> k2_theta(kvec.mag2(), kvec.theta());
......
......@@ -17,6 +17,7 @@
#include "IFresnelMap.h"
#include "ScalarRTCoefficients.h"
#include "SpecularScalarStrategy.h"
#include <cstddef>
#include <unordered_map>
#include <utility>
......@@ -48,8 +49,8 @@ private:
std::unique_ptr<const ILayerRTCoefficients> getCoefficients(const kvector_t& kvec,
size_t layer_index) const override;
const std::vector<std::unique_ptr<ScalarRTCoefficients>>& getCoefficientsFromCache(kvector_t kvec) const;
mutable std::unordered_map<std::pair<double, double>, std::vector<std::unique_ptr<ScalarRTCoefficients>>,
const SpecularScalarStrategy::coeffs_t& getCoefficientsFromCache(kvector_t kvec) const;
mutable std::unordered_map<std::pair<double, double>, SpecularScalarStrategy::coeffs_t,
Hash2Doubles> m_cache;
};
......
......@@ -42,20 +42,20 @@ const LayerRoughness* GetBottomRoughness(const std::vector<Slice>& slices,
const double pi2_15 = std::pow(M_PI_2, 1.5);
} // namespace
std::vector<std::unique_ptr<ScalarRTCoefficients>>
SpecularScalarStrategy::coeffs_t
SpecularScalarStrategy::Execute(const std::vector<Slice>& slices, kvector_t k)
{
std::vector<complex_t> kz = KzComputation::computeReducedKz(slices, k);
return Execute(slices, kz);
}
std::vector<std::unique_ptr<ScalarRTCoefficients>>
SpecularScalarStrategy::coeffs_t
SpecularScalarStrategy::Execute(const std::vector<Slice>& slices, const std::vector<complex_t>& kz)
{
if(slices.size() != kz.size())
throw std::runtime_error("Number of slices does not match the size of the kz-vector");
std::vector<std::unique_ptr<ScalarRTCoefficients>> result;
SpecularScalarStrategy::coeffs_t result;
for(auto& coeff : computeTR(slices, kz))
result.push_back( std::make_unique<ScalarRTCoefficients>(coeff) );
......
......@@ -29,17 +29,19 @@ class Slice;
class SpecularScalarStrategy
{
public:
//! Computes refraction angles and transmission/reflection coefficients
//! for given coherent wave propagation in a multilayer.
//! Roughness is modelled by tanh profile [see e.g. Phys. Rev. B, vol. 47 (8), p. 4385 (1993)].
BA_CORE_API_ std::vector<std::unique_ptr<ScalarRTCoefficients>>
Execute(const std::vector<Slice>& slices, kvector_t k);
//! Computes transmission/reflection coefficients
//! for given set of z-components of wave-vectors in a multilayer.
//! Roughness is modelled by tanh profile [see e.g. Phys. Rev. B, vol. 47 (8), p. 4385 (1993)].
BA_CORE_API_ std::vector<std::unique_ptr<ScalarRTCoefficients>>
Execute(const std::vector<Slice>& slices, const std::vector<complex_t>& kz);
typedef std::unique_ptr<const ScalarRTCoefficients> single_coeff_t;
typedef std::vector<single_coeff_t> coeffs_t;
//! Computes refraction angles and transmission/reflection coefficients
//! for given coherent wave propagation in a multilayer.
//! Roughness is modelled by tanh profile [see e.g. Phys. Rev. B, vol. 47 (8), p. 4385 (1993)].
BA_CORE_API_ coeffs_t Execute(const std::vector<Slice>& slices, kvector_t k);
//! Computes transmission/reflection coefficients
//! for given set of z-components of wave-vectors in a multilayer.
//! Roughness is modelled by tanh profile [see e.g. Phys. Rev. B, vol. 47 (8), p. 4385 (1993)].
BA_CORE_API_ coeffs_t Execute(const std::vector<Slice>& slices, const std::vector<complex_t>& kz);
}; // namespace SpecularMatrix
#endif // SPECULARSCALARSTRATEGY_H
......@@ -32,7 +32,7 @@ protected:
EXPECT_NEAR(coeff1.t_r(1).real(), coeff2.t_r(1).real(), 1e-10);
EXPECT_NEAR(coeff1.t_r(1).imag(), coeff2.t_r(1).imag(), 1e-10);
}
std::vector<ScalarRTCoefficients> getCoeffs(std::vector<std::unique_ptr<ScalarRTCoefficients>>&& inputCoeffs)
std::vector<ScalarRTCoefficients> getCoeffs(SpecularScalarStrategy::coeffs_t&& inputCoeffs)
{
std::vector<ScalarRTCoefficients> result;
for(auto& coeff : inputCoeffs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment