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

ART - Eigenray Search Worker

- started to update according to new CRayReceiverData in CRays
parent 3f8586c7
......@@ -6,6 +6,7 @@
//#include <VistaInterProcComm/Concurrency/VistaThread.h>
// STD
#include <algorithm>
using namespace ITAPropagationPathSim::AtmosphericRayTracing;
......@@ -22,6 +23,11 @@ void EigenraySearch::CWorkerBase::ProcessRay(RayPtr& pRay) const
{
UpdateMinimumReceiverDistance(pRay);
}
void EigenraySearch::CWorkerBase::FinalizeRay(RayPtr& pRay) const
{
pRay->FinalizeMinimumReceiverDistances();
}
const VistaVector3D& EigenraySearch::CWorkerBase::VirtualReceiverPosition(const int reflectionOrder) const
{
if (reflectionOrder % 2 != 0) //On uneven reflection order
......@@ -72,6 +78,23 @@ void EigenraySearch::CWorkerBase::InterpolateToRealMinimumPosition(const RayPtr&
dMin = dMinBefore;
}
}
EigenraySearch::RayPtr EigenraySearch::CWorkerBase::FindMinimumDistanceRay(const RayVector& rays, const int reflectionOrder)
{
float dMin = _FMAX;
const VistaVector3D& receiverPos = VirtualReceiverPosition(reflectionOrder);
RayPtr pMinRay = nullptr;
for each (const RayPtr & pRay in rays)
{
const CRayReceiverData* distanceData = pRay->ReceiverDistanceData(receiverPos);
if (distanceData && distanceData->distance < dMin)
{
dMin = distanceData->distance;
pMinRay = pRay;
}
}
return pMinRay;
}
#pragma endregion
......@@ -81,43 +104,41 @@ bool EigenraySearch::CInitialWorker::AbortRequested(const RayPtr& pRay) const
{
return pRay->LastTimeStamp() >= rayTracingAbortSettings.maxTime || pRay->ReflectionOrder() > rayTracingAbortSettings.maxReflectionOrder;
}
void EigenraySearch::CInitialWorker::UpdateMinimumReceiverDistance(RayPtr& pRay) const
{
pRay->UpdateMinimumReceiverDistance( ReceiverPosition() );
pRay->UpdateMinimumReceiverDistance( MirroredReceiverPosition() );
}
EigenraySearch::CInitialWorker::CInitialWorker(const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const RayTracingAbortSettings& abortSettings)
: CWorkerBase(sourcePosition, receiverPosition, simSettings, abortSettings) {}
std::vector<CRayGrid> EigenraySearch::CInitialWorker::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
CRayGrid rayGrid = InitRayGrid(atmosphere);
simulationEngine.Run(atmosphere, rayGrid.UniqueRays());
return FinalizeResult(rayGrid);
}
bool EigenraySearch::CInitialWorker::UpdateMinimumReceiverDistance(RayPtr& pRay) const
{
const int reflectionOrder = pRay->ReflectionOrder();
float receiverDistance = DistanceToVirtualReceiver(pRay->LastPoint(), reflectionOrder);
//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 EigenraySearch::CInitialWorker::InitRayGrid(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
return CEquiangularRayDistribution(v3SourcePosition, 7, 10);
//TODO: Set limits for additional directions according to atmosphere if possible
}
void EigenraySearch::CInitialWorker::FindMinimumDistanceRays(const RayVector& rays)
{
unsigned int maxReflOrder = 0;
for each (const RayPtr & ray in rays)
maxReflOrder = std::max( ray->ReflectionOrder(), maxReflOrder );
maxReflOrder = std::min(maxReflOrder, rayTracingAbortSettings.maxReflectionOrder);
maxReflOrder = std::min(1U, rayTracingAbortSettings.maxReflectionOrder);
vpMinDistanceRays.resize(maxReflOrder + 1);
for (int reflOrder = 0; reflOrder <= maxReflOrder; reflOrder++)
vpMinDistanceRays[reflOrder] = FindMinimumDistanceRay(rays, reflOrder);
}
std::vector<CRayGrid> EigenraySearch::CInitialWorker::FinalizeResult(const CRayGrid& initialRayGrid)
{
std::vector<CRayGrid> rayGridsOfReflectionOrder;
......@@ -160,10 +181,12 @@ EigenraySearch::RayPtr EigenraySearch::CAdaptiveWorker::Run(const ITAGeo::CStrat
//TODO: Postprocessing: Calculate spreading loss factor
}
bool EigenraySearch::CAdaptiveWorker::UpdateMinimumReceiverDistance(RayPtr& pRay) const
void EigenraySearch::CAdaptiveWorker::UpdateMinimumReceiverDistance(RayPtr& pRay) const
{
const VistaVector3D deltaVec = VectorToVirtualReceiver(pRay->LastPoint());
const float receiverDistance = deltaVec.GetLength();
pRay->UpdateMinimumReceiverDistance( VirtualReceiverPosition() );
//const VistaVector3D deltaVec = VectorToVirtualReceiver(pRay->LastPoint());
//const float receiverDistance = deltaVec.GetLength();
//if (fMinReceiverDistance <= receiverDistance)
// return false;
......@@ -171,7 +194,7 @@ bool EigenraySearch::CAdaptiveWorker::UpdateMinimumReceiverDistance(RayPtr& pRay
//v3MinReceiverVector = deltaVec;
//iMinReceiverDistanceIdx = pRay->NumPoints() - 1;
//pMinDistanceRay = pRay;
return true;
//return true;
}
bool EigenraySearch::CAdaptiveWorker::EigenrayAccuracyReached()
......
......@@ -66,13 +66,18 @@ namespace ITAPropagationPathSim
public:
//! Interface function to Simulation::Engine: Updates the minimum receiver distance of the ray after each processing step
virtual void ProcessRay(RayPtr& pRay) const;
//! Interface function to Simulation::Engine: Called after tracing a ray is finished.
virtual void FinalizeRay(RayPtr& pRay) const;
protected:
virtual bool UpdateMinimumReceiverDistance(RayPtr& pRay) const = 0;
virtual void UpdateMinimumReceiverDistance(RayPtr& pRay) const = 0;
const VistaVector3D& ReceiverPosition() const { return v3ReceiverPosition; }
const VistaVector3D& MirroredReceiverPosition() const { return v3MirroredReceiverPosition; }
const VistaVector3D& VirtualReceiverPosition(const int reflectionOrder) const;
const VistaVector3D& VectorToVirtualReceiver(const VistaVector3D& point, const int reflectionOrder) const;
float DistanceToVirtualReceiver(const VistaVector3D& point, const int reflectionOrder) const;
RayPtr FindMinimumDistanceRay(const RayVector& rays, const int reflectionOrder);
void InterpolateToRealMinimumPosition(const RayPtr& pRay, const VistaVector3D& receiverPos, int& iMinReceiverDistanceIdx, float& dMin, VistaVector3D& rMin);
};
......@@ -80,25 +85,21 @@ namespace ITAPropagationPathSim
class CInitialWorker : public CWorkerBase
{
private:
std::vector<std::map<RayPtr, float>> vRayDistanceMap;
std::vector<std::map<RayPtr, float>> vRayMinDistanceIdxMap;
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
public:
//! Interface function to Simulation::Engine: Checks whether ray does not have to be traced anymore.
virtual bool AbortRequested(const RayPtr& pRay) const;
//! Interface function to Simulation::Engine: Called after tracing a ray is finished. //TODO
virtual void FinalizeRay(RayPtr& pRay) const {}
private:
virtual void UpdateMinimumReceiverDistance(RayPtr& pRay) const;
public:
CInitialWorker(const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const RayTracingAbortSettings& abortSettings);
std::vector<CRayGrid> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere);
private:
virtual bool UpdateMinimumReceiverDistance(RayPtr& pRay) const;
private:
CRayGrid InitRayGrid(const ITAGeo::CStratifiedAtmosphere& atmosphere);
void FindMinimumDistanceRays(const RayVector& rays);
std::vector<CRayGrid> FinalizeResult(const CRayGrid& initialRayGrid);
};
......@@ -121,14 +122,12 @@ namespace ITAPropagationPathSim
public:
//! Interface function to Simulation::Engine: Checks whether ray does not have to be traced anymore.
virtual bool AbortRequested(const RayPtr& pRay) const;
//! Interface function to Simulation::Engine: Called after tracing a ray is finished. //TODO
virtual void FinalizeRay(RayPtr& pRay) const {}
public:
CAdaptiveWorker(const CRayGrid& rayGrid, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const Settings& eigenraySettings, const int activeReflectionOrder);
RayPtr Run(const ITAGeo::CStratifiedAtmosphere& atmosphere);
private:
virtual bool UpdateMinimumReceiverDistance(RayPtr& pRay) const;
virtual void UpdateMinimumReceiverDistance(RayPtr& pRay) const;
inline const VistaVector3D& VirtualReceiverPosition() const { return CWorkerBase::VirtualReceiverPosition(iActiveReflexionOrder); }
inline const VistaVector3D& VectorToVirtualReceiver(const VistaVector3D& point) const { return CWorkerBase::VectorToVirtualReceiver(point, iActiveReflexionOrder); }
......
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