Skip to content

Commit c884617

Browse files
committed
STY: Continue enforcing local vs global vars having different names in mag_grid
also move a couple functions around Just cleanin' up the code a bit
1 parent c1bcad2 commit c884617

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

include/grid.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ class Grid
9393
arma_cube magAlt_Below;
9494
arma_cube magAlt_Corner;
9595

96+
//For easier interpolation:
97+
arma_vec baseLats_down;
98+
9699
// these need to be stored in (p,q) coords for a bit, its messy:
97100
arma_cube magP_Down;
98101
arma_cube magP_Below;
@@ -245,6 +248,19 @@ class Grid
245248
precision_t Gamma, Planets planet,
246249
bool isCorner);
247250
void dipole_alt_edges(Planets planet);
251+
// get the latitude spacing given the quadtree start & size, and the latitude limits
252+
// extent: quadtree up
253+
// origin: quadtree origin
254+
// upper_lim: upper latitude limit (input)
255+
// lower_lim: lower latitude limit (from min_apex)
256+
// nLats: number of latitudes (nY)
257+
// spacing_factor: (not supported yet), so always 1.0. Will adjust baselat spacing, eventually.
258+
arma_vec baselat_spacing(precision_t extent,
259+
precision_t origin,
260+
precision_t upper_lim,
261+
precision_t lower_lim,
262+
// int16_t nLats,
263+
precision_t spacing_factor);
248264

249265

250266
void saveCubeToCSV(arma_cube cube, std::string filename);

include/init_mag_grid.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,6 @@ bool init_dipole_grid(Grid &mGrid, Planets planet);
1717
// return (r,theta)
1818
std::pair<precision_t, precision_t> qp_to_r_theta(precision_t q, precision_t p);
1919

20-
// get the latitude spacing given the quadtree start&size, and the latitude limits
21-
// extent quadtree up
22-
// origin quadtree origin
23-
// upper_lim upper latitude limit (input)
24-
// lower_lim lower latitude limit (from min_apex)
25-
// nLats number of latitudes (nY)
26-
// spacing_factor (not supported yet), so always 1.0.
27-
arma_vec baselat_spacing(precision_t extent,
28-
precision_t origin,
29-
precision_t upper_lim,
30-
precision_t lower_lim,
31-
int16_t nLats,
32-
precision_t spacing_factor);
33-
3420
// Take limits & specs of field line, fill it with points.
3521
// std:: tuple <arma_mat, arma_mat, arma_vec> Grid::fill_field_lines (arma_vec lShells,
3622
// int64_t nAlts,

src/init_mag_grid.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ std::pair<arma_cube, arma_cube> qp_to_r_theta(arma_cube q, arma_cube p)
5454
return {r, theta};
5555
}
5656

57-
arma_vec baselat_spacing(precision_t extent,
57+
arma_vec Grid::baselat_spacing(precision_t extent,
5858
precision_t origin,
5959
precision_t upper_lim,
6060
precision_t lower_lim,
61-
int16_t nLats,
62-
precision_t spacing_factor)
63-
{
61+
precision_t spacing_factor){
6462
std::string function = "Grid::baselat_spacing";
6563
static int iFunction = -1;
6664
report.enter(function, iFunction);
@@ -147,18 +145,15 @@ arma_vec baselat_spacing(precision_t extent,
147145
// Field line filling only needs to be redone for the "down" edges, left is the same p,q
148146
// and then for "lower", we just shift the p,q after
149147

150-
void Grid::fill_field_lines(arma_vec baseLats,
148+
void Grid::fill_field_lines(arma_vec baseLatsLoc,
151149
precision_t min_altRe, precision_t Gamma,
152150
Planets planet,
153-
bool isCorner=false)
154-
{
151+
bool isCorner=false){
155152

156153
std::string function = "Grid::fill_field_lines";
157154
static int iFunction = -1;
158155
report.enter(function, iFunction);
159156

160-
// int64_t nLats = baseLats.n_elem;
161-
162157
precision_t q_Start, delqp;
163158
arma_mat bAlts(nLats, nAlts), bLats(nLats, nAlts);
164159

@@ -175,7 +170,7 @@ void Grid::fill_field_lines(arma_vec baseLats,
175170
// using L=R/sin2(theta), where theta is from north pole
176171
arma_vec Lshells(nLats);
177172
for (int64_t iLat = 0; iLat < nLats; iLat++)
178-
Lshells(iLat) = (min_altRe) / pow(sin(cPI / 2 - baseLats(iLat)), 2.0);
173+
Lshells(iLat) = (min_altRe) / pow(sin(cPI / 2 - baseLatsLoc(iLat)), 2.0);
179174

180175
report.print(3, "lshells calculated!");
181176

@@ -203,7 +198,7 @@ void Grid::fill_field_lines(arma_vec baseLats,
203198

204199
for (int iLat = 0; iLat < nLats; iLat++)
205200
{
206-
q_Start = -cos(cPI / 2 + baseLats(iLat)) / pow(min_altRe, 2.0);
201+
q_Start = -cos(cPI / 2 + baseLatsLoc(iLat)) / pow(min_altRe, 2.0);
207202

208203
// calculate const stride in dipole coords, same as sami2/3 (huba & joyce 2000)
209204
// Note this is not the:
@@ -583,7 +578,7 @@ bool Grid::init_dipole_grid(Quadtree quadtree_ion, Planets planet)
583578
// latitude of field line base:
584579
// todo: needs support for variable stretching. it's like, halfway there.
585580
arma_vec baseLats = baselat_spacing(size_up_norm[1], lower_left_norm[1],
586-
max_lat, min_lat, nLats, 1.0);
581+
max_lat, min_lat, 1.0);
587582

588583
// downward sides (latitude shifted by 1/2 step):
589584
// TODO: This only works for linear latitude spacing, which is all that's supported right now.

0 commit comments

Comments
 (0)