HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
NavierStokes3DComputeCFL.c
Go to the documentation of this file.
1 
5 #include <stdlib.h>
6 #include <math.h>
7 #include <basic.h>
8 #include <arrayfunctions.h>
9 #include <mathfunctions.h>
11 #include <hypar.h>
12 
17  void *s,
18  void *m,
19  double dt,
20  double t
21  )
22 {
23  HyPar *solver = (HyPar*) s;
24  NavierStokes3D *param = (NavierStokes3D*) solver->physics;
25 
26  int *dim = solver->dim_local;
27  int ghosts = solver->ghosts;
28  int ndims = solver->ndims;
29  int index[ndims];
30  double *u = solver->u;
31 
32  double max_cfl = 0;
33  int done = 0; _ArraySetValue_(index,ndims,0);
34  while (!done) {
35  int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p);
36  double rho, vx, vy, vz, e, P, c, dxinv, dyinv, dzinv, local_cfl[3];
38 
39  c = sqrt(param->gamma*P/rho); /* speed of sound */
40  _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */
41  _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); /* 1/dy */
42  _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->dxinv,dzinv); /* 1/dz */
43 
44  local_cfl[_XDIR_] = (absolute(vx)+c)*dt*dxinv; /* local cfl for this grid point (x) */
45  local_cfl[_YDIR_] = (absolute(vy)+c)*dt*dyinv; /* local cfl for this grid point (y) */
46  local_cfl[_ZDIR_] = (absolute(vz)+c)*dt*dzinv; /* local cfl for this grid point (z) */
47  if (local_cfl[_XDIR_] > max_cfl) max_cfl = local_cfl[_XDIR_];
48  if (local_cfl[_YDIR_] > max_cfl) max_cfl = local_cfl[_YDIR_];
49  if (local_cfl[_ZDIR_] > max_cfl) max_cfl = local_cfl[_ZDIR_];
50 
51  _ArrayIncrementIndex_(ndims,dim,index,done);
52  }
53 
54  return(max_cfl);
55 }
#define absolute(a)
Definition: math_ops.h:32
Contains function definitions for common mathematical functions.
#define _ZDIR_
Structure containing variables and parameters specific to the 3D Navier Stokes equations. This structure contains the physical parameters, variables, and function pointers specific to the 3D Navier-Stokes equations.
double * u
Definition: hypar.h:116
Some basic definitions and macros.
3D Navier Stokes equations (compressible flows)
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _YDIR_
Definition: euler2d.h:41
Contains structure definition for hypar.
#define _ArrayIndex1D_(N, imax, i, ghost, index)
static const int _NavierStokes3D_stride_
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
double NavierStokes3DComputeCFL(void *s, void *m, double dt, double t)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
int ghosts
Definition: hypar.h:52
#define _MODEL_NVARS_
Definition: euler1d.h:58
Contains macros and function definitions for common array operations.
double * dxinv
Definition: hypar.h:110
#define _NavierStokes3DGetFlowVar_(u, stride, rho, vx, vy, vz, e, P, gamma)