...
 
Commits (3)
......@@ -37,10 +37,10 @@ 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) 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;
//! Allows additional proecssing of the ray at the end of each time step.
virtual void ProcessRay(std::shared_ptr<CRay>&) const = 0;
//! This is called after the tracing of a ray is finished.
virtual void FinalizeRay(std::shared_ptr<CRay>&) const = 0;
};
class ITA_PROPAGATION_PATH_SIM_API CAbortAtMaxTime : public IExternalWatcher
{
......
......@@ -12,10 +12,9 @@ using namespace ITAPropagationPathSim::AtmosphericRayTracing;
#pragma region WORKERBASE
EigenraySearch::CWorkerBase::CWorkerBase(const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const RayTracingAbortSettings& abortSettings)
: v3SourcePosition(sourcePosition), v3ReceiverPosition(receiverPosition), rayTracingAbortSettings(abortSettings), v3MirroredReceiverPosition(receiverPosition)
: v3SourcePosition(sourcePosition), v3ReceiverPosition(receiverPosition), rayTracingAbortSettings(abortSettings), v3MirroredReceiverPosition(receiverPosition), simulationEngine(Simulation::CEngine(*this))
{
simulationEngine.settings = simSettings;
simulationEngine.externalWatcher = *this;
v3MirroredReceiverPosition[Vista::Z] = -v3MirroredReceiverPosition[Vista::Z];
}
......@@ -28,49 +27,13 @@ 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
return v3MirroredReceiverPosition;
return v3ReceiverPosition;
}
inline VistaVector3D ClosestPointOnLineSegmentToReceiver(const VistaVector3D& segmentP1, const VistaVector3D& segmentP2, const VistaVector3D& receiverPoint)
{
const VistaVector3D normal = (segmentP2 - segmentP1).GetNormalized();
VistaVector3D intersectionPoint = segmentP1 + normal.Dot(receiverPoint - segmentP1) * normal; //intersection with line (not necessarily segment)
if ((segmentP1 - intersectionPoint).Dot(segmentP2 - intersectionPoint) < 0) //Point inside segment
return intersectionPoint;
float d1 = (segmentP1 - receiverPoint).GetLength();
float d2 = (segmentP2 - receiverPoint).GetLength();
return d1 < d2 ? segmentP1 : segmentP2;
}
void EigenraySearch::CWorkerBase::InterpolateToRealMinimumPosition(const RayPtr& pRay, const VistaVector3D& receiverPos, int& iMinReceiverDistanceIdx, float& dMin, VistaVector3D& rMin)
{
const VistaVector3D& rTmpMin = pRay->at(iMinReceiverDistanceIdx).position;
VistaVector3D rAfter = rTmpMin;
if (iMinReceiverDistanceIdx < pRay->size() - 1)
rAfter = ClosestPointOnLineSegmentToReceiver(rTmpMin, pRay->at(iMinReceiverDistanceIdx + 1).position, receiverPos);
VistaVector3D rBefore = rTmpMin;
if (iMinReceiverDistanceIdx > 0)
rBefore = ClosestPointOnLineSegmentToReceiver(rTmpMin, pRay->at(iMinReceiverDistanceIdx + 1).position, receiverPos);
rMin = rAfter;
dMin = (rAfter - receiverPos).GetLength();
const float dMinBefore = (rAfter - receiverPos).GetLength();
if (dMinBefore < dMin)
{
iMinReceiverDistanceIdx--;
rMin = rBefore;
dMin = dMinBefore;
}
}
EigenraySearch::RayPtr EigenraySearch::CWorkerBase::FindMinimumDistanceRay(const std::set<RayPtr>& rays, const int reflectionOrder)
{
float dMin = _FMAX;
......
......@@ -77,7 +77,6 @@ namespace ITAPropagationPathSim
const VistaVector3D& VirtualReceiverPosition(const int reflectionOrder) const;
RayPtr FindMinimumDistanceRay(const std::set<RayPtr>& rays, const int reflectionOrder);
void InterpolateToRealMinimumPosition(const RayPtr& pRay, const VistaVector3D& receiverPos, int& iMinReceiverDistanceIdx, float& dMin, VistaVector3D& rMin);
};
//! Does a rough search for potential eigenrays directions for multiple reflection orders
......
cmake_minimum_required( VERSION 2.8 )
add_subdirectory( "EigenraySearch" )
project( ITAPropagationPathSimTest )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
......@@ -33,11 +35,5 @@ vista_create_default_info_file( SimulationEngineTest )
set_property( TARGET SimulationEngineTest PROPERTY FOLDER "ITAGeometricalAcoustics/Tests/ITAPropagationPathSim/AtmosphericRayTracing" )
add_executable( AdaptiveRayGridTest AdaptiveRayGridTest.cpp )
target_link_libraries( AdaptiveRayGridTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( AdaptiveRayGridTest )
vista_install( AdaptiveRayGridTest )
vista_create_default_info_file( AdaptiveRayGridTest )
set_property( TARGET AdaptiveRayGridTest PROPERTY FOLDER "ITAGeometricalAcoustics/Tests/ITAPropagationPathSim/AtmosphericRayTracing" )
cmake_minimum_required( VERSION 2.8 )
project( ITAPropagationPathSimTest )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
vista_use_package( ITABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITAPropagationPathSim REQUIRED FIND_DEPENDENCIES )
if( ITA_CORE_LIBS_BUILD_STATIC )
add_definitions( -DITA_BASE_STATIC )
endif( )
if( ITA_GEOMETRICAL_ACOUSTICS_BUILD_STATIC )
add_definitions( -DITA_PROPAGATION_PATH_SIM_STATIC -DITA_GEO_STATIC )
endif( )
add_executable( AdaptiveRayGridTest AdaptiveRayGridTest.cpp )
target_link_libraries( AdaptiveRayGridTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( AdaptiveRayGridTest )
vista_install( AdaptiveRayGridTest )
vista_create_default_info_file( AdaptiveRayGridTest )
set_property( TARGET AdaptiveRayGridTest PROPERTY FOLDER "ITAGeometricalAcoustics/Tests/ITAPropagationPathSim/AtmosphericRayTracing/EigenraySearch" )
add_executable( EigenrayEngineTest EigenrayEngineTest.cpp )
target_link_libraries( EigenrayEngineTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( EigenrayEngineTest )
vista_install( EigenrayEngineTest )
vista_create_default_info_file( EigenrayEngineTest )
set_property( TARGET EigenrayEngineTest PROPERTY FOLDER "ITAGeometricalAcoustics/Tests/ITAPropagationPathSim/AtmosphericRayTracing/EigenraySearch" )
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*
*
*/
//#include <ITAStopWatch.h>
//#include <ITAStringUtils.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/Rays.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/Utils/RayToPropagationPath.h>
#include <ITAGeo/Base.h>
#include <ITAGeo/Utils/JSON/PropagationPath.h>
#include <ITAGeo/Atmosphere/StratifiedAtmosphere.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/Simulation/Engine.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/Simulation/Settings.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/EigenraySearch/Engine.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/EigenraySearch/Settings.h>
//#include <cassert>
#include <vector>
#include <stdio.h>
#include <math.h>
using namespace std;
using namespace ITAGeo;
using namespace ITAGeo::Utils;
using namespace ITAPropagationPathSim::AtmosphericRayTracing;
using namespace ITAPropagationPathSim::AtmosphericRayTracing::Utils;
void runTest(const CStratifiedAtmosphere& atmosphere, const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition, const string& filename)
{
EigenraySearch::CEngine engine;
engine.eigenraySettings.rayAdaptation.abort.maxNAdaptations = 30;
engine.eigenraySettings.rayAdaptation.abort.minAngleResolutionDeg = 0.001;
engine.eigenraySettings.rayAdaptation.accuracy.maxReceiverRadius = 1;
engine.eigenraySettings.rayAdaptation.accuracy.maxSourceReceiverAngle = 1;
engine.eigenraySettings.rayAdaptation.accuracy.maxAngleForGeomSpreading = 0.01;
engine.eigenraySettings.rayAdaptation.advancedRayZooming.threshold = 0.5;
engine.eigenraySettings.rayTracing.maxReflectionOrder = 3;
engine.eigenraySettings.rayTracing.maxTime = 15;
cout << filename << ":" << endl;
cout << "Starting Simulation-Engine..." << endl;
std::vector<std::shared_ptr<CRay>> eigenrays = engine.Run(atmosphere, sourcePosition, receiverPosition);
cout << "Starting export..." << endl;
CPropagationPath ray = ToPropagationPath(*eigenrays[0]);
JSON::Export(ray, filename + ".json");
cout << "Finished" << endl << endl;
}
void runTestReceiverNearGround(const CStratifiedAtmosphere& atmosphere, const int& sourceAngleDeg, const string& atmosphereSuffix)
{
VistaVector3D receiverPosition = VistaVector3D(0, 0, 1.8);
const double sourceReceiverDistance = 2000;
const double sourceX = sourceReceiverDistance * std::sin(sourceAngleDeg * M_PI / 180.0) + receiverPosition[Vista::X];
const double sourceY = +receiverPosition[Vista::Y];
const double sourceZ = sourceReceiverDistance * std::cos(sourceAngleDeg * M_PI / 180.0) + receiverPosition[Vista::Z];
const VistaVector3D sourcePosition = VistaVector3D(sourceX, sourceY, sourceZ);
const string filename = "ReceiverNearGround_" + atmosphereSuffix +"_SourceAngle" + to_string(sourceAngleDeg);
runTest(atmosphere, sourcePosition, receiverPosition, filename);
}
void TestReceiverNearGround(const CStratifiedAtmosphere& atmosphere, const string& atmosphereSuffix)
{
for (int angle = -90; angle <= 90; angle += 45)
runTestReceiverNearGround(atmosphere, angle, atmosphereSuffix);
}
CStratifiedAtmosphere GetHomogeneousAtmosphere()
{
auto humidProfile = std::make_unique<HumidityProfiles::CConstant>(50);
auto tempProfile = std::make_unique<TemperatureProfiles::CRoom>();
auto windProfile = std::make_unique<WindProfiles::CZero>();
return CStratifiedAtmosphere(std::move(tempProfile), std::move(windProfile), std::move(humidProfile));
}
CStratifiedAtmosphere GetInhomogeneousAtmosphere()
{
auto humidProfile = std::make_unique<HumidityProfiles::CConstant>(50);
auto tempProfile = std::make_unique<TemperatureProfiles::CISA>();
auto windProfile = std::make_unique<WindProfiles::CLog>(0.6, 0.1, VistaVector3D(1, 0, 0));
return CStratifiedAtmosphere(std::move(tempProfile), std::move(windProfile), std::move(humidProfile));
}
int main(int iNumInArgs, char* pcInArgs[])
{
CStratifiedAtmosphere homAtmosphere = GetHomogeneousAtmosphere();
CStratifiedAtmosphere inhomAtmosphere = GetInhomogeneousAtmosphere();
TestReceiverNearGround(homAtmosphere, "Homogeneous");
TestReceiverNearGround(inhomAtmosphere, "Inhomogeneous");
}