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

ART - Eigenray Worker

- removed unnecessary member variables and methods
- finished first version of implementation
parent b01c13fc
......@@ -34,14 +34,6 @@ const VistaVector3D& EigenraySearch::CWorkerBase::VirtualReceiverPosition(const
return v3MirroredReceiverPosition;
return v3ReceiverPosition;
}
const VistaVector3D& EigenraySearch::CWorkerBase::VectorToVirtualReceiver(const VistaVector3D& point, const int reflectionOrder) const
{
return VirtualReceiverPosition(reflectionOrder) - point;
}
float EigenraySearch::CWorkerBase::DistanceToVirtualReceiver(const VistaVector3D& point, const int reflectionOrder) const
{
return VectorToVirtualReceiver(point, reflectionOrder).GetLength();
}
inline VistaVector3D ClosestPointOnLineSegmentToReceiver(const VistaVector3D& segmentP1, const VistaVector3D& segmentP2, const VistaVector3D& receiverPoint)
{
......@@ -79,7 +71,7 @@ void EigenraySearch::CWorkerBase::InterpolateToRealMinimumPosition(const RayPtr&
}
}
EigenraySearch::RayPtr EigenraySearch::CWorkerBase::FindMinimumDistanceRay(const RayVector& rays, const int reflectionOrder)
EigenraySearch::RayPtr EigenraySearch::CWorkerBase::FindMinimumDistanceRay(const std::set<RayPtr>& rays, const int reflectionOrder)
{
float dMin = _FMAX;
const VistaVector3D& receiverPos = VirtualReceiverPosition(reflectionOrder);
......@@ -119,7 +111,7 @@ std::vector<CRayGrid> EigenraySearch::CInitialWorker::Run(const ITAGeo::CStratif
{
CRayGrid rayGrid = InitRayGrid(atmosphere);
simulationEngine.Run(atmosphere, rayGrid.UniqueRays());
//FindMinimumDistanceRays(rayGrid.UniqueRays()); //TODO: convert std::set to std::vector
FindMinimumDistanceRays(rayGrid.UniqueRays());
return FinalizeResult(rayGrid);
}
CRayGrid EigenraySearch::CInitialWorker::InitRayGrid(const ITAGeo::CStratifiedAtmosphere& atmosphere)
......@@ -127,7 +119,7 @@ CRayGrid EigenraySearch::CInitialWorker::InitRayGrid(const ITAGeo::CStratifiedAt
return CEquiangularRayDistribution(v3SourcePosition, 7, 10);
//TODO: Set limits for additional directions according to atmosphere if possible
}
void EigenraySearch::CInitialWorker::FindMinimumDistanceRays(const RayVector& rays)
void EigenraySearch::CInitialWorker::FindMinimumDistanceRays(const std::set<RayPtr>& rays)
{
int maxReflOrder = 0;
for each (const RayPtr & ray in rays)
......@@ -170,7 +162,7 @@ EigenraySearch::CAdaptiveWorker::CAdaptiveWorker(const CRayGrid& rayGrid, const
: CWorkerBase(rayGrid.SourcePosition(), receiverPosition, simSettings, eigenraySettings.rayTracing),
adaptiveRayGrid(rayGrid), iActiveReflexionOrder(activeReflectionOrder), rayAdaptationSettings(eigenraySettings.rayAdaptation)
{
const float sourceReceiverDistance = DistanceToVirtualReceiver(rayGrid.SourcePosition());
const float sourceReceiverDistance = (VirtualReceiverPosition() - rayGrid.SourcePosition()).GetLength();
fReceiverRadius = tan(rayAdaptationSettings.accuracy.maxSourceReceiverAngle) * sourceReceiverDistance;
fReceiverRadius = fmin(rayAdaptationSettings.accuracy.maxReceiverRadius, fReceiverRadius);
}
......@@ -178,14 +170,16 @@ EigenraySearch::CAdaptiveWorker::CAdaptiveWorker(const CRayGrid& rayGrid, const
EigenraySearch::RayPtr EigenraySearch::CAdaptiveWorker::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
simulationEngine.Run(atmosphere, adaptiveRayGrid.UniqueRays());
pMinDistanceRay = FindMinimumDistanceRay(adaptiveRayGrid.UniqueRays(), iActiveReflexionOrder);
while (!EigenrayAccuracyReached())
{
adaptiveRayGrid.ZoomIntoRay(pMinDistanceRay);
simulationEngine.Run(atmosphere, adaptiveRayGrid.NewRaysOfLastAdaptation());
pMinDistanceRay = FindMinimumDistanceRay(adaptiveRayGrid.UniqueRays(), iActiveReflexionOrder);
nAdaptations++;
}
PostProcessEigenray(atmosphere);
return pMinDistanceRay;
//TODO: Postprocessing: Calculate spreading loss factor
}
......@@ -194,24 +188,17 @@ void EigenraySearch::CAdaptiveWorker::UpdateMinimumReceiverDistance(RayPtr& pRay
{
pRay->UpdateMinimumReceiverDistance( VirtualReceiverPosition() );
//const VistaVector3D deltaVec = VectorToVirtualReceiver(pRay->LastPoint());
//const float receiverDistance = deltaVec.GetLength();
//if (fMinReceiverDistance <= receiverDistance)
// return false;
//fMinReceiverDistance = receiverDistance;
//v3MinReceiverVector = deltaVec;
//iMinReceiverDistanceIdx = pRay->NumPoints() - 1;
//pMinDistanceRay = pRay;
//return true;
//TODO: Track whether distance increased and use this for abortion
}
bool EigenraySearch::CAdaptiveWorker::EigenrayAccuracyReached()
{
if (fMinReceiverDistance <= fReceiverRadius)
const CRayReceiverData* receiverData = pMinDistanceRay->ReceiverDistanceData(VirtualReceiverPosition());
if (receiverData && receiverData->distance <= fReceiverRadius)
return true;
bool abort = nAdaptations > rayAdaptationSettings.abort.maxNAdaptations; //TODO: also check delta angle of RayResolutionAdapter?
bool abort = nAdaptations > rayAdaptationSettings.abort.maxNAdaptations
|| adaptiveRayGrid.MaxAngularResolution() < rayAdaptationSettings.abort.minAngleResolutionDeg;
if (abort)
{
//TODO: Warning: Abort criterion reached!
......@@ -220,14 +207,31 @@ bool EigenraySearch::CAdaptiveWorker::EigenrayAccuracyReached()
}
void EigenraySearch::CAdaptiveWorker::PostProcessEigenray(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
CalculateEigenraySpreadingLoss(atmosphere);
SetEigenrayEndPoint();
CalculateEigenraySpreadingLoss(atmosphere);
}
void EigenraySearch::CAdaptiveWorker::SetEigenrayEndPoint()
{
const CRayReceiverData* receiverData = pMinDistanceRay->ReceiverDistanceData(VirtualReceiverPosition());
const int idxBeforeMin = receiverData->idxMinDist;
const VistaVector3D& rMin = receiverData->posMinDist;
//Interpolate to new point of minimum
const VistaVector3D& r1 = pMinDistanceRay->at(idxBeforeMin).position;
const VistaVector3D& r2 = pMinDistanceRay->at(idxBeforeMin + 1).position;
const float pathFraction = (rMin - r1).GetLength() / (r2 - r1).GetLength();
CRayElement newRayElement = pMinDistanceRay->at(idxBeforeMin).Interpolate(pMinDistanceRay->at(idxBeforeMin + 1), pathFraction);
//Remove all points before and add new point
pMinDistanceRay->resize(idxBeforeMin + 2);
pMinDistanceRay->back() = newRayElement;
}
void EigenraySearch::CAdaptiveWorker::CalculateEigenraySpreadingLoss(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
const double time = pMinDistanceRay->at(iMinReceiverDistanceIdx).timeStamp;
const double zReceiver = std::abs(pMinDistanceRay->at(iMinReceiverDistanceIdx).position[Vista::Z]);
const double zRef = std::abs(pMinDistanceRay->SourcePoint()[Vista::Z]);
const double& time = pMinDistanceRay->back().timeStamp;
const double zReceiver = std::abs( pMinDistanceRay->back().position[Vista::Z] );
const double zRef = std::abs( pMinDistanceRay->SourcePoint()[Vista::Z] );
if (adaptiveRayGrid.MaxAngularResolution() > rayAdaptationSettings.accuracy.maxAngleForGeomSpreading || !adaptiveRayGrid.Is2D())
{
......@@ -243,43 +247,6 @@ void EigenraySearch::CAdaptiveWorker::CalculateEigenraySpreadingLoss(const ITAGe
const double cReceiver = atmosphere.SpeedOfSound(zReceiver);
const double cRef = atmosphere.SpeedOfSound(zRef);
const double spreadingLoss = surfaceRef/surfaceReceiver * cReceiver/cRef;
}
void EigenraySearch::CAdaptiveWorker::SetEigenrayEndPoint()
{
const VistaVector3D& receiverPos = VirtualReceiverPosition();
const VistaVector3D& rTmpMin = pMinDistanceRay->at(iMinReceiverDistanceIdx).position;
VistaVector3D rAfter = rTmpMin;
if (iMinReceiverDistanceIdx < pMinDistanceRay->size() - 1)
rAfter = ClosestPointOnLineSegmentToReceiver(rTmpMin, pMinDistanceRay->at(iMinReceiverDistanceIdx + 1).position, receiverPos);
VistaVector3D rBefore = rTmpMin;
if (iMinReceiverDistanceIdx > 0)
rBefore = ClosestPointOnLineSegmentToReceiver(rTmpMin, pMinDistanceRay->at(iMinReceiverDistanceIdx + 1).position, receiverPos);
int idxBeforeMin = iMinReceiverDistanceIdx;
VistaVector3D rMin = rAfter;
if ((rBefore - receiverPos).GetLength() < (rAfter - receiverPos).GetLength())
{
idxBeforeMin--;
rMin = rBefore;
}
//TODO:
//Everything up to here should be done during finalization of EACH ray.
//Afterwards the ray of minimum distance has to be calculated.
//The part below should be executed during post processing.
//Interpolate to new point of minimum
const VistaVector3D& r1 = pMinDistanceRay->at(idxBeforeMin).position;
const VistaVector3D& r2 = pMinDistanceRay->at(idxBeforeMin + 1).position;
const float pathFraction = (rMin - r1).GetLength() / (r2-r1).GetLength();
CRayElement newRayElement = pMinDistanceRay->at(idxBeforeMin).Interpolate(pMinDistanceRay->at(idxBeforeMin + 1), pathFraction);
//Remove all points before and add new point
pMinDistanceRay->resize(idxBeforeMin + 2);
pMinDistanceRay->at(pMinDistanceRay->size() - 1) = newRayElement;
pMinDistanceRay->SetSpreadingLoss( surfaceRef/surfaceReceiver * cReceiver/cRef );
}
#pragma endregion
......@@ -37,6 +37,7 @@
// STD
#include <vector>
#include <set>
#include <map>
#include <memory>
......@@ -74,10 +75,8 @@ namespace ITAPropagationPathSim
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);
RayPtr FindMinimumDistanceRay(const std::set<RayPtr>& rays, const int reflectionOrder);
void InterpolateToRealMinimumPosition(const RayPtr& pRay, const VistaVector3D& receiverPos, int& iMinReceiverDistanceIdx, float& dMin, VistaVector3D& rMin);
};
......@@ -99,7 +98,7 @@ namespace ITAPropagationPathSim
std::vector<CRayGrid> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere);
private:
CRayGrid InitRayGrid(const ITAGeo::CStratifiedAtmosphere& atmosphere);
void FindMinimumDistanceRays(const RayVector& rays);
void FindMinimumDistanceRays(const std::set<RayPtr>& rays);
std::vector<CRayGrid> FinalizeResult(const CRayGrid& initialRayGrid);
};
......@@ -110,14 +109,10 @@ namespace ITAPropagationPathSim
CAdaptiveRayGrid adaptiveRayGrid;
const int iActiveReflexionOrder;
RayAdaptationSettings rayAdaptationSettings;
float fReceiverRadius;
RayPtr pMinDistanceRay;
float fMinReceiverDistance;
VistaVector3D v3MinReceiverVector;
int iMinReceiverDistanceIdx;
int nAdaptations = 0;
float fReceiverRadius;
public:
//! Interface function to Simulation::Engine: Checks whether ray does not have to be traced anymore.
......@@ -130,13 +125,11 @@ namespace ITAPropagationPathSim
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); }
inline float DistanceToVirtualReceiver(const VistaVector3D& point) const { return CWorkerBase::DistanceToVirtualReceiver(point, iActiveReflexionOrder); }
bool EigenrayAccuracyReached();
void PostProcessEigenray(const ITAGeo::CStratifiedAtmosphere& atmosphere);
void CalculateEigenraySpreadingLoss(const ITAGeo::CStratifiedAtmosphere& atmosphere);
void SetEigenrayEndPoint();
void CalculateEigenraySpreadingLoss(const ITAGeo::CStratifiedAtmosphere& atmosphere);
};
}
}
......
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