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

Atmospheric Ray Tracing - EigenrayFinder

- version 2 -> still WIP
parent 6d017535
......@@ -25,8 +25,8 @@
#include <VistaBase/VistaVector3D.h>
// ITA includes
#include <ITAPropagationPathSim/AtmosphericRayTracing/Simulation/Engine.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/Rays.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/Simulation/Settings.h>
#include <ITAGeo/Atmosphere/StratifiedAtmosphere.h>
// STD
......@@ -40,40 +40,41 @@ namespace ITAPropagationPathSim
{
namespace Simulation {
struct ITA_PROPAGATION_PATH_SIM_API EigenraySettings {
unsigned int maxReflectionOrder; //< Maximum considered order of reflections
struct ITA_PROPAGATION_PATH_SIM_API RayAdaptationSettings {
struct {
unsigned int maxNAdaptations = 15; //< Abort after X adaptations of the ray resolution
//double minAngleResolutionDeg = 0.001; //< []
} abort;
struct {
double maxReceiverRadius = 1; //< [m]
double maxSourceReceiverAngle = 1; //< []
double maxAngleForGeomSpreading = 0.01; //< []
} accuracy;
struct {
double threshold = 0.1; //< [0 1]
} advancedRayZooming;
};
struct ITA_PROPAGATION_PATH_SIM_API RayTracingAbortSettings {
unsigned int maxReflectionOrder = 3; //< Maximum considered order of reflections
double maxTime = 30; //< [s]
double maxReceiverRadius = 1; //< [m]
double maxSourceReceiverAngle = 1; //< []
unsigned int maxNAdaptations = 15; //< Abort after X adaptations of the ray resolution
//double minAngleResolutionDeg = 0.001; //< []
double advangedRayZoomingThreshold = 0.1; //< [0 1]
double maxAngleForGeomSpreading = 0.01; //< []
};
struct ITA_PROPAGATION_PATH_SIM_API EigenraySettings {
RayTracingAbortSettings rayTracing;
RayAdaptationSettings rayAdaptation;
};
class ITA_PROPAGATION_PATH_SIM_API CEigenrayFinder
{
private:
CEngine simulationEngine;
EigenraySettings eigenSettings;
VistaVector3D v3SourcePosition;
VistaVector3D v3ReceiverPosition;
public:
CEigenrayFinder() {}
EigenraySettings eigenraySettings;
SimulationSettings simulationSettings;
public:
SimulationSettings& SimulationSettings() { return simulationEngine.settings; }
EigenraySettings& EigenraySettings() { return eigenSettings; }
CEigenrayFinder() {}
public:
std::vector<std::shared_ptr<CRay>> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition);
private:
void InitialRayTracing(const ITAGeo::CStratifiedAtmosphere& atmosphere);
};
}
}
......
#include <ITAPropagationPathSim/AtmosphericRayTracing/Simulation/EigenrayFinder.h>
// ITA includes
#include <ITAPropagationPathSim/AtmosphericRayTracing/Simulation/Engine.h>
#include "RayResolutionAdapter.h"
#include <ITAPropagationPathSim/AtmosphericRayTracing/RayGrid.h>
......@@ -13,18 +14,175 @@
using namespace ITAPropagationPathSim::AtmosphericRayTracing;
using namespace ITAPropagationPathSim::AtmosphericRayTracing::Simulation;
std::vector<std::shared_ptr<CRay>> CEigenrayFinder::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition)
namespace ITAPropagationPathSim
{
v3ReceiverPosition = receiverPosition;
v3SourcePosition = sourcePosition;
namespace AtmosphericRayTracing
{
namespace Simulation {
typedef std::shared_ptr<CRay> RayPtr;
typedef std::vector< RayPtr > RayVector;
class CEigenrayWorkerBase : public IAbortCriterion
{
protected:
CEngine simulationEngine;
RayTracingAbortSettings rayTracingAbortSettings;
VistaVector3D v3ReceiverPosition;
public:
virtual bool AbortRequested(const RayPtr& pRay) {
if (pRay->LastTimeStamp() >= rayTracingAbortSettings.maxTime)
return true;
if (pRay->ReflectionOrder() > rayTracingAbortSettings.maxReflectionOrder)
return true;
UpdateMinimumReceiverDistance(pRay);
return false;
}
public:
CEigenrayWorkerBase(const VistaVector3D& receiverPosition, const SimulationSettings& simSettings, const RayTracingAbortSettings& rtSettings)
: v3ReceiverPosition(receiverPosition), rayTracingAbortSettings(rtSettings) { simulationEngine.settings = simSettings; }
protected:
virtual bool UpdateMinimumReceiverDistance(const RayPtr& pRay) = 0;
VistaVector3D ReceiverDistanceVector(const unsigned int& reflectionOrder, const VistaVector3D& rayPoint) { return VirtualReceiverPosition(reflectionOrder) - rayPoint; }
float ReceiverDistance(const unsigned int& reflectionOrder, const VistaVector3D& rayPoint) { return ReceiverDistanceVector(reflectionOrder, rayPoint).GetLength(); }
VistaVector3D VirtualReceiverPosition(const unsigned int& reflectionOrder) {
VistaVector3D out = v3ReceiverPosition;
if (reflectionOrder % 2 != 0) //On uneven reflection order
out[Vista::Z] = -out[Vista::Z];
return out;
}
};
class CMinDistanceRayInitializer : public CEigenrayWorkerBase
{
private:
VistaVector3D v3SourcePosition;
RayVector vpMinDistanceRays; //< Vector containing the current ray of minimum receiver distance for each reflection order
std::vector<float> vfMinDistances; //< Current minimum distance to receiver for each reflection order
private:
virtual bool UpdateMinimumReceiverDistance(const RayPtr& pRay)
{
const int reflectionOrder = pRay->ReflectionOrder();
float receiverDistance = ReceiverDistance(reflectionOrder, pRay->LastPoint());
if (reflectionOrder < vfMinDistances.size())
{
if (vfMinDistances[reflectionOrder] <= receiverDistance)
return false;
vfMinDistances[reflectionOrder] = receiverDistance;
vpMinDistanceRays[reflectionOrder] = pRay;
return true;
}
vfMinDistances.push_back(receiverDistance);
vpMinDistanceRays.push_back(pRay);
return true;
}
CRayGrid rayGrid = CEquiangularRayDistribution(sourcePosition, 7, 10);
CRayGrid InitRayGrid(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
return CEquiangularRayDistribution(v3SourcePosition, 7, 10);
}
std::vector<CRayGrid> FinalizeResult(const CRayGrid& initialRayGrid)
{
std::vector<CRayGrid> rayGridsOfReflectionOrder;
for each (RayPtr pRay in vpMinDistanceRays)
rayGridsOfReflectionOrder.push_back(initialRayGrid.GetNeighboringRays(pRay).NewRays());
return std::vector<std::shared_ptr<CRay>>();
return rayGridsOfReflectionOrder;
}
public:
CMinDistanceRayInitializer(const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition, const SimulationSettings& simSettings, const RayTracingAbortSettings& abortSettings)
: CEigenrayWorkerBase(receiverPosition, simSettings, abortSettings) , v3SourcePosition(sourcePosition) {}
std::vector<CRayGrid> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
CRayGrid rayGrid = InitRayGrid(atmosphere);
simulationEngine.Run(atmosphere, rayGrid.Rays());
return FinalizeResult(rayGrid);
}
};
class CEigenrayWorker : public CEigenrayWorkerBase
{
private:
CRayResolutionAdapter rayResolutionAdapter;
unsigned int iActiveReflexionOrder;
RayAdaptationSettings rayAdaptationSettings;
RayPtr pMinDistanceRay;
float fMinReceiverDistance;
VistaVector3D v3MinReceiverVector;
int iMinReceiverDistanceIdx;
public:
//virtual bool AbortRequested(const RayPtr pRay) {
// if (pRay->LastTimeStamp() >= eigenraySettings.maxTime)
// return true;
// if (pRay->ReflectionOrder() > eigenraySettings.maxReflectionOrder)
// return true;
// UpdateMinimumReceiverDistance(pRay);
// return false;
//}
protected:
bool UpdateMinimumReceiverDistance(const RayPtr& pRay)
{
const VistaVector3D deltaVec = ReceiverDistanceVector(iActiveReflexionOrder, pRay->LastPoint());
const float receiverDistance = deltaVec.GetLength();
if (fMinReceiverDistance <= receiverDistance)
return false;
fMinReceiverDistance = receiverDistance;
v3MinReceiverVector = deltaVec;
iMinReceiverDistanceIdx = pRay->NumPoints() - 1;
pMinDistanceRay = pRay;
}
public:
CEigenrayWorker(const CRayGrid& rayGrid, const VistaVector3D& receiverPosition, const SimulationSettings& simSettings, const EigenraySettings& eigenraySettings, const int& activeReflectionOrder)
: CEigenrayWorkerBase(receiverPosition, simSettings, eigenraySettings.rayTracing), iActiveReflexionOrder(activeReflectionOrder), rayAdaptationSettings(eigenraySettings.rayAdaptation) {}
void Init()
{
}
public:
RayPtr Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
return RayPtr();
}
};
}
}
}
void CEigenrayFinder::InitialRayTracing(const ITAGeo::CStratifiedAtmosphere& atmosphere)
std::vector<std::shared_ptr<CRay>> CEigenrayFinder::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition)
{
CRayGrid rayGrid = CEquiangularRayDistribution(v3SourcePosition, 7, 10);
simulationEngine.Run(atmosphere, rayGrid.Rays());
}
SimulationSettings initialSettings = simulationSettings;
initialSettings.dIntegrationTimeStep *= 10;
CMinDistanceRayInitializer initialRayTracing(sourcePosition, receiverPosition, initialSettings, eigenraySettings.rayTracing);
std::vector<CRayGrid> initialRayGrids = initialRayTracing.Run(atmosphere);
RayVector eigenrays;
for (int reflectionOrder = 0; reflectionOrder < initialRayGrids.size(); reflectionOrder++)
{
CEigenrayWorker worker(initialRayGrids[reflectionOrder], receiverPosition, simulationSettings, eigenraySettings, reflectionOrder);
eigenrays.push_back( worker.Run(atmosphere) );
}
return eigenrays;
}
\ No newline at end of file
Supports Markdown
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