HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BurgersAdvection.c
Go to the documentation of this file.
1 
6 #include <stdlib.h>
7 #include <basic.h>
8 #include <arrayfunctions.h>
10 #include <hypar.h>
11 
17 int BurgersAdvection( double *f,
18  double *u,
19  int dir,
20  void *s,
21  double t
22  )
23 {
24  HyPar *solver = (HyPar*) s;
25  Burgers *param = (Burgers*) solver->physics;
26  int i, v;
27 
28  int *dim = solver->dim_local;
29  int ghosts = solver->ghosts;
30  int ndims = solver->ndims;
31  int nvars = solver->nvars;
32  int index[ndims], bounds[ndims], offset[ndims];
33 
34  /* set bounds for array index to include ghost points */
35  _ArrayCopy1D_(dim,bounds,ndims);
36  for (i=0; i<ndims; i++) bounds[i] += 2*ghosts;
37 
38  /* set offset such that index is compatible with ghost point arrangement */
39  _ArraySetValue_(offset,ndims,-ghosts);
40 
41  int done = 0; _ArraySetValue_(index,ndims,0);
42  while (!done) {
43  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
44  for (v = 0; v < nvars; v++) f[nvars*p+v] = 0.5 * u[nvars*p+v] * u[nvars*p+v];
45  _ArrayIncrementIndex_(ndims,bounds,index,done);
46  }
47 
48  return(0);
49 }
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
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)
int nvars
Definition: hypar.h:29
Contains structure definition for hypar.
Some basic definitions and macros.
int BurgersAdvection(double *f, double *u, int dir, void *s, double t)
int ndims
Definition: hypar.h:26
Contains macros and function definitions for common array operations.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23