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

Contains the function to compute the modified solution for a balanced discretization scheme. More...

#include <basic.h>
#include <arrayfunctions.h>
#include <physicalmodels/shallowwater2d.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

int ShallowWater2DModifiedSolution (double *uC, double *u, int d, void *s, void *m, double waqt)
 

Detailed Description

Contains the function to compute the modified solution for a balanced discretization scheme.

Author
Debojyoti Ghosh

Definition in file ShallowWater2DModifiedSolution.c.

Function Documentation

int ShallowWater2DModifiedSolution ( double *  uC,
double *  u,
int  d,
void *  s,
void *  m,
double  waqt 
)

Compute the modified solution for the upwinding step in a balanced conservative finite-difference algorithm for the 2D shallow water equations.

Refer to:

  • 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
uCThe modified solution (same array size and layout as u)
uThe solution (conserved variables)
dSpatial dimension
sSolver object of type HyPar
mMPI object of type MPIVariables
waqtCurrent solution time

Definition at line 21 of file ShallowWater2DModifiedSolution.c.

29 {
30  HyPar *solver = (HyPar*) s;
31  ShallowWater2D *param = (ShallowWater2D*) solver->physics;
32 
33  int ghosts = solver->ghosts;
34  int *dim = solver->dim_local;
35  int ndims = solver->ndims;
36  int index[ndims], bounds[ndims], offset[ndims];
37 
38  /* set bounds for array index to include ghost points */
39  _ArrayCopy1D_(dim,bounds,ndims);
40  int i; for (i=0; i<ndims; i++) bounds[i] += 2*ghosts;
41 
42  /* set offset such that index is compatible with ghost point arrangement */
43  _ArraySetValue_(offset,ndims,-ghosts);
44 
45  int done = 0; _ArraySetValue_(index,ndims,0);
46  while (!done) {
47  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
48  double h,uvel,vvel;
49  _ShallowWater2DGetFlowVar_((u+_MODEL_NVARS_*p),h,uvel,vvel);
50  uC[_MODEL_NVARS_*p+0] = h + param->b[p];
51  uC[_MODEL_NVARS_*p+1] = h * uvel;
52  uC[_MODEL_NVARS_*p+2] = h * vvel;
53  _ArrayIncrementIndex_(ndims,bounds,index,done);
54  }
55  return(0);
56 }
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _MODEL_NVARS_
Definition: euler1d.h:58
void * physics
Definition: hypar.h:266
int * dim_local
Definition: hypar.h:37
int ghosts
Definition: hypar.h:52
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArrayCopy1D_(x, y, size)
#define _ShallowWater2DGetFlowVar_(u, h, uvel, vvel)
int ndims
Definition: hypar.h:26
Structure containing variables and parameters specific to the 2D Shallow Water equations. This structure contains the physical parameters, variables, and function pointers specific to the 2D ShallowWater equations.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23