HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
Euler2DComputeCFL.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <math.h>
3 #include <basic.h>
4 #include <arrayfunctions.h>
5 #include <mathfunctions.h>
7 #include <hypar.h>
8 
9 double Euler2DComputeCFL(void *s,void *m,double dt,double t)
10 {
11  HyPar *solver = (HyPar*) s;
12  Euler2D *param = (Euler2D*) solver->physics;
14 
15  int *dim = solver->dim_local;
16  int ghosts = solver->ghosts;
17  int ndims = solver->ndims;
18  int index[ndims];
19  double *u = solver->u;
20 
21  double max_cfl = 0;
22  int done = 0; _ArraySetValue_(index,ndims,0);
23  while (!done) {
24  int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p);
25  double rho,vx,vy,e,P,c,dxinv,dyinv,local_cfl[2];
26  _Euler2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param);
27 
28  c = sqrt(param->gamma*P/rho); /* speed of sound */
29  _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */
30  _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); /* 1/dy */
31 
32  local_cfl[_XDIR_] = (absolute(vx)+c)*dt*dxinv; /* local cfl for this grid point (x) */
33  local_cfl[_YDIR_] = (absolute(vy)+c)*dt*dyinv; /* local cfl for this grid point (y) */
34  if (local_cfl[_XDIR_] > max_cfl) max_cfl = local_cfl[_XDIR_];
35  if (local_cfl[_YDIR_] > max_cfl) max_cfl = local_cfl[_YDIR_];
36 
37  _ArrayIncrementIndex_(ndims,dim,index,done);
38  }
39 
40  return(max_cfl);
41 }
#define absolute(a)
Definition: math_ops.h:32
Contains function definitions for common mathematical functions.
double Euler2DComputeCFL(void *s, void *m, double dt, double t)
double * u
Definition: hypar.h:116
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
#define _Euler2DGetFlowVar_(u, rho, vx, vy, e, P, p)
Definition: euler2d.h:44
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _YDIR_
Definition: euler2d.h:41
double gamma
Definition: euler2d.h:245
Contains structure definition for hypar.
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#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
#define _DECLARE_IERR_
Definition: basic.h:17
Contains macros and function definitions for common array operations.
double * dxinv
Definition: hypar.h:110