PLUTO  4.4-patch2
Macros | Functions | Variables
sb_flux.c File Reference

Enforce conservation at the X1 boundaries in the shearing-box module. More...

#include "pluto.h"

Macros

#define swL   0.0
 

Functions

void SB_SaveFluxes (Sweep *sweep, Grid *grid)
 
void SB_CorrectFluxes (Data_Arr U, double t, double dt, Grid *grid)
 
void SB_CorrectEMF (EMF *emf, Data_Arr V0, Grid *grid)
 
void ExchangeX (double *bufL, double *bufR, int nel, Grid *grid)
 

Variables

static double *** FluxL
 
static double *** FluxR
 

Detailed Description

This file provides functions to store and then modify the upwind fluxes computed during the Riemann solver at the leftmost and righmost physical boundaries. These tasks are performed only when either SB_SYMMETRIZE_HYDRO, SB_SYMMETRIZE_EY, SB_SYMMETRIZE_EZ flags are set to YES in Src/MHD/shearingbox.h and are useful to avoid loss of conservation in the hydrodynamical variables (density, momentum, energy) and/or magnetic fields.

This is first achieved by calling the SB_SaveFluxes() function during the time stepping scheme, with the purpose of storing the leftmost and rightmost conservative fluxes in the x-direction into the static arrays FluxL[] and FluxR[].

These fluxes are then subsequently used by SB_CorrectFluxes() which interpolates the fluxes and properly correct leftmost and rightmost cell-centered flow quantities to ensure conservation.

The treatment of staggered magnetic field is done similarly by SB_CorrectEMF().

References

Authors
A. Mignone (migno.nosp@m.ne@t.nosp@m.o.inf.nosp@m.n.it)
G. Muscianisi (g.mus.nosp@m.ican.nosp@m.isi@c.nosp@m.inec.nosp@m.a.it)
G. Bodo (bodo@.nosp@m.oato.nosp@m..inaf.nosp@m..it)
Date
July 08, 2019

Macro Definition Documentation

◆ swL

#define swL   0.0

Sets the weight coefficient in the range [0,1] used during flux symmetrization at the left and right boundaries,

FL -> swL*FL    + swR*I(FR)
FR -> swL*I(FL) + swR*FR 

where swR=1-swL and I() stands for conservative interpolation.

Function Documentation

◆ ExchangeX()

void ExchangeX ( double *  bufL,
double *  bufR,
int  nel,
Grid grid 
)

Send bufL owned by processor at X1_BEG to the processor at X1_END; Send bufR owned by processor at X1_END to the processor at X1_BEG;

◆ SB_CorrectEMF()

void SB_CorrectEMF ( EMF emf,
Data_Arr  V0,
Grid grid 
)

Correct the electromotive force by enforcing symmetrization in order to guarantee that Bx on the left is mapped from Bx on the right. This is done by re-defining the y- and z-components of the electric field as follows:

\[ E_{z,L} \to \frac{1}{2}\left[E_{z,L} + \Aop^{t_E}_{>}(E_{z,R}) + wF_{+}\right] \,,\qquad E_{z,R} \to \frac{1}{2}\left[\Aop^{t_E}_<(E_{z,L}) + E_{z,R} - wF_-\right] \]

where $t_E =$ is time level of the electric field, $$ are the forward (>) or backward (<) shift operators. The corrective terms $F_{\pm}$ are the upwind numerical flux computed in the advection of the x-component of magnetic field:

\[ F_{+} = B_{x,L} + \frac{\widetilde{\Delta B}_{xL}}{2} \left(1 - \frac{\delta t}{\Delta y}w\right) \,,\qquad F_{-} = B_{x,R} - \frac{\widetilde{\Delta B}_{xR}}{2} \left(1 - \frac{\delta t}{\Delta y}w\right) \]

where $ \delta t\ne \Delta t$ is the time increment of the shift operator applied to the magnetic field, $B_{xL}$ and $B_{xR}$ are the x component of magnetic field computed at some intermediate time tB while

\[ \widetilde{\Delta B}_{xL} = \frac{ \overline{\Delta B}_{xL} + \Aop^{tB}_{>}(\overline{\Delta B}_{xR})}{2} \;,\qquad \widetilde{\Delta B}_{xR} = \frac{ \Aop^{tB}_{<}(\overline{\Delta B}_{xL}) + \overline{\Delta B}_{xR}}{2} \]

are the arithmetic average of the limited slopes of Bx computed at the left and right boundaries.

Parameters
[in,out]emfpointer to EMF structure
[in]V04D array of staggered fields
[in]gridpointer to array of Grid structures
Note
Symmetrization of Ez can only be done using weight coefficients of 1/2 (and not swL, swR) since limited slopes (dbxL_lim and dbxR_lim) do not satisfy the property that their sum is zero (as expected for a periodic function).

◆ SB_CorrectFluxes()

void SB_CorrectFluxes ( Data_Arr  U,
double  t,
double  dt,
Grid grid 
)

Interpolate x-fluxes FLuxL and FluxR and properly correct leftmost and rightmost cells to ensure conservation.

Parameters
[in,out]Udata array containing cell-centered quantities
[in]tthe time step at which fluxes have been computed
[in]dtthe time step being used in the integrator stage
[in]gridpointer to array of Grid structures
Note
Modify the values of FluxR (on the left) and FluxL (on the right) to properly account for the shift induced by the moving boundaries. For safety reason (avoid overwriting arrays when a processor owns both the left and the right side) we first copy, then interpolate and finally average:
  • On the left boundary:

    FluxR -> FluxLR -> I(FluxLR) -> fL = wL*FluxL + wR*FluxLR

  • On the right boundary:

    FluxL -> FluxLR -> I(FluxLR) -> fR = wL*FluxLR + wR*FluxR


◆ SB_SaveFluxes()

void SB_SaveFluxes ( Sweep sweep,
Grid grid 
)

Store leftmost and rightmost conservative fluxes in the x direction into FluxL and FluxR.

Parameters
[in]sweeppointer to a Sweep structure
[in]gridpointer to an array of Grid structures
Returns
This function has no return value.

Variable Documentation

◆ FluxL

double*** FluxL
static

Array of fluxes at the left x-boundary.

◆ FluxR

double*** FluxR
static

Array of fluxes at the right x-boundary.