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

ART - SimulationEngine

- now uses OpenMP to parallelize ray tracing
parent 697da52a
......@@ -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" )
......
......@@ -52,6 +52,8 @@ namespace ITAPropagationPathSim
public:
std::vector<std::shared_ptr<CRay>> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const VistaVector3D& v3SourcePosition, const std::vector<VistaVector3D>& v3RayDirections) const;
void Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::set<std::shared_ptr<CRay>>& rays) const;
private:
void TraceRays(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::vector<std::shared_ptr<CRay>>& rays) const;
};
}
}
......
......@@ -4,12 +4,14 @@
#include "AdaptiveSolver.h"
#include <ITAPropagationPathSim/AtmosphericRayTracing/ODESolver/ODESolver.h>
// Vista includes
//#include <VistaInterProcComm/Concurrency/VistaThread.h>
// STD
#include <cmath>
// OMP
#ifdef _OPENMP
#include <omp.h>
#endif
using namespace ITAPropagationPathSim::AtmosphericRayTracing;
using namespace ITAPropagationPathSim::AtmosphericRayTracing::Simulation;
......@@ -130,21 +132,23 @@ std::vector<std::shared_ptr<CRay>> CEngine::Run(const ITAGeo::CStratifiedAtmosph
for each (const VistaVector3D & v3Direction in v3RayDirections)
rays.push_back(std::make_shared<CRay>(v3SourcePosition, v3Direction));
for each (std::shared_ptr<CRay> pRay in rays)
{
auto worker = CWorker(pRay, settings, externalWatcher);
worker.TraceRay(atmosphere);
}
TraceRays(atmosphere, rays);
return rays;
}
void CEngine::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::set<std::shared_ptr<CRay>>& rays) const
{
for each (std::shared_ptr<CRay> pRay in rays)
TraceRays(atmosphere, std::vector<std::shared_ptr<CRay>>(rays.begin(), rays.end()));
}
void CEngine::TraceRays(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::vector<std::shared_ptr<CRay>>& rays) const
{
#pragma omp parallel for schedule(static)
for (int idx = 0; idx < rays.size(); idx++)
{
if (pRay == nullptr)
if (rays[idx] == nullptr)
continue;
auto worker = CWorker(pRay, settings, externalWatcher);
auto worker = CWorker(rays[idx], settings, externalWatcher);
worker.TraceRay(atmosphere);
}
}
\ No newline at end of file
}
Markdown is supported
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