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

ART - RayGrid

- cleaned up code
- renamed GetSurroundingGrid() to SurroundingGrid()
ART - AdaptiveRayGrid:
- added variable storing the resolution of theta and phi
ART - Eigenray Worker
- addes some TODOs
parent 90d16771
......@@ -35,14 +35,23 @@ namespace ITAPropagationPathSim
class ITA_PROPAGATION_PATH_SIM_API CAdaptiveRayGrid : public CRayGrid
{
private:
double dMaxDeltaTheta = -1;
double dMaxDeltaPhi = -1;
std::set< std::shared_ptr<CRay> > vpNewRaysOfLastAdaptation;
public:
CAdaptiveRayGrid() {}
CAdaptiveRayGrid(const CRayGrid& rayGrid) : CRayGrid(rayGrid) {}
CAdaptiveRayGrid(const CRayGrid& rayGrid);
public:
void Init();
void Reset(const CRayGrid& rayGrid);
//! Maximum angular resolution in degrees
const double& MaxAngularResolution() { return dMaxDeltaTheta < dMaxDeltaPhi ? dMaxDeltaPhi : dMaxDeltaTheta; }
//! Maximum elevation resolution in degrees
const double& MaxDeltaTheta() { return dMaxDeltaTheta; }
//! Maximum azimuth resolution in degrees
const double& MaxDeltaPhi() { return dMaxDeltaPhi; }
//! Returns a unique set of the rays which were adding during the last adaptation
const std::set< std::shared_ptr<CRay> >& NewRaysOfLastAdaptation() const { return vpNewRaysOfLastAdaptation; }
......
......@@ -113,11 +113,14 @@ namespace ITAPropagationPathSim
inline const std::set<std::shared_ptr<CRay>>& UniqueRays() const { return vpUniqueRays; }
inline const std::shared_ptr<CRay>& At(int idxTheta, int idxPhi) const { return vvpRayMatrix[idxTheta][idxPhi]; }
//! Calculates and returns an approximation for the surface area of the wavefront at given time by spanning triangles between rays
//double WavefrontSurface(const double& time);
//! Returns a ray grid containing the rays surrounding the given ray (including this ray).
/**
* Returns an empty ray grid if the given ray is not part of this ray grid.
*/
CRayGrid GetSurroundingGrid(const std::shared_ptr<CRay>& pRay) const;
CRayGrid SurroundingGrid(const std::shared_ptr<CRay>& pRay) const;
//! Sets the boundaries of this ray grid to the rays surrounding the given ray (including this ray).
/**
* If the ray is not part of this ray grid, this will be empty.
......
......@@ -7,15 +7,49 @@
using namespace ITAPropagationPathSim::AtmosphericRayTracing;
using namespace ITAPropagationPathSim::AtmosphericRayTracing::EigenraySearch;
#pragma region CONSTRUCTOR / INITIATION
inline EigenraySearch::CAdaptiveRayGrid::CAdaptiveRayGrid(const CRayGrid& rayGrid) : CRayGrid(rayGrid)
{
if (rayGrid.UniqueRays().size() <= 1)
ITA_EXCEPT_INVALID_PARAMETER("Ray Grid must atleast contain 2 unique rays");
Init();
}
void EigenraySearch::CAdaptiveRayGrid::Init()
{
vpNewRaysOfLastAdaptation.clear();
for (int idx = 1; idx < vdThetaDeg.size(); idx++)
{
double deltaTheta = vdThetaDeg[idx] - vdThetaDeg[idx - 1];
if (dMaxDeltaTheta < deltaTheta)
dMaxDeltaTheta = deltaTheta;
}
for (int idx = 1; idx < vdPhiDeg.size(); idx++)
{
double deltaPhi = vdPhiDeg[idx] - vdPhiDeg[idx - 1];
if (deltaPhi < 0)
deltaPhi += 360;
if (dMaxDeltaPhi < deltaPhi)
dMaxDeltaPhi = deltaPhi;
}
}
void CAdaptiveRayGrid::Reset(const CRayGrid& rayGrid)
{
if (rayGrid.UniqueRays().size() <= 1)
ITA_EXCEPT_INVALID_PARAMETER("Ray Grid must atleast contain 2 unique rays");
*this = rayGrid;
vpNewRaysOfLastAdaptation.clear();
Init();
}
#pragma endregion
#pragma region RAY ZOOMING - public
void CAdaptiveRayGrid::ZoomIntoRay(const std::shared_ptr<CRay>& pRay)
{
if(!Contains(pRay) /*|| NRays() <= 1*/)
if(!Contains(pRay))
ITA_EXCEPT_INVALID_PARAMETER("Given ray is not part of the adaptive ray grid.");
SetToSurroundingGrid(pRay);
......@@ -24,14 +58,16 @@ void CAdaptiveRayGrid::ZoomIntoRay(const std::shared_ptr<CRay>& pRay)
void CAdaptiveRayGrid::ZoomIntoRay(const std::shared_ptr<CRay>& pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold)
{
if (!Contains(pRay) /*|| NRays() <= 1*/)
if (!Contains(pRay))
ITA_EXCEPT_INVALID_PARAMETER("Given ray is not part of the adapted grid.");
SetToSurroundingGrid(pRay);
SetAdvancedRayGridLimits(pRay, idxMinDist, receiverPosition, threshold);
DoubleRayResolution();
}
#pragma endregion
#pragma region NEW RAY LIMITS - private
void CAdaptiveRayGrid::SetAdvancedRayGridLimits(const std::shared_ptr<CRay>& pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold)
{
if (NPhi() > 3) // There can be more than three rays if pRay is located at a pole
......@@ -68,7 +104,10 @@ std::vector<int> CAdaptiveRayGrid::FindAdvancedRayGridLimits1D(const std::vector
return {0, 1};
return {1, 2};
}
#pragma endregion
#pragma region DOUBLING RESOLUTION - private
void CAdaptiveRayGrid::DoubleRayResolution()
{
if (NRays() <= 1)
......@@ -121,7 +160,9 @@ void CAdaptiveRayGrid::DoubleThetaResolution()
newAngleVector.push_back((angle1 + angle2) / 2);
newAngleVector.push_back(angle2);
}
vdThetaDeg = newAngleVector;
dMaxDeltaTheta /= 2;
}
void CAdaptiveRayGrid::DoublePhiResolution()
......@@ -151,4 +192,6 @@ void CAdaptiveRayGrid::DoublePhiResolution()
}
vdPhiDeg = newAngleVector;
}
\ No newline at end of file
dMaxDeltaPhi /= 2;
}
#pragma endregion
\ No newline at end of file
......@@ -83,13 +83,14 @@ bool EigenraySearch::CInitialWorker::UpdateMinimumReceiverDistance(const RayPtr&
CRayGrid EigenraySearch::CInitialWorker::InitRayGrid(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
return CEquiangularRayDistribution(v3SourcePosition, 7, 10);
//TODO: Set limits for additional directions according to atmosphere if possible
}
std::vector<CRayGrid> EigenraySearch::CInitialWorker::FinalizeResult(const CRayGrid& initialRayGrid)
{
std::vector<CRayGrid> rayGridsOfReflectionOrder;
for each (RayPtr pRay in vpMinDistanceRays)
rayGridsOfReflectionOrder.push_back(initialRayGrid.GetSurroundingGrid(pRay).CopyWithNewRays());
rayGridsOfReflectionOrder.push_back(initialRayGrid.SurroundingGrid(pRay).CopyWithNewRays());
return rayGridsOfReflectionOrder;
}
......@@ -131,6 +132,7 @@ EigenraySearch::RayPtr EigenraySearch::CAdaptiveWorker::Run(const ITAGeo::CStrat
}
return pMinDistanceRay;
//TODO: Postprocessing: Calculate spreading loss factor
}
bool EigenraySearch::CAdaptiveWorker::UpdateMinimumReceiverDistance(const RayPtr& pRay)
......@@ -144,6 +146,7 @@ bool EigenraySearch::CAdaptiveWorker::UpdateMinimumReceiverDistance(const RayPtr
v3MinReceiverVector = deltaVec;
iMinReceiverDistanceIdx = pRay->NumPoints() - 1;
pMinDistanceRay = pRay;
return true;
}
bool EigenraySearch::CAdaptiveWorker::EigenrayAccuracyReached()
......@@ -158,4 +161,14 @@ bool EigenraySearch::CAdaptiveWorker::EigenrayAccuracyReached()
}
return abort;
}
void EigenraySearch::CAdaptiveWorker::PostProcessEigenray()
{
//Interpolate to point of minimum
if (adaptiveRayGrid.MaxAngularResolution() > rayAdaptationSettings.accuracy.maxAngleForGeomSpreading)
bool doMoreRayTracing = true;
//adaptiveRayGrid.SetToSurroudingGrid(dMinDistanceRay);
//adaptiveRayGrid.WavefrontSurface(time);
}
#pragma endregion
\ No newline at end of file
......@@ -108,6 +108,7 @@ namespace ITAPropagationPathSim
private:
bool UpdateMinimumReceiverDistance(const RayPtr& pRay);
bool EigenrayAccuracyReached();
void PostProcessEigenray();
};
}
}
......
......@@ -97,6 +97,9 @@ void CRayGrid::InitRays()
#pragma endregion
// --- PROTECTED ---
// -----------------
#pragma region PROTECTED
void CRayGrid::SetRayMatrix(const RayMatrix& newRayMatrix)
{
vvpRayMatrix = newRayMatrix;
......@@ -134,7 +137,6 @@ const CRayGrid::RayVector& CRayGrid::GetRaysWithSameTheta(const std::shared_ptr<
return vvpRayMatrix[idxTheta];
}
CRayGrid::RayVector CRayGrid::GetRaysWithSamePhi(const std::shared_ptr<CRay>& pRay)
{
const int idxPhi = IndexToPhiIndex(GetIndex(pRay));
......@@ -147,13 +149,18 @@ CRayGrid::RayVector CRayGrid::GetRaysWithSamePhi(const std::shared_ptr<CRay>& pR
return thetaRays;
}
#pragma endregion
//double CRayGrid::WavefrontSurface(const double& time)
//{
// return 0.0;
//}
// --- PUBLIC ---
// --------------
#pragma region Public
CRayGrid CRayGrid::GetSurroundingGrid(const std::shared_ptr<CRay>& pRay) const
// --- NEIGHBORING RAYS ---
// ------------------------
#pragma region NEIGHBORING RAYS - public
CRayGrid CRayGrid::SurroundingGrid(const std::shared_ptr<CRay>& pRay) const
{
if (!Contains(pRay))
ITA_EXCEPT_INVALID_PARAMETER("Given ray is not part of this ray grid.");
......@@ -183,9 +190,11 @@ CRayGrid CRayGrid::GetSurroundingGrid(const std::shared_ptr<CRay>& pRay) const
void CRayGrid::SetToSurroundingGrid(const std::shared_ptr<CRay>& pRay)
{
*this = GetSurroundingGrid(pRay);
*this = SurroundingGrid(pRay);
}
#pragma endregion
#pragma region COPY - public
CRayGrid CRayGrid::CopyWithNewRays() const
{
return CRayGrid(v3SourcePos, vdThetaDeg, vdPhiDeg, bCircularPhi);
......@@ -193,6 +202,7 @@ CRayGrid CRayGrid::CopyWithNewRays() const
#pragma endregion
// --- PROTECTED HELPERS ---
// -------------------------
#pragma region INDICING
......
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