Skip to content

Commit

Permalink
examples/dalf3 tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
bendudson committed Dec 4, 2023
1 parent 34950b5 commit e57389a
Showing 1 changed file with 12 additions and 28 deletions.
40 changes: 12 additions & 28 deletions examples/dalf3/dalf3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class DALF3 : public PhysicsModel {
Field2D phi2D; // Axisymmetric potential, used when split_n0=true

protected:
int init(bool UNUSED(restarting)) {
int init(bool UNUSED(restarting)) override {

/////////////////////////////////////////////////////
// Load data from the grid
Expand Down Expand Up @@ -115,11 +115,6 @@ class DALF3 : public PhysicsModel {
mesh->get(hthe, "hthe"); // m
mesh->get(I, "sinty"); // m^-2 T^-1

// Set locations of staggered variables
jpar.setLocation(CELL_YLOW);
Ajpar.setLocation(CELL_YLOW);
apar.setLocation(CELL_YLOW);

//////////////////////////////////////////////////////////////
// Options

Expand Down Expand Up @@ -328,25 +323,14 @@ class DALF3 : public PhysicsModel {
return 2. * bracket(log(B0), f, bm);
}

const Field3D Grad_parP(const Field3D& f, CELL_LOC loc) {
Field3D result;
if (mesh->StaggerGrids) {
result = Grad_par(f, loc);
if (nonlinear) {
result -=
beta_hat * bracket(interp_to(apar, loc), interp_to(f, loc), BRACKET_ARAKAWA);
}
} else {
if (nonlinear) {
result = ::Grad_parP(apar * beta_hat, f);
} else {
result = Grad_par(f, loc);
}
const Field3D Grad_parP(const Field3D& f) {
if (nonlinear) {
return ::Grad_parP(apar * beta_hat, f);
}
return result;
return Grad_par(f);
}

int rhs(BoutReal UNUSED(time)) {
int rhs(BoutReal UNUSED(time)) override {

// Invert vorticity to get electrostatic potential
if (split_n0) {
Expand All @@ -367,7 +351,7 @@ class DALF3 : public PhysicsModel {
apar = 0.;
if (ZeroElMass) {
// Not evolving Ajpar
jpar = Grad_par(Pe - phi, CELL_YLOW) / eta;
jpar = Grad_par(Pe - phi) / eta;
jpar.applyBoundary();
} else {
jpar = Ajpar / mu_hat;
Expand Down Expand Up @@ -427,7 +411,7 @@ class DALF3 : public PhysicsModel {
}

// Vorticity equation
ddt(Vort) = B0 * B0 * Grad_parP(jpar / interp_to(B0, CELL_YLOW), CELL_CENTRE)
ddt(Vort) = B0 * B0 * Grad_parP(jpar / B0)
- B0 * Kappa(Pe);

if (nonlinear) {
Expand All @@ -452,7 +436,7 @@ class DALF3 : public PhysicsModel {
// Parallel Ohm's law
if (!(estatic && ZeroElMass)) {
// beta_hat*apar + mu_hat*jpar
ddt(Ajpar) = Grad_parP(Pe - phi, CELL_YLOW)
ddt(Ajpar) = Grad_parP(Pe - phi)
- beta_hat * bracket(apar, Pe0, BRACKET_ARAKAWA) - eta * jpar;

if (nonlinear) {
Expand All @@ -465,8 +449,8 @@ class DALF3 : public PhysicsModel {
}

// Parallel velocity
ddt(Vpar) = -Grad_parP(Pe, CELL_YLOW)
+ beta_hat * bracket(apar, interp_to(Pe0, CELL_YLOW), BRACKET_ARAKAWA);
ddt(Vpar) = -Grad_parP(Pe)
+ beta_hat * bracket(apar, Pe0);

if (nonlinear) {
ddt(Vpar) -= bracket(phi, Vpar, bm);
Expand All @@ -485,7 +469,7 @@ class DALF3 : public PhysicsModel {
-bracket(phi, Pet, bm)
+ Pet
* (Kappa(phi - Pe)
+ B0 * Grad_parP((jpar - Vpar) / interp_to(B0, CELL_YLOW), CELL_YLOW));
+ B0 * Grad_parP(jpar - Vpar) / B0);

if (smooth_separatrix) {
// Experimental smoothing across separatrix
Expand Down

0 comments on commit e57389a

Please sign in to comment.