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

ART - Simulation Engine

- ExternalWatcher now has a new function to do some additional processing of the ray after each step.
- Adjusted Eigenray Workers accordingly
parent 4fa36ec3
......@@ -36,18 +36,21 @@ namespace ITAPropagationPathSim
{
public:
//! Returns true if the abort criterion for tracing the given ray is reached
virtual bool AbortRequested(const std::shared_ptr<CRay>& pRay) = 0;
//! This is called after the tracing of a ray is finished
virtual void FinalizeRay(const std::shared_ptr<CRay>& pRay) = 0;
virtual bool AbortRequested(const std::shared_ptr<CRay>& pRay) const = 0;
//! Allows additional proecssing of the ray at the end of each time step. If not overloaded this does nothing.
inline virtual void ProcessRay(std::shared_ptr<CRay>&) const = 0;
//! This is called after the tracing of a ray is finished. If not overloaded this does nothing.
inline virtual void FinalizeRay(std::shared_ptr<CRay>&) const = 0;
};
class ITA_PROPAGATION_PATH_SIM_API CAbortAtMaxTime : public IExternalWatcher
{
private:
double dTMax;
public:
CAbortAtMaxTime(double tMax = 30) : dTMax(tMax) {}
bool AbortRequested(const std::shared_ptr<CRay>& pRay) { return pRay->LastTimeStamp() >= dTMax; }
void FinalizeRay(const std::shared_ptr<CRay>& pRay) {}
inline CAbortAtMaxTime(double tMax = 30) : dTMax(tMax) {}
inline bool AbortRequested(const std::shared_ptr<CRay>& pRay) const { return pRay->LastTimeStamp() >= dTMax; }
inline virtual void ProcessRay(std::shared_ptr<CRay>&) const {}
inline virtual void FinalizeRay(std::shared_ptr<CRay>&) const {}
};
enum ITA_PROPAGATION_PATH_SIM_API SolverMethod
......
......@@ -18,13 +18,9 @@ EigenraySearch::CWorkerBase::CWorkerBase(const VistaVector3D& sourcePosition, co
v3MirroredReceiverPosition[Vista::Z] = -v3MirroredReceiverPosition[Vista::Z];
}
bool EigenraySearch::CWorkerBase::AbortRequested(const RayPtr& pRay)
void EigenraySearch::CWorkerBase::ProcessRay(RayPtr& pRay) const
{
if (CheckAbort(pRay))
return true;
UpdateMinimumReceiverDistance(pRay);
return false;
}
const VistaVector3D& EigenraySearch::CWorkerBase::VirtualReceiverPosition(const int reflectionOrder) const
{
......@@ -81,6 +77,11 @@ void EigenraySearch::CWorkerBase::InterpolateToRealMinimumPosition(const RayPtr&
#pragma region INITIAL WORKER
bool EigenraySearch::CInitialWorker::AbortRequested(const RayPtr& pRay) const
{
return pRay->LastTimeStamp() >= rayTracingAbortSettings.maxTime || pRay->ReflectionOrder() > rayTracingAbortSettings.maxReflectionOrder;
}
EigenraySearch::CInitialWorker::CInitialWorker(const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const RayTracingAbortSettings& abortSettings)
: CWorkerBase(sourcePosition, receiverPosition, simSettings, abortSettings) {}
......@@ -91,28 +92,23 @@ std::vector<CRayGrid> EigenraySearch::CInitialWorker::Run(const ITAGeo::CStratif
return FinalizeResult(rayGrid);
}
bool EigenraySearch::CInitialWorker::CheckAbort(const RayPtr& pRay)
{
return pRay->LastTimeStamp() >= rayTracingAbortSettings.maxTime || pRay->ReflectionOrder() > rayTracingAbortSettings.maxReflectionOrder;
}
bool EigenraySearch::CInitialWorker::UpdateMinimumReceiverDistance(const RayPtr& pRay)
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;
//if (reflectionOrder < vfMinDistances.size())
//{
// if (vfMinDistances[reflectionOrder] <= receiverDistance)
// return false;
vfMinDistances[reflectionOrder] = receiverDistance;
vpMinDistanceRays[reflectionOrder] = pRay;
return true;
}
// vfMinDistances[reflectionOrder] = receiverDistance;
// vpMinDistanceRays[reflectionOrder] = pRay;
// return true;
//}
vfMinDistances.push_back(receiverDistance);
vpMinDistanceRays.push_back(pRay);
//vfMinDistances.push_back(receiverDistance);
//vpMinDistanceRays.push_back(pRay);
return true;
}
......@@ -135,6 +131,11 @@ std::vector<CRayGrid> EigenraySearch::CInitialWorker::FinalizeResult(const CRayG
#pragma region ADAPTIVE WORKER
bool EigenraySearch::CAdaptiveWorker::AbortRequested(const RayPtr& pRay) const
{
return pRay->LastTimeStamp() >= rayTracingAbortSettings.maxTime || pRay->ReflectionOrder() > rayTracingAbortSettings.maxReflectionOrder;
}
EigenraySearch::CAdaptiveWorker::CAdaptiveWorker(const CRayGrid& rayGrid, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const Settings& eigenraySettings, const int activeReflectionOrder)
: CWorkerBase(rayGrid.SourcePosition(), receiverPosition, simSettings, eigenraySettings.rayTracing),
adaptiveRayGrid(rayGrid), iActiveReflexionOrder(activeReflectionOrder), rayAdaptationSettings(eigenraySettings.rayAdaptation)
......@@ -159,22 +160,17 @@ EigenraySearch::RayPtr EigenraySearch::CAdaptiveWorker::Run(const ITAGeo::CStrat
//TODO: Postprocessing: Calculate spreading loss factor
}
bool EigenraySearch::CAdaptiveWorker::CheckAbort(const RayPtr& pRay)
{
return pRay->LastTimeStamp() >= rayTracingAbortSettings.maxTime || pRay->ReflectionOrder() > rayTracingAbortSettings.maxReflectionOrder;
}
bool EigenraySearch::CAdaptiveWorker::UpdateMinimumReceiverDistance(const RayPtr& pRay)
bool EigenraySearch::CAdaptiveWorker::UpdateMinimumReceiverDistance(RayPtr& pRay) const
{
const VistaVector3D deltaVec = VectorToVirtualReceiver(pRay->LastPoint());
const float receiverDistance = deltaVec.GetLength();
if (fMinReceiverDistance <= receiverDistance)
return false;
//if (fMinReceiverDistance <= receiverDistance)
// return false;
fMinReceiverDistance = receiverDistance;
v3MinReceiverVector = deltaVec;
iMinReceiverDistanceIdx = pRay->NumPoints() - 1;
pMinDistanceRay = pRay;
//fMinReceiverDistance = receiverDistance;
//v3MinReceiverVector = deltaVec;
//iMinReceiverDistanceIdx = pRay->NumPoints() - 1;
//pMinDistanceRay = pRay;
return true;
}
......
......@@ -64,11 +64,10 @@ namespace ITAPropagationPathSim
CWorkerBase(const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const RayTracingAbortSettings& abortSettings);
public:
//! Interface function to Simulation::Engine: Checks whether ray does not have to be traced anymore. If not, updates the distance between ray and receiver.
virtual bool AbortRequested(const RayPtr& pRay);
//! Interface function to Simulation::Engine: Updates the minimum receiver distance of the ray after each processing step
virtual void ProcessRay(RayPtr& pRay) const;
protected:
virtual bool CheckAbort(const RayPtr& pRay) = 0;
virtual bool UpdateMinimumReceiverDistance(const RayPtr& pRay) = 0;
virtual bool UpdateMinimumReceiverDistance(RayPtr& pRay) const = 0;
const VistaVector3D& VirtualReceiverPosition(const int reflectionOrder) const;
const VistaVector3D& VectorToVirtualReceiver(const VistaVector3D& point, const int reflectionOrder) const;
......@@ -88,15 +87,16 @@ namespace ITAPropagationPathSim
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(const RayPtr& pRay) {}
virtual void FinalizeRay(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 CheckAbort(const RayPtr& pRay);
virtual bool UpdateMinimumReceiverDistance(const RayPtr& pRay);
virtual bool UpdateMinimumReceiverDistance(RayPtr& pRay) const;
CRayGrid InitRayGrid(const ITAGeo::CStratifiedAtmosphere& atmosphere);
std::vector<CRayGrid> FinalizeResult(const CRayGrid& initialRayGrid);
......@@ -119,15 +119,16 @@ namespace ITAPropagationPathSim
float fReceiverRadius;
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(const RayPtr& pRay) {}
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 CheckAbort(const RayPtr& pRay);
virtual bool UpdateMinimumReceiverDistance(const RayPtr& pRay);
virtual bool 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); }
......
......@@ -60,6 +60,7 @@ class CWorker
const VistaVector3D r = pRay->at(idx).position + rXYOffset;
const VistaVector3D n = pRay->at(idx).wavefrontNormal;
pRay->Append(r, n, t);
rExternalWatcher.ProcessRay(pRay);
if (rExternalWatcher.AbortRequested(pRay))
return;
......@@ -69,6 +70,7 @@ class CWorker
const VistaVector3D r = pRay->at(idxEndReflection).position + rXYOffset;
const VistaVector3D n = pRay->at(idxEndReflection).wavefrontNormal;
pRay->AppendReflection(r, n, t);
rExternalWatcher.ProcessRay(pRay);
}
void ExtendRayPeriodically()
{
......@@ -98,6 +100,7 @@ class CWorker
InterpolateToReflectionPoint(r, rNew, dt, rGround, dtGround);
rGround[Vista::Z] = 0; //Making sure z-component is truely zero
pRay->AppendReflection(rGround, n, time + dtGround);
rExternalWatcher.ProcessRay(pRay);
if ( rExternalWatcher.AbortRequested(pRay) )
return;
......@@ -113,6 +116,7 @@ class CWorker
s = sNew;
time += dt;
pRay->Append(r, n, time);
rExternalWatcher.ProcessRay(pRay);
}
}
public:
......
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