HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
Numa2DComputeCFL.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 Numa2DComputeCFL(void *s,void *m,double dt,double t)
10 {
11  HyPar *solver = (HyPar*) s;
12  Numa2D *param = (Numa2D*) solver->physics;
13 
14  int *dim = solver->dim_local;
15  int ghosts = solver->ghosts;
16  int ndims = solver->ndims;
17  double *u = solver->u;
18  int index[ndims];
19 
20  double max_cfl = 0;
21  int done = 0; _ArraySetValue_(index,ndims,0);
22  while (!done) {
23  int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p);
24  double drho,uvel,vvel,dT,rho0,T0,P0,EP,c,ycoord;
25 
26  _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->x,ycoord);
27  param->StandardAtmosphere (param,ycoord,&EP,&P0,&rho0,&T0);
28  _Numa2DGetFlowVars_ ((u+_MODEL_NVARS_*p),drho,uvel,vvel,dT,rho0);
29  _Numa2DComputeSpeedofSound_ (param->gamma,param->R,T0,dT,rho0,drho,EP,c);
30 
31  double dxinv, dyinv;
32  _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */
33  _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); /* 1/dy */
34 
35  double local_cfl[2];
36  local_cfl[_XDIR_] = (absolute(uvel)+c)*dt*dxinv; /* local cfl for this grid point (x) */
37  local_cfl[_YDIR_] = (absolute(vvel)+c)*dt*dyinv; /* local cfl for this grid point (y) */
38  if (local_cfl[_XDIR_] > max_cfl) max_cfl = local_cfl[_XDIR_];
39  if (local_cfl[_YDIR_] > max_cfl) max_cfl = local_cfl[_YDIR_];
40 
41  _ArrayIncrementIndex_(ndims,dim,index,done);
42  }
43 
44  return(max_cfl);
45 }
#define _Numa2DComputeSpeedofSound_(gamma, R, T0, dT, rho0, drho, EP, c)
Definition: numa2d.h:99
#define absolute(a)
Definition: math_ops.h:32
Contains function definitions for common mathematical functions.
double * u
Definition: hypar.h:116
Some basic definitions and macros.
double * x
Definition: hypar.h:107
double R
Definition: numa2d.h:111
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
Definition: numa2d.h:109
#define _YDIR_
Definition: euler2d.h:41
Contains structure definition for hypar.
double gamma
Definition: numa2d.h:110
double Numa2DComputeCFL(void *s, void *m, double dt, double t)
#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 _Numa2DGetFlowVars_(u, drho, uvel, vvel, dT, rho0)
Definition: numa2d.h:33
#define _XDIR_
Definition: euler1d.h:75
int ghosts
Definition: hypar.h:52
#define _MODEL_NVARS_
Definition: euler1d.h:58
void(* StandardAtmosphere)(void *, double, double *, double *, double *, double *)
Definition: numa2d.h:120
Contains macros and function definitions for common array operations.
double * dxinv
Definition: hypar.h:110