USML
profile_grid.h
1 
6 #ifndef USML_OCEAN_PROFILE_GRID_H
7 #define USML_OCEAN_PROFILE_GRID_H
8 
9 #include <usml/ocean/profile_model.h>
10 
11 namespace usml {
12 namespace ocean {
13 
16 
36 template< class DATA_TYPE, int NUM_DIMS > class profile_grid
37  : public profile_model
38 {
39  protected:
40 
41  //**************************************************
42  // sound speed model
43 
46 
47  public:
48 
57  virtual void sound_speed( const wposition& location,
58  matrix<double>* speed, wvector* gradient=NULL )
59  {
60  switch( NUM_DIMS ) {
61 
62  //***************
63  // 1-D grids
64 
65  case 1 :
66  if ( gradient ) {
67  matrix<double> rho( location.size1(), location.size2() ) ;
68  this->_sound_speed->interpolate(
69  location.rho(),
70  speed, &rho ) ;
71  gradient->rho( rho ) ;
72  } else {
73  this->_sound_speed->interpolate(
74  location.rho(),
75  speed ) ;
76  }
77  break ;
78 
79  //***************
80  // 2-D grids
81 
82  case 2 :
83  if ( gradient ) {
84  matrix<double> rho( location.size1(), location.size2() ) ;
85  matrix<double> theta( location.size1(), location.size2() ) ;
86  this->_sound_speed->interpolate(
87  location.rho(), location.theta(),
88  speed, &rho, &theta ) ;
89  gradient->rho(rho) ;
90  gradient->theta(theta) ;
91  } else {
92  this->_sound_speed->interpolate(
93  location.rho(), location.theta(),
94  speed ) ;
95  }
96  break ;
97 
98  //***************
99  // 3-D grids
100 
101  case 3 :
102  if ( gradient ) {
103  matrix<double> rho( location.size1(), location.size2() ) ;
104  matrix<double> theta( location.size1(), location.size2() ) ;
105  matrix<double> phi( location.size1(), location.size2() ) ;
106  this->_sound_speed->interpolate(
107  location.rho(), location.theta(), location.phi(),
108  speed, &rho, &theta, &phi ) ;
109  gradient->rho(rho) ;
110  gradient->theta(theta) ;
111  gradient->phi(phi) ;
112  } else {
113  this->_sound_speed->interpolate(
114  location.rho(), location.theta(), location.phi(),
115  speed ) ;
116  }
117  break ;
118 
119  //***************
120  // error
121 
122  default :
123  throw std::invalid_argument(
124  "sound speed must be 1-D, 2-D, or 3-D") ;
125  break ;
126  }
127  this->adjust_speed( location, speed, gradient ) ;
128  }
129 
130  //**************************************************
131  // initialization
132 
144  data_grid<DATA_TYPE,NUM_DIMS>* speed, attenuation_model* attmodel=NULL)
145  : profile_model(attmodel), _sound_speed(speed) { }
146 
150  virtual ~profile_grid() {
151  delete _sound_speed ;
152  }
153 
154 };
155 
157 } // end of namespace ocean
158 } // end of namespace usml
159 
160 #endif
unsigned size2() const
Number of columns in each coordinate.
Definition: wvector.h:264
const matrix< double > & rho() const
Retrieves the radial component of the spherical earth coordinate system.
Definition: wvector.h:76
World location in geodetic earth coordinates (latitude, longitude, and altitude). ...
Definition: wposition.h:39
unsigned size1() const
Number of rows in each coordinate.
Definition: wvector.h:256
profile_grid(data_grid< DATA_TYPE, NUM_DIMS > *speed, attenuation_model *attmodel=NULL)
Default behavior for new profile models.
Definition: profile_grid.h:143
data_grid< DATA_TYPE, NUM_DIMS > * _sound_speed
Sound speed for all locations.
Definition: profile_grid.h:45
const matrix< double > & phi() const
Retrieves the longitude component of the spherical earth coordinate system.
Definition: wvector.h:204
const matrix< double > & theta() const
Retrieves the colatitude component of the spherical earth coordinate system.
Definition: wvector.h:140
N-dimensional data set and its associated axes.
Definition: data_grid.h:64
A "profile model" computes the environmental parameters of ocean water.
Definition: profile_model.h:28
virtual ~profile_grid()
Delete sound speed grid.
Definition: profile_grid.h:150
Sound speed model constructed from a 1-D, 2-D, or 3-D data grid.
Definition: profile_grid.h:36
World vector in spherical earth coordinates.
Definition: wvector.h:42
An attenuation loss model computes the absorption of sound by the minerals in sea water...
Definition: attenuation_model.h:30
virtual void adjust_speed(const wposition &location, matrix< double > *speed, wvector *gradient=NULL)
When the flat earth option is enabled, this routine applies an anti-correction term to the profile...
Definition: profile_model.cc:14
virtual void sound_speed(const wposition &location, matrix< double > *speed, wvector *gradient=NULL)
Compute the speed of sound and it's first derivatives at a series of locations.
Definition: profile_grid.h:57