RSTT  3.2.0
Regional Seismic Travel Time
All Classes Namespaces Files Functions Variables Typedefs Friends Macros
GridProfileSLBM.h
Go to the documentation of this file.
1 //- ****************************************************************************
2 //-
3 //- Copyright 2009 National Technology & Engineering Solutions of Sandia, LLC
4 //- (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
5 //- Government retains certain rights in this software.
6 //-
7 //- BSD Open Source License
8 //- All rights reserved.
9 //-
10 //- Redistribution and use in source and binary forms, with or without
11 //- modification, are permitted provided that the following conditions are met:
12 //-
13 //- 1. Redistributions of source code must retain the above copyright notice,
14 //- this list of conditions and the following disclaimer.
15 //-
16 //- 2. Redistributions in binary form must reproduce the above copyright
17 //- notice, this list of conditions and the following disclaimer in the
18 //- documentation and/or other materials provided with the distribution.
19 //-
20 //- 3. Neither the name of the copyright holder nor the names of its
21 //- contributors may be used to endorse or promote products derived from
22 //- this software without specific prior written permission.
23 //-
24 //- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 //- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 //- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 //- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28 //- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 //- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 //- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 //- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 //- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 //- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 //- POSSIBILITY OF SUCH DAMAGE.
35 //-
36 //- ****************************************************************************
37 
38 #ifndef GRIDPROFILESLBM_H_
39 #define GRIDPROFILESLBM_H_
40 
41 // **** _SYSTEM INCLUDES_ ******************************************************
42 
43 #include <vector>
44 #include <set>
45 
46 using namespace std;
47 
48 // **** _LOCAL INCLUDES_ *******************************************************
49 
50 #include "SLBMGlobals.h"
51 #include "Location.h"
52 #include "GeoStack.h"
53 
54 // **** _BEGIN SLBM NAMESPACE_ **************************************************
55 
56 namespace slbm {
57 
58 class InterpolatedProfile;
59 class Grid;
60 
71 {
72 
73 // let Grid objects access protected members of GridProfileSLBM.
74 friend class Grid;
75 
76 public:
77 
84  const int& i, const double& lat,
85  const double& lon, const double& elev,
86  const double& zwater, GeoStack* gstack);
87 
92 
97 
98  static string class_name() { return "GridProfileSLBM"; };
99 
107  int getGeoStackId() { return geoStack->getIndex(); };
108 
118  void getData(double* depths, double* pvelocity, double* svelocity, double* gradient);
119 
130  void setData(double* depths, double* pvelocities,
131  double* svelocities, double* gradients);
132 
137  void setDepths(const vector<double>& depths);
138 
144  void setVelocity(const int& waveType, const vector<double>& velocity);
145 
150  void setGradient(const vector<double>& gradient);
151 
155  double getInterfaceRadius(const int& k);
156 
162  double getInterfaceDepth(const int& k);
163 
170  double getVelocity(const int& waveType, const int& k)
171  { return geoStack->getVelocity(waveType, k); };
172 
177  double getMantleGradient(const int& waveType)
178  { return geoStack->getMantleGradient(waveType); };
179 
183  void getInterfaceDepths(vector<double>& depths);
184 
190  void getVelocity(const int& waveType, double* velocity)
191  { geoStack->getVelocity(waveType, velocity); };
192 
196  void getMantleGradient(double* g) { geoStack->getMantleGradient(g); };
197 
198  double getWaterThick() { return waterThick; };
199 
200 protected:
201 
203 
210 
211  double waterThick;
212 
213 };
214 
215 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
216 //
217 // INLINE FUNCTIONS
218 //
219 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
220 
221 inline double GridProfileSLBM::getInterfaceRadius(const int& k)
222 {
223  // radius is the radius of the surface of the solid earth.
224  // geoStack->getDepth(k) returns the depth of top of layer k
225  // relative to surface of solid earth.
226  // The difference is the radius of the top of layer k.
227  // Layer 0 is the water layer and waterThick is the nominal
228  // thickness of the water layer. Since waterThick is only
229  // a nominal value, it is not guaranteed that top of water
230  // is at sea level.
231  if (k > 0)
232  return radius - geoStack->getDepth(k);
233  return radius + waterThick;
234 }
235 
236 inline void GridProfileSLBM::getData(double* d,
237  double* pv, double* sv, double* g)
238 {
239  double r = getEarthRadius();
240  for (int k=0; k<NLAYERS; k++)
241  {
242  d[k] = r - getInterfaceRadius(k);
243  pv[k] = geoStack->getVelocity(PWAVE, k);
244  sv[k] = geoStack->getVelocity(SWAVE, k);
245  }
246  g[PWAVE] = geoStack->getMantleGradient(PWAVE);
247  g[SWAVE] = geoStack->getMantleGradient(SWAVE);
248 }
249 
250 inline double GridProfileSLBM::getInterfaceDepth(const int& k)
251 {
252  // getEarthRadius is the radius of sea level.
253  return getEarthRadius() - getInterfaceRadius(k);
254 }
255 
256 inline void GridProfileSLBM::getInterfaceDepths(vector<double>& depths)
257 {
258  depths.resize(NLAYERS);
259  double r = getEarthRadius();
260  for (int k=0; k<NLAYERS; k++)
261  depths[k] = r - getInterfaceRadius(k);
262 }
263 
264 } // end slbm namespace
265 
266 #endif // GRIDPROFILESLBM_H_.h
#define SLBM_EXP_IMP
Definition: SLBMGlobals.h:180
Manages all information related to a single node in a Grid object.
Definition: GeoStack.h:65
A 2 dimensional, horizontal grid of GirdProfile objects.
Definition: Grid.h:91
Manages all information related to a single node in a Grid object.
Definition: GridProfile.h:71
Manages all information related to a single node in a Grid object.
GeoStack * geoStack
The GeoStack object that holds all the interface depths, velocities and gradients.
GridProfileSLBM(const GridProfileSLBM &other)
Copy constructor.
~GridProfileSLBM()
Destructor.
double getVelocity(const int &waveType, const int &k)
Retrieve the P or S velocity of the k'th interval, in km/sec.
void setDepths(const vector< double > &depths)
Set the layer depths to specified values.
int getGeoStackId()
Retrieve the index of the GeoStack that holds the information about model interfaces,...
void setVelocity(const int &waveType, const vector< double > &velocity)
Set the P or S velocity to specified values.
void setData(double *depths, double *pvelocities, double *svelocities, double *gradients)
Set the P and S velocities and gradients associated with this GridProfileSLBM object to specified val...
static string class_name()
void setGradient(const vector< double > &gradient)
Set the P and S velocity gradients to specified values.
double getMantleGradient(const int &waveType)
Retrieve the P or S velocity gradient in the mantle, in 1/sec.
GridProfileSLBM(Grid &g, const int &i, const double &lat, const double &lon, const double &elev, const double &zwater, GeoStack *gstack)
Parameterized constructor.
void getMantleGradient(double *g)
Retrieve the P and S velocity gradients in the mantle, in 1/sec.
void getVelocity(const int &waveType, double *velocity)
Retrieve the P or S velocities of all intervals, in km/sec.