Skip to content

Commit 3866b60

Browse files
committed
FEAT: Add isClosed to all grids & doesTouch(S/N) pole to dipole
1 parent 5515253 commit 3866b60

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

include/grid.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ class Grid
111111
// in the k-up and k-down direction (altitude for geo grids, q for dipole).
112112
arma_mat first_lower_gc, first_upper_gc;
113113

114+
// Whether to close field lines on dipole grid (Always false for geo grids)
115+
bool IsClosed;
116+
114117
// These are the locations of the magnetic poles:
115118
// ll -> lat, lon, radius independent
116119
arma_vec mag_pole_north_ll;

src/grid.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ Grid::Grid(std::string gridtype) {
271271
HasBField = 0;
272272
IsExperimental = false;
273273

274+
// Spatial info defaults
275+
IsClosed = false;
276+
DoesTouchNorthPole = false;
277+
DoesTouchSouthPole = false;
278+
274279
UseThisCell.set_size(nX, nY, nZ);
275280
UseThisCell.fill(true);
276281
first_lower_gc.set_size(nX, nY);

src/init_mag_grid.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ bool Grid::init_dipole_grid(Quadtree quadtree_ion, Planets planet) {
236236
lat1dDown(nLats - 1) = (lat1dDown(nLats) + lat1dDown(nLats - 2)) / 2.0;
237237
lat1d(nLats - 1) = (lat1dDown(nLats) + lat1dDown(nLats - 1)) / 2.0;
238238
lat1d(nLats - 2) = (lat1dDown(nLats - 1) + lat1dDown(nLats - 2)) / 2.0;
239+
240+
if (sign(lower_left_norm(1)) > 0)
241+
DoesTouchNorthPole = true;
242+
else
243+
DoesTouchSouthPole = true;
239244
}
240245

241246
// l-shells of centers
@@ -267,15 +272,14 @@ bool Grid::init_dipole_grid(Quadtree quadtree_ion, Planets planet) {
267272
// - minimum Lshell in this block is < max_alt (the q-value would be undefined)
268273

269274
precision_t q_min;
270-
bool close_this_block = false;
271275

272276
if (Pcorners.min() < max_alt_re) // invalid q's - Lshell < max_alt
273-
close_this_block = true;
277+
IsClosed = true;
274278

275279
if (lat_origin < 0.01) // equator, with some imprecision
276-
close_this_block = true;
280+
IsClosed = true;
277281

278-
if (close_this_block)
282+
if (IsClosed)
279283
q_min = 0; // q=0 at equator (for closed blocks)
280284
else
281285
// invLats are still all in North Hemisphere & increasing.

0 commit comments

Comments
 (0)