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 File Reference

Contains the function to compute the hyperbolic flux for the Burgers equations over the domain. More...

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

Go to the source code of this file.

Functions

int BurgersAdvection (double *f, double *u, int dir, void *s, double t)
 

Detailed Description

Contains the function to compute the hyperbolic flux for the Burgers equations over the domain.

Author
John Loffeld

Definition in file BurgersAdvection.c.

Function Documentation

int BurgersAdvection ( double *  f,
double *  u,
int  dir,
void *  s,
double  t 
)

Compute the hyperbolic flux over the local domain.

\begin{equation} {\bf F}\left({\bf u}\right) = 0.5 {\bf u}^2 \end{equation}

Parameters
fArray to hold the computed flux (same size and layout as u)
uArray containing the conserved solution
dirSpatial dimension
sSolver object of type HyPar
tCurrent time

Definition at line 17 of file BurgersAdvection.c.

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
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23