@@ -155,28 +155,30 @@ void Grid::fill_field_lines(arma_vec baseLatsLoc,
155
155
report.enter (function, iFunction);
156
156
157
157
precision_t q_Start, delqp;
158
- arma_mat bAlts (nLats, nAlts), bLats (nLats, nAlts);
159
158
160
159
// allocate & calculate some things outside of the main loop
161
160
// - mostly just factors to make the code easier to read
162
161
precision_t qp0, fb0, ft, delq, qp2, fa, fb, term0, term1, term2, term3;
163
162
// exp_q_dist is the fraction of total q-distance to step for each pt along field line
164
163
arma_vec exp_q_dist (nAlts);
164
+
165
+ // corners/edges have one more lat dimension...
166
+ int64_t nLatLoc = baseLatsLoc.n_elem ;
165
167
166
168
// temp holding of results from q,p -> r,theta conversion:
167
169
std:: pair<precision_t , precision_t > r_theta;
168
170
169
171
// Find L-Shell for each baseLat
170
172
// using L=R/sin2(theta), where theta is from north pole
171
- arma_vec Lshells (nLats );
172
- for (int64_t iLat = 0 ; iLat < nLats ; iLat++)
173
+ arma_vec Lshells (nLatLoc );
174
+ for (int64_t iLat = 0 ; iLat < nLatLoc ; iLat++)
173
175
Lshells (iLat) = (min_altRe) / pow (sin (cPI / 2 - baseLatsLoc (iLat)), 2.0 );
174
176
175
177
report.print (3 , " lshells calculated!" );
176
178
177
179
if (!isCorner){
178
180
for (int64_t iLon = 0 ; iLon < nLons; iLon ++){
179
- for (int64_t iLat = 0 ; iLat < nLats ; iLat ++){
181
+ for (int64_t iLat = 0 ; iLat < nLatLoc ; iLat ++){
180
182
for (int64_t iAlt = 0 ; iAlt < nAlts; iAlt ++){
181
183
magP_scgc (iLon, iLat, iAlt) = Lshells (iLat);
182
184
}
@@ -185,7 +187,7 @@ void Grid::fill_field_lines(arma_vec baseLatsLoc,
185
187
}
186
188
else {
187
189
for (int64_t iLon = 0 ; iLon < nLons; iLon ++){
188
- for (int64_t iLat = 0 ; iLat < nLats ; iLat ++){
190
+ for (int64_t iLat = 0 ; iLat < nLatLoc ; iLat ++){
189
191
for (int64_t iAlt = 0 ; iAlt < nAlts; iAlt ++){
190
192
magP_Down (iLon, iLat, iAlt) = Lshells (iLat);
191
193
}}}
@@ -196,7 +198,10 @@ void Grid::fill_field_lines(arma_vec baseLatsLoc,
196
198
exp_q_dist (iAlt) = Gamma + (1 - Gamma) * exp (-pow (((iAlt - nAlts) / (nAlts / 5.0 )), 2.0 ));
197
199
report.print (3 , " expQ" );
198
200
199
- for (int iLat = 0 ; iLat < nLats; iLat++)
201
+ // mag alts and lats:
202
+ arma_mat bAlts (nLatLoc, nAlts), bLats (nLatLoc, nAlts);
203
+
204
+ for (int iLat = 0 ; iLat < nLatLoc; iLat++)
200
205
{
201
206
q_Start = -cos (cPI / 2 + baseLatsLoc (iLat)) / pow (min_altRe, 2.0 );
202
207
@@ -247,7 +252,7 @@ void Grid::fill_field_lines(arma_vec baseLatsLoc,
247
252
// This is wrong (same lat everywhere), but get_radius doesnt support oblate earth yet.
248
253
planetRadius = planet.get_radius (bLats (0 ));
249
254
250
- for (int64_t iLat = 0 ; iLat < nLats ; iLat++)
255
+ for (int64_t iLat = 0 ; iLat < nLatLoc ; iLat++)
251
256
{
252
257
for (int64_t iLon = 0 ; iLon < nLons; iLon++)
253
258
{
0 commit comments