HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ShallowWater1DSourceUpwind.c File Reference

Contains functions to compute the "upwind" source term at an interface (for a balanced finite-difference discretization of the 1D shallow water equations). More...

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

Go to the source code of this file.

Functions

int ShallowWater1DSourceUpwindLLF (double *fI, double *fL, double *fR, double *u, int dir, void *s, double t)
 
int ShallowWater1DSourceUpwindRoe (double *fI, double *fL, double *fR, double *u, int dir, void *s, double t)
 

Detailed Description

Contains functions to compute the "upwind" source term at an interface (for a balanced finite-difference discretization of the 1D shallow water equations).

Author
Debojyoti Ghosh

Definition in file ShallowWater1DSourceUpwind.c.

Function Documentation

int ShallowWater1DSourceUpwindLLF ( double *  fI,
double *  fL,
double *  fR,
double *  u,
int  dir,
void *  s,
double  t 
)

Compute the "upwind" source term in the balanced formulation introduced in the reference below. The "upwind" state is just the arithmetic average of the left and right states.

  • Xing, Y., Shu, C.-W., "High order finite difference WENO schemes with the exact conservation property for the shallow water equations", Journal of Computational Physics, 208, 2005, pp. 206-227. http://dx.doi.org/10.1016/j.jcp.2005.02.006
Parameters
fIComputed interface source term ("upwinded")
fLLeft-biased interface source term
fRRight-biased interface source term
uSolution (conserved variables)
dirSpatial dimension (unused since this is a 1D case)
sSolver object of type HyPar
tCurrent solution time

Definition at line 22 of file ShallowWater1DSourceUpwind.c.

31 {
32  HyPar *solver = (HyPar*) s;
33  int done,k;
34 
35  int ndims = solver->ndims;
36  int *dim = solver->dim_local;
37 
38  int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims];
39  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
40  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
41 
42  done = 0; _ArraySetValue_(index_outer,ndims,0);
43  while (!done) {
44  _ArrayCopy1D_(index_outer,index_inter,ndims);
45  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
46  int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p);
47  for (k = 0; k < _MODEL_NVARS_; k++)
48  (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]);
49  }
50  _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done);
51  }
52 
53  return(0);
54 }
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _MODEL_NVARS_
Definition: euler1d.h:58
int * dim_local
Definition: hypar.h:37
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArrayCopy1D_(x, y, size)
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
int ShallowWater1DSourceUpwindRoe ( double *  fI,
double *  fL,
double *  fR,
double *  u,
int  dir,
void *  s,
double  t 
)

Compute the "upwind" source term in the balanced formulation introduced in the reference below. The "upwind" state is just the arithmetic average of the left and right states.

  • Xing, Y., Shu, C.-W., "High order finite difference WENO schemes with the exact conservation property for the shallow water equations", Journal of Computational Physics, 208, 2005, pp. 206-227. http://dx.doi.org/10.1016/j.jcp.2005.02.006
Parameters
fIComputed interface source term ("upwinded")
fLLeft-biased interface source term
fRRight-biased interface source term
uSolution (conserved variables)
dirSpatial dimension (unused since this is a 1D case)
sSolver object of type HyPar
tCurrent solution time

Definition at line 64 of file ShallowWater1DSourceUpwind.c.

73 {
74  HyPar *solver = (HyPar*) s;
75  int done,k;
76 
77  int ndims = solver->ndims;
78  int *dim = solver->dim_local;
79 
80  int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims];
81  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
82  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
83 
84  done = 0; _ArraySetValue_(index_outer,ndims,0);
85  while (!done) {
86  _ArrayCopy1D_(index_outer,index_inter,ndims);
87  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
88  int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p);
89  for (k = 0; k < _MODEL_NVARS_; k++)
90  (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]);
91  }
92  _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done);
93  }
94 
95  return(0);
96 }
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _MODEL_NVARS_
Definition: euler1d.h:58
int * dim_local
Definition: hypar.h:37
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArrayCopy1D_(x, y, size)
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23