Skip to content

Commit 6b5ba69

Browse files
committed
SPEED: speed up calc_efield a tiny bit
1 parent fd13016 commit 6b5ba69

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/calc_ion_drift.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
void Ions::calc_efield(Grid grid) {
1111

1212
// efield = - grad(potential)
13-
efield_vcgc = calc_gradient_vector(potential_scgc, grid);
14-
15-
for (int64_t iComp = 0; iComp < 3; iComp++)
16-
efield_vcgc[iComp] = -efield_vcgc[iComp];
13+
efield_vcgc = calc_gradient_vector(-1.0 * potential_scgc, grid);
1714

1815
// Remove component along b-field (should be zero, anyways!)
1916
arma_cube edotb = dot_product(efield_vcgc, grid.bfield_unit_vcgc);
@@ -28,12 +25,16 @@ void Ions::calc_efield(Grid grid) {
2825
// --------------------------------------------------------------------------
2926

3027
void Ions::calc_exb_drift(Grid grid) {
28+
std::string function = "Ions::calc_exb";
29+
static int iFunction = -1;
30+
report.enter(function, iFunction);
3131
arma_cube bmag2 =
3232
(grid.bfield_mag_scgc) % (grid.bfield_mag_scgc);
3333
exb_vcgc = cross_product(efield_vcgc, grid.bfield_vcgc);
3434

3535
for (int64_t iComp = 0; iComp < 3; iComp++)
3636
exb_vcgc[iComp] = exb_vcgc[iComp] / bmag2;
37+
report.exit(function);
3738
}
3839

3940
// --------------------------------------------------------------------------
@@ -42,6 +43,10 @@ void Ions::calc_exb_drift(Grid grid) {
4243

4344
std::vector<arma_cube> Ions::calc_ion_electron_pressure_gradient(int64_t iIon,
4445
Grid grid) {
46+
47+
std::string function = "Ions::elec_ion_pressure_gradient";
48+
static int iFunction = -1;
49+
report.enter(function, iFunction);
4550
std::vector<arma_cube> pressure_gradient_vcgc;
4651
arma_cube total_pressure_scgc;
4752

@@ -57,6 +62,7 @@ std::vector<arma_cube> Ions::calc_ion_electron_pressure_gradient(int64_t iIon,
5762
cKB;
5863

5964
pressure_gradient_vcgc = calc_gradient_vector(total_pressure_scgc, grid);
65+
report.exit(function);
6066

6167
return pressure_gradient_vcgc;
6268
}

0 commit comments

Comments
 (0)