World Ocean Simulation System (WOSS) library
altimetry-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 ALTIMETRY_DEFINITIONS_H
41#define ALTIMETRY_DEFINITIONS_H
42
43
44#include <cassert>
45#include <climits>
46#include <map>
48#include "time-definitions.h"
49
50
51namespace woss {
52
53
59 typedef std::map < PDouble , double > AltimetryMap;
60 typedef AltimetryMap::iterator AltIt;
61 typedef AltimetryMap::const_iterator AltCIt;
62 typedef AltimetryMap::reverse_iterator AltRIt;
63 typedef AltimetryMap::const_reverse_iterator AltCRIt;
64
65
69 #define ALTIMETRY_RANGE_STEPS (1)
70
71
78 class Altimetry {
79
80
81 public:
82
83
87 Altimetry();
88
93 Altimetry( AltimetryMap& map );
94
100 Altimetry( double range, double altimetry );
101
106 Altimetry( const Altimetry& copy );
107
108 virtual ~Altimetry() { }
109
110
115 virtual Altimetry* create() const {
116 return &((new Altimetry() )->updateMinMaxAltimetryValues()); ; }
117
123 virtual Altimetry* create( AltimetryMap& map ) const {
124 return &((new Altimetry( map ) )->updateMinMaxAltimetryValues()); }
125
131 virtual Altimetry* create( const Altimetry& copy ) const { return new Altimetry( copy ); }
132
137 virtual Altimetry* clone() const { return new Altimetry(*this); }
138
144
149 static AltimetryMap& createFlat(double altimetry = 0 );
150
151
158 Altimetry& insertValue( double range, double altimetry );
159
165 Altimetry& sumValue( double range, double altimetry );
166
167
173 AltCIt findValue( double range ) const { return( altimetry_map.find(range) ); }
174
175
181 Altimetry& eraseValue( double range ) { altimetry_map.erase(range); return *this; }
182
183
191 virtual Altimetry* crop( double range_start, double range_end );
192
198 virtual Altimetry* randomize( double ratio_incr_value ) const;
199
204 AltCIt begin() const { return altimetry_map.begin(); }
205
210 AltCIt end() const { return altimetry_map.end(); }
211
217 AltCIt at( const int i ) const ;
218
223 int size() const { return altimetry_map.size(); }
224
229 bool empty() const { return altimetry_map.empty(); }
230
231
235 void clear() { altimetry_map.clear(); }
236
237
242 static void setDebug( bool flag ) { debug = flag; }
243
248 static bool getDebug( bool flag ) { return debug; }
249
254 Altimetry& setEvolutionTimeQuantum( double quantum ) { evolution_time_quantum = quantum; return *this;}
255
260 Altimetry& setTotalRangeSteps( int r_s ) { total_range_steps = r_s; return *this;}
261
266 Altimetry& setRange( double r ) { range = r; return *this; }
267
272 Altimetry& setDepth( double d) { depth = d; return *this; }
273
274
279 double getMaxRangeValue() const { return( altimetry_map.rbegin()->first ); }
280
285 double getMinRangeValue() const { return( altimetry_map.begin()->first ); }
286
291 double getMaxAltimetryValue() const { return( max_altimetry_value ); }
292
297 double getMinAltimetryValue() const { return( min_altimetry_value ); }
298
303 long double getRangePrecision() const { return range_precision; }
304
310
315 double getRange() const { return range; }
316
321 int getTotalRangeSteps() const { return total_range_steps; }
322
327 double getDepth() const { return depth; }
328
329
334 virtual bool isValid() const;
335
341 virtual bool initialize();
342
348 virtual Altimetry* timeEvolve( const Time& time_value );
349
350
356 Altimetry& operator=( const Altimetry& copy ) ;
357
358
365 friend bool operator==( const Altimetry& left, const Altimetry& right ) ;
366
373 friend bool operator!=( const Altimetry& left, const Altimetry& right );
374
375
382 friend const Altimetry operator+( const Altimetry& left, const Altimetry& right );
383
390 friend const Altimetry operator-( const Altimetry& left, const Altimetry& right );
391
392
399 friend const Altimetry operator+( const Altimetry& left, const double right );
400
407 friend const Altimetry operator-( const Altimetry& left, const double right );
408
415 friend const Altimetry operator/( const Altimetry& left, const double right );
416
423 friend const Altimetry operator*( const Altimetry& left, const double right );
424
425
432 friend const Altimetry operator+( const double left, const Altimetry& right );
433
440 friend const Altimetry operator-( const double left, const Altimetry& right );
441
448 friend const Altimetry operator/( const double left, const Altimetry& right );
449
456 friend const Altimetry operator*( const double left, const Altimetry& right );
457
458
465 friend Altimetry& operator+=( Altimetry& left, const Altimetry& right );
466
473 friend Altimetry& operator-=( Altimetry& left, const Altimetry& right );
474
475
482 friend Altimetry& operator+=( Altimetry& left, double right );
483
490 friend Altimetry& operator-=( Altimetry& left, double right );
491
498 friend Altimetry& operator/=( Altimetry& left, double right );
499
506 friend Altimetry& operator*=( Altimetry& left, double right );
507
508
515 friend std::ostream& operator<<( std::ostream& os, const Altimetry& instance );
516
517
518 protected:
519
520
521 virtual Altimetry& updateMinMaxAltimetryValues();
522
526 static bool debug;
527
531 double range;
532
537
542
547
551 long double range_precision;
552
557
562
566 double depth;
567
572
573
574 };
575
576
583
584 public:
585
590
596
604 AltimBretschneider( double ch_height, double avg_per, int total_range_steps, double depth );
605
611
612 virtual ~AltimBretschneider() { }
613
614
619 virtual AltimBretschneider* create() const {
620 AltimBretschneider* ret_val = new AltimBretschneider();
621 ret_val->updateMinMaxAltimetryValues();
622 return ret_val; }
623
629 virtual AltimBretschneider* create( AltimetryMap& map ) const {
630 AltimBretschneider* ret_val = new AltimBretschneider( map );
631 ret_val->updateMinMaxAltimetryValues();
632 return ret_val; }
633
639 virtual AltimBretschneider* create( const AltimBretschneider& copy ) const {
640 return new AltimBretschneider( copy ); }
641
647 virtual AltimBretschneider* create( const Altimetry& copy ) const {
648 AltimBretschneider const* dyn_ptr = dynamic_cast<AltimBretschneider const*>(&copy);
649 if (dyn_ptr) {
650 return new AltimBretschneider( *dyn_ptr );
651 }
652 return create();
653 }
654
663 virtual AltimBretschneider* create( double ch_height, double avg_per, int total_range_steps, double depth ) const {
664 return new AltimBretschneider( ch_height, avg_per, total_range_steps, depth);
665 }
666
671 virtual AltimBretschneider* clone() const { return new AltimBretschneider(*this); }
672
673
680
681
687 virtual bool initialize();
688
689
694 virtual bool isValid() const;
695
696
702 virtual AltimBretschneider* timeEvolve( const Time& time_value );
703
704
710 virtual AltimBretschneider* randomize( double ratio_incr_value ) const;
711
717 AltimBretschneider& setCharacteristicHeight( double h ) { char_height = h; return *this; }
718
724 AltimBretschneider& setAveragePeriod( double p ) { average_period = p; return *this; }
725
730 double getCharacteristicHeight() const { return char_height; }
731
736 double getAveragePeriod() const { return average_period; }
737
738
739 protected:
740
741
742 virtual AltimBretschneider& createWaveSpectrum();
743
750
757
758 };
759
760 //non-inline operator declarations
762 const Altimetry operator+( const Altimetry& left, const Altimetry& right );
763
764 const Altimetry operator-( const Altimetry& left, const Altimetry& right );
765
766
767 const Altimetry operator+( const Altimetry& left, const double right );
768
769 const Altimetry operator-( const Altimetry& left, const double right );
770
771 const Altimetry operator/( const Altimetry& left, const double right );
772
773 const Altimetry operator*( const Altimetry& left, const double right );
774
775
776 const Altimetry operator+( const double left, const Altimetry& right );
777
778 const Altimetry operator-( const double left, const Altimetry& right );
779
780 const Altimetry operator/( const double left, const Altimetry& right );
781
782 const Altimetry operator*( const double left, const Altimetry& right );
783
784
785 Altimetry& operator+=( Altimetry& left, const Altimetry& right );
786
787 Altimetry& operator-=( Altimetry& left, const Altimetry& right );
788
789 Altimetry& operator+=( Altimetry& left, double right );
790
791
792 Altimetry& operator-=( Altimetry& left, double right );
793
794 Altimetry& operator/=( Altimetry& left, double right );
795
796 Altimetry& operator*=( Altimetry& left, double right );
797
799 //inline functions
802 altimetry_map.clear();
803 return altimetry_map;
804 }
805
806
807 inline AltimetryMap& Altimetry::createFlat( double altimetry ) {
809 altimetry_map.clear();
810 altimetry_map[0.0] = altimetry;
811 return altimetry_map;
812 }
813
814
815 inline Altimetry& Altimetry::sumValue( double range, double altimetry ) {
816 if ( altimetry < min_altimetry_value ) min_altimetry_value = altimetry;
817 if ( altimetry > max_altimetry_value ) max_altimetry_value = altimetry;
818
819 AltIt it = altimetry_map.find( range );
820 if ( it == altimetry_map.end() ) altimetry_map.insert( std::make_pair( range, altimetry ) );
821 else it->second += altimetry;
822 return *this;
823 }
824
825
826 inline std::ostream& operator<<( std::ostream& os, const Altimetry& instance ) {
827 if ( !instance.altimetry_map.empty() ) {
828 os << "size = " << instance.altimetry_map.size() << "; min range = " << instance.altimetry_map.begin()->first
829 << "; altimetry = " << instance.begin()->second
830 << "; max range = " << instance.altimetry_map.rbegin()->first
831 << "; altimetry = " << instance.altimetry_map.rbegin()->second;
832 }
833 else {
834 os << "is empty.";
835 }
836 return os;
837 }
838
839
840 inline bool operator==( const Altimetry& left, const Altimetry& right ) {
841 if ( &left == &right ) return true;
842 return( left.altimetry_map == right.altimetry_map );
843 }
844
845
846 inline bool operator!=( const Altimetry& left, const Altimetry& right ) {
847 if ( &left == &right ) return false;
848 return( left.altimetry_map != right.altimetry_map );
849 }
850
851}
852
853
854#endif /* ALTIMETRY_DEFINITIONS_H */
855
856
857
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
std::map< PDouble, double > AltimetryMap
Definition altimetry-definitions.h:59
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
AltimBretschneider supports Bretschneider wave model.
Definition altimetry-definitions.h:582
AltimBretschneider & operator=(const AltimBretschneider &copy)
Definition altimetry-definitions.cpp:412
double average_period
Definition altimetry-definitions.h:756
virtual AltimBretschneider * timeEvolve(const Time &time_value)
Definition altimetry-definitions.cpp:443
virtual bool initialize()
Definition altimetry-definitions.cpp:422
virtual AltimBretschneider * randomize(double ratio_incr_value) const
Definition altimetry-definitions.cpp:470
virtual AltimBretschneider * create(AltimetryMap &map) const
Definition altimetry-definitions.h:629
virtual AltimBretschneider * create(const Altimetry &copy) const
Definition altimetry-definitions.h:647
virtual AltimBretschneider * create() const
Definition altimetry-definitions.h:619
virtual bool isValid() const
Definition altimetry-definitions.cpp:431
virtual AltimBretschneider * create(const AltimBretschneider &copy) const
Definition altimetry-definitions.h:639
AltimBretschneider & setAveragePeriod(double p)
Definition altimetry-definitions.h:724
double char_height
Definition altimetry-definitions.h:749
AltimBretschneider & setCharacteristicHeight(double h)
Definition altimetry-definitions.h:717
double getAveragePeriod() const
Definition altimetry-definitions.h:736
virtual AltimBretschneider * create(double ch_height, double avg_per, int total_range_steps, double depth) const
Definition altimetry-definitions.h:663
virtual AltimBretschneider * clone() const
Definition altimetry-definitions.h:671
AltimBretschneider()
Definition altimetry-definitions.cpp:375
double getCharacteristicHeight() const
Definition altimetry-definitions.h:730
Altimetry profile class.
Definition altimetry-definitions.h:78
virtual bool initialize()
Definition altimetry-definitions.cpp:238
double getMaxAltimetryValue() const
Definition altimetry-definitions.h:291
virtual Altimetry * clone() const
Definition altimetry-definitions.h:137
long double getRangePrecision() const
Definition altimetry-definitions.h:303
AltimetryMap altimetry_map
Definition altimetry-definitions.h:571
double getDepth() const
Definition altimetry-definitions.h:327
Altimetry & operator=(const Altimetry &copy)
Definition altimetry-definitions.cpp:131
Altimetry & setTotalRangeSteps(int r_s)
Definition altimetry-definitions.h:260
double getEvolutionTimeQuantum() const
Definition altimetry-definitions.h:309
virtual Altimetry * crop(double range_start, double range_end)
Definition altimetry-definitions.cpp:168
double evolution_time_quantum
Definition altimetry-definitions.h:561
Altimetry & eraseValue(double range)
Definition altimetry-definitions.h:181
AltCIt end() const
Definition altimetry-definitions.h:210
friend const Altimetry operator/(const double left, const Altimetry &right)
virtual Altimetry * create() const
Definition altimetry-definitions.h:115
static AltimetryMap & createFlat(double altimetry=0)
Definition altimetry-definitions.h:807
double getMinAltimetryValue() const
Definition altimetry-definitions.h:297
double depth
Definition altimetry-definitions.h:566
friend const Altimetry operator+(const Altimetry &left, const Altimetry &right)
void clear()
Definition altimetry-definitions.h:235
bool empty() const
Definition altimetry-definitions.h:229
friend const Altimetry operator-(const double left, const Altimetry &right)
Altimetry & insertValue(double range, double altimetry)
Definition altimetry-definitions.cpp:146
AltCIt at(const int i) const
Definition altimetry-definitions.cpp:157
friend Altimetry & operator+=(Altimetry &left, const Altimetry &right)
double range
Definition altimetry-definitions.h:531
double getMinRangeValue() const
Definition altimetry-definitions.h:285
AltCIt findValue(double range) const
Definition altimetry-definitions.h:173
static bool getDebug(bool flag)
Definition altimetry-definitions.h:248
friend std::ostream & operator<<(std::ostream &os, const Altimetry &instance)
Definition altimetry-definitions.h:826
friend const Altimetry operator+(const Altimetry &left, const double right)
double getRange() const
Definition altimetry-definitions.h:315
static AltimetryMap & createNotValid()
Definition altimetry-definitions.h:800
friend const Altimetry operator+(const double left, const Altimetry &right)
virtual Altimetry * create(const Altimetry &copy) const
Definition altimetry-definitions.h:131
friend const Altimetry operator*(const Altimetry &left, const double right)
int total_range_steps
Definition altimetry-definitions.h:536
friend const Altimetry operator-(const Altimetry &left, const double right)
virtual Altimetry * timeEvolve(const Time &time_value)
Definition altimetry-definitions.cpp:213
Altimetry()
Definition altimetry-definitions.cpp:59
friend bool operator==(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.h:840
static void setDebug(bool flag)
Definition altimetry-definitions.h:242
Altimetry & sumValue(double range, double altimetry)
Definition altimetry-definitions.h:815
friend bool operator!=(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.h:846
double min_altimetry_value
Definition altimetry-definitions.h:541
Altimetry & setEvolutionTimeQuantum(double quantum)
Definition altimetry-definitions.h:254
int getTotalRangeSteps() const
Definition altimetry-definitions.h:321
Altimetry & setRange(double r)
Definition altimetry-definitions.h:266
friend Altimetry & operator-=(Altimetry &left, double right)
long double range_precision
Definition altimetry-definitions.h:551
friend const Altimetry operator-(const Altimetry &left, const Altimetry &right)
virtual Altimetry * randomize(double ratio_incr_value) const
Definition altimetry-definitions.cpp:189
int size() const
Definition altimetry-definitions.h:223
double getMaxRangeValue() const
Definition altimetry-definitions.h:279
Altimetry & setDepth(double d)
Definition altimetry-definitions.h:272
friend const Altimetry operator*(const double left, const Altimetry &right)
virtual bool isValid() const
Definition altimetry-definitions.cpp:123
friend Altimetry & operator*=(Altimetry &left, double right)
friend Altimetry & operator+=(Altimetry &left, double right)
AltCIt begin() const
Definition altimetry-definitions.h:204
static bool debug
Definition altimetry-definitions.h:526
friend Altimetry & operator-=(Altimetry &left, const Altimetry &right)
Time last_evolution_time
Definition altimetry-definitions.h:556
friend Altimetry & operator/=(Altimetry &left, double right)
virtual Altimetry * create(AltimetryMap &map) const
Definition altimetry-definitions.h:123
double max_altimetry_value
Definition altimetry-definitions.h:546
friend const Altimetry operator/(const Altimetry &left, const double right)
a class for time date manipulation
Definition time-definitions.h:95
Provides the interface for the woss::PDouble class.
Definitions and library for woss::Time, woss::SimTime, woss::TimeReference and woss::TimeReferenceTcl...