Skip to content

Commit 406642d

Browse files
committed
FEAT: needed for grid to grid MP
1 parent fc6f18b commit 406642d

File tree

1 file changed

+59
-21
lines changed

1 file changed

+59
-21
lines changed

include/grid.h

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,33 @@
1111
// Grid class
1212
// ----------------------------------------------------------------------------
1313

14+
struct interp_coef_t
15+
{
16+
// The point is inside the cube of [iRow, iRow+1], [iCol, iCol+1], [iAlt, iAlt+1]
17+
uint64_t iRow;
18+
uint64_t iCol;
19+
uint64_t iAlt;
20+
// The coefficients along row, column and altitude
21+
precision_t rRow;
22+
precision_t rCol;
23+
precision_t rAlt;
24+
// Whether the point is within this grid or not
25+
bool in_grid;
26+
// If this is set to true:
27+
bool above_grid, below_grid;
28+
// do interpolation in lat and lon, but extrapolate in altitude
29+
};
30+
31+
struct grid_to_grid_t {
32+
int64_t iProcTo;
33+
int64_t nPts;
34+
int64_t nPtsReceive;
35+
std::vector<struct interp_coef_t> interpCoefs;
36+
std::vector<precision_t *> valueToSend;
37+
std::vector<precision_t *> valueToReceive;
38+
};
39+
40+
1441
class Grid
1542
{
1643

@@ -20,13 +47,24 @@ class Grid
2047
const int iDipole_ = 3;
2148
int iGridShape_ = -1;
2249

23-
// Armidillo Cube Versions:
50+
// The index and coefficient used for interpolation
51+
// Each point is processed by the function set_interpolation_coefs and stored
52+
// in the form of this structure.
53+
// If the point is out of the grid, in_grid = false and all other members are undefined
54+
55+
std::vector<struct grid_to_grid_t> gridToGridCoefs;
56+
arma::Cube<int> gridToGridMap;
57+
58+
// Armadillo Cube Versions:
2459
// Cell Center Coordinates
2560
arma_cube geoLon_scgc, geoX_scgc;
2661
arma_cube geoLat_scgc, geoY_scgc;
2762
arma_cube geoAlt_scgc, geoZ_scgc;
2863
arma_cube geoLocalTime_scgc;
2964

65+
// This is an array for testing things:
66+
arma_cube test_scgc;
67+
3068
// Reference coordinate
3169
arma_cube refx_scgc, refy_scgc;
3270

@@ -434,6 +472,22 @@ class Grid
434472
bool set_interpolation_coefs(const std::vector<precision_t> &Lons,
435473
const std::vector<precision_t> &Lats,
436474
const std::vector<precision_t> &Alts);
475+
476+
/**
477+
* \brief Set the interpolation coefficients
478+
* \param Lons The longitude of points
479+
* \param Lats The latitude of points
480+
* \param Alts The altitude of points
481+
* \pre This instance is an geo grid
482+
* \pre Lons, Lats and Alts have the same size
483+
* \return list of interpolation coefficients
484+
*/
485+
486+
std::vector<struct interp_coef_t> get_interpolation_coefs(
487+
const std::vector<precision_t> &Lons,
488+
const std::vector<precision_t> &Lats,
489+
const std::vector<precision_t> &Alts);
490+
437491
/**
438492
* \brief Create a map of geographic locations to data and do the interpolation
439493
* \param data The value at the positions of geoLon, geoLat, and geoAlt
@@ -443,6 +497,8 @@ class Grid
443497
* an empty vector if the data is not the same size as the geo grid.
444498
*/
445499
std::vector<precision_t> get_interpolation_values(const arma_cube &data) const;
500+
std::vector<precision_t> get_interpolation_values(arma_cube data,
501+
std::vector<struct interp_coef_t> coefArray);
446502

447503
private:
448504
bool IsGeoGrid;
@@ -513,24 +569,6 @@ class Grid
513569
bool col_max_exclusive;
514570
};
515571

516-
// The index and coefficient used for interpolation
517-
// Each point is processed by the function set_interpolation_coefs and stored
518-
// in the form of this structure.
519-
// If the point is out of the grid, in_grid = false and all other members are undefined
520-
struct interp_coef_t
521-
{
522-
// The point is inside the cube of [iRow, iRow+1], [iCol, iCol+1], [iAlt, iAlt+1]
523-
uint64_t iRow;
524-
uint64_t iCol;
525-
uint64_t iAlt;
526-
// The coefficients along row, column and altitude
527-
precision_t rRow;
528-
precision_t rCol;
529-
precision_t rAlt;
530-
// Whether the point is within this grid or not
531-
bool in_grid;
532-
};
533-
534572
// Return the index of the last element that has altitude smaller than or euqal to the input
535573
uint64_t search_altitude(const precision_t alt_in) const;
536574

@@ -540,11 +578,11 @@ class Grid
540578
void get_cubesphere_grid_range(struct cubesphere_range &cr) const;
541579

542580
// Helper function for set_interpolation_coefs
543-
void set_interp_coef_sphere(const sphere_range &sr,
581+
struct interp_coef_t get_interp_coef_sphere(const sphere_range &sr,
544582
const precision_t lon_in,
545583
const precision_t lat_in,
546584
const precision_t alt_in);
547-
void set_interp_coef_cubesphere(const cubesphere_range &cr,
585+
struct interp_coef_t get_interp_coef_cubesphere(const cubesphere_range &cr,
548586
const precision_t lon_in,
549587
const precision_t lat_in,
550588
const precision_t alt_in);

0 commit comments

Comments
 (0)