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

ART - Eigenray Worker

- 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
parent 9ebdcb1c
......@@ -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;
};
......
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