Commit a5e70a5d authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Merge branch 'psc' into develop

parents a88bfade 6ceed542
......@@ -28,3 +28,4 @@ svnaccess
*.exp
*.skp
*.skb
*.json
......@@ -6,10 +6,16 @@ project( ITAPropagationPathSim )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
if( NOT DEFINED ITA_PROPAGATION_PATH_SIM_WITH_OPENMP )
set( ITA_PROPAGATION_PATH_SIM_WITH_OPENMP ON CACHE BOOL "Build ITA propagation path sim using OpenMP parallelization." )
endif( )
# dependencies
vista_use_package( ITABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITAGeo REQUIRED FIND_DEPENDENCIES )
if( ITA_PROPAGATION_PATH_SIM_WITH_OPENMP )
vista_use_package( OpenMP REQUIRED )
endif( )
# includes
include_directories( "include" )
......
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_ADAPTIVERAYGRID
#define IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_ADAPTIVERAYGRID
#include <ITAPropagationPathSim/AtmosphericRayTracing/RayGrid.h>
//STD
#include <set>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
namespace EigenraySearch
{
class ITA_PROPAGATION_PATH_SIM_API CAdaptiveRayGrid : public CRayGrid
{
private:
double m_dMaxDeltaTheta = -1;
double m_dMaxDeltaPhi = -1;
std::set< std::shared_ptr<CRay> > m_vpNewRaysOfLastAdaptation;
public:
inline CAdaptiveRayGrid() {};
CAdaptiveRayGrid(const CRayGrid& rayGrid);
public:
void Init();
void Reset(const CRayGrid& rayGrid);
//! Maximum angular resolution in degrees
inline const double& MaxAngularResolution() { return m_dMaxDeltaTheta < m_dMaxDeltaPhi ? m_dMaxDeltaPhi : m_dMaxDeltaTheta; };
//! Maximum elevation resolution in degrees
inline const double& MaxDeltaTheta() { return m_dMaxDeltaTheta; };
//! Maximum azimuth resolution in degrees
inline const double& MaxDeltaPhi() { return m_dMaxDeltaPhi; };
//! Returns a unique set of the rays which were adding during the last adaptation
inline const std::set< std::shared_ptr<CRay> >& NewRaysOfLastAdaptation() const { return m_vpNewRaysOfLastAdaptation; };
//! Simple adaptation method: Setting the limits to neighboring rays and shoots additional rays to double the angular resolution of the grid.
void ZoomIntoRay(const std::shared_ptr<CRay> pRay);
//! Advanced adaptation method: Further reduces the angular limits using additional information compared to simple method before doubling the angular resolution.
void ZoomIntoRay(const std::shared_ptr<CRay> pRay, const VistaVector3D& v3ReceiverPosition, const double& dThreshold);
//! Zooms into the given ray using a specific angular resolution by creating up to 8 new rays surrounding the given one.
void ZoomIntoRay(const std::shared_ptr<CRay> pRay, const double& deltaTheta, const double& deltaPhi);
private:
//! Further reduces the limits of the ray grid using additional information on given rays and the receiver position
/**
* If the original ray grid looks like the sketch below where r5 is the ray with minimum distance to the receiver,
* this will decide whether the eigenray is rather above/below and left/right of it. In best case, the number of rays is reduced from 9 to 4.
*
* r1--------r2----------r3
* | c1 / c2 \
* r4------r5-------------r6
* \ c3 \ c4 /
* r7------r8--------r9
*
* Also works for a 1D ray grid (NTheta == 1 or NPhi() == 1)
*/
void SetAdvancedRayGridLimits(const std::shared_ptr<CRay> pRay, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold);
//! By comparing the vector from three rays to the receiver, this decides between which two rays the eigenray is located and returns their indices
std::vector<int> FindAdvancedRayGridLimits1D(const std::vector< std::shared_ptr<CRay> >& pRays, const int idxMinDist, const VistaVector3D& receiverPosition, const double& threshold) const;
void DoubleRayResolution();
void DoubleThetaResolution();
void DoublePhiResolution();
};
}
}
}
#endif //IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_ADAPTIVERAYGRID
\ No newline at end of file
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_ENGINE
#define IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_ENGINE
#include <ITAPropagationPathSim/Definitions.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
// ITA includes
#include <ITAPropagationPathSim/AtmosphericRayTracing/EigenraySearch/Settings.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/Simulation/Settings.h>
#include <ITAPropagationPathSim/AtmosphericRayTracing/Rays.h>
#include <ITAGeo/Atmosphere/StratifiedAtmosphere.h>
// STD
#include <vector>
#include <memory>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
namespace EigenraySearch {
class ITA_PROPAGATION_PATH_SIM_API CEngine
{
public:
EigenraySearch::Settings eigenraySettings;
Simulation::Settings simulationSettings;
public:
inline CEngine() {};
std::vector<std::shared_ptr<CRay>> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition);
};
}
}
}
#endif //IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_ENGINE
\ No newline at end of file
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_SETTINGS
#define IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_SETTINGS
#include <ITAPropagationPathSim/Definitions.h>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
namespace EigenraySearch {
struct ITA_PROPAGATION_PATH_SIM_API RayAdaptationSettings {
struct {
int maxNAdaptations = 15; //< Abort after N adaptations of the ray resolution
double minAngleResolutionDeg = 0.001; //< Abort if angle between neighboring rays is below this value []
} abort;
struct {
double maxReceiverRadius = 1; //< Maximum radius of receiver sphere [m]
double maxSourceReceiverAngle = 1; //< Maximum angle between vectors from source to receiver point and receiver sphere []
double maxAngleForGeomSpreading = 0.01; //< Angular resolution of rays which is required to calculate spreading loss []
} accuracy;
struct {
bool bActive = true; //< Switch to enable/disable advanced ray zooming
double threshold = 0.1; //< Threshold between 0 and 2 above which advanced ray zooming is performed (0 = always, 2 = never)
} advancedRayZooming;
};
struct ITA_PROPAGATION_PATH_SIM_API RayTracingAbortSettings {
int maxReflectionOrder = 1; //< Maximum considered order of reflections
double maxTime = 30; //< Maximum propagation time of rays [s]
bool bAbortOnReceiverDistIncrease = true; //< If enabled, ray tracing will be aborted as soon as ray receiver distance increases
};
struct ITA_PROPAGATION_PATH_SIM_API Settings {
RayTracingAbortSettings rayTracing;
RayAdaptationSettings rayAdaptation;
};
}
}
}
#endif //IW_ITA_PROPAGATIONPATHSIM_ART_EIGENRAYSEARCH_SETTINGS
\ No newline at end of file
# $Id:$
set( RelativeDir "include/ITAPropagationPathSim/AtmosphericRayTracing/EigenraySearch" )
set( RelativeSourceGroup "Header Files\\ITAPropagationPathSim\\AtmosphericRayTracing\\EigenraySearch" )
set( DirFiles
Settings.h
Engine.h
AdaptiveRayGrid.h
)
set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
set( LocalSourceGroupFiles )
foreach( File ${DirFiles} )
list( APPEND LocalSourceGroupFiles "${RelativeDir}/${File}" )
list( APPEND ProjectSources "${RelativeDir}/${File}" )
endforeach()
source_group( ${DirFiles_SourceGroup} FILES ${LocalSourceGroupFiles} )
\ No newline at end of file
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_ART_ODESOLVER
#define IW_ITA_PROPAGATIONPATHSIM_ART_ODESOLVER
#include <ITAPropagationPathSim/Definitions.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
// ITA includes
#include <ITAGeo/Atmosphere/StratifiedAtmosphere.h>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
namespace ODESolver
{
//! Converts a wavefront normal to a slowness vector for given altitude in stratified atmosphere
ITA_PROPAGATION_PATH_SIM_API VistaVector3D NormalToSlowness(const VistaVector3D& n, const double& rz, const ITAGeo::CStratifiedAtmosphere& atmosphere);
//! Converts a slowness vector to a wavefront normal
/**
* The wavefront normal has the same direction as the slowness vector (n = s / norm(s))
*/
ITA_PROPAGATION_PATH_SIM_API VistaVector3D SlownessToNormal(const VistaVector3D& s);
//! Solves the ordinary differential equations (ODEs) of ray propagation in a stratified medium using the Euler method
/**
* @param[in,out] r Current wavefront position. Will be updated.
* @param[in,out] s Current slowness vector. Will be updated.
* @param[in] dt Time step for integration
* @param[in] atmosphere Stratified atmosphere
*/
ITA_PROPAGATION_PATH_SIM_API void Euler(VistaVector3D& r, VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere);
//! Solves the ordinary differential equations (ODEs) of ray propagation in a stratified medium using the Euler method
/**
* @param[in] r Current wavefront position.
* @param[in] s Current slowness vector.
* @param[in] dt Time step for integration
* @param[in] atmosphere Stratified atmosphere
* @param[out] rNew New wavefront position.
* @param[out] sNew New slowness vector.
*
* Literature for solver:
* W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery. Numerical recipes in C: The Art of Scientific Computing. Cambridge University Press, 2nd edition, 1992.
*
* The differential equations are taken from the slowness vector approach described in:
* A. D. Pierce. Acoustics: An Introduction to Its Physical Principles and Applications, volume 20. McGraw-Hill New York, 1981.
*/
ITA_PROPAGATION_PATH_SIM_API void Euler(const VistaVector3D& r, const VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere, VistaVector3D& rNew, VistaVector3D& sNew);
//! Solves the ordinary differential equations (ODEs) of ray propagation in a stratified medium using the classical Runge-Kutta method (RK4)
/**
* @param[in,out] r Current wavefront position. Will be updated.
* @param[in,out] s Current slowness vector. Will be updated.
* @param[in] dt Time step for integration
* @param[in] atmosphere Stratified atmosphere
*/
ITA_PROPAGATION_PATH_SIM_API void RungeKutta(VistaVector3D& r, VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere);
//! Solves the ordinary differential equations (ODEs) of ray propagation in a stratified medium using the classical Runge-Kutta method (RK4)
/**
* @param[in] r Current wavefront position.
* @param[in] s Current slowness vector.
* @param[in] dt Time step for integration
* @param[in] atmosphere Stratified atmosphere
* @param[out] rNew New wavefront position.
* @param[out] sNew New slowness vector.
*
* Literature for solver:
* W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery. Numerical recipes in C: The Art of Scientific Computing. Cambridge University Press, 2nd edition, 1992.
*
* The differential equations are taken from the slowness vector approach described in:
* A. D. Pierce. Acoustics: An Introduction to Its Physical Principles and Applications, volume 20. McGraw-Hill New York, 1981.
*/
ITA_PROPAGATION_PATH_SIM_API void RungeKutta(const VistaVector3D& r, const VistaVector3D& s, const double& dt, const ITAGeo::CStratifiedAtmosphere& atmosphere, VistaVector3D& rNew, VistaVector3D& sNew);
}
}
}
#endif //IW_ITA_PROPAGATIONPATHSIM_ART_ODESOLVER
\ No newline at end of file
# $Id:$
set( RelativeDir "include/ITAPropagationPathSim/AtmosphericRayTracing/ODESolver" )
set( RelativeSourceGroup "Header Files\\ITAPropagationPathSim\\AtmosphericRayTracing\\ODESolver" )
set( DirFiles
ODESolver.h
)
set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
set( LocalSourceGroupFiles )
foreach( File ${DirFiles} )
list( APPEND LocalSourceGroupFiles "${RelativeDir}/${File}" )
list( APPEND ProjectSources "${RelativeDir}/${File}" )
endforeach()
source_group( ${DirFiles_SourceGroup} FILES ${LocalSourceGroupFiles} )
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_ART_SIMULATION_RAYGRID
#define IW_ITA_PROPAGATIONPATHSIM_ART_SIMULATION_RAYGRID
#include <ITAPropagationPathSim/Definitions.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
// ITA includes
#include <ITAPropagationPathSim/AtmosphericRayTracing/Rays.h>
// STD
#include <vector>
#include <set>
#include <memory>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
//! This class represents a set of rays which is ordered in a grid (matrix) referring to the angles of initial direction (theta and phi)
/**
* This special arrangement of rays allows to find the direct neigbors of any ray in this grid.
*/
class ITA_PROPAGATION_PATH_SIM_API CRayGrid
{
protected:
typedef std::shared_ptr<CRay> RayPtr;
typedef std::vector< RayPtr > RayVector;
typedef std::vector<RayVector> RayMatrix;
VistaVector3D m_v3SourcePos; //< Origin of all rays in this ray grid.
std::vector<double> m_vdThetaDeg; //< Sorted vector of elevation angles in degrees.
std::vector<double> m_vdPhiDeg; //< Sorted vector of azimuth angles in degrees.
private:
RayMatrix m_vvpRayMatrix; //< Matrix of pointers to ray. First index refers to elevation (theta), second to azimuth (phi) angle.
RayVector m_vpRays; //< Vector of all rays contained by vvpRayMatrix. May contain duplicates at poles (theta = 0 or 180°).
std::set<RayPtr> m_vpUniqueRays; // Unique set of all rays contained by vvpRayMatrix.
bool m_bCircularPhi = false; //< Indicates whether the azimuth vector is considered to be circular (phi covers full 360 degrees) or not.
private:
CRayGrid(const RayMatrix& rayMatrix, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool circularPhi = false);
void UpdateDependentRayContainers();
protected:
inline CRayGrid(bool circularPhi = false) : m_bCircularPhi(circularPhi) {};
//! Creates new rays using the angles of initial directions and inserts them into the ray matrix
void InitRays();
public:
//! Creates a set of rays using a source position and the given elevation and azimuth angles [°] for the inital directions. An optional bool indicates whether the azimuth angle covers the full 360°.
/**
* For each combination of theta and phi, one ray is created and stored.
* Note, that both vectors with angles will be sorted before creating the rays if not specified otherwise.
*/
CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool circularPhi = false, const bool sortAngleVectors = true);
protected:
//! Updates the ray matrix and depenent vectors/set of rays.
void SetRayMatrix(const RayMatrix& newRayMatrix);
//! Filters for certain rays using indices for theta and phi.
void FilterDirections(const std::vector<int>& thetaIdxVec, const std::vector<int>& phiIdxVec, const bool circularPhi = false);
//! Returns a vector with all rays having the same initial elevation as the given ray. Throws an exception if the ray is not part of this grid.
const RayVector& GetRaysWithSameTheta(const std::shared_ptr<CRay> pRay);
//! Returns a vector with all rays having the same initial azimuth as the given ray. Throws an exception if the ray is not part of this grid.
RayVector GetRaysWithSamePhi(const std::shared_ptr<CRay> pRay);
//---Indicing Functions---
protected:
int GetIndex(const std::shared_ptr<CRay> pRay) const;
int IndexToThetaIndex(const int idx) const;
int IndexToPhiIndex(const int idx) const;
void GetNeighboringAngleIndices(const std::shared_ptr<CRay> pRay, std::vector<int>& thetaIdxVec, std::vector<int>& phiIdxVec) const;
//---Booleans---
protected:
bool IsPoleDirection(const double& thetaDeg) const;
bool HasPoleDirection(const std::shared_ptr<CRay> pRay) const;
public:
//! Returns true if the phi angles are defined circular (covering a full circle)
inline bool IsCircular() const { return m_bCircularPhi; };
bool IsEmpty() const;
bool Is2D() const;
bool Contains(const std::shared_ptr<CRay> pRay) const;
//---GET Functions---
protected:
inline const std::vector<std::shared_ptr<CRay>>& Rays() const { return m_vpRays; };
inline const RayMatrix& Matrix() const { return m_vvpRayMatrix; };
public:
inline const std::vector<double>& ThetaDeg() const { return m_vdThetaDeg; };
inline const std::vector<double>& PhiDeg() const { return m_vdPhiDeg; };
inline int NTheta() const { return m_vdThetaDeg.size(); };
inline int NPhi() const { return m_vdPhiDeg.size(); };
inline int NRays() const { return m_vpRays.size(); };
inline const VistaVector3D& SourcePosition() const { return m_v3SourcePos; };
inline const std::set<std::shared_ptr<CRay>>& UniqueRays() const { return m_vpUniqueRays; };
inline const std::shared_ptr<CRay> At(int idxTheta, int idxPhi) const { return m_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) const;
//! Calculates the surface area for a spherical wavefront at 1m distance using the limits of theta and phi of this grid
double WavefrontSurfaceReference() const;
//! Returns a ray grid containing the rays surrounding the given ray (including this ray).
/**
* Throws an exception if the given ray is not part of this ray grid.
*/
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).
/**
* Throws an exception if the given ray is not part of this ray grid.
*/
void SetToSurroundingGrid(const std::shared_ptr<CRay> pRay);
//! Creates a ray grid with the same initial ray directions but new rays
CRayGrid CopyWithNewRays() const;
};
//! A special CRayGrid with an equiangular distribution
class ITA_PROPAGATION_PATH_SIM_API CEquiangularRayDistribution : public CRayGrid
{
public:
//! Creates an equiangular ray distribution with N rays along elevation and azimuth respectively
CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int nAngles);
//! Creates an equiangular ray distribution with N1 rays along elevation and N2 rays along azimuth
CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int nTheta, const int nPhi);
};
}
}
#endif //IW_ITA_PROPAGATIONPATHSIM_ART_SIMULATION_RAYGRID
\ No newline at end of file
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_PROPAGATIONPATHSIM_ART_RAYS
#define IW_ITA_PROPAGATIONPATHSIM_ART_RAYS
#include <ITAPropagationPathSim/Definitions.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
// ITA includes
// STD
#include <vector>
#include <map>
namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
class ITA_PROPAGATION_PATH_SIM_API CRayElement {
public:
VistaVector3D position;
VistaVector3D wavefrontNormal;
double timeStamp;
inline CRayElement() {};
inline CRayElement(const VistaVector3D& r, const VistaVector3D& n, const double& time) : position(r), wavefrontNormal(n), timeStamp(time) {};
//! Does a linear interpolation from this element to the given one using a factor [0.0 1.0] and returns the new element.
CRayElement Interpolate(const CRayElement& target, const float fFraction) const;
};
//! Compares the timestamps of given CRayElements using the < operator
inline bool operator<(const CRayElement& lhs, const CRayElement& rhs) { return lhs.timeStamp < rhs.timeStamp; };
class ITA_PROPAGATION_PATH_SIM_API CRayReceiverData {
public: