HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
NavierStokes2DFlux.c
Go to the documentation of this file.
1 
6 #include <stdlib.h>
7 #include <arrayfunctions.h>
8 #include <mathfunctions.h>
9 #include <matmult_native.h>
11 #include <hypar.h>
12 
22  double *f,
23  double *u,
24  int dir,
25  void *s,
26  double t
27  )
28 {
29  HyPar *solver = (HyPar*) s;
30  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
31  int *dim = solver->dim_local;
32  int ghosts = solver->ghosts;
33  static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_];
34 
35  /* set bounds for array index to include ghost points */
36  _ArrayAddCopy1D_(dim,(2*ghosts),bounds,_MODEL_NDIMS_);
37  /* set offset such that index is compatible with ghost point arrangement */
38  _ArraySetValue_(offset,_MODEL_NDIMS_,-ghosts);
39 
40  int done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0);
41  while (!done) {
42  int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p);
43  double rho, vx, vy, e, P;
44  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma);
45  _NavierStokes2DSetFlux_((f+_MODEL_NVARS_*p),rho,vx,vy,e,P,dir);
46  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done);
47  }
48 
49  return(0);
50 }
51 
64  double *f,
65  double *u,
66  int dir,
67  void *s,
68  double t
69  )
70 {
71  HyPar *solver = (HyPar*) s;
72  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
73  int *dim = solver->dim_local;
74  int ghosts = solver->ghosts;
75  static const int JacSize = _MODEL_NVARS_*_MODEL_NVARS_;
76  static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_];
77 
78  /* set bounds for array index to include ghost points */
79  _ArrayAddCopy1D_(dim,(2*ghosts),bounds,_MODEL_NDIMS_);
80  /* set offset such that index is compatible with ghost point arrangement */
81  _ArraySetValue_(offset,_MODEL_NDIMS_,-ghosts);
82 
83  int done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0);
84  while (!done) {
85  int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p);
86  double *Af = param->fast_jac+(2*p+dir)*JacSize;
88  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done);
89  }
90 
91  return(0);
92 }
93 
105  double *f,
106  double *u,
107  int dir,
108  void *s,
109  double t
110  )
111 {
112  HyPar *solver = (HyPar*) s;
113  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
114  int *dim = solver->dim_local;
115  int ghosts = solver->ghosts;
116  static const int JacSize = _MODEL_NVARS_*_MODEL_NVARS_;
117  static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_];
118  static double ftot[_MODEL_NVARS_], fstiff[_MODEL_NVARS_];
119 
120  /* set bounds for array index to include ghost points */
121  _ArrayAddCopy1D_(dim,(2*ghosts),bounds,_MODEL_NDIMS_);
122  /* set offset such that index is compatible with ghost point arrangement */
123  _ArraySetValue_(offset,_MODEL_NDIMS_,-ghosts);
124 
125  int done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0);
126  while (!done) {
127  int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p);
128  /* compute total flux */
129  double rho, vx, vy, e, P;
130  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma);
131  _NavierStokes2DSetFlux_(ftot,rho,vx,vy,e,P,dir);
132  /* compute stiff stuff */
133  double *Af = param->fast_jac+(2*p+dir)*JacSize;
134  MatVecMult4(_MODEL_NVARS_,fstiff,Af,(u+_MODEL_NVARS_*p));
135  /* subtract stiff flux from total flux */
136  _ArraySubtract1D_((f+_MODEL_NVARS_*p),ftot,fstiff,_MODEL_NVARS_);
137  /* Done */
138  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done);
139  }
140 
141  return(0);
142 }
#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
#define _MODEL_NDIMS_
Definition: euler1d.h:56
int NavierStokes2DFlux(double *f, double *u, int dir, void *s, double t)
#define _ArraySubtract1D_(x, a, b, size)
int ghosts
Definition: hypar.h:52
2D Navier Stokes equations (compressible flows)
Contains function definitions for common mathematical functions.
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
int NavierStokes2DStiffFlux(double *f, double *u, int dir, void *s, double t)
#define _NavierStokes2DSetFlux_(f, rho, vx, vy, e, P, dir)
Contains structure definition for hypar.
#define MatVecMult4(N, y, A, x)
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
Structure containing variables and parameters specific to the 2D Navier Stokes equations. This structure contains the physical parameters, variables, and function pointers specific to the 2D Navier-Stokes equations.
Contains macros and function definitions for common array operations.
#define _ArrayAddCopy1D_(x, a, y, size)
int NavierStokes2DNonStiffFlux(double *f, double *u, int dir, void *s, double t)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
Contains macros and function definitions for common matrix multiplication.