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

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

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

Go to the source code of this file.

Functions

int ShallowWater2DSourceUpwindLLF (double *fI, double *fL, double *fR, double *u, int dir, void *s, double t)
 
int ShallowWater2DSourceUpwindRoe (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 2D shallow water equations).

Author
Debojyoti Ghosh

Definition in file ShallowWater2DSourceUpwind.c.

Function Documentation

◆ ShallowWater2DSourceUpwindLLF()

int ShallowWater2DSourceUpwindLLF ( 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
sSolver object of type HyPar
tCurrent solution time

Definition at line 22 of file ShallowWater2DSourceUpwind.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 }
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)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)

◆ ShallowWater2DSourceUpwindRoe()

int ShallowWater2DSourceUpwindRoe ( 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
sSolver object of type HyPar
tCurrent solution time

Definition at line 64 of file ShallowWater2DSourceUpwind.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 }
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)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)