World Ocean Simulation System (WOSS) library
pressure-definitions.h
Go to the documentation of this file.
1/* WOSS - World Ocean Simulation System -
2 *
3 * Copyright (C) 2009 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - federico@guerra-tlc.com
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation;
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22/*
23 * This software has been developed by Federico Guerra and SIGNET lab,
24 * University of Padova, in collaboration with the NATO Centre for
25 * Maritime Research and Experimentation (http://www.cmre.nato.int ;
26 * E-mail: pao@cmre.nato.int), whose support is gratefully acknowledged.
27 */
28
29
40#ifndef PRESSURE_DEFINITIONS_H
41#define PRESSURE_DEFINITIONS_H
42
43
44#include <complex>
45
46
47namespace woss {
48
49
50 class TimeArr;
51
59 class Pressure {
60
61
62 public:
63
64
70 Pressure( double real = 0.0, double imag = 0.0 );
71
76 Pressure( const ::std::complex<double>& complex_press );
77
82 Pressure( const TimeArr& time_arr );
83
88 Pressure( const Pressure& copy );
89
90
97 virtual Pressure* create( double real = 0.0, double imag = 0.0 ) const { return new Pressure( real, imag ); }
98
104 virtual Pressure* create( const ::std::complex<double>& complex_press ) const { return new Pressure( complex_press ); }
105
111 virtual Pressure* create( const TimeArr& time_arr ) const { return new Pressure( time_arr ); }
112
118 virtual Pressure* create( const Pressure& copy ) const { return new Pressure( copy ); }
119
124 virtual Pressure* clone() const { return new Pressure(*this); }
125
131 virtual Pressure* createArray( unsigned int array_size ) const { return new Pressure[array_size]; }
132
133
134 virtual ~Pressure() { }
135
136
141 operator ::std::complex<double>() const { return complex_pressure; }
142
143
148 static const ::std::complex<double> createNotValid() { return( ::std::complex<double>( HUGE_VAL, HUGE_VAL ) ); }
149
150
155 double real() const { return complex_pressure.real(); }
156
161 double imag() const { return complex_pressure.imag(); }
162
163
168 double abs() const { return ::std::abs( complex_pressure ); }
169
174 double phase() const { return ::std::arg( complex_pressure ); }
175
180 Pressure sqrt() const { return ::std::sqrt( complex_pressure ); }
181
182
187 virtual bool isValid() const { return( complex_pressure != ::std::complex<double>( HUGE_VAL, HUGE_VAL ) ); }
188
189
194 static double getTxLossDb( const ::std::complex<double>& val ) { if ( val == ::std::complex<double>( HUGE_VAL, HUGE_VAL ) ) return -HUGE_VAL;
195 else if( val == ::std::complex<double>( 0.0, 0.0 ) ) return HUGE_VAL;
196 else return( -20.0 * log10( ::std::abs(val) ) ); }
197
202 double getTxLossDb() const {
203 if (isValid() == false) return -HUGE_VAL;
204 else if ( complex_pressure == ::std::complex<double>( 0.0, 0.0 ) ) return HUGE_VAL;
205 else return ( -20.0 * log10( abs() ));
206 }
207
216 virtual bool checkAttenuation( double distance, double frequency );
217
218
223 static void setDebug( bool flag ) { debug = flag; }
224
225
231 Pressure& operator=( const Pressure& x );
232
233
240 friend const Pressure operator+( const Pressure& left, const Pressure& right );
241
248 friend const Pressure operator-( const Pressure& left, const Pressure& right );
249
256 friend const Pressure operator/( const Pressure& left, const Pressure& right );
257
264 friend const Pressure operator*( const Pressure& left, const Pressure& right );
265
266
273 friend Pressure& operator+=( Pressure& left, const Pressure& right );
274
281 friend Pressure& operator-=( Pressure& left, const Pressure& right );
282
289 friend Pressure& operator/=( Pressure& left, const Pressure& right );
290
297 friend Pressure& operator*=( Pressure& left, const Pressure& right );
298
299
306 friend bool operator==( const Pressure& left, const Pressure& right );
307
314 friend bool operator!=( const Pressure& left, const Pressure& right );
315
316
323 friend ::std::ostream& operator<<( ::std::ostream& os, const Pressure& instance );
324
325
326 protected:
327
328
332 static bool debug;
333
334
338 ::std::complex< double > complex_pressure;
339
346 virtual double getAttenuation( double dist, double freq );
347
353 double getThorpAtt( double frequency );
354
355 };
356
357
358 //inline functions
360 inline bool operator==( const Pressure& left, const Pressure& right ) {
361 if ( &left == &right ) return true;
362 return( left.complex_pressure == right.complex_pressure );
363 }
364
365
366 inline bool operator!=( const Pressure& left, const Pressure& right ) {
367 if ( &left == &right ) return false;
368 return( left.complex_pressure != right.complex_pressure );
369 }
370
371
372 inline const Pressure operator+( const Pressure& left, const Pressure& right ) {
373 return( Pressure( left.complex_pressure + right.complex_pressure ) );
374 }
375
376
377 inline const Pressure operator-( const Pressure& left, const Pressure& right ) {
378 return( Pressure( left.complex_pressure - right.complex_pressure ) );
379 }
380
381
382 inline const Pressure operator/( const Pressure& left, const Pressure& right ) {
383 return( Pressure( left.complex_pressure / right.complex_pressure ) );
384 }
385
386
387 inline const Pressure operator*( const Pressure& left, const Pressure& right ) {
388 return( Pressure( left.complex_pressure * right.complex_pressure ) );
389 }
390
391
392 inline Pressure& operator+=( Pressure& left, const Pressure& right ) {
394 return left;
395 }
396
397
398 inline Pressure& operator-=( Pressure& left, const Pressure& right ) {
400 return left;
401 }
402
403
404 inline Pressure& operator/=( Pressure& left, const Pressure& right ) {
406 return left;
407 }
408
409
410 inline Pressure& operator*=( Pressure& left, const Pressure& right ) {
412 return left;
413 }
414
415
416 inline ::std::ostream& operator<<( ::std::ostream& os, const Pressure& instance ) {
417 os << instance.complex_pressure << " TL = " << instance.getTxLossDb() << " dB";
418 return os;
419 }
420
421
422}
423
424
425#endif /* PRESSURE_DEFINITIONS_H */
426
bool operator!=(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.h:846
std::ostream & operator<<(std::ostream &os, const Altimetry &instance)
Definition altimetry-definitions.h:826
Altimetry & operator*=(Altimetry &left, double right)
Definition altimetry-definitions.cpp:367
const Altimetry operator/(const Altimetry &left, const double right)
Definition altimetry-definitions.cpp:285
bool operator==(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.h:840
Altimetry & operator+=(Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.cpp:327
const Altimetry operator+(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.cpp:257
const Altimetry operator*(const Altimetry &left, const double right)
Definition altimetry-definitions.cpp:292
Altimetry & operator-=(Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.cpp:335
const Altimetry operator-(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.cpp:264
Altimetry & operator/=(Altimetry &left, double right)
Definition altimetry-definitions.cpp:359
Complex attenuated pressure class.
Definition pressure-definitions.h:59
friend const Pressure operator+(const Pressure &left, const Pressure &right)
Definition pressure-definitions.h:372
virtual Pressure * clone() const
Definition pressure-definitions.h:124
::std::complex< double > complex_pressure
Definition pressure-definitions.h:338
friend const Pressure operator*(const Pressure &left, const Pressure &right)
Definition pressure-definitions.h:387
friend Pressure & operator+=(Pressure &left, const Pressure &right)
Definition pressure-definitions.h:392
Pressure & operator=(const Pressure &x)
Definition pressure-definitions.cpp:79
static void setDebug(bool flag)
Definition pressure-definitions.h:223
double getThorpAtt(double frequency)
Definition pressure-definitions.cpp:114
virtual Pressure * create(double real=0.0, double imag=0.0) const
Definition pressure-definitions.h:97
static bool debug
Definition pressure-definitions.h:332
Pressure sqrt() const
Definition pressure-definitions.h:180
virtual Pressure * create(const TimeArr &time_arr) const
Definition pressure-definitions.h:111
friend Pressure & operator/=(Pressure &left, const Pressure &right)
Definition pressure-definitions.h:404
friend Pressure & operator*=(Pressure &left, const Pressure &right)
Definition pressure-definitions.h:410
static double getTxLossDb(const ::std::complex< double > &val)
Definition pressure-definitions.h:194
virtual Pressure * create(const Pressure &copy) const
Definition pressure-definitions.h:118
virtual bool isValid() const
Definition pressure-definitions.h:187
friend const Pressure operator-(const Pressure &left, const Pressure &right)
Definition pressure-definitions.h:377
friend bool operator!=(const Pressure &left, const Pressure &right)
Definition pressure-definitions.h:366
friend const Pressure operator/(const Pressure &left, const Pressure &right)
Definition pressure-definitions.h:382
double real() const
Definition pressure-definitions.h:155
double abs() const
Definition pressure-definitions.h:168
double phase() const
Definition pressure-definitions.h:174
friend::std::ostream & operator<<(::std::ostream &os, const Pressure &instance)
virtual bool checkAttenuation(double distance, double frequency)
Definition pressure-definitions.cpp:86
friend bool operator==(const Pressure &left, const Pressure &right)
Definition pressure-definitions.h:360
static const ::std::complex< double > createNotValid()
Definition pressure-definitions.h:148
virtual double getAttenuation(double dist, double freq)
Definition pressure-definitions.cpp:102
friend Pressure & operator-=(Pressure &left, const Pressure &right)
Definition pressure-definitions.h:398
double imag() const
Definition pressure-definitions.h:161
virtual Pressure * createArray(unsigned int array_size) const
Definition pressure-definitions.h:131
double getTxLossDb() const
Definition pressure-definitions.h:202
virtual Pressure * create(const ::std::complex< double > &complex_press) const
Definition pressure-definitions.h:104
Pressure(const ::std::complex< double > &complex_press)
Channel power delay profile class.
Definition time-arrival-definitions.h:82