...
 
Commits (3)
  • Philipp Schäfer's avatar
    ART - Eigenray Settings · dae2bf62
    Philipp Schäfer authored
    - added bool to increase speed by stopping ray tracing when receiver distance increase
    dae2bf62
  • Philipp Schäfer's avatar
    ART - CRay · 9ebdcb1c
    Philipp Schäfer authored
    - added bool to ray receiver data which indicates whether receiver distance was updated during last integration step
    - added function check whether any receiver data was updated on last time step
    9ebdcb1c
  • Philipp Schäfer's avatar
    ART - Eigenray Worker · c411417d
    Philipp Schäfer authored
    - now receiver distances are initialized before ray tracing starts
    - now can abort tracing a ray if no distance to any receiver was updated during last time step
    c411417d
......@@ -45,8 +45,9 @@ namespace ITAPropagationPathSim
} advancedRayZooming;
};
struct ITA_PROPAGATION_PATH_SIM_API RayTracingAbortSettings {
int maxReflectionOrder = 1; //< Maximum considered order of reflections
double maxTime = 30; //< Maximum propagation time of rays [s]
int maxReflectionOrder = 1; //< Maximum considered order of reflections
double maxTime = 30; //< Maximum propagation time of rays [s]
bool bAbortOnReceiverDistIncrease = true; //< If enabled, ray tracing will be aborted as soon as ray receiver distance increases
};
struct ITA_PROPAGATION_PATH_SIM_API Settings {
RayTracingAbortSettings rayTracing;
......
......@@ -51,13 +51,14 @@ namespace ITAPropagationPathSim
class ITA_PROPAGATION_PATH_SIM_API CRayReceiverData {
public:
bool bDistanceUpdatedInLastIt; //< indicates whether receiver distance was updated in last during last integration step
float distance;
int idxMinDist;
int reflectionOrder;
VistaVector3D posMinDist;
inline CRayReceiverData() : idxMinDist(-1), distance(-1), reflectionOrder(-1), posMinDist(VistaVector3D()) {};
inline CRayReceiverData(int iMin, float dMin, int reflOrder, const VistaVector3D& rMin = VistaVector3D()) : idxMinDist(iMin), distance(dMin), reflectionOrder(reflOrder), posMinDist(rMin) {};
inline CRayReceiverData() : idxMinDist(-1), distance(-1), reflectionOrder(-1), posMinDist(VistaVector3D()), bDistanceUpdatedInLastIt(false) {};
inline CRayReceiverData(int iMin, float dMin, int reflOrder, const VistaVector3D& rMin = VistaVector3D()) : idxMinDist(iMin), distance(dMin), reflectionOrder(reflOrder), posMinDist(rMin), bDistanceUpdatedInLastIt(true){};
};
class ITA_PROPAGATION_PATH_SIM_API CRay : public std::vector<CRayElement>
......@@ -90,7 +91,7 @@ namespace ITAPropagationPathSim
inline int ReflectionOrder() const { return m_viReflectionIndices.size(); };
//! Returns the reflection order of the ray element with given index
int ReflectionOrder(const int idx) const;
//int ReflectionOrder(const int idx) const;
//! Returns the spreading loss at end point of receiver. If this has not been calculated yet, this returns -1.
inline double SpreadingLoss() const { return m_dSpreadingLoss; };
......@@ -125,7 +126,11 @@ namespace ITAPropagationPathSim
/**
* To be called after each integration step.
*/
bool UpdateMinimumReceiverDistance(const VistaVector3D& receiverPos);
void UpdateMinimumReceiverDistance(const VistaVector3D& receiverPos);
//! Returns true if the receiver distance has been updated for at least one receiver during the last integration time step.
bool ReceiverDistanceUpdatedOnLastTimeStep();
//! Increases the accuracy of each receiver distance using a linear interpolation to adjacent ray points.
/**
* To be called after the ray tracing has been finished.
......
......@@ -8,9 +8,10 @@ using namespace ITAPropagationPathSim::AtmosphericRayTracing;
#pragma region EigenraySearchWatcher
EigenraySearch::CEigenraySearchWatcher::CEigenraySearchWatcher(const ReceiverDataVector& vReceiverData, const double& tMax)
EigenraySearch::CEigenraySearchWatcher::CEigenraySearchWatcher(const ReceiverDataVector& vReceiverData, const double& tMax, const bool bAbortOnReceiverDistIncreas)
: m_vReceiverData(vReceiverData)
, m_dTMax(tMax)
, m_bAbortOnReceiverDistIncrease(bAbortOnReceiverDistIncreas)
{
int maxReflOrder = 0;
for each (const CReceiverData& receiverData in m_vReceiverData)
......@@ -19,10 +20,23 @@ EigenraySearch::CEigenraySearchWatcher::CEigenraySearchWatcher(const ReceiverDat
m_iMaxReflectionOrderRTAbort = maxReflOrder + 1; //Abort Ray Tracing only if the reflection order is 2 above the maximum eigenray reflection order
}
void EigenraySearch::CEigenraySearchWatcher::InitRayReceiverDistances(const std::set<RayPtr>& vpRays) const
{
for each (RayPtr pRay in vpRays)
{
if (!pRay)
continue;
for each (const CReceiverData & receiverData in m_vReceiverData)
pRay->UpdateMinimumReceiverDistance(receiverData.v3Position);
}
}
bool EigenraySearch::CEigenraySearchWatcher::AbortRequested(const std::shared_ptr<CRay> pRay) const
{
//TODO: For CAdaptiveWorker: Track whether distance increased and use this for abortion
return pRay->LastTimeStamp() >= m_dTMax || pRay->ReflectionOrder() > m_iMaxReflectionOrderRTAbort;
return pRay->LastTimeStamp() >= m_dTMax ||
pRay->ReflectionOrder() > m_iMaxReflectionOrderRTAbort ||
m_bAbortOnReceiverDistIncrease && !pRay->ReceiverDistanceUpdatedOnLastTimeStep();
}
void EigenraySearch::CEigenraySearchWatcher::ProcessRay(std::shared_ptr<CRay> pRay) const
......@@ -58,6 +72,11 @@ const VistaVector3D& EigenraySearch::CWorkerBase::VirtualReceiverPosition(const
return m_v3MirroredReceiverPosition;
return m_v3ReceiverPosition;
}
void EigenraySearch::CWorkerBase::RunRayTracing(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::set<RayPtr>& rays) const
{
m_pSimulationWatcher->InitRayReceiverDistances(rays);
m_simulationEngine.Run(atmosphere, rays);
}
EigenraySearch::RayPtr EigenraySearch::CWorkerBase::FindMinimumDistanceRay(const std::set<RayPtr>& rays, const int reflectionOrder) const
{
float dMin = FLT_MAX;
......@@ -83,7 +102,7 @@ EigenraySearch::CInitialWorker::CInitialWorker(const VistaVector3D& sourcePositi
: CWorkerBase(sourcePosition, receiverPosition, simSettings, abortSettings)
{
ReceiverDataVector receiverData = { CReceiverData(ReceiverPosition(), 0) , CReceiverData(MirroredReceiverPosition(), 1) };
m_pSimulationWatcher = std::make_shared<CEigenraySearchWatcher>(receiverData, m_rayTracingAbortSettings.maxTime);
m_pSimulationWatcher = std::make_shared<CEigenraySearchWatcher>(receiverData, m_rayTracingAbortSettings.maxTime, m_rayTracingAbortSettings.bAbortOnReceiverDistIncrease);
m_simulationEngine.pExternalWatcher = m_pSimulationWatcher;
}
......@@ -91,7 +110,7 @@ EigenraySearch::CInitialWorker::CInitialWorker(const VistaVector3D& sourcePositi
std::vector<CRayGrid> EigenraySearch::CInitialWorker::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
CRayGrid rayGrid = InitRayGrid(atmosphere);
m_simulationEngine.Run(atmosphere, rayGrid.UniqueRays());
RunRayTracing(atmosphere, rayGrid.UniqueRays());
FindMinimumDistanceRays(rayGrid.UniqueRays());
return FinalizeResult(rayGrid);
}
......@@ -143,15 +162,14 @@ EigenraySearch::CAdaptiveWorker::CAdaptiveWorker(const CRayGrid& rayGrid, const
m_fReceiverRadius = tan(m_rayAdaptationSettings.accuracy.maxSourceReceiverAngle * M_PI/180.0) * sourceReceiverDistance;
m_fReceiverRadius = fmin(m_rayAdaptationSettings.accuracy.maxReceiverRadius, m_fReceiverRadius);
//TODO: Track whether distance increased and use this for abortion
ReceiverDataVector receiverData = { CReceiverData(VirtualReceiverPosition(), m_iActiveReflexionOrder) };
m_pSimulationWatcher = std::make_shared<CEigenraySearchWatcher>(receiverData, m_rayTracingAbortSettings.maxTime);
m_pSimulationWatcher = std::make_shared<CEigenraySearchWatcher>(receiverData, m_rayTracingAbortSettings.maxTime, m_rayTracingAbortSettings.bAbortOnReceiverDistIncrease);
m_simulationEngine.pExternalWatcher = m_pSimulationWatcher;
}
EigenraySearch::RayPtr EigenraySearch::CAdaptiveWorker::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
m_simulationEngine.Run(atmosphere, m_adaptiveRayGrid.UniqueRays());
RunRayTracing(atmosphere, m_adaptiveRayGrid.UniqueRays());
m_pMinDistanceRay = FindMinimumDistanceRay(m_adaptiveRayGrid.UniqueRays(), m_iActiveReflexionOrder);
while (!EigenrayAccuracyReached())
{
......@@ -160,7 +178,7 @@ EigenraySearch::RayPtr EigenraySearch::CAdaptiveWorker::Run(const ITAGeo::CStrat
else
m_adaptiveRayGrid.ZoomIntoRay(m_pMinDistanceRay);
m_simulationEngine.Run(atmosphere, m_adaptiveRayGrid.NewRaysOfLastAdaptation());
RunRayTracing(atmosphere, m_adaptiveRayGrid.NewRaysOfLastAdaptation());
m_pMinDistanceRay = FindMinimumDistanceRay(m_adaptiveRayGrid.UniqueRays(), m_iActiveReflexionOrder);
m_nAdaptations++;
}
......
......@@ -69,9 +69,12 @@ namespace ITAPropagationPathSim
ReceiverDataVector m_vReceiverData;
double m_dTMax;
int m_iMaxReflectionOrderRTAbort;
bool m_bAbortOnReceiverDistIncrease;
public:
CEigenraySearchWatcher(const ReceiverDataVector& vReceiverData, const double& tMax);
CEigenraySearchWatcher(const ReceiverDataVector& vReceiverData, const double& tMax, const bool bAbortOnReceiverDistIncrease);
public:
void InitRayReceiverDistances(const std::set<RayPtr>& rays) const;
virtual bool AbortRequested(const std::shared_ptr<CRay> pRay) const;
//! Interface function to Simulation::Engine: Updates the minimum receiver distance of the ray after each processing step
virtual void ProcessRay(std::shared_ptr<CRay>) const;
......@@ -99,6 +102,7 @@ namespace ITAPropagationPathSim
inline const VistaVector3D& MirroredReceiverPosition() const { return m_v3MirroredReceiverPosition; };
const VistaVector3D& VirtualReceiverPosition(const int reflectionOrder) const;
void RunRayTracing(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::set<RayPtr>& rays) const;
RayPtr FindMinimumDistanceRay(const std::set<RayPtr>& rays, const int reflectionOrder) const;
};
......
......@@ -128,23 +128,38 @@ const CRayReceiverData* CRay::ReceiverDistanceData(const VistaVector3D& receiver
}
bool CRay::UpdateMinimumReceiverDistance(const VistaVector3D& receiverPos)
void CRay::UpdateMinimumReceiverDistance(const VistaVector3D& receiverPos)
{
float distance = (LastPoint() - receiverPos).GetLength();
if (m_mReceiverDistanceMap.find(&receiverPos) == m_mReceiverDistanceMap.cend()) //Receiver not yet in map
{
m_mReceiverDistanceMap[&receiverPos] = CRayReceiverData(NumPoints() - 1, distance, ReflectionOrder());
return true;
return;
}
CRayReceiverData& receiverDistanceData = m_mReceiverDistanceMap[&receiverPos];
if (distance >= receiverDistanceData.distance)
return false;
{
receiverDistanceData.bDistanceUpdatedInLastIt = false;
}
else
{
receiverDistanceData.distance = distance;
receiverDistanceData.idxMinDist = NumPoints() - 1;
receiverDistanceData.reflectionOrder = ReflectionOrder();
receiverDistanceData.bDistanceUpdatedInLastIt = true;
}
}
receiverDistanceData.distance = distance;
receiverDistanceData.idxMinDist = NumPoints() - 1;
receiverDistanceData.reflectionOrder = ReflectionOrder();
return true;
bool CRay::ReceiverDistanceUpdatedOnLastTimeStep()
{
for (auto const& element : m_mReceiverDistanceMap)
{
const CRayReceiverData receiverData = element.second;
if (receiverData.bDistanceUpdatedInLastIt)
return true;
}
return false;
}
void CRay::FinalizeMinimumReceiverDistances()
......