RSTT 3.2.1 Regional Seismic Travel Time

Loading...
Searching...
No Matches
InterpolatedProfile.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 InterpolatedProfile_H
39#define InterpolatedProfile_H
40
41// **** _SYSTEM INCLUDES_ ******************************************************
42
43#include <vector>
44
45 using namespace std;
46
47// **** _LOCAL INCLUDES_ *******************************************************
48
49#include "SLBMGlobals.h"
50#include "GridProfile.h"
51
52// **** _BEGIN SLBM NAMESPACE_ **************************************************
53
54 namespace slbm {
55
56 class SLBM_EXP_IMP InterpolatedProfile
67{
68 public:
69
73 InterpolatedProfile();
74
82 InterpolatedProfile(Grid& grid, Location& location);
83
87 InterpolatedProfile(const InterpolatedProfile& other);
88
92 virtual ~InterpolatedProfile();
93
97 InterpolatedProfile& operator=(const InterpolatedProfile& other);
98
102 bool operator==(const InterpolatedProfile& other);
103
107 bool operator!=(const InterpolatedProfile& other) {return ! (*this == other);};
108
109 int getNCoefficients() { return nodes.size(); }
110
116 vector<GridProfile*>& getNodes() { return nodes; }
117
118 GridProfile* getNode(const int& i) { return nodes[i]; }
119
120 vector<int>& getNodeIds() { return nodeIds; }
121
122 int getNodeId(const int& i) { return nodeIds[i]; }
123
132 vector<double>& getCoefficients() { return coefficients; };
133
134 double getCoefficient(const int& i) { return coefficients[i]; }
135
144 void getNodeIds(int* nodeIds, int& size);
145
156 void getCoefficients(double* coeff, int& size);
157
158 void getWeights(int* nodeIds, double* coeff, int&size);
159
167 void interpRadius(const int& k, double& radius);
168
176 void interpDepth(const int& k, double& depth);
177
186 void interpVelocity(const int& type, const int& k, double& velocity);
187
195 void interpGradient(const int& type, double& gradient);
196
202 bool isActiveProfile();
203
204 virtual size_t memSize();
205
206 static int getClassCount();
207
208 protected:
209
210 static int interpolatedProfileClassCount;
211
217 vector<GridProfile*> nodes;
218
224 vector<int> nodeIds;
225
231 vector<double> coefficients;
232
233};
234
235//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
236//
237// INLINE FUNCTIONS
238//
239//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
240
241 inline void InterpolatedProfile::getWeights(int* nodeids, double* coeff, int& size)
242{
243 size = nodes.size();
244 for (int i=0; i<(int)nodes.size(); i++)
245 {
246 nodeids[i] = nodes[i]->getNodeId();
247 coeff[i] = coefficients[i];
248 }
249}
250
251 inline void InterpolatedProfile::getNodeIds(int* nodeids, int& size)
252{
253 size = nodes.size();
254 for (int i=0; i<(int)nodes.size(); i++)
255 nodeids[i] = nodes[i]->getNodeId();
256}
257
258 inline void InterpolatedProfile::getCoefficients(double* coeff, int& size)
259{
260 size = nodes.size();
261 for (int i=0; i<(int)nodes.size(); i++)
262 coeff[i] = coefficients[i];
263}
264
265 inline void InterpolatedProfile::interpRadius(const int& k, double& radius)
266{
267 radius = 0.;
268 for (int i=0; i<(int)nodes.size(); i++) if (nodes[i])
269 radius += nodes[i]->getInterfaceRadius(k) * coefficients[i];
270}
271
272 inline void InterpolatedProfile::interpDepth(const int& k, double& depth)
273{
274 depth = 0.;
275 for (int i=0; i<(int)nodes.size(); i++) if (nodes[i])
276 depth += nodes[i]->getInterfaceDepth(k) * coefficients[i];
277}
278
279 inline void InterpolatedProfile::interpVelocity(const int& type, const int& k, double& velocity)
280{
281 velocity = 0.;
282 for (int i=0; i<(int)nodes.size(); i++) if (nodes[i])
283 velocity += nodes[i]->getVelocity(type,k) * coefficients[i];
284}
285
286 inline void InterpolatedProfile::interpGradient(const int& type, double& gradient)
287{
288 gradient = 0.;
289 for (int i=0; i<(int)nodes.size(); i++) if (nodes[i])
290 gradient += nodes[i]->getMantleGradient(type) * coefficients[i];
291}
292
293 inline bool InterpolatedProfile::isActiveProfile()
294{
295 for (int i=0; i<(int)nodes.size(); i++)
296 if (nodes[i]->getActiveNodeId() < 0)
297 return false;
298 return true;
299}
300
301} // end slbm namespace
302
303#endif // InterpolatedProfile.h
GridProfile.h
SLBMGlobals.h
SLBM_EXP_IMP
#define SLBM_EXP_IMP
Definition SLBMGlobals.h:180
slbm::Grid
A 2 dimensional, horizontal grid of GirdProfile objects.
Definition Grid.h:91
slbm::GridProfile
Manages all information related to a single node in a Grid object.
Definition GridProfile.h:71
slbm::InterpolatedProfile::getNodeIds
vector< int > & getNodeIds()
Definition InterpolatedProfile.h:120
slbm::InterpolatedProfile::getWeights
void getWeights(int *nodeIds, double *coeff, int &size)
Definition InterpolatedProfile.h:241
slbm::InterpolatedProfile::interpDepth
void interpDepth(const int &k, double &depth)
Calculate a single depth value based on the neighboring GridProfile objects and the interpolation coe...
Definition InterpolatedProfile.h:272
slbm::InterpolatedProfile::interpGradient
void interpGradient(const int &type, double &gradient)
Calculate a single gradient value based on the neighboring GridProfile objects and the interpolation ...
Definition InterpolatedProfile.h:286
slbm::InterpolatedProfile::coefficients
vector< double > coefficients
The interpolation coefficients which should be applied to this InterpolatedProfile's neighbors in ord...
Definition InterpolatedProfile.h:231
slbm::InterpolatedProfile::interpolatedProfileClassCount
static int interpolatedProfileClassCount
Definition InterpolatedProfile.h:210
slbm::InterpolatedProfile::nodes
vector< GridProfile * > nodes
An array of pointers to the GridProfile objects upon which this InterpolatedProfile is dependent.
Definition InterpolatedProfile.h:217
slbm::InterpolatedProfile::getNode
GridProfile * getNode(const int &i)
Definition InterpolatedProfile.h:118
slbm::InterpolatedProfile::interpRadius
void interpRadius(const int &k, double &radius)
Calculate a single radius value based on the neighboring GridProfile objects and the interpolation co...
Definition InterpolatedProfile.h:265
slbm::InterpolatedProfile::getNodes
vector< GridProfile * > & getNodes()
Retrieve a list of pointers to the GridProfile objects upon which this InterpolatedProfile is depende...
Definition InterpolatedProfile.h:116
slbm::InterpolatedProfile::isActiveProfile
bool isActiveProfile()
Returns true if all of the neighboring GridProfile objects.
Definition InterpolatedProfile.h:293
slbm::InterpolatedProfile::InterpolatedProfile
InterpolatedProfile(const InterpolatedProfile &other)
Copy constructor.
slbm::InterpolatedProfile::getClassCount
static int getClassCount()
slbm::InterpolatedProfile::~InterpolatedProfile
virtual ~InterpolatedProfile()
Destructor.
slbm::InterpolatedProfile::operator=
InterpolatedProfile & operator=(const InterpolatedProfile &other)
Equal operator.
slbm::InterpolatedProfile::getCoefficients
vector< double > & getCoefficients()
Retrieve the interpolation coefficients that define the dependency of this InterpolatedProfile on its...
Definition InterpolatedProfile.h:132
slbm::InterpolatedProfile::nodeIds
vector< int > nodeIds
An array of pointers to the GridProfile objects upon which this InterpolatedProfile is dependent.
Definition InterpolatedProfile.h:224
slbm::InterpolatedProfile::InterpolatedProfile
InterpolatedProfile(Grid &grid, Location &location)
Parameterized constructor.
slbm::InterpolatedProfile::getNCoefficients
int getNCoefficients()
Definition InterpolatedProfile.h:109
slbm::InterpolatedProfile::interpVelocity
void interpVelocity(const int &type, const int &k, double &velocity)
Calculate a single velocity value based on the neighboring GridProfile objects and the interpolation ...
Definition InterpolatedProfile.h:279
slbm::InterpolatedProfile::getCoefficient
double getCoefficient(const int &i)
Definition InterpolatedProfile.h:134
slbm::InterpolatedProfile::memSize
virtual size_t memSize()
slbm::InterpolatedProfile::operator!=
bool operator!=(const InterpolatedProfile &other)
Inequality operator.
Definition InterpolatedProfile.h:107
slbm::InterpolatedProfile::getNodeId
int getNodeId(const int &i)
Definition InterpolatedProfile.h:122
slbm::InterpolatedProfile::operator==
bool operator==(const InterpolatedProfile &other)
Equality operator.
slbm::InterpolatedProfile::InterpolatedProfile
InterpolatedProfile()
Default constructor.
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
Definition CrustalProfile.h:59