HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Euler1DSourceUpwind.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>
11 #include <physicalmodels/euler1d.h>
12 #include <hypar.h>
13 
22  double *fI,
23  double *fL,
24  double *fR,
25  double *u,
26  int dir,
27  void *s,
28  double t
29  )
30 {
31  HyPar *solver = (HyPar*) s;
32  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  /* Local Lax-Friedrich upwinding scheme */
48  for (k = 0; k < _MODEL_NVARS_; k++)
49  (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]);
50  }
51  _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done);
52  }
53 
54  return(0);
55 }
56 
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;
77 
78  int ndims = solver->ndims;
79  int *dim = solver->dim_local;
80 
81  int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims];
82  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
83  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
84 
85  done = 0; _ArraySetValue_(index_outer,ndims,0);
86  while (!done) {
87  _ArrayCopy1D_(index_outer,index_inter,ndims);
88  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
89  int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p);
90  /* Local Lax-Friedrich upwinding scheme */
91  for (k = 0; k < _MODEL_NVARS_; k++)
92  (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]);
93  }
94  _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done);
95  }
96 
97  return(0);
98 }
#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.
int Euler1DSourceUpwindRoe(double *, double *, double *, double *, int, void *, double)
#define _ArrayCopy1D_(x, y, size)
int Euler1DSourceUpwindLLF(double *, double *, double *, double *, int, void *, double)
Contains structure definition for hypar.
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Contains macros and function definitions for common array operations.
1D Euler Equations (inviscid, compressible flows)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _DECLARE_IERR_
Definition: basic.h:17