Commit 60540778 authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

ART - Simulation Engine

- now expects a unique set of rays

ART - RayGrid
- now additionally stores unique set of rays, only this can be accessed publicly
- ray matrix is now private and can be adjusted using protected set method

ART - AdaptiveRayGrid
- NewRaysOfLastAdaptation now is also a set instead of a vector
parent e384e096
......@@ -22,6 +22,10 @@
#include <ITAPropagationPathSim/AtmosphericRayTracing/RayGrid.h>
//STD
#include <set>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
......@@ -31,7 +35,7 @@ namespace ITAPropagationPathSim
class CAdaptiveRayGrid : private CRayGrid
{
private:
std::vector< std::shared_ptr<CRay> > vpNewRaysOfLastAdaptation;
std::set< std::shared_ptr<CRay> > vpNewRaysOfLastAdaptation;
public:
CAdaptiveRayGrid() {}
CAdaptiveRayGrid(const CRayGrid& rayGrid) : CRayGrid(rayGrid) {}
......@@ -40,8 +44,8 @@ namespace ITAPropagationPathSim
void Reset(const CRayGrid& rayGrid);
CRayGrid RayGrid() { return *this; }
const std::vector< std::shared_ptr<CRay> >& Rays() { return CRayGrid::Rays(); }
const std::vector< std::shared_ptr<CRay> >& NewRaysOfLastAdaptation() { return vpNewRaysOfLastAdaptation; }
std::set< std::shared_ptr<CRay> > UniqueRays() { return CRayGrid::UniqueRays(); }
const std::set< std::shared_ptr<CRay> >& NewRaysOfLastAdaptation() { return vpNewRaysOfLastAdaptation; }
//! Simple adaptation method: Setting the limits to neighboring rays and shoots additional rays to double the angular resolution of the grid.
void ZoomIntoRay(const std::shared_ptr<CRay>& pRay);
......
......@@ -29,6 +29,7 @@
// STD
#include <vector>
#include <set>
#include <memory>
namespace ITAPropagationPathSim
......@@ -49,13 +50,15 @@ namespace ITAPropagationPathSim
VistaVector3D v3SourcePos; //< Origin of all rays in this ray grid.
std::vector<double> vdThetaDeg; //< Sorted vector of elevation angles in degrees.
std::vector<double> vdPhiDeg; //< Sorted vector of azimuth angles in degrees.
RayMatrix vvpRayMatrix; //< Matrix of pointers to ray. First index refers to elevation (theta), second to azimuth (phi) angle.
private:
RayVector vpRays; //< Vector of all rays contained by vppRayMatrix. Call InitRayVectorFromRayMatrix() if vppRayMatrix changes.
RayMatrix vvpRayMatrix; //< Matrix of pointers to ray. First index refers to elevation (theta), second to azimuth (phi) angle.
RayVector vpRays; //< Vector of all rays contained by vvpRayMatrix. May contain duplicates at poles (theta = 0 or 180°).
std::set<RayPtr> vpUniqueRays; // Unique set of all rays contained by vvpRayMatrix.
bool bCircularPhi = false; //< Indicates whether the azimuth vector is considered to be circular (phi covers full 360 degrees) or not.
private:
CRayGrid(const RayMatrix& rayMatrix, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool circularPhi = false);
void UpdateDependentRayContainers();
public:
//! Creates a set of rays using a source position and the given elevation and azimuth angles [°] for the inital directions. An optional bool indicates whether the azimuth angle covers the full 360°.
/**
......@@ -65,7 +68,8 @@ namespace ITAPropagationPathSim
CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool circularPhi = false);
protected:
CRayGrid() {}
void InitRayVectorFromRayMatrix();
//! Updates the ray matrix and depenent vectors/set of rays.
void SetRayMatrix(const RayMatrix& newRayMatrix);
//! Filters for certain rays using indices for theta and phi.
void FilterDirections(const std::vector<int>& thetaIdxVec, const std::vector<int>& phiIdxVec, const bool circularPhi = false);
......@@ -82,6 +86,8 @@ namespace ITAPropagationPathSim
bool HasPoleDirection(const std::shared_ptr<CRay>& pRay) const;
//---GET Functions---
protected:
const std::vector<std::shared_ptr<CRay>>& Rays() const { return vpRays; }
public:
const std::vector<double>& ThetaDeg() const { return vdThetaDeg; }
const std::vector<double>& PhiDeg() const { return vdPhiDeg; }
......@@ -89,7 +95,7 @@ namespace ITAPropagationPathSim
int NPhi() const { return vdPhiDeg.size(); }
int NRays() const { return vpRays.size(); }
const VistaVector3D& SourcePosition() const { return v3SourcePos; }
const std::vector<std::shared_ptr<CRay>>& Rays() const { return vpRays; }
std::set<std::shared_ptr<CRay>> UniqueRays() const { return vpUniqueRays; }
bool IsEmpty() const { return NTheta() == 0 || NPhi() == 0; }
bool Contains(const std::shared_ptr<CRay>& pRay) const { return std::find(vpRays.cbegin(), vpRays.cend(), pRay) == vpRays.cend(); }
......
......@@ -31,6 +31,7 @@
// STD
#include <vector>
#include <set>
#include <memory>
namespace ITAPropagationPathSim
......@@ -50,7 +51,7 @@ namespace ITAPropagationPathSim
public:
std::vector<std::shared_ptr<CRay>> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const VistaVector3D& v3SourcePosition, const std::vector<VistaVector3D>& v3RayDirections) const;
void Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::vector<std::shared_ptr<CRay>>& rays) const;
void Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::set<std::shared_ptr<CRay>>& rays) const;
};
}
}
......
......@@ -89,7 +89,7 @@ void CAdaptiveRayGrid::DoubleRayResolution()
if (isNewTheta || isNewPhi)
{
pRay = std::make_shared<CRay>(v3SourcePos, vdThetaDeg[idxTheta], vdPhiDeg[idxPhi]);
vpNewRaysOfLastAdaptation.push_back(pRay);
vpNewRaysOfLastAdaptation.insert(pRay);
}
else
pRay = *iteratorOldRays++;
......@@ -97,8 +97,7 @@ void CAdaptiveRayGrid::DoubleRayResolution()
newRayMatrix[idxTheta].push_back(pRay);
}
}
vvpRayMatrix = newRayMatrix;
InitRayVectorFromRayMatrix();
SetRayMatrix(newRayMatrix);
}
std::vector<double> CAdaptiveRayGrid::DoubleAngularResolution(const std::vector<double>& angleVector) const
......
......@@ -56,7 +56,7 @@ EigenraySearch::CInitialWorker::CInitialWorker(const VistaVector3D& sourcePositi
std::vector<CRayGrid> EigenraySearch::CInitialWorker::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
CRayGrid rayGrid = InitRayGrid(atmosphere);
simulationEngine.Run(atmosphere, rayGrid.Rays());
simulationEngine.Run(atmosphere, rayGrid.UniqueRays());
return FinalizeResult(rayGrid);
}
......@@ -121,7 +121,7 @@ EigenraySearch::CAdaptiveWorker::CAdaptiveWorker(const CRayGrid& rayGrid, const
EigenraySearch::RayPtr EigenraySearch::CAdaptiveWorker::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
simulationEngine.Run(atmosphere, adaptiveRayGrid.Rays());
simulationEngine.Run(atmosphere, adaptiveRayGrid.UniqueRays());
while (!EigenrayAccuracyReached())
{
......
......@@ -17,7 +17,7 @@ using namespace ITAPropagationPathSim::AtmosphericRayTracing;
CRayGrid::CRayGrid(const RayMatrix& rayMatrix, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool circularPhi /*= false*/)
: vvpRayMatrix(rayMatrix), vdThetaDeg(thetaDeg), vdPhiDeg(phiDeg), bCircularPhi(circularPhi)
{
InitRayVectorFromRayMatrix();
UpdateDependentRayContainers();
if (!vpRays.empty())
v3SourcePos = vpRays.front()->SourcePoint();
......@@ -49,7 +49,7 @@ CRayGrid::CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& th
vvpRayMatrix[idxTheta][idxPhi] = std::make_shared<CRay>(sourcePos, vdThetaDeg[idxTheta], vdPhiDeg[idxPhi]);
}
}
InitRayVectorFromRayMatrix();
UpdateDependentRayContainers();
}
......@@ -79,17 +79,25 @@ CEquiangularRayDistribution::CEquiangularRayDistribution(const VistaVector3D& so
// ----------------------
#pragma region Initialization
void CRayGrid::InitRayVectorFromRayMatrix()
void CRayGrid::UpdateDependentRayContainers()
{
vpRays.clear();
vpRays.reserve( NTheta() * NPhi() );
for each (RayVector rayVector in vvpRayMatrix)
for each (RayPtr pRay in rayVector)
vpRays.push_back(pRay);
vpUniqueRays = std::set<RayPtr>(vpRays.begin(), vpRays.end());
}
#pragma endregion
void CRayGrid::SetRayMatrix(const RayMatrix& newRayMatrix)
{
vvpRayMatrix = newRayMatrix;
UpdateDependentRayContainers();
}
void CRayGrid::FilterDirections(const std::vector<int>& thetaIdxVec, const std::vector<int>& phiIdxVec, const bool circularPhi /*= false*/)
{
auto newThetaDeg = std::vector<double>(thetaIdxVec.size());
......@@ -110,7 +118,7 @@ void CRayGrid::FilterDirections(const std::vector<int>& thetaIdxVec, const std::
vdThetaDeg = newThetaDeg;
vdPhiDeg = newPhiDeg;
vvpRayMatrix = newRayMatrix;
InitRayVectorFromRayMatrix();
UpdateDependentRayContainers();
}
const CRayGrid::RayVector& CRayGrid::GetRaysWithSameTheta(const std::shared_ptr<CRay>& pRay)
......
......@@ -121,18 +121,25 @@ class CWorker
std::vector<std::shared_ptr<CRay>> CEngine::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const VistaVector3D& v3SourcePosition, const std::vector<VistaVector3D>& v3RayDirections) const
{
std::vector<std::shared_ptr<CRay>> rays;
rays.reserve(v3RayDirections.size());
for each (const VistaVector3D & v3Direction in v3RayDirections)
rays.push_back(std::make_shared<CRay>(v3SourcePosition, v3Direction));
Run(atmosphere, rays);
for each (std::shared_ptr<CRay> pRay in rays)
{
auto worker = CWorker(pRay, settings, iAbortCriterion);
worker.TraceRay(atmosphere);
}
return rays;
}
void CEngine::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::vector<std::shared_ptr<CRay>>& rays) const
void CEngine::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::set<std::shared_ptr<CRay>>& rays) const
{
for (int idx = 0; idx < rays.size(); idx++)
for each (std::shared_ptr<CRay> pRay in rays)
{
//CRay& ray = rays[idx];
auto worker = CWorker(rays[idx], settings, iAbortCriterion);
if (pRay == nullptr)
continue;
auto worker = CWorker(pRay, settings, iAbortCriterion);
worker.TraceRay(atmosphere);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment