Compute interface states using characteristic tracing step.
Tasks are numbered below.
1) Compute eigenvectors and eigenvalues if not yet defined.
2) Obtain characteristic variable increments dwp and dwm.
3) Initialize vp and vm to the reference state. Since this is somewhat arbitrary we use the value of CHTR_REF_STATE to select one of the following cases:
Passive scalars use always CHTR_REF_STATE == 2.
4) Compute left and right states in primitive variables. This step also depends on the value of CHTR_REF_STATE and include:
27 double nup=1.0, num=-1.0, nu[
NVAR];
29 double *vc, *vp, *vm, **L, **R, *lambda;
36 #if CHAR_LIMITING == NO
41 for (i =
beg; i <=
end; i++){
57 #if CHAR_LIMITING == NO
60 for (k =
NFLX; k <
NVAR; k++) lambda[k] = vc[V1];
63 for (k = 0; k <
NVAR; k++) nu[k] = dtdx*lambda[k];
69 for (nv = NVAR; nv--; ) {
70 dvp[nv] = vp[nv] - vc[nv];
71 dvm[nv] = vm[nv] - vc[nv];
90 for (nv =
NFLX; nv--; ) vp[nv] = vm[nv] = vc[nv];
92 nup =
MAX(nu[1], 0.0); num =
MIN(nu[0], 0.0);
93 for (nv =
NFLX; nv--; ){
94 dwh = vp[nv] - vm[nv];
95 d2w = vp[nv] + vm[nv] - 2.0*vc[nv];
96 vp[nv] -= 0.5*nup*(dwh + d2w*(3.0 - 2.0*nup));
97 vm[nv] -= 0.5*num*(dwh - d2w*(3.0 + 2.0*num));
110 for (k = 0; k <
NFLX; k++){
111 dwh = dwp[
k] - dwm[
k];
112 d2w = dwp[
k] + dwm[
k];
115 Spp = dwp[
k] - 0.5*nu[
k]*(dwh + d2w*(3.0 - 2.0*nu[
k]));
117 Spp = - 0.5*nu[
k]*(dwh + d2w*(3.0 - 2.0*nu[
k]));
119 Spp = -0.5*(nu[
k]-nup)*(dwh + 3.0*d2w) + (nu[
k]*nu[
k] - nup*nup)*d2w;
121 for (nv = NFLX; nv--; ) vp[nv] += Spp*R[nv][k];
124 Smm = dwm[
k] - 0.5*nu[
k]*(dwh - d2w*(3.0 + 2.0*nu[
k]));
126 Smm = - 0.5*nu[
k]*(dwh - d2w*(3.0 + 2.0*nu[
k]));
128 Smm = -0.5*(nu[
k]-num)*(dwh - 3.0*d2w) + (nu[
k]*nu[
k] - num*num)*d2w;
130 for (nv = NFLX; nv--; ) vm[nv] += Smm*R[nv][k];
138 for (nv = NFLX; nv--; ){
139 dwh = 0.5*
g_dt*src[
i][nv];
149 if (nu[NFLX] >= 0.0) {
150 for (k = NFLX; k <
NVAR; k++){
151 dwh = dwp[
k] - dwm[
k];
152 d2w = dwp[
k] + dwm[
k];
153 vp[
k] -= 0.5*nu[
k]*(dwh + d2w*(3.0 - 2.0*nu[
k]));
156 for (k = NFLX; k <
NVAR; k++){
157 dwh = dwp[
k] - dwm[
k];
158 d2w = dwp[
k] + dwm[
k];
159 vm[
k] -= 0.5*nu[
k]*(dwh - d2w*(3.0 + 2.0*nu[
k]));
166 for (i =
beg-1; i <=
end; i++) {
173 for (i =
beg; i <=
end; i++) {
176 for (nv = NVAR; nv--; ) {
177 state->
vh[
i][nv] = 0.5*(vp[nv] + vm[nv]);
double ** v
Cell-centered primitive varables at the base time level, v[i] = .
int end
Global end index for the local array.
double ** vh
Primitive state at n+1/2 (only for one step method)
void PrimEigenvectors(double *q, double cs2, double h, double *lambda, double **LL, double **RR)
void CheckPrimStates(double **vM, double **vP, double **v0, int beg, int end)
double g_dt
The current integration time step.
double ** vR
Primitive variables to the right of the interface, .
void SoundSpeed2(double **v, double *cs2, double *h, int beg, int end, int pos, Grid *grid)
double ** vp
prim vars at i+1/2 edge, vp[i] = vL(i+1/2)
int g_dir
Specifies the current sweep or direction of integration.
int beg
Global start index for the local array.
double ** lambda
Characteristic speed associated to Lp and Rp.
void PrimSource(const State_1D *, int, int, double *, double *, double **, Grid *)
void PrimToChar(double **L, double *v, double *w)
double ** vm
prim vars at i-1/2 edge, vm[i] = vR(i-1/2)
long int NMAX_POINT
Maximum number of points among the three directions, boundaries excluded.
double * bn
Face magentic field, bn = bx(i+1/2)
double ** vL
Primitive variables to the left of the interface, .
double * a2
Sound speed squared.
#define ARRAY_2D(nx, ny, type)
double *** Rp
Left and right primitive eigenvectors.