Skip to content
Snippets Groups Projects
Commit 48fc9a63 authored by Yurov, Dmitry's avatar Yurov, Dmitry
Browse files

fillSpecularData for SpecularSimulationElement (code doubling)

parent 52abac2d
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
class ILayerRTCoefficients;
class MultiLayer;
class SimulationElement;
class SpecularSimulationElement;
//! Holds the necessary information to calculate the radiation wavefunction in every layer
//! for different incoming (outgoing) angles of the beam in the top layer
......@@ -44,6 +45,7 @@ public:
//! Fills simulation element specular data
virtual void fillSpecularData(SimulationElement& sim_element) const = 0;
virtual void fillSpecularData(SpecularSimulationElement& sim_element) const = 0;
//! Sets the multilayer to be used for the Fresnel calculations.
virtual void setMultilayer(const MultiLayer& multilayer);
......
......@@ -19,6 +19,7 @@
#include "SimulationElement.h"
#include "SpecularData.h"
#include "SpecularMagnetic.h"
#include "SpecularSimulationElement.h"
namespace {
std::vector<MatrixRTCoefficients> calculateCoefficients(const MultiLayer& multilayer,
......@@ -57,6 +58,17 @@ void MatrixFresnelMap::fillSpecularData(SimulationElement& sim_element) const
sim_element.setSpecular(std::make_unique<SpecularData>(std::move(coef_vector)));
}
void MatrixFresnelMap::fillSpecularData(SpecularSimulationElement& sim_element) const
{
const auto& kvec = sim_element.getKi();
std::vector<MatrixRTCoefficients> coef_vector;
if (m_use_cache)
coef_vector = getCoefficientsFromCache(kvec, *mP_multilayer, m_hash_table_in);
else
coef_vector = calculateCoefficients(*mP_multilayer, kvec);
sim_element.setSpecular(std::make_unique<SpecularData>(std::move(coef_vector)));
}
const ILayerRTCoefficients* MatrixFresnelMap::getCoefficients(kvector_t kvec, size_t layer_index,
const MultiLayer& multilayer,
CoefficientHash& hash_table) const
......
......@@ -45,6 +45,7 @@ public:
//! Fills simulation element specular data
void fillSpecularData(SimulationElement& sim_element) const override;
void fillSpecularData(SpecularSimulationElement& sim_element) const override;
typedef std::unordered_map<kvector_t, std::vector<MatrixRTCoefficients>, HashKVector>
CoefficientHash;
......
......@@ -18,6 +18,7 @@
#include "SimulationElement.h"
#include "SpecularData.h"
#include "SpecularMatrix.h"
#include "SpecularSimulationElement.h"
namespace {
std::vector<ScalarRTCoefficients> calculateCoefficients(const MultiLayer& multilayer,
......@@ -53,6 +54,17 @@ void ScalarFresnelMap::fillSpecularData(SimulationElement& sim_element) const
sim_element.setSpecular(std::make_unique<SpecularData>(std::move(coef_vector)));
}
void ScalarFresnelMap::fillSpecularData(SpecularSimulationElement& sim_element) const
{
const auto& kvec = sim_element.getKi();
std::vector<ScalarRTCoefficients> coef_vector;
if (m_use_cache)
coef_vector = getCoefficientsFromCache(kvec);
else
coef_vector = calculateCoefficients(*mP_multilayer, kvec);
sim_element.setSpecular(std::make_unique<SpecularData>(std::move(coef_vector)));
}
const ScalarRTCoefficients* ScalarFresnelMap::getCoefficients(
kvector_t kvec, size_t layer_index) const
{
......
......@@ -45,6 +45,7 @@ public:
//! Fills simulation element specular data
void fillSpecularData(SimulationElement& sim_element) const override;
void fillSpecularData(SpecularSimulationElement& sim_element) const override;
private:
const ScalarRTCoefficients* getCoefficients(kvector_t kvec, size_t layer_index) const;
......
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