45 #ifndef GRIDGEOTESS_H_
46 #define GRIDGEOTESS_H_
52 #include "GeoTessPosition.h"
56 using namespace geotess;
127 {
return model->getAverageMantleVelocity(waveType); };
136 {model->setAverageMantleVelocity(waveType, velocity); };
158 vector<GridProfile*>& neighbors, vector<int>& nodeIds,
159 vector<double>& coefficients);
180 void getNodeNeighbors(
const int& nodeId,
int neighbors[],
int& nNeighbors);
187 void getNodeNeighbors(
const int& nodeId, vector<int>& neighbors);
189 void getActiveNodeNeighbors(
const int& nodeid,
int neighbors[],
int& nNeighbors);
191 void getActiveNodeNeighbors(
const int& nodeid, vector<int>& neighbors);
201 double distance[],
double azimuth[],
int& nNeighbors)
204 model->getGrid().getVertexNeighbors(0, model->getGrid().getLastLevel(0),
207 nNeighbors = (int)nbrs.size();
209 for (set<int>::iterator it=nbrs.begin(); it != nbrs.end(); it++)
211 nid = profiles[*it]->getNodeId();
215 distance[i] = GeoTessUtils::angle(model->getGrid().getVertex(nodeid),
216 model->getGrid().getVertex(nid));
218 azimuth[i] = GeoTessUtils::azimuth(model->getGrid().getVertex(nodeid),
219 model->getGrid().getVertex(nid), NA_VALUE);
226 vector<double>& distance, vector<double>& azimuth)
229 model->getGrid().getVertexNeighbors(0, model->getGrid().getLastLevel(0),
232 int nNeighbors = (int)nbrs.size();
236 neighbors.reserve(nNeighbors);
237 distance.reserve(nNeighbors);
238 azimuth.reserve(nNeighbors);
240 for (set<int>::iterator it=nbrs.begin(); it != nbrs.end(); it++)
242 nid = profiles[*it]->getNodeId();
244 neighbors.push_back(nid);
246 distance.push_back(GeoTessUtils::angle(model->getGrid().getVertex(nodeid),
247 model->getGrid().getVertex(nid)));
249 azimuth.push_back(GeoTessUtils::azimuth(model->getGrid().getVertex(nodeid),
250 model->getGrid().getVertex(nid), NA_VALUE));
259 void getNodeSeparation(
const int& node1,
const int& node2,
double& distance);
264 void getNodeAzimuth(
const int& node1,
const int& node2,
double& azimuth);
268 string getTessId() {
return model->getGrid().getGridID(); }
277 void setInterpolatorType(
const string& interpolatorType);
285 GeoTessPosition* position;
289 inline void GridGeoTess::setInterpolatorType(
const string& interpolatorType)
291 string type = CPPUtils::uppercase_string(interpolatorType);
292 if (position->getInterpolatorType().toString() != type)
294 if (type ==
"LINEAR")
297 position = model->getPosition(GeoTessInterpolatorType::LINEAR);
299 else if (type ==
"NATURAL_NEIGHBOR")
302 position = model->getPosition(GeoTessInterpolatorType::NATURAL_NEIGHBOR);
307 os << endl <<
"ERROR in GridGeoTess::setInterpolatorType()" << endl
308 << interpolatorType <<
" is not a recognized interpolator type." << endl
309 <<
"Must be one of [ LINEAR | NATURAL_NEIGHBOR ]."
310 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
316 inline void GridGeoTess::getNodeNeighbors(
const int& nodeId,
int neighbors[],
int& nNeighbors)
319 model->getGrid().getVertexNeighbors(0, model->getGrid().getLastLevel(0),
321 nNeighbors = (int)nbrs.size();
322 set<int>::iterator it;
324 for (it=nbrs.begin(); it != nbrs.end(); ++it)
325 neighbors[i++] = *it;
328 inline void GridGeoTess::getNodeNeighbors(
const int& nodeId, vector<int>& neighbors)
331 const int level = model->getGrid().getLastLevel(0);
332 model->getGrid().getVertexNeighbors(0, level, nodeId, nbrs);
333 neighbors.resize(nbrs.size());
334 set<int>::iterator it;
336 for (it=nbrs.begin(); it != nbrs.end(); ++it)
337 neighbors[i++] = *it;
340 inline void GridGeoTess::getActiveNodeNeighbors(
const int& activeNodeId,
int neighbors[],
int& nNeighbors)
342 int nodeId = getGridNodeId(activeNodeId);
348 model->getGrid().getVertexNeighbors(0, model->getGrid().getLastLevel(0),
352 for (set<int>::iterator it=nbrs.begin(); it != nbrs.end(); it++)
354 id = getActiveNodeId(profiles[*it]->getNodeId());
356 neighbors[nNeighbors++] = id;
361 inline void GridGeoTess::getActiveNodeNeighbors(
const int& activeNodeId, vector<int>& neighbors)
365 int nodeId = getGridNodeId(activeNodeId);
369 model->getGrid().getVertexNeighbors(0, model->getGrid().getLastLevel(0),
372 for (set<int>::iterator it=nbrs.begin(); it != nbrs.end(); it++)
374 id = getActiveNodeId(profiles[*it]->getNodeId());
376 neighbors.push_back(
id);
381 inline void GridGeoTess::getNodeSeparation(
const int& node1,
const int& node2,
double& distance)
383 distance = GeoTessUtils::angle(model->getGrid().getVertex(node1),
384 model->getGrid().getVertex(node2));
387 inline void GridGeoTess::getNodeAzimuth(
const int& node1,
const int& node2,
double& azimuth)
389 azimuth = GeoTessUtils::azimuth(model->getGrid().getVertex(node1),
390 model->getGrid().getVertex(node2), NaN_DOUBLE);
Manages all information related to a single node in a Grid object.
GeoTessModelSLBM * loadModel(const string &filename, const string &relGridPath="")
void loadFromFile(const string &filename)
Load the depth, velocity and gradient information from an ascii flat file.
GeoTessModelSLBM * getModel()
int addGeoStack(GeoStack *geoStack)
void clear()
Clears and releases all memory held by this GridSLBM object.
void getNodeNeighborInfo(const int &nodeid, vector< int > &neighbors, vector< double > &distance, vector< double > &azimuth)
Retrieve the grid node id of the nodes that are direct neighbors of the specified grid node.
void setAverageMantleVelocity(const int &waveType, const double &velocity)
Retreive the average P or S wave velocity of the mantle, in km/sec.
int getBufferSize() const
Returns the size of a DataBuffer object required to store this Grid objects model data.
void saveVelocityModel(util::DataBuffer &buffer)
Save the Earth model currently in memory, to a DataBuffer.
virtual bool findProfile(Location &location, vector< GridProfile * > &neighbors, vector< int > &nodeIds, vector< double > &coefficients)
Find the neighboring GridProfile objects and associated interpolation coefficients at a specified Loc...
string getInterpolatorType()
static string class_name()
double getAverageMantleVelocity(const int &waveType)
Retreive the average P or S wave velocity of the mantle, in km/sec.
void loadFromDataBuffer(util::DataBuffer &buffer)
Load the depth, velocity and gradient information from DataBuffer.
void getNodeNeighborInfo(const int &nodeid, int neighbors[], double distance[], double azimuth[], int &nNeighbors)
Retrieve the grid node id of the nodes that are direct neighbors of the specified grid node.
void loadFromDirectory(const string &dirName)
Load the depth, velocity and gradient information from binary files in specified directory.
virtual ~GridGeoTess()
Destructor.
void saveVelocityModel(const string &filename, const int &format)
Save the Earth model currently in memory, to an ascii flat file.
A 2 dimensional, horizontal grid of GirdProfile objects.
The Location Class manages a single point in/on the Earth, which is described by the GRS80 ellipsoid.
An Exception class for Grid and related objects.
A byte array container used to hold binary data in the same manner as disk based file system.