RSTT  3.2.0
Regional Seismic Travel Time
All Classes Namespaces Files Functions Variables Typedefs Friends Macros
GeoStack.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 GeoStack_H
39 #define GeoStack_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 
52 // **** _BEGIN SLBM NAMESPACE_ **************************************************
53 
54 namespace slbm {
55 
65 {
66 
67 public:
68 
73 
74  GeoStack(const int& index, double* depths, double* pvelocities,
75  double* svelocities, double* gradients);
76 
81 
86 
90  GeoStack& operator=(const GeoStack& other);
91 
95  bool operator==(const GeoStack& other);
96 
100  bool operator!=(const GeoStack& other) {return ! (*this == other);};
101 
102  int getRefCount() { return refCount; };
103 
104  void incRefCount() { ++refCount; };
105 
106  void decRefCount() { --refCount; };
107 
108  void setRefCount(const int& count) { refCount = count; };
109 
110  int getIndex() { return index; };
111 
112  void setIndex(const int& idx) { index = idx; };
113 
123  void getData(double* depths,
124  double* pvelocity, double* svelocity, double* gradient);
125 
136  void setData(double* depths, double* pvelocities, double* svelocities, double* gradients);
137 
142  void setDepth(const vector<double>& z);
143 
149  void setVelocity(const int& waveType, const vector<double>& velocity);
150 
155  void setGradient(const vector<double>& gradient);
156 
160  double getDepth(const int& k) { return depth[k]; };
161 
162  double* getDepth() { return depth; };
163 
170  double getVelocity(const int& waveType, const int& k);
171 
176  double getMantleGradient(const int& waveType);
177 
183  void getVelocity(const int& waveType, double* velocity);
184 
188  void getMantleGradient(double* g) { g[0] = gradient[0]; g[1] = gradient[1]; };
189 
200 
206  string toString();
207 
208  static int getClassCount();
209 
211 
212 protected:
213 
214  static int geoStackClassCount;
215 
216  int index;
217 
218  int refCount;
219 
225  double depth[NLAYERS];
226 
232  double pvelocity[NLAYERS];
233  double svelocity[NLAYERS];
234 
238  double gradient[2];
239 
240 };
241 
242 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
243 //
244 // INLINE FUNCTIONS
245 //
246 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
247 
248 inline void GeoStack::getData(double* d, double* pv, double* sv, double* g)
249 {
250  for (int i=0; i<NLAYERS; i++)
251  {
252  d[i] = depth[i];
253  pv[i] = pvelocity[i];
254  sv[i] = svelocity[i];
255  }
256  g[PWAVE] = gradient[PWAVE];
257  g[SWAVE] = gradient[SWAVE];
258 }
259 
260 inline void GeoStack::setData(double* depths, double* pvelocities,
261  double* svelocities, double* gradients)
262 {
263  for (int i=0; i<NLAYERS; i++)
264  {
265  depth[i] = depths[i];
266  pvelocity[i] = pvelocities[i];
267  svelocity[i] = svelocities[i];
268  }
269  gradient[PWAVE] = gradients[PWAVE];
270  gradient[SWAVE] = gradients[SWAVE];
271 
272  thicknessTest();
273 }
274 
275 inline double GeoStack::getVelocity(const int& waveType, const int& k)
276 {
277  if (waveType == PWAVE)
278  return pvelocity[k];
279  return svelocity[k];
280 }
281 
282 inline double GeoStack::getMantleGradient(const int& waveType)
283 {
284  return gradient[waveType];
285 }
286 
287 inline void GeoStack::getVelocity(const int& waveType, double* v)
288 {
289  if (waveType == PWAVE)
290  for (int k=0; k<NLAYERS; ++k)
291  v[k] = pvelocity[k];
292  else
293  for (int k=0; k<NLAYERS; ++k)
294  v[k] = svelocity[k];
295 }
296 
297 inline void GeoStack::setDepth(const vector<double>& z)
298 {
299  for (int i=0; i<NLAYERS; i++)
300  depth[i] = z[i];
301 
302  thicknessTest();
303 }
304 
305 inline void GeoStack::setVelocity(const int& waveType, const vector<double>& v)
306 {
307  if (waveType == PWAVE)
308  for (int i=0; i<NLAYERS; i++)
309  pvelocity[i] = v[i];
310  else if (waveType == SWAVE)
311  for (int i=0; i<NLAYERS; i++)
312  svelocity[i] = v[i];
313 }
314 
315 inline void GeoStack::setGradient(const vector<double>& g)
316 {
317  gradient[PWAVE] = g[PWAVE];
318  gradient[SWAVE] = g[SWAVE];
319 }
320 
321 } // end slbm namespace
322 
323 #endif // GeoStack.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
double getDepth(const int &k)
Retrieve the depth of the k'th interval, in km.
Definition: GeoStack.h:160
~GeoStack()
Destructor.
GeoStack(const GeoStack &GeoStack)
Copy constructor.
void decRefCount()
Definition: GeoStack.h:106
void setRefCount(const int &count)
Definition: GeoStack.h:108
bool hasLowVelocityZone()
Return true if (1) any finite thickness layer above the middle crust has a velocity that exceeds the ...
GeoStack & operator=(const GeoStack &other)
Equal operator.
static int geoStackClassCount
Definition: GeoStack.h:214
void incRefCount()
Definition: GeoStack.h:104
void setIndex(const int &idx)
Definition: GeoStack.h:112
bool thicknessTest()
bool operator==(const GeoStack &other)
Equality operator.
void getMantleGradient(double *g)
Retrieve the P and S velocity gradients in the mantle, in 1/sec.
Definition: GeoStack.h:188
GeoStack(const int &index, double *depths, double *pvelocities, double *svelocities, double *gradients)
bool operator!=(const GeoStack &other)
Inequality operator.
Definition: GeoStack.h:100
static int getClassCount()
double * getDepth()
Definition: GeoStack.h:162
int getIndex()
Definition: GeoStack.h:110
GeoStack()
Default constructor.
int getRefCount()
Definition: GeoStack.h:102
string toString()
Return the information content of this GeoStack formatted in small text table.