Skip to content

Commit 0003b19

Browse files
committed
STY: astyle
1 parent f0ba8ce commit 0003b19

10 files changed

+135
-105
lines changed

src/advance.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ bool advance(Planets &planet,
5959
// first
6060

6161
neutrals.calc_scale_height(gGrid);
62+
6263
if (didWork)
6364
didWork = neutrals.set_bcs(gGrid, time, indices);
6465

src/calc_neutral_derived.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ precision_t Neutrals::calc_dt_cubesphere(Grid grid) {
393393
int64_t nAlts = grid.get_nAlts();
394394
int64_t nXs = grid.get_nLons();
395395
int64_t nYs = grid.get_nLats();
396-
396+
397397
// dtx dty for reference coordinate system
398398
arma_cube dtx(size(cMax_vcgc[0]));
399399
arma_cube dty(size(cMax_vcgc[0]));
@@ -405,17 +405,17 @@ precision_t Neutrals::calc_dt_cubesphere(Grid grid) {
405405
for (int iAlt = 0; iAlt < nAlts; iAlt++) {
406406
// Conver cMax to contravariant velocity first
407407
arma_mat u1 = sqrt(
408-
cMax_vcgc[0].slice(iAlt) % grid.A11_inv_scgc.slice(iAlt) %
409-
cMax_vcgc[0].slice(iAlt) % grid.A11_inv_scgc.slice(iAlt) +
410-
cMax_vcgc[1].slice(iAlt) % grid.A12_inv_scgc.slice(iAlt) %
411-
cMax_vcgc[1].slice(iAlt) % grid.A12_inv_scgc.slice(iAlt));
408+
cMax_vcgc[0].slice(iAlt) % grid.A11_inv_scgc.slice(iAlt) %
409+
cMax_vcgc[0].slice(iAlt) % grid.A11_inv_scgc.slice(iAlt) +
410+
cMax_vcgc[1].slice(iAlt) % grid.A12_inv_scgc.slice(iAlt) %
411+
cMax_vcgc[1].slice(iAlt) % grid.A12_inv_scgc.slice(iAlt));
412412
arma_mat u2 = sqrt(
413-
cMax_vcgc[0].slice(iAlt) % grid.A21_inv_scgc.slice(iAlt) %
414-
cMax_vcgc[0].slice(iAlt) % grid.A21_inv_scgc.slice(iAlt) +
415-
cMax_vcgc[1].slice(iAlt) % grid.A22_inv_scgc.slice(iAlt) %
416-
cMax_vcgc[1].slice(iAlt) % grid.A22_inv_scgc.slice(iAlt));
417-
dtx.slice(iAlt) = grid.drefx(iAlt) * dummy_1 / u1;
418-
dty.slice(iAlt) = grid.drefy(iAlt) * dummy_1 / u2;
413+
cMax_vcgc[0].slice(iAlt) % grid.A21_inv_scgc.slice(iAlt) %
414+
cMax_vcgc[0].slice(iAlt) % grid.A21_inv_scgc.slice(iAlt) +
415+
cMax_vcgc[1].slice(iAlt) % grid.A22_inv_scgc.slice(iAlt) %
416+
cMax_vcgc[1].slice(iAlt) % grid.A22_inv_scgc.slice(iAlt));
417+
dtx.slice(iAlt) = grid.drefx(iAlt) * dummy_1 / u1;
418+
dty.slice(iAlt) = grid.drefy(iAlt) * dummy_1 / u2;
419419
}
420420

421421
// simply some things, and just take the bulk value for now:

src/electrodynamics.cpp

Lines changed: 79 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
// -----------------------------------------------------------------------------
8-
// Call (fortran) ionospheric electrodynamics if we enable this
8+
// Call (fortran) ionospheric electrodynamics if we enable this
99
// in the cmake file
1010
// -----------------------------------------------------------------------------
1111

@@ -27,36 +27,40 @@ Electrodynamics::Electrodynamics(Times time) {
2727
HaveFortranIe = false;
2828
isSet = false;
2929

30-
#ifdef FORTRAN
31-
// Initialize IE components (reading in the data files):
32-
std::string ieDir = input.get_electrodynamics_dir();
33-
int* ieDir_iArray = copy_string_to_int(ieDir);
34-
std::string efield = input.get_potential_model();
35-
std::string aurora = input.get_diffuse_auroral_model();
30+
#ifdef FORTRAN
31+
// Initialize IE components (reading in the data files):
32+
std::string ieDir = input.get_electrodynamics_dir();
33+
int* ieDir_iArray = copy_string_to_int(ieDir);
34+
std::string efield = input.get_potential_model();
35+
std::string aurora = input.get_diffuse_auroral_model();
3636

37-
if (efield.length() == 0 & aurora.length() == 0) {
38-
HaveFortranIe = false;
37+
if (efield.length() == 0 & aurora.length() == 0)
38+
HaveFortranIe = false;
39+
40+
else {
41+
int* efield_iArray = copy_string_to_int(efield);
42+
int* aurora_iArray = copy_string_to_int(aurora);
43+
ie_init_library(ieDir_iArray, efield_iArray, aurora_iArray, &iError);
44+
45+
if (iError > 0) {
46+
report.print(0, "Error in setting fortran IE!");
47+
IsOk = false;
3948
} else {
40-
int* efield_iArray = copy_string_to_int(efield);
41-
int* aurora_iArray = copy_string_to_int(aurora);
42-
ie_init_library(ieDir_iArray, efield_iArray, aurora_iArray, &iError);
43-
if (iError > 0) {
44-
report.print(0,"Error in setting fortran IE!");
45-
IsOk = false;
46-
} else {
47-
HaveFortranIe = true;
48-
isSet = true;
49-
}
49+
HaveFortranIe = true;
50+
isSet = true;
5051
}
51-
isCompiled = true;
52-
#else
53-
isCompiled = false;
54-
#endif
52+
}
53+
54+
isCompiled = true;
55+
#else
56+
isCompiled = false;
57+
#endif
5558

5659
// If we don't set IE through Fortran, then try to set it through a file:
5760

5861
if (!HaveFortranIe) {
5962
std::string electrodynamics_file = input.get_electrodynamics_file();
63+
6064
if (electrodynamics_file.length() > 0 &
6165
electrodynamics_file != "none") {
6266
// This function sets HaveElectrodynamicsFile = true.
@@ -83,7 +87,7 @@ Electrodynamics::Electrodynamics(Times time) {
8387
// -----------------------------------------------------------------------------
8488

8589
void Electrodynamics::set_all_indices_for_ie(Times time,
86-
Indices &indices) {
90+
Indices &indices) {
8791
std::string function = "Electrodynamics::set_all_indices_for_ie";
8892
static int iFunction = -1;
8993
report.enter(function, iFunction);
@@ -111,17 +115,18 @@ void Electrodynamics::set_all_indices_for_ie(Times time,
111115
std::cout << "sw v : " << iVx_ << " " << swv << "\n";
112116
std::cout << "sw n : " << iN_ << " " << swn << "\n";
113117
}
114-
#ifdef FORTRAN
115-
ie_set_time(&time_now);
116-
ie_set_imfby(&imfby);
117-
ie_set_imfbz(&imfbz);
118-
ie_set_swv(&swv);
119-
ie_set_swn(&swn);
120-
ie_set_ae(&ae);
121-
ie_set_au(&au);
122-
ie_set_al(&al);
123-
ie_set_hp_from_ae(&ae);
124-
#endif
118+
119+
#ifdef FORTRAN
120+
ie_set_time(&time_now);
121+
ie_set_imfby(&imfby);
122+
ie_set_imfbz(&imfbz);
123+
ie_set_swv(&swv);
124+
ie_set_swn(&swn);
125+
ie_set_ae(&ae);
126+
ie_set_au(&au);
127+
ie_set_al(&al);
128+
ie_set_hp_from_ae(&ae);
129+
#endif
125130

126131
report.exit(function);
127132
return;
@@ -154,60 +159,62 @@ bool Electrodynamics::update(Planets planet,
154159
ions.eflux.zeros();
155160
ions.avee.ones();
156161

157-
#ifdef FORTRAN
158-
if (HaveFortranIe) {
159-
report.print(3, "Using Fortran Electrodynamics!");
160-
set_all_indices_for_ie(time, indices);
161-
162-
if (!IsAllocated) {
163-
int nXs = gGrid.get_nX();
164-
ie_set_nxs(&nXs);
165-
int nYs = gGrid.get_nY();
166-
ie_set_nys(&nYs);
167-
int64_t iTotal = nXs * nYs;
168-
mlt2d = static_cast<float*>(malloc(iTotal * sizeof(float)));
169-
lat2d = static_cast<float*>(malloc(iTotal * sizeof(float)));
170-
pot2d = static_cast<float*>(malloc(iTotal * sizeof(float)));
171-
eflux2d = static_cast<float*>(malloc(iTotal * sizeof(float)));
172-
avee2d = static_cast<float*>(malloc(iTotal * sizeof(float)));
173-
IsAllocated = true;
174-
}
162+
#ifdef FORTRAN
163+
164+
if (HaveFortranIe) {
165+
report.print(3, "Using Fortran Electrodynamics!");
166+
set_all_indices_for_ie(time, indices);
167+
168+
if (!IsAllocated) {
169+
int nXs = gGrid.get_nX();
170+
ie_set_nxs(&nXs);
171+
int nYs = gGrid.get_nY();
172+
ie_set_nys(&nYs);
173+
int64_t iTotal = nXs * nYs;
174+
mlt2d = static_cast<float*>(malloc(iTotal * sizeof(float)));
175+
lat2d = static_cast<float*>(malloc(iTotal * sizeof(float)));
176+
pot2d = static_cast<float*>(malloc(iTotal * sizeof(float)));
177+
eflux2d = static_cast<float*>(malloc(iTotal * sizeof(float)));
178+
avee2d = static_cast<float*>(malloc(iTotal * sizeof(float)));
179+
IsAllocated = true;
180+
}
175181

176-
int64_t nZs = gGrid.get_nZ();
177-
int64_t iZ;
182+
int64_t nZs = gGrid.get_nZ();
183+
int64_t iZ;
178184

179-
int iError;
185+
int iError;
180186

181-
for (iZ = 0; iZ < nZs; iZ++) {
182-
copy_mat_to_array(gGrid.magLocalTime_scgc.slice(iZ), mlt2d, true);
183-
copy_mat_to_array(gGrid.magLat_scgc.slice(iZ), lat2d, true);
187+
for (iZ = 0; iZ < nZs; iZ++) {
188+
copy_mat_to_array(gGrid.magLocalTime_scgc.slice(iZ), mlt2d, true);
189+
copy_mat_to_array(gGrid.magLat_scgc.slice(iZ), lat2d, true);
184190

185-
ie_set_mlts(mlt2d, &iError);
186-
ie_set_lats(lat2d, &iError);
187-
ie_update_grid(&iError);
191+
ie_set_mlts(mlt2d, &iError);
192+
ie_set_lats(lat2d, &iError);
193+
ie_update_grid(&iError);
188194

189-
ie_get_potential(pot2d, &iError);
190-
copy_array_to_mat(pot2d, ions.potential_scgc.slice(iZ), true);
195+
ie_get_potential(pot2d, &iError);
196+
copy_array_to_mat(pot2d, ions.potential_scgc.slice(iZ), true);
191197

192-
if (iZ == nZs-1) {
193-
ie_get_electron_diffuse_aurora(eflux2d, avee2d, &iError);
194-
copy_array_to_mat(avee2d, ions.avee, true);
195-
copy_array_to_mat(eflux2d, ions.eflux, true);
196-
}
198+
if (iZ == nZs - 1) {
199+
ie_get_electron_diffuse_aurora(eflux2d, avee2d, &iError);
200+
copy_array_to_mat(avee2d, ions.avee, true);
201+
copy_array_to_mat(eflux2d, ions.eflux, true);
197202
}
198203
}
199-
#endif
204+
}
205+
206+
#endif
200207

201208
if (HaveElectrodynamicsFile) {
202209
report.print(3, "Setting electrodynamics from file!");
203210
auto electrodynamics_values =
204211
get_electrodynamics(gGrid.magLat_scgc,
205-
gGrid.magLocalTime_scgc);
212+
gGrid.magLocalTime_scgc);
206213
ions.potential_scgc = std::get<0>(electrodynamics_values);
207214
ions.eflux = std::get<1>(electrodynamics_values);
208215
ions.avee = std::get<2>(electrodynamics_values);
209216
}
210-
}
217+
}
211218

212219
report.exit(function);
213220
return true;

src/exchange_messages_v2.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,12 @@ void Grid::exchange(arma_cube &data, const bool pole_inverse) {
602602
bool Neutrals::exchange(Grid &grid) {
603603
// For each species, exchange if its DoAdvect is true
604604
int64_t nGCs = grid.get_nGCs();
605+
605606
for (int i = 0; i < nSpecies; ++i) {
606607
if (species[i].DoAdvect)
607608
grid.exchange(species[i].density_scgc, false);
608-
fill_corners(species[i].density_scgc, nGCs);
609+
610+
fill_corners(species[i].density_scgc, nGCs);
609611
}
610612

611613
// Exchange temperature
@@ -617,7 +619,9 @@ bool Neutrals::exchange(Grid &grid) {
617619
grid.exchange(velocity_vcgc[0], true);
618620
grid.exchange(velocity_vcgc[1], true);
619621
grid.exchange(velocity_vcgc[2], false);
622+
620623
for (int iDir = 0; iDir < 3; iDir++)
621624
fill_corners(velocity_vcgc[iDir], nGCs);
625+
622626
return true;
623627
}

src/init_geo_grid.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,10 +984,12 @@ bool Grid::init_geo_grid(Quadtree quadtree,
984984

985985
// Calculate the radius (for spherical or non-spherical)
986986
fill_grid_radius(planet);
987+
987988
// Correct the reference grid with correct length scale:
988989
// (with R = actual radius)
989990
if (input.get_is_cubesphere())
990991
correct_xy_grid(planet);
992+
991993
// Calculate grid spacing
992994
calc_grid_spacing(planet);
993995
//calculate radial unit vector (for spherical or oblate planet)

src/inputs.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ bool Inputs::get_euv_douse() {
461461
}
462462

463463
// -----------------------------------------------------------------------
464-
// Return the Electrodynamics Dir - this is where all of the
464+
// Return the Electrodynamics Dir - this is where all of the
465465
// files that are for the empirical models reside
466466
// -----------------------------------------------------------------------
467467

@@ -470,7 +470,7 @@ std::string Inputs::get_electrodynamics_north_file() {
470470
}
471471

472472
// -----------------------------------------------------------------------
473-
// Return the Electrodynamics Dir - this is where all of the
473+
// Return the Electrodynamics Dir - this is where all of the
474474
// files that are for the empirical models reside
475475
// -----------------------------------------------------------------------
476476

@@ -479,7 +479,7 @@ std::string Inputs::get_electrodynamics_south_file() {
479479
}
480480

481481
// -----------------------------------------------------------------------
482-
// Return the Electrodynamics Dir - this is where all of the
482+
// Return the Electrodynamics Dir - this is where all of the
483483
// files that are for the empirical models reside
484484
// -----------------------------------------------------------------------
485485

@@ -488,7 +488,7 @@ std::string Inputs::get_electrodynamics_file() {
488488
}
489489

490490
// -----------------------------------------------------------------------
491-
// Return the Electrodynamics Dir - this is where all of the
491+
// Return the Electrodynamics Dir - this is where all of the
492492
// files that are for the empirical models reside
493493
// -----------------------------------------------------------------------
494494

src/neutrals.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,22 +290,25 @@ bool Neutrals::check_for_nonfinites() {
290290
bool didWork = true;
291291

292292
isBad = !all_finite(density_scgc, "density_scgc");
293+
293294
if (isBad) {
294295
report.error("non-finite found in neutral density!");
295296
didWork = false;
296297
}
297298

298299
isBad = !all_finite(temperature_scgc, "temperature_scgc");
300+
299301
if (isBad) {
300302
report.error("non-finite found in neutral temperature!");
301303
didWork = false;
302-
}
304+
}
303305

304306
isBad = !all_finite(velocity_vcgc, "velocity_vcgc");
307+
305308
if (isBad) {
306309
report.error("non-finite found in neutral velocity!");
307310
didWork = false;
308-
}
311+
}
309312

310313
return didWork;
311314
}

src/solver_gradients.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ std::vector<arma_cube> calc_gradient_vector(arma_cube value_scgc, Grid grid) {
1111

1212
std::vector<arma_cube> gradient_vcgc;
1313

14-
if (input.get_is_cubesphere()) {
14+
if (input.get_is_cubesphere())
1515
gradient_vcgc = calc_gradient_cubesphere(value_scgc, grid);
16-
} else {
16+
17+
else {
1718
gradient_vcgc.push_back(calc_gradient_lon(value_scgc, grid));
1819
gradient_vcgc.push_back(calc_gradient_lat(value_scgc, grid));
1920
gradient_vcgc.push_back(calc_gradient_alt(value_scgc, grid));
2021
}
22+
2123
return gradient_vcgc;
2224
}
2325

@@ -215,6 +217,7 @@ std::vector<arma_cube> calc_gradient_cubesphere(arma_cube value, Grid grid) {
215217
}
216218
}
217219
}
220+
218221
// We then use A transformation matrices to convert grad_xy to grad_latlon
219222
// Ref -> Physical, we use A matrix
220223
grad_lon.slice(iAlt) = grad_x_curr % grid.A11_inv_scgc.slice(

0 commit comments

Comments
 (0)