00001
00005 #pragma once
00006
00007 #include <usml/ocean/ocean.h>
00008 #include <usml/waveq3d/wave_front.h>
00009 #include <usml/waveq3d/eigenrayListener.h>
00010 #include <netcdfcpp.h>
00011
00012 namespace usml {
00013 namespace waveq3d {
00014
00015 using namespace usml::ocean ;
00016 class reflection_model ;
00017 class spreading_model ;
00018 class spreading_ray ;
00019 class spreading_hybrid_gaussian ;
00020 class eigenrayListener ;
00021
00024
00060 class USML_DECLSPEC wave_queue {
00061
00062 friend class reflection_model ;
00063 friend class spreading_ray ;
00064 friend class spreading_hybrid_gaussian ;
00065
00066 public:
00067
00071 typedef enum { CLASSIC_RAY, HYBRID_GAUSSIAN } spreading_type ;
00072
00073
00074
00075
00099 wave_queue(
00100 ocean_model& ocean,
00101 const seq_vector& freq,
00102 const wposition1& pos,
00103 const seq_vector& de, const seq_vector& az,
00104 double time_step,
00105 const wposition* targets=NULL,
00106 const size_t run_id=1,
00107 spreading_type type=HYBRID_GAUSSIAN
00108 ) ;
00109
00111 virtual ~wave_queue() ;
00112
00118 inline const wposition1& source_pos() const {
00119 return _source_pos ;
00120 }
00121
00127 inline const seq_vector* frequencies() const {
00128 return _frequencies ;
00129 }
00130
00138 inline double source_de( size_t de ) const {
00139 return (*_source_de)(de) ;
00140 }
00141
00149 inline double source_az( size_t az ) const {
00150 return (*_source_az)(az) ;
00151 }
00152
00156 inline double time() const {
00157 return _time ;
00158 }
00159
00163 inline double time_step() const {
00164 return _time_step ;
00165 }
00166
00170 inline const wposition* targets() const {
00171 return _targets;
00172 }
00173
00177 inline const wave_front* next() {
00178 return _next ;
00179 }
00180
00184 inline const wave_front* next() const {
00185 return _next ;
00186 }
00187
00191 inline const wave_front* curr() {
00192 return _curr ;
00193 }
00194
00198 inline const wave_front* curr() const {
00199 return _curr ;
00200 }
00201
00205 inline const wave_front* prev() {
00206 return _prev ;
00207 }
00208
00212 inline const wave_front* prev() const {
00213 return _prev ;
00214 }
00215
00219 inline const wave_front* past() {
00220 return _past ;
00221 }
00222
00226 inline const wave_front* past() const {
00227 return _past ;
00228 }
00229
00233 inline size_t num_de() const {
00234 return _source_de->size() ;
00235 }
00236
00240 inline size_t num_az() const {
00241 return _source_az->size() ;
00242 }
00243
00249 inline void setIntensityThreshold(double dThreshold) {
00250
00251
00252
00253 _intensity_threshold = abs(dThreshold);
00254 }
00259 inline double getIntensityThreshold() {
00260 return _intensity_threshold;
00261 }
00262
00266 bool addEigenrayListener(eigenrayListener* pListener);
00267
00271 bool removeEigenrayListener(eigenrayListener* pListener);
00272
00280 bool checkEigenrayListeners(long waveTime);
00281
00287 inline void setID( size_t id ) {
00288 _run_id = id ;
00289 }
00290
00297 inline const size_t getID() {
00298 return _run_id ;
00299 }
00300
00305 virtual bool is_ray_valid( size_t de, size_t az ) {
00306 return false ;
00307 }
00308
00330 void step() ;
00331
00332 protected:
00333
00338 ocean_model& _ocean ;
00339
00344 const seq_vector* _frequencies ;
00345
00353 wposition1 _source_pos ;
00354
00360 const seq_vector *_source_de ;
00361
00367 const seq_vector *_source_az ;
00368
00370 double _time_step ;
00371
00373 double _time ;
00374
00378 const wposition* _targets;
00379
00381 size_t _run_id ;
00382
00390 matrix<double> _targets_sin_theta ;
00391
00393 reflection_model* _reflection_model ;
00394
00399 spreading_model* _spreading_model ;
00400
00407 double _intensity_threshold;
00408
00418 wave_front *_past, *_prev, *_curr, *_next ;
00419
00420
00426 std::vector<eigenrayListener *> _eigenrayListenerVec;
00427
00434 bool _az_boundary ;
00435
00440 bool _de_branch ;
00441
00457 void init_wavefronts() ;
00458
00459
00460
00461
00479 virtual void detect_reflections() ;
00480
00492 bool detect_reflections_surface( size_t de, size_t az ) ;
00493
00505 bool detect_reflections_bottom( size_t de, size_t az ) ;
00506
00514 void detect_vertices( size_t de, size_t az ) ;
00515
00523 void detect_caustics( size_t de, size_t az ) ;
00524
00525
00526
00527
00534 void detect_eigenrays() ;
00535
00566 bool is_closest_ray(
00567 size_t t1, size_t t2,
00568 size_t de, size_t az,
00569 const double ¢er,
00570 double distance2[3][3][3] ) ;
00571
00596 void build_eigenray(
00597 size_t t1, size_t t2,
00598 size_t de, size_t az,
00599 double distance2[3][3][3] ) ;
00600
00673 void compute_offsets(
00674 size_t t1, size_t t2,
00675 size_t de, size_t az,
00676 const double distance2[3][3][3], const c_vector<double,3>& delta,
00677 c_vector<double,3>& offset, c_vector<double,3>& distance ) ;
00678
00696 static void make_taylor_coeff(
00697 const double value[3][3][3], const c_vector<double,3>& delta,
00698 double& center, c_vector<double,3>& gradient, c_matrix<double,3,3>& hessian ) ;
00699
00714 void collision_location(
00715 size_t de, size_t az, double dtime,
00716 wposition1* position, wvector1* ndirection, double* speed ) const ;
00717
00722 bool notifyEigenrayListeners(size_t targetRow, size_t targetCol, eigenray pEigenray);
00723
00724
00725
00726
00727 private:
00728
00733 NcFile* _nc_file ;
00734
00736 NcVar *_nc_time, *_nc_latitude, *_nc_longitude, *_nc_altitude,
00737 *_nc_surface, *_nc_bottom, *_nc_caustic, *_nc_upper,
00738 *_nc_lower, *_nc_on_edge ;
00739
00741 long _nc_rec ;
00742
00743 public:
00744
00804 void init_netcdf( const char* filename, const char* long_name=NULL ) ;
00805
00811 void save_netcdf() ;
00812
00816 void close_netcdf() ;
00817
00818 };
00819
00821 }
00822 }