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

WIP adding outdoor acoustics classes

parent 6194eb80
......@@ -33,6 +33,14 @@ if( NOT DEFINED ITA_SIMULATION_SCHEDULER_RAVEN_MODULE )
set( ITA_SIMULATION_SCHEDULER_RAVEN_MODULE OFF CACHE BOOL "Build RAVEN scheduler workers and applications for distributed computing" )
endif( )
if( NOT DEFINED ITA_SIMULATION_SCHEDULER_URBAN_MODULE )
set( ITA_SIMULATION_SCHEDULER_URBAN_MODULE OFF CACHE BOOL "Build urban scheduler workers" )
endif( )
if( NOT DEFINED ITA_SIMULATION_SCHEDULER_ART_MODULE )
set( ITA_SIMULATION_SCHEDULER_ART_MODULE OFF CACHE BOOL "Build atmospheric ray tracing (ART) scheduler workers" )
endif( )
if( NOT DEFINED ITA_SIMULATION_SCHEDULER_WITH_PROFILER )
set( ITA_SIMULATION_SCHEDULER_WITH_PROFILER ON CACHE BOOL "Build with profiler" )
endif( )
......@@ -82,6 +90,19 @@ if( ITA_SIMULATION_SCHEDULER_RAVEN_MODULE )
endif( )
# Outdoor specifics
if( ITA_SIMULATION_SCHEDULER_URBAN_MODULE )
add_definitions( -DWITH_URBAN )
endif( )
if( ITA_SIMULATION_SCHEDULER_ART_MODULE )
add_definitions( -DWITH_ART )
endif( )
# includes
include_directories( "include" )
......
set( RelativeDir "include/ITA/SimulationScheduler/OutdoorAcoustics/ART" )
set( RelativeSourceGroup "Header Files\\ITA\\SimulationScheduler\\OutdoorAcoustics\\ART" )
set( SubDirs
)
set( DirFiles
raven_scene.h
raven_simulation_result.h
simulation_task.h
simulator.h
raven_worker_interface.h
worker_thread.h
simulator_interface.h
#_SourceFiles.cmake
)
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} )
set( SubDirFiles "" )
foreach( Dir ${SubDirs} )
list( APPEND SubDirFiles "${RelativeDir}/${Dir}/_SourceFiles.cmake" )
endforeach()
foreach( SubDirFile ${SubDirFiles} )
include( ${SubDirFile} )
endforeach()
set( RelativeDir "include/ITA/SimulationScheduler/OutdoorAcoustics/Urban" )
set( RelativeSourceGroup "Header Files\\ITA\\SimulationScheduler\\OutdoorAcoustics\\Urban" )
set( SubDirs
)
set( DirFiles
raven_scene.h
raven_simulation_result.h
simulation_task.h
simulator.h
raven_worker_interface.h
worker_thread.h
simulator_interface.h
#_SourceFiles.cmake
)
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} )
set( SubDirFiles "" )
foreach( Dir ${SubDirs} )
list( APPEND SubDirFiles "${RelativeDir}/${Dir}/_SourceFiles.cmake" )
endforeach()
foreach( SubDirFile ${SubDirFiles} )
include( ${SubDirFile} )
endforeach()
set( RelativeDir "include/ITA/SimulationScheduler/OutdoorAcoustics" )
set( RelativeSourceGroup "Header Files\\ITA\\SimulationScheduler\\OutdoorAcoustics" )
if( ITA_SIMULATION_SCHEDULER_URBAN_MODULE )
list( APPEND SubDirs Urban )
endif( )
if( ITA_SIMULATION_SCHEDULER_ART_MODULE )
list( APPEND SubDirs ART )
endif( )
set( DirFiles
#master_simulation_controller.h
outdoor_simulation_result.h
outdoor_acoustics_worker_interface.h
#_SourceFiles.cmake
)
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} )
set( SubDirFiles "" )
foreach( Dir ${SubDirs} )
list( APPEND SubDirFiles "${RelativeDir}/${Dir}/_SourceFiles.cmake" )
endforeach()
foreach( SubDirFile ${SubDirFiles} )
include( ${SubDirFile} )
endforeach()
#ifndef INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_ROOM_ACOUSTICS_MASTER_SIMULATION_CONTROLLER
#define INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_ROOM_ACOUSTICS_MASTER_SIMULATION_CONTROLLER
// std includes
#include <memory>
#include <list>
// API includes
#include <ITA/SimulationScheduler/definitions.h>
// simulation scheduler includes
#include <ITA/SimulationScheduler/update_message.h>
#include <ITA/SimulationScheduler/scheduler_interface.h>
#include <ITA/SimulationScheduler/scheduler.h>
// VISTA includes
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
#include <VistaInterProcComm/Concurrency/VistaThreadEvent.h>
#include <VistaAspects/VistaPropertyList.h>
// ITA includes
#include <ITAAtomicPrimitives.h>
// Other includes
#include <tbb/concurrent_queue.h>
namespace ITA
{
namespace SimulationScheduler
{
class IResultHandler;
namespace RoomAcoustics
{
///
/// \brief Primary interaction class for room acoustic simulations.
///
/// This class represents the interface with which external software should interact with the simulation scheduler for room acoustic simulations.
/// It allows for easy interaction and configuration of the system.
/// - Updates can be issued via postUpdate().
/// - A IResultHandler can be registered via attachResultHandler.
/// - A simple replacement filter can be enabled for the CMasterSimulationController.
///
/// The actual computation takes place in its own thread (loop), see LoopBody().
/// \todo Inherit the scheduler interface? But we dont need handle simulation here :/
///
class ITA_SIMULATION_SCHEDULER_API CMasterSimulationController : public VistaThreadLoop
{
public:
///
/// \brief Configuration class for the master simulation controller.
///
struct ITA_SIMULATION_SCHEDULER_API MasterSimulationControllerConfig : public IConfig
{
std::shared_ptr<ISchedulerInterface::SchedulerConfig> oDSSchedulerConfig;
std::shared_ptr<ISchedulerInterface::SchedulerConfig> oERSchedulerConfig;
std::shared_ptr<ISchedulerInterface::SchedulerConfig> oDDSchedulerConfig;
bool bReplaceUpdates = true;
VistaPropertyList Store ( ) const override;
void Load ( const VistaPropertyList& oProperties ) override;
};
///
/// \brief Constructor for the CMasterSimulationController.
///
/// This constructor configures itself via the given configuration.
/// After a resultHandler is attached the controller is functional.
/// Note, that external schedulers have to be running for the master controller to work correctly.
/// \throw ITAException When creation or connection to schedulers failed.
/// \param pConfig the configuration from which to construct the CMasterSimulationController.
///
explicit CMasterSimulationController ( const MasterSimulationControllerConfig& pConfig );
///
/// \brief Destructor for CMasterSimulationController
///
~CMasterSimulationController ( );
///
/// \brief Post a new update to the CMasterSimulationController.
///
/// \note This method takes ownership of the update.
/// \param pUpdateMessage the new update for the CMasterSimulationController.
///
void PostUpdate ( std::unique_ptr<IUpdateMessage> pUpdateMessage );
///
/// \brief Attach a IResultHandler to the controller.
/// \remark Internally, the IResultHandler is attached to the simulators themselves.
/// \param pResultHandler the new IResultHandler.
/// \todo Maybe use shared_ptr ... resultHandler have to support make shared form this ... and consequently have to be shared_ptr. This would also mean ,that the scheduler own the handler.
///
void AttachResultHandler ( IResultHandler* pResultHandler ) const;
///
/// \brief Detach a IResultHandler from the controller.
/// \param pResultHandler the IResultHandler to detach.
///
void DetachResultHandler ( IResultHandler* pResultHandler ) const;
///
/// \brief Checks if the CMasterSimulationController is busy.
///
/// The CMasterSimulationController is busy if any of its scheduler is busy.
/// \return true if the CMasterSimulationController is busy, else false.
///
virtual bool IsBusy ( );
protected:
///
/// \brief Loop body for the CMasterSimulationController.
///
/// The following steps are done in the loop:
/// - Wait for a new update in m_qUpdateQueue.
/// - move the updates from the concurrent queue to a list.
/// - If the updates should be filtered, filterReplace() is called.
/// - The updates get copied, and send to the three schedulers.
/// - The m_lUpdateList gets cleared for the next loop iteration.
/// \return true if VistaThreadLoop::ThreadBody() shall call VistaThread::YieldThread() before the next loop, false else
///
bool LoopBody ( ) override;
///
/// \brief Pre loop function.
///
/// This function is called once before the thread starts.
/// \note This is primarily used to set the thread name while profiling.
///
void PreLoop ( ) override;
///
/// \brief Removes duplicate updates for source-receiver-pairs in its m_qUpdateList.
///
/// If the m_qUpdateQueue has multiple updates for the same source-receiver-pair, this method removes all but the newest update.
///
void FilterReplace ( );
///
/// \brief Setter for the scheduler.
/// \note This function is primarily for testing.
/// However, it could also be useful in the long run.
/// \param pDSScheduler the DS scheduler.
/// \param pERScheduler the ER scheduler.
/// \param pDDScheduler the DD scheduler.
///
void SetScheduler ( std::unique_ptr<ISchedulerInterface> pDSScheduler,
std::unique_ptr<ISchedulerInterface> pERScheduler,
std::unique_ptr<ISchedulerInterface> pDDScheduler );
private:
///
/// \brief Modify a CScheduler::LocalSchedulerConfig so that all worker have the given ::FieldOfDuty.
/// \param oConfig the CScheduler::LocalSchedulerConfig to be modified.
/// \param eFOD the ::FieldOfDuty to set the workers to.
/// \throw std::bad_cast one of the worker configs is not a ::IRoomAcousticsWorkerInterface::RoomAcousticsWorkerInterfaceConfig
/// \return a modified copy of the given config.
///
static CScheduler::LocalSchedulerConfig SetWorkerFieldOfDuty ( const CScheduler::LocalSchedulerConfig& oConfig, FieldOfDuty eFOD );
///
/// \brief Update queue for the controller.
///
/// postUpdate() adds new updates to this queue before they get passed to the schedulers in LoopBody().
///
tbb::concurrent_queue<std::unique_ptr<IUpdateMessage>> m_qUpdateQueue;
std::list<std::unique_ptr<IUpdateMessage>> m_lUpdateList;
///
/// \brief True if the controller should filter its received updates using filterReplace().
///
bool m_bReplaceUpdates;
///
/// \brief The scheduler for the direct sound of the RIR.
///
std::unique_ptr<ISchedulerInterface> m_pDSScheduler;
///
/// \brief The scheduler for the early reflections of the RIR.
///
std::unique_ptr<ISchedulerInterface> m_pERScheduler;
///
/// \brief The scheduler for the diffuse decay of the RIR.
///
std::unique_ptr<ISchedulerInterface> m_pDDScheduler;
///
/// \brief Trigger for starting a thread loop.
///
VistaThreadEvent m_evTriggerLoop;
///
/// \{
/// \brief Bools for handling the stop of the loop.
///
/// As these will be accessed by two threads, they have to be atomic.
///
ITAAtomicBool m_bStopIndicated = false;
ITAAtomicBool m_bStopACK = false;
/// \}
};
} // namespace RoomAcoustics
} // namespace SimulationScheduler
} // namespace ITA
#endif // INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_ROOM_ACOUSTICS_MASTER_SIMULATION_CONTROLLER
#ifndef INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_OUTDOOR_ACOUSTICS_WORKER_INTERFACE
#define INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_OUTDOOR_ACOUSTICS_WORKER_INTERFACE
// API includes
#include <ITA/SimulationScheduler/definitions.h>
// simulation scheduler includes
#include <ITA/SimulationScheduler/types.h>
#include <ITA/SimulationScheduler/worker_interface.h>
//#include "../src/ITA/SimulationScheduler/utils.h" // jst: what for?
namespace ITA
{
namespace SimulationScheduler
{
namespace OutdoorAcoustics
{
///
/// \brief Interface for a room acoustics worker.
///
class ITA_SIMULATION_SCHEDULER_API IOutdoorAcousticsWorkerInterface : public IWorkerInterface
{
public:
struct ITA_SIMULATION_SCHEDULER_API OutdoorAcousticsWorkerInterfaceConfig : public IWorkerInterface::WorkerConfig
{
explicit OutdoorAcousticsWorkerInterfaceConfig( std::string sType );
VistaPropertyList Store ( ) const override = 0;
void Load ( const VistaPropertyList& oProperties ) override = 0;
};
///
/// \brief Constructor for IRoomAcousticsWorkerInterface.
/// \param oConfig the config for the IRoomAcousticsWorkerInterface.
/// \param pParent the parent scheduler of the worker.
///
IOutdoorAcousticsWorkerInterface( const OutdoorAcousticsWorkerInterfaceConfig& oConfig, ISchedulerInterface* pParent );
virtual ~IOutdoorAcousticsWorkerInterface() = 0;
};
} // namespace OutdoorAcoustics
} // namespace SimulationScheduler
} // namespace ITA
#endif // INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_OUTDOOR_ACOUSTICS_WORKER_INTERFACE
\ No newline at end of file
#ifndef INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_OUTDOOR_ACOUSTICS_SIMULATION_RESULT
#define INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_OUTDOOR_ACOUSTICS_SIMULATION_RESULT
// API includes
#include <ITA/SimulationScheduler/definitions.h>
// simulation scheduler includes
#include <ITA/SimulationScheduler/simulation_result.h>
// ITA includes
#include <ITAThirdOctaveMagnitudeSpectrum.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
namespace ITA
{
namespace SimulationScheduler
{
namespace OutdoorAcoustics
{
///
/// \brief Result of a room acoustic simulation.
///
/// This class is primarily just a container for the data of an update.
///
struct ITA_SIMULATION_SCHEDULER_API COutdoorSimulationResult : public CSimulationResult
{
class CPathProperty
{
double dPropagationDelay;
double dSpreadingLoss; //!< Wave type specific spreading loss factor
int iReflectionOrder = 0;
int iDiffractionOrder = 0;
ITABase::CThirdOctaveFactorMagnitudeSpectrum oGeoAttenuationSpectrum; //!< Combined attenuation of geometry interaction (reflections and diffractions)
ITABase::CThirdOctaveFactorMagnitudeSpectrum oAirAttenuationSpectrum;
VistaVector3D v3SourceWaveFrontNormal; //!< Outgoing wave front normal at source
VistaVector3D v3ReceiverWaveFrontNormal; //!< Incident wave front normal at receiver
};
std::vector< CPathProperty > voPathProperties;
///
/// \brief Serialize the object.
/// \param pSerializer the IVistaSerializer to use.
/// \return the number of bytes written or -1 on failure.
///
int Serialize ( IVistaSerializer& pSerializer ) const override;
///
/// \brief DeSerialize the object.
/// \param pDeserializer the IVistaDeSerializer to use.
/// \return the number of bytes written or -1 on failure.
///
int DeSerialize ( IVistaDeSerializer& pDeserializer ) override;
///
/// \brief Return a unique identifier for the object for serialization.
/// \return "COutdoorSimulationResult".
///
inline std::string GetSignature() const override
{
return "COutdoorSimulationResult";
};
///
/// \brief Method to clone the object.
/// \return a clone of the object.
///
std::unique_ptr<CSimulationResult> Clone ( ) const override;
};
} // namespace OutdoorAcoustics
} // namespace SimulationScheduler
} // namespace ITA
#endif // INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_OUTDOOR_ACOUSTICS_SIMULATION_RESULT
\ No newline at end of file
......@@ -4,6 +4,7 @@ set( SubDirs
AudibilityFilter
#network_interface
RoomAcoustics
OutdoorAcoustics
Utils
Profiler
)
......
......@@ -92,19 +92,19 @@ namespace ITA
virtual bool IsBusy ( ) const = 0;
};
inline ISchedulerInterface::SchedulerConfig::SchedulerConfig ( ) : sSchedulerType ( "Unknown" )
{ }
inline ISchedulerInterface::SchedulerConfig::SchedulerConfig() : sSchedulerType( "Unknown" )
{ };
inline ISchedulerInterface::SchedulerConfig::SchedulerConfig ( std::string sType ) : sSchedulerType ( m_sSchedulerType )
{
m_sSchedulerType = sType;
}
};
inline ISchedulerInterface::SchedulerConfig::SchedulerConfig ( const SchedulerConfig& other ) :
IConfig ( other ),
sSchedulerType ( m_sSchedulerType ),
m_sSchedulerType ( other.m_sSchedulerType )
{ }
inline ISchedulerInterface::SchedulerConfig::SchedulerConfig( const SchedulerConfig& other ) :
IConfig( other ),
sSchedulerType( m_sSchedulerType ),
m_sSchedulerType( other.m_sSchedulerType )
{ };
inline ISchedulerInterface::SchedulerConfig& ISchedulerInterface::SchedulerConfig::operator=(
const SchedulerConfig& other )
......@@ -114,23 +114,23 @@ namespace ITA
IConfig::operator =( other );
m_sSchedulerType = other.m_sSchedulerType;
return *this;
}
};
inline VistaPropertyList ISchedulerInterface::SchedulerConfig::Store ( ) const
{
VistaPropertyList oProperties;
oProperties.SetValue ( schedulerTypeKey, m_sSchedulerType );
return oProperties;
}
};
inline void ISchedulerInterface::SchedulerConfig::Load ( const VistaPropertyList& oProperties )
{
oProperties.GetValue <std::string> ( schedulerTypeKey, m_sSchedulerType );
}
};
inline void ISchedulerInterface::AttachResultHandler(IResultHandler* pResultHandler)
{
}
};
} // namespace SimulationScheduler
} // namespace ITA
......
......@@ -13,9 +13,15 @@ namespace ITA
// todo This can fail if the name changes .. Fix this/make it bullet proof
std::map<std::string, std::pair<CWorkerFactory::CreateCallback, CWorkerFactory::ConfigCreateCallback>> CWorkerFactory::m_mWorkers =
{
#ifdef WITH_RAVEN
{RoomAcoustics::Raven::CWorkerThread::GetType ( ), {RoomAcoustics::Raven::CWorkerThread::CreateWorker, std::make_shared<RoomAcoustics::Raven::CWorkerThread::WorkerThreadConfig> } }
#endif
#ifdef WITH_RAVEN
{ RoomAcoustics::Raven::CWorkerThread::GetType(), { RoomAcoustics::Raven::CWorkerThread::CreateWorker, std::make_shared<RoomAcoustics::Raven::CWorkerThread::WorkerThreadConfig> } },
#endif
#ifdef WITH_URBAN
{OutdoorAcoustics::Urban::CWorkerThread::GetType(), { OutdoorAcoustics::Urban::CWorkerThread::CreateWorker, std::make_shared<OutdoorAcoustics::Urban::CWorkerThread::WorkerThreadConfig> } },
#endif
#ifdef WITH_ART
{OutdoorAcoustics::ART::CWorkerThread::GetType(), { OutdoorAcoustics::ART::CWorkerThread::CreateWorker, std::make_shared<OutdoorAcoustics::ART::CWorkerThread::WorkerThreadConfig> } },
#endif
};
IWorkerInterface::WorkerConfig::WorkerConfig ( ) : sWorkerType ( m_sWorkerType )
......
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