Skip to content

Commit

Permalink
STY: Astyle, yo!
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjridley committed Aug 14, 2023
1 parent 8c2991b commit 086cf47
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 68 deletions.
10 changes: 5 additions & 5 deletions src/add_sources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ void Neutrals::add_sources(Times time) {
+ conduction_scgc
- O_cool_scgc
- NO_cool_scgc);

for (int64_t iSpec = 0; iSpec < nSpecies; iSpec++) {
for (int iDir = 0; iDir < 3; iDir++) {
// update velocities based on acceleration:
// reduce neutral friction until solver is added
species[iSpec].velocity_vcgc[iDir] =
species[iSpec].velocity_vcgc[iDir] +
dt * (species[iSpec].acc_neutral_friction[iDir] / 4.0 +
species[iSpec].acc_ion_drag[iDir]);
dt * (species[iSpec].acc_neutral_friction[iDir] / 4.0 +
species[iSpec].acc_ion_drag[iDir]);

// eddy acceleration is only in the vertical direction:
if (iDir == 2)
species[iSpec].velocity_vcgc[iDir] =
species[iSpec].velocity_vcgc[iDir] +
dt * species[iSpec].acc_eddy;
dt * species[iSpec].acc_eddy;
}
}

calc_bulk_velocity();

report.exit(function);
Expand Down
10 changes: 5 additions & 5 deletions src/advance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ int advance(Planets &planet,

// ------------------------------------
// Do advection first :

// Upper BCs requires the scale height to be calculated, so do that
// first

neutrals.calc_scale_height(gGrid);
neutrals.set_bcs(gGrid, time, indices);
neutrals.advect_vertical(gGrid, time);

// ------------------------------------
// Calculate source terms next:

Expand Down Expand Up @@ -96,8 +96,8 @@ int advance(Planets &planet,
calc_ion_collisions(neutrals, ions);
calc_neutral_friction(neutrals);

neutrals.add_sources(time);
neutrals.add_sources(time);

ions.calc_ion_temperature(neutrals, gGrid, time);
ions.calc_electron_temperature(neutrals, gGrid);

Expand Down
26 changes: 13 additions & 13 deletions src/calc_ion_drift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void Ions::calc_ion_drift(Neutrals neutrals,
int64_t nZ = grid.get_nZ();

set_floor();

report.print(5, "going into calc_efield");
calc_efield(grid);

Expand All @@ -95,7 +95,7 @@ void Ions::calc_ion_drift(Neutrals neutrals,
std::vector<arma_cube> grad_Pi_plus_Pe;
arma_cube rho, rho_nuin, nuin_sum, Nie, sum_rho;
arma_cube top, bottom;

nuin_sum.set_size(nX, nY, nZ);
nuin_sum.zeros();

Expand Down Expand Up @@ -128,7 +128,7 @@ void Ions::calc_ion_drift(Neutrals neutrals,
// Want actual gravity for 3rd dim
for (iDim = 0; iDim < 3; iDim ++)
gravity_vcgc[iDim] = species[iIon].mass *
grid.gravity_vcgc[iDim] % species[iIon].density_scgc;
grid.gravity_vcgc[iDim] % species[iIon].density_scgc;

// Neutral Wind Forcing:
report.print(5, "neutral winds");
Expand Down Expand Up @@ -170,17 +170,17 @@ void Ions::calc_ion_drift(Neutrals neutrals,

a_x_b = cross_product(a_perp, grid.bfield_vcgc);

// With floats, this can become 0, which then makes the
// velocity a nan, so the clamp ensures that the bottom is not 0
bottom =
rho_nuin % rho_nuin +
Nie % Nie % grid.bfield_mag_scgc % grid.bfield_mag_scgc;
bottom.clamp(1e-32, 1e32);
// With floats, this can become 0, which then makes the
// velocity a nan, so the clamp ensures that the bottom is not 0
bottom =
rho_nuin % rho_nuin +
Nie % Nie % grid.bfield_mag_scgc % grid.bfield_mag_scgc;
bottom.clamp(1e-32, 1e32);

for (int64_t iComp = 0; iComp < 3; iComp++) {
top = rho_nuin % a_perp[iComp] + Nie % a_x_b[iComp];
species[iIon].perp_velocity_vcgc[iComp] = top / bottom;
}
top = rho_nuin % a_perp[iComp] + Nie % a_x_b[iComp];
species[iIon].perp_velocity_vcgc[iComp] = top / bottom;
}
} else {
// No Planetary Magnetic field
for (int64_t iComp = 0; iComp < 3; iComp++) {
Expand Down
8 changes: 5 additions & 3 deletions src/calc_neutral_derived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,14 @@ void Neutrals::calc_bulk_velocity() {

for (int64_t iDir = 0; iDir < 3; iDir++) {
velocity_vcgc[iDir].zeros();

for (int64_t iSpecies = 0; iSpecies < nSpecies; iSpecies++) {
velocity_vcgc[iDir] = velocity_vcgc[iDir] +
species[iSpecies].mass *
species[iSpecies].density_scgc %
species[iSpecies].velocity_vcgc[iDir];
species[iSpecies].mass *
species[iSpecies].density_scgc %
species[iSpecies].velocity_vcgc[iDir];
}

velocity_vcgc[iDir] = velocity_vcgc[iDir] / rho_scgc;
}

Expand Down
17 changes: 8 additions & 9 deletions src/inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,26 +696,25 @@ json Inputs::get_boundary_condition_types() {
std::string Inputs::get_advection_neutrals_vertical() {

std::string value = "none";

if (settings.contains("Advection"))
if (settings["Advection"].contains("Neutrals"))
if (settings["Advection"]["Neutrals"].contains("Vertical"))
value = settings["Advection"]["Neutrals"]["Vertical"];
value = settings["Advection"]["Neutrals"]["Vertical"];
else {
std::cout << "Error trying to get inputs:\n";
std::cout << " settings['Advection']['Neutrals']['Vertical']\n";
}
else {
std::cout << "Error trying to get inputs:\n";
std::cout << " settings['Advection']['Neutrals']['Vertical']\n";
} else {
std::cout << "Error trying to get inputs:\n";
std::cout << " settings['Advection']['Neutrals']\n";
}
else {
} else {
std::cout << "Error trying to get inputs:\n";
std::cout << " settings['Advection']\n";
}

return value;
}


// --------------------------------------------------------------------------
// check to see if class is ok
Expand Down
6 changes: 4 additions & 2 deletions src/ions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Ions::species_chars Ions::create_species(Grid grid) {

// The collision frequencies need the neutrals, so those are
// initialized in init_ion_temperature.

return tmp;
}

Expand Down Expand Up @@ -87,8 +87,10 @@ Ions::Ions(Grid grid, Planets planet) {
density_scgc.set_size(nLons, nLats, nAlts);
density_scgc.ones();
velocity_vcgc = make_cube_vector(nLons, nLats, nAlts, 3);

for (int iDir = 0; iDir < 3; iDir++)
velocity_vcgc[iDir].zeros();

temperature_scgc.set_size(nLons, nLats, nAlts);
temperature_scgc.fill(200.0);
electron_temperature_scgc.set_size(nLons, nLats, nAlts);
Expand Down Expand Up @@ -170,7 +172,7 @@ void Ions::set_floor() {
int iSpecies;

for (iSpecies = 0; iSpecies < nSpecies; iSpecies++)
species[iSpecies].density_scgc.clamp(1.0,1e15);
species[iSpecies].density_scgc.clamp(1.0, 1e15);

return;
}
Expand Down
9 changes: 6 additions & 3 deletions src/neutrals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ Neutrals::species_chars Neutrals::create_species(Grid grid) {
tmp.newDensity_scgc.set_size(nLons, nLats, nAlts);
tmp.velocity_vcgc = make_cube_vector(nLons, nLats, nAlts, 3);
tmp.newVelocity_vcgc = make_cube_vector(nLons, nLats, nAlts, 3);

for (int iDir = 0; iDir < 3; iDir++) {
tmp.velocity_vcgc[iDir].zeros();
tmp.newVelocity_vcgc[iDir].zeros();
}

tmp.chapman_scgc.set_size(nLons, nLats, nAlts);
tmp.scale_height_scgc.set_size(nLons, nLats, nAlts);
tmp.ionization_scgc.set_size(nLons, nLats, nAlts);
Expand Down Expand Up @@ -109,8 +110,10 @@ Neutrals::Neutrals(Grid grid,
rho_scgc.set_size(nLons, nLats, nAlts);
rho_scgc.ones();
velocity_vcgc = make_cube_vector(nLons, nLats, nAlts, 3);

for (int iDir = 0; iDir < 3; iDir++)
velocity_vcgc[iDir].zeros();

cMax_vcgc = make_cube_vector(nLons, nLats, nAlts, 3);
mean_major_mass_scgc.set_size(nLons, nLats, nAlts);
mean_major_mass_scgc.ones();
Expand Down Expand Up @@ -201,8 +204,8 @@ void Neutrals::fill_with_hydrostatic(int64_t iStart,
// Integrate with hydrostatic equilibrium up:
for (int iAlt = iStart; iAlt < iEnd; iAlt++) {
species[iSpecies].density_scgc.slice(iAlt) =
temperature_scgc.slice(iAlt - 1) /
temperature_scgc.slice(iAlt) %
temperature_scgc.slice(iAlt - 1) /
temperature_scgc.slice(iAlt) %
species[iSpecies].density_scgc.slice(iAlt - 1) %
exp(-grid.dalt_lower_scgc.slice(iAlt) /
species[iSpecies].scale_height_scgc.slice(iAlt));
Expand Down
7 changes: 4 additions & 3 deletions src/neutrals_advect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
bool Neutrals::advect_vertical(Grid grid, Times time) {

bool didWork = true;

std::string function = "Neutrals::advance_vertical";
static int iFunction = -1;
report.enter(function, iFunction);
Expand All @@ -24,10 +24,11 @@ bool Neutrals::advect_vertical(Grid grid, Times time) {
else {
std::cout << "Vertical solver not found!\n";
std::cout << " ==> Requested : "
<< input.get_advection_neutrals_vertical()
<< "\n";
<< input.get_advection_neutrals_vertical()
<< "\n";
didWork = false;
}

report.exit(function);
return didWork;
}
Expand Down
38 changes: 19 additions & 19 deletions src/neutrals_momentum_friction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,30 @@ void calc_neutral_friction(Neutrals &neutrals) {
for (iDir = 0; iDir < 3; iDir++) {
if (iDir < 2) {
for (iSpecies = 0; iSpecies < neutrals.nSpecies; iSpecies++)
neutrals.species[iSpecies].acc_neutral_friction[iDir].zeros();
neutrals.species[iSpecies].acc_neutral_friction[iDir].zeros();
} else {

for (iAlt = 0; iAlt < nZs; iAlt++) {
for (iLat = 0; iLat < nYs; iLat++) {
for (iLon = 0; iLon < nXs; iLon++) {
vels.zeros();

//Put the old velocities into vels:
for (iSpecies = 0; iSpecies < neutrals.nSpecies; iSpecies++)
vels(iSpecies) =
neutrals.species[iSpecies].velocity_vcgc[iDir](iLon, iLat, iAlt);

acc = neutral_friction_one_cell(iLon, iLat, iAlt, vels, neutrals);

for (iSpecies = 0; iSpecies < neutrals.nSpecies; iSpecies++)
neutrals.species[iSpecies].acc_neutral_friction[iDir](iLon, iLat, iAlt) =
acc(iSpecies);
} // for long
} // for lat
for (iLat = 0; iLat < nYs; iLat++) {
for (iLon = 0; iLon < nXs; iLon++) {
vels.zeros();

//Put the old velocities into vels:
for (iSpecies = 0; iSpecies < neutrals.nSpecies; iSpecies++)
vels(iSpecies) =
neutrals.species[iSpecies].velocity_vcgc[iDir](iLon, iLat, iAlt);

acc = neutral_friction_one_cell(iLon, iLat, iAlt, vels, neutrals);

for (iSpecies = 0; iSpecies < neutrals.nSpecies; iSpecies++)
neutrals.species[iSpecies].acc_neutral_friction[iDir](iLon, iLat, iAlt) =
acc(iSpecies);
} // for long
} // for lat
} // for alt
} // if iDir
} // for direction

report.exit(function);
return;
} //calc_neutral_friction
10 changes: 5 additions & 5 deletions src/solver_vertical_rusanov.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void calc_grad_and_diff_alts_rusanov(Grid &grid,

outDiff.zeros();
outGrad.zeros();

report.print(3, "before facevalues");

calc_facevalues_alts_rusanov(grid, inVar, varLeft, varRight);
Expand Down Expand Up @@ -279,8 +279,8 @@ void Neutrals::solver_vertical_rusanov(Grid grid,
- dt * (species[iSpecies].velocity_vcgc[2] % gradVertVel_s[iSpecies]
- v2or
+ 0.1 * (temperature_scgc % gradLogN_s[iSpecies] * cKB / mass
+ gradTemp * cKB / mass
+ abs(grid.gravity_vcgc[2])))
+ gradTemp * cKB / mass
+ abs(grid.gravity_vcgc[2])))
+ dt * diffVertVel_s[iSpecies];
} else {
species[iSpecies].newVelocity_vcgc[2].zeros();
Expand Down Expand Up @@ -326,13 +326,13 @@ void Neutrals::solver_vertical_rusanov(Grid grid,
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++) {
if (species[iSpecies].DoAdvect) {
species[iSpecies].density_scgc(iX, iY, iZ) =
species[iSpecies].newDensity_scgc(iX, iY, iZ);
species[iSpecies].newDensity_scgc(iX, iY, iZ);
species[iSpecies].velocity_vcgc[2](iX, iY, iZ) =
species[iSpecies].newVelocity_vcgc[2](iX, iY, iZ);
} else {
// assign bulk vertical velocity to the non-advected species:
species[iSpecies].velocity_vcgc[2](iX, iY, iZ) =
velocity_vcgc[2](iX, iY, iZ);
velocity_vcgc[2](iX, iY, iZ);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void Times::calc_dt(precision_t dtNeutral,
dt = end - current;

double cfl = 0.5;

if (cfl * dtNeutral < dt)
dt = cfl * dtNeutral;

Expand Down

0 comments on commit 086cf47

Please sign in to comment.