RSTT 3.2.1 Regional Seismic Travel Time

Loading...
Searching...
No Matches
SlbmInterfaceToJNI.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 SlbmInterfaceToJNI_H
39#define SlbmInterfaceToJNI_H
40
41// **** _SYSTEM INCLUDES_ ******************************************************
42#include <cmath>
43
44 using namespace std;
45
46// **** _LOCAL INCLUDES_ *******************************************************
47
48#include "SLBMGlobals.h"
49#include "SlbmInterface.h"
50#include "GridProfile.h"
51#include "SLBMException.h"
52
53// **** _BEGIN SLBM NAMESPACE_ **************************************************
54
55 namespace slbm {
56
66 class SLBM_EXP_IMP SlbmInterfaceToJNI : public SlbmInterface
67{
68
69 public:
70
74 SlbmInterfaceToJNI();
75
76 SlbmInterfaceToJNI(const double& earthRadius);
77
81 ~SlbmInterfaceToJNI();
82
83 string getPhase();
84
85 void accessGridProfile(const int& nodeId);
86
87 void deleteGridProfile();
88
89 double getGridLat();
90
91 double getGridLon();
92
93 void getGridDepth(vector<double>& depths);
94
95 void getGridVelocity(const int& waveType, double* velocity);
96
97 void getGridGradient(double* gradient);
98
99 //void setGridDepths(const vector<double>& depth);
100
101 //void setGridVelocity(const int& waveType, const vector<double>& velocity);
102
103 // setGridGradient(const vector<double>& gradient);
104
105 void createQueryProfile(const double& lat, const double& lon);
106
107 void deleteQueryProfile();
108
109 int getQueryNCoefficients();
110
111 vector<int>& getQueryNodeId();
112
113 vector<double>& getQueryCoefficient();
114
115 double* getQueryDepth();
116
117 double* getQueryVelocity(const int& waveType);
118
119 double* getQueryGradient();
120
121 void computeWeights();
122
123 void computeWeightsSource();
124
125 void computeWeightsReceiver();
126
127 void deleteWeights() { nodeIds.clear(); weights.clear(); };
128
129 const vector<int>& getWeightNodes() { return nodeIds; };
130
131 const vector<double>& getWeights() { return weights; };
132
133 string getGreatCirclePhase();
134
135 double getActualPathIncrement();
136
137 void getGreatCircleNeighbors(const int& i, int* nodeIds, int& size);
138
139 void getGreatCircleCoefficients(const int& i, double* coeff, int& size);
140
141 void getGreatCircleSourceDepth(double* depths, int& n);
142
143 void getGreatCircleReceiverDepth(double* depths, int& n);
144
145 double* getGreatCircleSourceVelocity(int& n);
146
147 double* getGreatCircleReceiverVelocity(int& n);
148
149 void getGreatCircleHeadwaveVelocity(vector<double>& velocities);
150
151 void getGreatCircleHeadwaveGradient(vector<double>& gradients);
152
153 void computeGreatCirclePoints(
154 const double& aLat,
155 const double& aLon,
156 const double& bLat,
157 const double& bLon,
158 const int& npoints,
159 const bool& onCenters);
160
161 void computeGreatCircleLocations();
162
163 void deleteGreatCirclePoints()
164 { greatCirclePointsLat.clear(); greatCirclePointsLon.clear(); greatCirclePointsDepth.clear(); };
165
166 const vector<double>& getGreatCirclePointsLat() { return greatCirclePointsLat; };
167
168 const vector<double>& getGreatCirclePointsLon() { return greatCirclePointsLon; };
169
170 const vector<double>& getGreatCirclePointsDepth() { return greatCirclePointsDepth; };
171
172 int getNGridNodes();
173
174 int getNHeadWavePoints();
175
176 void accessGridNodeNeighbors(int nid );
177
178 static bool modelsEqual(const string modelPath1, const string modelPath2);
179
180
181 private:
182
183 QueryProfile* queryProfile;
184
185 GridProfile* gridProfile;
186
187 vector<int> nodeIds;
188
189 vector<double> weights;
190
191 vector<double> greatCirclePointsLat, greatCirclePointsLon, greatCirclePointsDepth;
192
193};
194
195 inline void SlbmInterfaceToJNI::computeGreatCirclePoints(
196 const double& aLat,
197 const double& aLon,
198 const double& bLat,
199 const double& bLon,
200 const int& npoints,
201 const bool& onCenters)
202{
203 deleteGreatCirclePoints();
204
205 Location a(aLat, aLon, 0.);
206 Location b(bLat, bLon, 0.);
207 double delta, delta0;
208
209 if (onCenters)
210 {
211 delta = a.distance(b)/npoints;
212 delta0 = 0.5*delta;
213 }
214 else
215 {
216 delta = a.distance(b)/(npoints-1);
217 delta0 = 0;
218 }
219
220 double moveDirection[3];
221 a.vectorTripleProduct(b, moveDirection);
222 for (int i=0; i<npoints; i++)
223 {
224 a.move(moveDirection, delta0+i*delta, b);
225 greatCirclePointsLat.push_back(b.getLat());
226 greatCirclePointsLon.push_back(b.getLon());
227 }
228}
229
230 inline void SlbmInterfaceToJNI::computeGreatCircleLocations()
231{
232 deleteGreatCirclePoints();
233
234 Location loc;
235 for (int i=0; i<greatCircle->getNProfiles(); i++)
236 {
237 // get the location of this layer profile
238 greatCircle->getLayerProfileLocation(i, loc);
239 greatCirclePointsLat.push_back(loc.getLat());
240 greatCirclePointsLon.push_back(loc.getLon());
241 greatCirclePointsDepth.push_back(loc.getDepth());
242 }
243}
244
245 inline string SlbmInterfaceToJNI::getPhase()
246{
247 if (greatCircle->getPhase() == Pn)
248 return "Pn";
249 if (greatCircle->getPhase() == Sn)
250 return "Sn";
251 if (greatCircle->getPhase() == Pg)
252 return "Pg";
253 if (greatCircle->getPhase() == Lg)
254 return "Lg";
255 return "unknown";
256}
257
258 inline void SlbmInterfaceToJNI::accessGridProfile(const int& nodeId)
259{
260 gridProfile = grid->getProfile(nodeId);
261}
262
263 inline double SlbmInterfaceToJNI::getGridLat()
264{
265 return gridProfile->getLat();
266}
267
268 inline double SlbmInterfaceToJNI::getGridLon()
269{
270 return gridProfile->getLon();
271}
272
273
274 inline void SlbmInterfaceToJNI::getGridDepth(vector<double>& depths)
275{
276 gridProfile->getInterfaceDepths(depths);
277}
278
279 inline void SlbmInterfaceToJNI::getGridVelocity(const int& waveType, double* velocity)
280{
281 gridProfile->getVelocity(waveType, velocity);
282}
283
284 inline void SlbmInterfaceToJNI::getGridGradient(double* gradient)
285{
286 gridProfile->getMantleGradient(gradient);
287}
288
289//inline void SlbmInterfaceToJNI::setGridDepths(const vector<double>& depth)
290//{
291// gridProfile->setDepths(depth);
292//}
293//
294//inline void SlbmInterfaceToJNI::setGridVelocity(const int& waveType,
295// const vector<double>& velocity)
296//{
297// gridProfile->setVelocity(waveType, velocity);
298//}
299//
300//inline void SlbmInterfaceToJNI::setGridGradient(const vector<double>& gradient)
301//{
302// gridProfile->setGradient(gradient);
303//}
304
305 inline void SlbmInterfaceToJNI::createQueryProfile(const double &lat, const double &lon)
306{
307 deleteQueryProfile();
308 Location loc(lat, lon, 0.);
309 queryProfile = grid->getQueryProfile(loc);
310}
311
312 inline void SlbmInterfaceToJNI::deleteQueryProfile()
313{
314 if (queryProfile) delete queryProfile;
315 queryProfile = NULL;
316}
317
318 inline int SlbmInterfaceToJNI::getQueryNCoefficients()
319{
320 return queryProfile->getNCoefficients();
321}
322
323 inline vector<int>& SlbmInterfaceToJNI::getQueryNodeId()
324{
325 return queryProfile->getNodeIds();
326}
327
328 inline vector<double>& SlbmInterfaceToJNI::getQueryCoefficient()
329{
330 return queryProfile->getCoefficients();
331}
332
333 inline double* SlbmInterfaceToJNI::getQueryDepth()
334{
335 return queryProfile->getDepth();
336}
337
338 inline double* SlbmInterfaceToJNI::getQueryVelocity(const int& waveType)
339{
340 return queryProfile->getVelocity(waveType);
341}
342
343 inline double* SlbmInterfaceToJNI::getQueryGradient()
344{
345 return queryProfile->getMantleGradient();
346}
347
348 inline void SlbmInterfaceToJNI::computeWeights()
349{
350 SlbmInterface::getWeights(nodeIds, weights);
351}
352
353
354 inline string SlbmInterfaceToJNI::getGreatCirclePhase()
355{
356 return greatCircle->getPhaseString();
357}
358
359 inline double SlbmInterfaceToJNI::getActualPathIncrement()
360{
361 return greatCircle->getActualPathIncrement();
362}
363
364 inline void SlbmInterfaceToJNI::getGreatCircleNeighbors(const int& i, int* nodeids, int& size)
365{
366 greatCircle->getProfile(i)->getNodeIds(nodeids, size);
367}
368
369 inline void SlbmInterfaceToJNI::getGreatCircleCoefficients(const int& i, double* coeff, int& size)
370{
371 greatCircle->getProfile(i)->getCoefficients(coeff, size);
372}
373
374 inline void SlbmInterfaceToJNI::getGreatCircleSourceDepth(double* depths, int& n)
375{
376 n = greatCircle->getSourceProfile()->getNIntervals();
377 greatCircle->getSourceProfile()->getDepths(depths);
378}
379
380 inline void SlbmInterfaceToJNI::getGreatCircleReceiverDepth(double* depths, int& n)
381{
382 n = greatCircle->getReceiverProfile()->getNIntervals();
383 greatCircle->getReceiverProfile()->getDepths(depths);
384}
385
386 inline double* SlbmInterfaceToJNI::getGreatCircleSourceVelocity(int& n)
387{
388 n = greatCircle->getSourceProfile()->getNIntervals();
389 return greatCircle->getSourceProfile()->getVelocities();
390}
391
392 inline double* SlbmInterfaceToJNI::getGreatCircleReceiverVelocity(int& n)
393{
394 n = greatCircle->getReceiverProfile()->getNIntervals();
395 return greatCircle->getReceiverProfile()->getVelocities();
396}
397
398 inline void SlbmInterfaceToJNI::getGreatCircleHeadwaveVelocity(vector<double>& v)
399{
400 v.clear();
401 for (int i=0; i<greatCircle->getNProfiles(); i++)
402 v.push_back(greatCircle->getProfile(i)->getVelocity());
403}
404
405 inline void SlbmInterfaceToJNI::getGreatCircleHeadwaveGradient(vector<double>& g)
406{
407 g.clear();
408 for (int i=0; i<greatCircle->getNProfiles(); i++)
409 g.push_back(greatCircle->getProfile(i)->getGradient());
410}
411
412 inline int SlbmInterfaceToJNI::getNGridNodes()
413{
414 int n = -1;
415 n = grid->getNNodes();
416 return n;
417}
418
419 inline int SlbmInterfaceToJNI::getNHeadWavePoints()
420{
421 int nHeadWavePoints = -1;
422 nHeadWavePoints = greatCircle->getNProfiles();
423 return nHeadWavePoints;
424}
425
426 inline void SlbmInterfaceToJNI::computeWeightsSource()
427{
428 nodeIds = greatCircle->getSourceProfile()->getNodeIds();
429 weights = greatCircle->getSourceProfile()->getCoefficients();
430}
431 inline void SlbmInterfaceToJNI::computeWeightsReceiver()
432{
433 nodeIds = greatCircle->getReceiverProfile()->getNodeIds();
434 weights = greatCircle->getReceiverProfile()->getCoefficients();
435}
436 bool SlbmInterfaceToJNI::modelsEqual(const string modelPath1, const string modelPath2)
437{
438 return SlbmInterface::modelsEqual(modelPath1, modelPath2);
439}
440
441} // end slbm namespace
442
443#endif
GridProfile.h
SLBMException.h
SLBMGlobals.h
SLBM_EXP_IMP
#define SLBM_EXP_IMP
Definition SLBMGlobals.h:180
SlbmInterface.h
slbm::GridProfile
Manages all information related to a single node in a Grid object.
Definition GridProfile.h:71
slbm::Location
The Location Class manages a single point in/on the Earth, which is described by the GRS80 ellipsoid.
Definition Location.h:78
slbm::Location::getLon
double getLon() const
Retrieve the longitude of this Location. Value will be between -PI and PI radians.
Definition Location.h:548
slbm::Location::distance
double distance(const Location &other) const
Definition Location.h:583
slbm::Location::vectorTripleProduct
bool vectorTripleProduct(const Location &other, double vtp[]) const
Compute the vector triple product (this x other) x this, normalized to unit length....
Definition Location.h:691
slbm::Location::move
void move(const double &azimuth, const double &distance, Location &loc) const
Retrieve a Location that is a specified distance away from this Location, in a specified direction.
Definition Location.h:638
slbm::Location::getDepth
double getDepth() const
Definition Location.h:573
slbm::Location::getLat
double getLat() const
Retrieve the geographic latitude of this Location, radians.
Definition Location.h:542
slbm::QueryProfile
An InterpolatedProfile object that also has information about the the P and S wave velocity as a func...
Definition QueryProfile.h:68
slbm::SlbmInterface::greatCircle
GreatCircle * greatCircle
The most recently requested GreatCircle object.
Definition SlbmInterface.h:1907
slbm::SlbmInterface::SlbmInterface
SlbmInterface()
Default constructor. Instantiates an SlbmInterface object based on an ellipsoidal earth.
slbm::SlbmInterface::getWeights
void getWeights(int nodeId[], double weight[], int &nWeights)
Retrieve the weight assigned to each grid node that was touched by the GreatCircle.
Definition SlbmInterface.h:2239
slbm::SlbmInterface::grid
Grid * grid
The Grid object that stores the velocity model.
Definition SlbmInterface.h:1902
slbm::SlbmInterface::modelsEqual
static bool modelsEqual(const string modelPath1, const string modelPath2)
Check if two models are equal.
slbm::SlbmInterfaceToJNI::modelsEqual
static bool modelsEqual(const string modelPath1, const string modelPath2)
Definition SlbmInterfaceToJNI.h:436
slbm::SlbmInterfaceToJNI::getGreatCircleHeadwaveVelocity
void getGreatCircleHeadwaveVelocity(vector< double > &velocities)
Definition SlbmInterfaceToJNI.h:398
slbm::SlbmInterfaceToJNI::SlbmInterfaceToJNI
SlbmInterfaceToJNI()
Default constructor.
slbm::SlbmInterfaceToJNI::computeWeightsReceiver
void computeWeightsReceiver()
Definition SlbmInterfaceToJNI.h:431
slbm::SlbmInterfaceToJNI::getGridLon
double getGridLon()
Definition SlbmInterfaceToJNI.h:268
slbm::SlbmInterfaceToJNI::getQueryNCoefficients
int getQueryNCoefficients()
Definition SlbmInterfaceToJNI.h:318
slbm::SlbmInterfaceToJNI::getGridGradient
void getGridGradient(double *gradient)
Definition SlbmInterfaceToJNI.h:284
slbm::SlbmInterfaceToJNI::getGreatCircleNeighbors
void getGreatCircleNeighbors(const int &i, int *nodeIds, int &size)
Definition SlbmInterfaceToJNI.h:364
slbm::SlbmInterfaceToJNI::getGreatCircleSourceVelocity
double * getGreatCircleSourceVelocity(int &n)
Definition SlbmInterfaceToJNI.h:386
slbm::SlbmInterfaceToJNI::deleteWeights
void deleteWeights()
Definition SlbmInterfaceToJNI.h:127
slbm::SlbmInterfaceToJNI::createQueryProfile
void createQueryProfile(const double &lat, const double &lon)
Definition SlbmInterfaceToJNI.h:305
slbm::SlbmInterfaceToJNI::getQueryVelocity
double * getQueryVelocity(const int &waveType)
Definition SlbmInterfaceToJNI.h:338
slbm::SlbmInterfaceToJNI::computeWeightsSource
void computeWeightsSource()
Definition SlbmInterfaceToJNI.h:426
slbm::SlbmInterfaceToJNI::getGreatCirclePointsLon
const vector< double > & getGreatCirclePointsLon()
Definition SlbmInterfaceToJNI.h:168
slbm::SlbmInterfaceToJNI::getQueryGradient
double * getQueryGradient()
Definition SlbmInterfaceToJNI.h:343
slbm::SlbmInterfaceToJNI::getGreatCircleReceiverVelocity
double * getGreatCircleReceiverVelocity(int &n)
Definition SlbmInterfaceToJNI.h:392
slbm::SlbmInterfaceToJNI::getGreatCircleCoefficients
void getGreatCircleCoefficients(const int &i, double *coeff, int &size)
Definition SlbmInterfaceToJNI.h:369
slbm::SlbmInterfaceToJNI::computeGreatCircleLocations
void computeGreatCircleLocations()
Definition SlbmInterfaceToJNI.h:230
slbm::SlbmInterfaceToJNI::~SlbmInterfaceToJNI
~SlbmInterfaceToJNI()
Destructor.
slbm::SlbmInterfaceToJNI::getGridVelocity
void getGridVelocity(const int &waveType, double *velocity)
Definition SlbmInterfaceToJNI.h:279
slbm::SlbmInterfaceToJNI::getGreatCirclePhase
string getGreatCirclePhase()
Definition SlbmInterfaceToJNI.h:354
slbm::SlbmInterfaceToJNI::getGreatCircleSourceDepth
void getGreatCircleSourceDepth(double *depths, int &n)
Definition SlbmInterfaceToJNI.h:374
slbm::SlbmInterfaceToJNI::getNGridNodes
int getNGridNodes()
Definition SlbmInterfaceToJNI.h:412
slbm::SlbmInterfaceToJNI::getGridDepth
void getGridDepth(vector< double > &depths)
Definition SlbmInterfaceToJNI.h:274
slbm::SlbmInterfaceToJNI::accessGridNodeNeighbors
void accessGridNodeNeighbors(int nid)
slbm::SlbmInterfaceToJNI::getNHeadWavePoints
int getNHeadWavePoints()
Definition SlbmInterfaceToJNI.h:419
slbm::SlbmInterfaceToJNI::getWeights
const vector< double > & getWeights()
Definition SlbmInterfaceToJNI.h:131
slbm::SlbmInterfaceToJNI::getPhase
string getPhase()
Definition SlbmInterfaceToJNI.h:245
slbm::SlbmInterfaceToJNI::deleteGridProfile
void deleteGridProfile()
slbm::SlbmInterfaceToJNI::deleteQueryProfile
void deleteQueryProfile()
Definition SlbmInterfaceToJNI.h:312
slbm::SlbmInterfaceToJNI::getActualPathIncrement
double getActualPathIncrement()
Definition SlbmInterfaceToJNI.h:359
slbm::SlbmInterfaceToJNI::deleteGreatCirclePoints
void deleteGreatCirclePoints()
Definition SlbmInterfaceToJNI.h:163
slbm::SlbmInterfaceToJNI::getGreatCirclePointsDepth
const vector< double > & getGreatCirclePointsDepth()
Definition SlbmInterfaceToJNI.h:170
slbm::SlbmInterfaceToJNI::getGreatCircleReceiverDepth
void getGreatCircleReceiverDepth(double *depths, int &n)
Definition SlbmInterfaceToJNI.h:380
slbm::SlbmInterfaceToJNI::computeWeights
void computeWeights()
Definition SlbmInterfaceToJNI.h:348
slbm::SlbmInterfaceToJNI::getGridLat
double getGridLat()
Definition SlbmInterfaceToJNI.h:263
slbm::SlbmInterfaceToJNI::getQueryNodeId
vector< int > & getQueryNodeId()
Definition SlbmInterfaceToJNI.h:323
slbm::SlbmInterfaceToJNI::getGreatCircleHeadwaveGradient
void getGreatCircleHeadwaveGradient(vector< double > &gradients)
Definition SlbmInterfaceToJNI.h:405
slbm::SlbmInterfaceToJNI::computeGreatCirclePoints
void computeGreatCirclePoints(const double &aLat, const double &aLon, const double &bLat, const double &bLon, const int &npoints, const bool &onCenters)
Definition SlbmInterfaceToJNI.h:195
slbm::SlbmInterfaceToJNI::getWeightNodes
const vector< int > & getWeightNodes()
Definition SlbmInterfaceToJNI.h:129
slbm::SlbmInterfaceToJNI::getQueryCoefficient
vector< double > & getQueryCoefficient()
Definition SlbmInterfaceToJNI.h:328
slbm::SlbmInterfaceToJNI::getGreatCirclePointsLat
const vector< double > & getGreatCirclePointsLat()
Definition SlbmInterfaceToJNI.h:166
slbm::SlbmInterfaceToJNI::getQueryDepth
double * getQueryDepth()
Definition SlbmInterfaceToJNI.h:333
slbm::SlbmInterfaceToJNI::accessGridProfile
void accessGridProfile(const int &nodeId)
Definition SlbmInterfaceToJNI.h:258
slbm::SlbmInterfaceToJNI::SlbmInterfaceToJNI
SlbmInterfaceToJNI(const double &earthRadius)
slbm
Definition CrustalProfile.h:59