Skip to content

Commit 0b8e801

Browse files
committed
psc_shock: mv bg calcs
1 parent b1ce9f5 commit 0b8e801

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/psc_shock.cxx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ double b_x;
5656
double b_y;
5757
double b_z;
5858

59+
Real3 background_e;
60+
Real3 background_h;
61+
5962
int nx;
6063
int ny;
6164
int nz;
@@ -114,6 +117,12 @@ void setupParameters(int argc, char** argv)
114117
b_y = b_mag * cos(b_angle_y_to_x_rad);
115118
b_z = 0.0;
116119

120+
Real3 v_upstream = {v_upstream_x, v_upstream_y, v_upstream_z};
121+
double gamma = 1 / sqrt(1 - v_upstream.mag2());
122+
background_e = -gamma * v_upstream.cross({b_x, b_y, b_z});
123+
// note: this only holds for vx=vz=0
124+
background_h = {b_x * gamma, b_y, b_z * gamma};
125+
117126
nx = inputParams.get<int>("nx");
118127
ny = inputParams.get<int>("ny");
119128
nz = inputParams.get<int>("nz");
@@ -901,10 +910,6 @@ static void run(int argc, char** argv)
901910

902911
psc.add_gauss_corrector(&marder);
903912

904-
double gamma = 1 / sqrt(1 - sqr(v_upstream_y));
905-
Real3 background_e =
906-
-gamma * Real3{0, v_upstream_y, 0}.cross({b_x, b_y, b_z});
907-
Real3 background_h = {b_x * gamma, b_y, b_z * gamma};
908913
psc.bndf.background_e = background_e;
909914
psc.bndf.background_h = background_h;
910915
psc.bndf.radiation =

0 commit comments

Comments
 (0)