Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
ITAPropagationPathSim
Commits
6f57ad49
Commit
6f57ad49
authored
Apr 15, 2020
by
Philipp Schäfer
Browse files
Atmospheric Ray Tracing
- simulation engine now hold rays as shared pointers
parent
9b5e7ed1
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/ITAPropagationPathSim/AtmosphericRayTracing/Simulation/Engine.h
View file @
6f57ad49
...
...
@@ -29,6 +29,10 @@
#include <ITAPropagationPathSim/AtmosphericRayTracing/Rays.h>
#include <ITAGeo/Atmosphere/StratifiedAtmosphere.h>
// STD
#include <vector>
#include <memory>
namespace
ITAPropagationPathSim
{
namespace
AtmosphericRayTracing
...
...
@@ -44,7 +48,7 @@ namespace ITAPropagationPathSim
VistaVector3D
v3SourcePosition
;
std
::
vector
<
VistaVector3D
>
v3RayDirections
;
private:
std
::
vector
<
CRay
>
rays
;
std
::
vector
<
std
::
shared_ptr
<
CRay
>
>
rays
;
//const IAbortCriterion& iAbortCriterion; //!< Reference to externally defined abort criterion.
public:
...
...
@@ -52,7 +56,7 @@ namespace ITAPropagationPathSim
virtual
~
CEngine
()
{}
public:
std
::
vector
<
CRay
>
Run
(
const
ITAGeo
::
CStratifiedAtmosphere
&
atmosphere
);
std
::
vector
<
std
::
shared_ptr
<
CRay
>
>
Run
(
const
ITAGeo
::
CStratifiedAtmosphere
&
atmosphere
);
private:
void
InitRays
();
};
...
...
src/ITAPropagationPathSim/AtmosphericRayTracing/Simulation/Engine.cpp
View file @
6f57ad49
...
...
@@ -18,12 +18,12 @@ namespace ITAPropagationPathSim { namespace AtmosphericRayTracing { namespace Si
class
CWorker
{
private:
CRay
&
r
Ray
;
std
::
shared_ptr
<
CRay
>
p
Ray
;
const
IAbortCriterion
&
rAbortCriterion
;
//!< Reference to externally defined abort criterion.
CAdaptiveSolver
mSolver
;
public:
CWorker
(
CRay
&
ray
,
const
SimulationSettings
&
simSettings
,
const
IAbortCriterion
&
abortCriterion
)
:
r
Ray
(
ray
),
rAbortCriterion
(
abortCriterion
),
mSolver
(
CAdaptiveSolver
(
simSettings
))
{}
CWorker
(
std
::
shared_ptr
<
CRay
>
ray
,
const
SimulationSettings
&
simSettings
,
const
IAbortCriterion
&
abortCriterion
)
:
p
Ray
(
ray
),
rAbortCriterion
(
abortCriterion
),
mSolver
(
CAdaptiveSolver
(
simSettings
))
{}
private:
bool
GroundReflectionOccured
(
const
double
&
rz1
,
const
double
&
rz2
)
const
...
...
@@ -41,50 +41,50 @@ class CWorker
}
void
ExtendRayByOnePeriod
()
{
std
::
vector
<
unsigned
int
>
iReflectionIndices
=
r
Ray
.
RelectionIndices
();
int
reflectionOrder
=
r
Ray
.
ReflectionOrder
();
const
std
::
vector
<
unsigned
int
>
iReflectionIndices
=
p
Ray
->
RelectionIndices
();
const
int
reflectionOrder
=
p
Ray
->
ReflectionOrder
();
if
(
reflectionOrder
<
2
)
ITA_EXCEPT_INVALID_PARAMETER
(
"Cannot extend a ray with a reflection order below 2."
);
int
idxStartReflection
=
iReflectionIndices
[
reflectionOrder
-
2
];
int
idxEndReflection
=
iReflectionIndices
[
reflectionOrder
-
1
];
const
int
idxStartReflection
=
iReflectionIndices
[
reflectionOrder
-
2
];
const
int
idxEndReflection
=
iReflectionIndices
[
reflectionOrder
-
1
];
double
tOffset
=
r
Ray
.
TimeStamps
()[
idxEndReflection
]
-
r
Ray
.
TimeStamps
()[
idxStartReflection
];
double
tOffset
=
p
Ray
->
TimeStamps
()[
idxEndReflection
]
-
p
Ray
->
TimeStamps
()[
idxStartReflection
];
for
(
int
idx
=
idxStartReflection
+
1
;
idx
<
idxEndReflection
;
idx
++
)
{
const
double
t
=
r
Ray
.
TimeStamps
()[
idx
]
+
tOffset
;
const
VistaVector3D
r
=
r
Ray
.
SamplingPoints
()[
idx
];
const
VistaVector3D
n
=
r
Ray
.
WavefrontNormals
()[
idx
];
r
Ray
.
Append
(
r
,
n
,
t
);
const
double
t
=
p
Ray
->
TimeStamps
()[
idx
]
+
tOffset
;
const
VistaVector3D
r
=
p
Ray
->
SamplingPoints
()[
idx
];
const
VistaVector3D
n
=
p
Ray
->
WavefrontNormals
()[
idx
];
p
Ray
->
Append
(
r
,
n
,
t
);
if
(
rAbortCriterion
.
AbortRequested
(
r
Ray
))
if
(
rAbortCriterion
.
AbortRequested
(
*
p
Ray
))
return
;
}
const
double
t
=
r
Ray
.
TimeStamps
()[
idxEndReflection
]
+
tOffset
;
const
VistaVector3D
r
=
r
Ray
.
SamplingPoints
()[
idxEndReflection
];
const
VistaVector3D
n
=
r
Ray
.
WavefrontNormals
()[
idxEndReflection
];
r
Ray
.
AppendReflection
(
r
,
n
,
t
);
const
double
t
=
p
Ray
->
TimeStamps
()[
idxEndReflection
]
+
tOffset
;
const
VistaVector3D
r
=
p
Ray
->
SamplingPoints
()[
idxEndReflection
];
const
VistaVector3D
n
=
p
Ray
->
WavefrontNormals
()[
idxEndReflection
];
p
Ray
->
AppendReflection
(
r
,
n
,
t
);
}
void
ExtendRayPeriodically
()
{
while
(
!
rAbortCriterion
.
AbortRequested
(
r
Ray
))
while
(
!
rAbortCriterion
.
AbortRequested
(
*
p
Ray
))
ExtendRayByOnePeriod
();
}
public:
void
TraceRay
(
const
ITAGeo
::
CStratifiedAtmosphere
&
atmosphere
)
{
VistaVector3D
r
=
r
Ray
.
LastPoint
();
VistaVector3D
r
=
p
Ray
->
LastPoint
();
double
rz
=
r
[
Vista
::
Z
];
VistaVector3D
n
=
r
Ray
.
LastWavefrontNormal
();
double
time
=
r
Ray
.
LastTimeStamp
();
VistaVector3D
n
=
p
Ray
->
LastWavefrontNormal
();
double
time
=
p
Ray
->
LastTimeStamp
();
VistaVector3D
s
=
ODESolver
::
NormalToSlowness
(
n
,
rz
,
atmosphere
);
VistaVector3D
rNew
,
sNew
;
while
(
!
rAbortCriterion
.
AbortRequested
(
r
Ray
)
)
while
(
!
rAbortCriterion
.
AbortRequested
(
*
p
Ray
)
)
{
mSolver
.
Process
(
r
,
s
,
atmosphere
,
rNew
,
sNew
);
n
=
ODESolver
::
SlownessToNormal
(
s
);
...
...
@@ -95,12 +95,12 @@ class CWorker
VistaVector3D
rGround
;
double
dtGround
;
InterpolateToReflectionPoint
(
r
,
rNew
,
dt
,
rGround
,
dtGround
);
r
Ray
.
AppendReflection
(
rGround
,
n
,
time
+
dtGround
);
p
Ray
->
AppendReflection
(
rGround
,
n
,
time
+
dtGround
);
if
(
rAbortCriterion
.
AbortRequested
(
r
Ray
)
)
if
(
rAbortCriterion
.
AbortRequested
(
*
p
Ray
)
)
return
;
if
(
r
Ray
.
ReflectionOrder
()
>=
2
)
//Ray is periodic
if
(
p
Ray
->
ReflectionOrder
()
>=
2
)
//Ray is periodic
{
ExtendRayPeriodically
();
return
;
...
...
@@ -110,20 +110,20 @@ class CWorker
r
=
rNew
;
s
=
sNew
;
time
+=
dt
;
r
Ray
.
Append
(
r
,
n
,
time
);
p
Ray
->
Append
(
r
,
n
,
time
);
}
}
};
}}}
std
::
vector
<
CRay
>
CEngine
::
Run
(
const
ITAGeo
::
CStratifiedAtmosphere
&
atmosphere
)
std
::
vector
<
std
::
shared_ptr
<
CRay
>
>
CEngine
::
Run
(
const
ITAGeo
::
CStratifiedAtmosphere
&
atmosphere
)
{
InitRays
();
for
(
int
idx
=
0
;
idx
<
rays
.
size
();
idx
++
)
{
CRay
&
ray
=
rays
[
idx
];
auto
worker
=
CWorker
(
ray
,
settings
,
iAbortCriterion
);
//
CRay& ray = rays[idx];
auto
worker
=
CWorker
(
ray
s
[
idx
]
,
settings
,
iAbortCriterion
);
worker
.
TraceRay
(
atmosphere
);
}
return
rays
;
...
...
@@ -132,5 +132,5 @@ void CEngine::InitRays()
{
rays
.
clear
();
for
each
(
const
VistaVector3D
&
v3Direction
in
v3RayDirections
)
rays
.
push_back
(
CRay
(
v3SourcePosition
,
v3Direction
));
rays
.
push_back
(
std
::
make_shared
<
CRay
>
(
v3SourcePosition
,
v3Direction
)
);
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment