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

ART - Eigenray Engine

- renamed workers and finished alpha version of adaptive worker
parent 51e94481
......@@ -22,7 +22,21 @@ namespace ITAPropagationPathSim
typedef std::shared_ptr<CRay> RayPtr;
typedef std::vector< RayPtr > RayVector;
class CEigenrayWorkerBase : public Simulation::IAbortCriterion
//class CMinReceiverDistanceResult : public CRayGrid
//{
//private:
// RayPtr pMinDistanceRay;
// int iMinDistanceIndex;
//public:
// CMinReceiverDistanceResult(const CRayGrid& minDistRayGrid, const RayPtr& minDistRay, const int& idxMinDist)
// : CRayGrid(minDistRayGrid), pMinDistanceRay(minDistRay), iMinDistanceIndex(idxMinDist)
// {
// if (IsEmpty() || NTheta() > 3 || NPhi() > 3)
// return; //TODO: Throw exception
// }
//};
class CWorkerBase : public Simulation::IAbortCriterion
{
protected:
Simulation::CEngine simulationEngine;
......@@ -43,7 +57,7 @@ namespace ITAPropagationPathSim
}
public:
CEigenrayWorkerBase(const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const RayTracingAbortSettings& rtSettings)
CWorkerBase(const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const RayTracingAbortSettings& rtSettings)
: v3ReceiverPosition(receiverPosition), rayTracingAbortSettings(rtSettings) { simulationEngine.settings = simSettings; }
protected:
......@@ -60,7 +74,7 @@ namespace ITAPropagationPathSim
};
class CMinDistanceRayInitializer : public CEigenrayWorkerBase
class CInitialWorker : public CWorkerBase
{
private:
VistaVector3D v3SourcePosition;
......@@ -102,8 +116,8 @@ namespace ITAPropagationPathSim
return rayGridsOfReflectionOrder;
}
public:
CMinDistanceRayInitializer(const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const RayTracingAbortSettings& abortSettings)
: CEigenrayWorkerBase(receiverPosition, simSettings, abortSettings) , v3SourcePosition(sourcePosition) {}
CInitialWorker(const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const RayTracingAbortSettings& abortSettings)
: CWorkerBase(receiverPosition, simSettings, abortSettings) , v3SourcePosition(sourcePosition) {}
std::vector<CRayGrid> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
......@@ -113,7 +127,7 @@ namespace ITAPropagationPathSim
}
};
class CEigenrayWorker : public CEigenrayWorkerBase
class CAdaptiveWorker : public CWorkerBase
{
private:
CRayResolutionAdapter rayResolutionAdapter;
......@@ -126,6 +140,9 @@ namespace ITAPropagationPathSim
VistaVector3D v3MinReceiverVector;
int iMinReceiverDistanceIdx;
int nAdaptations = 0;
float fReceiverRadius;
public:
//virtual bool AbortRequested(const RayPtr pRay) {
......@@ -151,18 +168,42 @@ namespace ITAPropagationPathSim
iMinReceiverDistanceIdx = pRay->NumPoints() - 1;
pMinDistanceRay = pRay;
}
private:
bool EigenrayAccuracyReached()
{
if (fMinReceiverDistance <= fReceiverRadius)
return true;
bool abort = nAdaptations > rayAdaptationSettings.abort.maxNAdaptations; //TODO: also check delta angle of RayResolutionAdapter?
if (abort)
{
//TODO: Warning: Abort criterion reached!
}
return abort;
}
public:
CEigenrayWorker(const CRayGrid& rayGrid, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const Settings& eigenraySettings, const int& activeReflectionOrder)
: CEigenrayWorkerBase(receiverPosition, simSettings, eigenraySettings.rayTracing), iActiveReflexionOrder(activeReflectionOrder), rayAdaptationSettings(eigenraySettings.rayAdaptation) {}
void Init()
CAdaptiveWorker(const CRayGrid& rayGrid, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const Settings& eigenraySettings, const int& activeReflectionOrder)
: CWorkerBase(receiverPosition, simSettings, eigenraySettings.rayTracing),
rayResolutionAdapter(rayGrid), iActiveReflexionOrder(activeReflectionOrder), rayAdaptationSettings(eigenraySettings.rayAdaptation)
{
const float sourceReceiverDistance = ReceiverDistance(iActiveReflexionOrder, rayGrid.SourcePosition());
fReceiverRadius = tan(rayAdaptationSettings.accuracy.maxSourceReceiverAngle) * sourceReceiverDistance;
fReceiverRadius = fmin(rayAdaptationSettings.accuracy.maxReceiverRadius, fReceiverRadius);
}
public:
RayPtr Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
return RayPtr();
simulationEngine.Run(atmosphere, rayResolutionAdapter.Rays());
while (!EigenrayAccuracyReached())
{
rayResolutionAdapter.ZoomIntoRay(pMinDistanceRay);
simulationEngine.Run(atmosphere, rayResolutionAdapter.NewRaysOfLastAdaptation());
nAdaptations++;
}
return pMinDistanceRay;
}
};
}
......@@ -174,13 +215,13 @@ std::vector<std::shared_ptr<CRay>> CEngine::Run(const ITAGeo::CStratifiedAtmosph
{
Simulation::Settings initialSettings = simulationSettings;
initialSettings.dIntegrationTimeStep *= 10;
CMinDistanceRayInitializer initialRayTracing(sourcePosition, receiverPosition, initialSettings, eigenraySettings.rayTracing);
CInitialWorker 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);
CAdaptiveWorker worker(initialRayGrids[reflectionOrder], receiverPosition, simulationSettings, eigenraySettings, reflectionOrder);
eigenrays.push_back( worker.Run(atmosphere) );
}
return eigenrays;
......
......@@ -40,6 +40,7 @@ namespace ITAPropagationPathSim
std::vector< std::shared_ptr<CRay> > NewRaysOfLastAdaptation() { return vpNewRaysOfLastAdaptation; }
bool ZoomIntoRay(std::shared_ptr<CRay> pRay);
//bool ZoomIntoRay(std::shared_ptr<CRay> pRay, const int idxMinDist& = -1, const VistaVector3D& receiverPosition = VistaVector3D());
private:
void DoubleRayResolution();
......
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