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
Go to the documentation of this file.
1 
6 #include <stdlib.h>
7 #include <math.h>
8 #include <basic.h>
9 #include <arrayfunctions.h>
10 #include <mathfunctions.h>
12 #include <hypar.h>
13 
23  double *fI,
24  double *fL,
25  double *fR,
26  double *u,
27  int dir,
28  void *s,
29  double t
30  )
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 }
55 
65  double *fI,
66  double *fL,
67  double *fR,
68  double *u,
69  int dir,
70  void *s,
71  double t
72  )
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)
Contains function definitions for common mathematical functions.
#define _ArrayCopy1D_(x, y, size)
Contains structure definition for hypar.
int ShallowWater1DSourceUpwindLLF(double *, double *, double *, double *, int, void *, double)
1D Shallow Water Equations
int ShallowWater1DSourceUpwindRoe(double *, double *, double *, double *, int, void *, double)
Some basic definitions and macros.
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