HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
BurgersUpwind.c File Reference

Contains functions to compute the upwind flux at grid interfaces for the Burgers equations. More...

#include <stdlib.h>
#include <math.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <mathfunctions.h>
#include <physicalmodels/burgers.h>
#include <hypar.h>

Go to the source code of this file.

Functions

int BurgersUpwind (double *fI, double *fL, double *fR, double *uL, double *uR, double *u, int dir, void *s, double t)
 

Detailed Description

Contains functions to compute the upwind flux at grid interfaces for the Burgers equations.

Author
John Loffeld

Definition in file BurgersUpwind.c.

Function Documentation

◆ BurgersUpwind()

int BurgersUpwind ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

Upwinding scheme for the Burgers equations

Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension
sSolver object of type HyPar
tCurrent solution time

Definition at line 15 of file BurgersUpwind.c.

25 {
26  HyPar *solver = (HyPar*) s;
27  Burgers *param = (Burgers*) solver->physics;
28  int done,v;
29 
30  int ndims = solver->ndims;
31  int nvars = solver->nvars;
32  int *dim = solver->dim_local;
33  int ghosts = solver->ghosts;
34 
35  int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims];
36  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
37  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
38 
39  done = 0; _ArraySetValue_(index_outer,ndims,0);
40  while (!done) {
41  _ArrayCopy1D_(index_outer,index_inter,ndims);
42  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
43 
44  int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p);
45  int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--;
46  int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims);
47  int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL);
48  int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR);
49 
50  for (v = 0; v < nvars; v++) {
51  double eigL = u[nvars*pL+v],
52  eigR = u[nvars*pR+v];
53 
54  if ((eigL > 0) && (eigR > 0)) {
55  fI[nvars*p+v] = fL[nvars*p+v];
56  } else if ((eigL < 0) && (eigR < 0)) {
57  fI[nvars*p+v] = fR[nvars*p+v];
58  } else {
59  double alpha = max(absolute(eigL), absolute(eigR));
60  fI[nvars*p+v] = 0.5 * (fL[nvars*p+v] + fR[nvars*p+v] - alpha * (uR[nvars*p+v] - uL[nvars*p+v]));
61  }
62  }
63 
64  }
65  _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done);
66 
67  }
68 
69  return(0);
70 }
#define absolute(a)
Definition: math_ops.h:32
int nvars
Definition: hypar.h:29
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
#define _ArrayCopy1D_(x, y, size)
#define max(a, b)
Definition: math_ops.h:18