HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
Euler1DComputeCFL.c
Go to the documentation of this file.
1 
6 #include <stdlib.h>
7 #include <basic.h>
8 #include <math.h>
9 #include <arrayfunctions.h>
10 #include <mathfunctions.h>
11 #include <physicalmodels/euler1d.h>
12 #include <hypar.h>
13 
18  void *s,
19  void *m,
20  double dt,
21  double t
22  )
23 {
24  HyPar *solver = (HyPar*) s;
25  Euler1D *param = (Euler1D*) solver->physics;
26 
27  int *dim = solver->dim_local;
28  int ghosts = solver->ghosts;
29  int ndims = solver->ndims;
30  int index[ndims];
31  double *u = solver->u;
32 
33  double max_cfl = 0;
34  int done = 0; _ArraySetValue_(index,ndims,0);
35  while (!done) {
36  int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p);
37  double rho, v, e, P, c, dxinv, local_cfl;
38  _Euler1DGetFlowVar_((u+_MODEL_NVARS_*p),rho,v,e,P,param);
39  _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */
40  c = sqrt(param->gamma*P/rho); /* speed of sound */
41  local_cfl = (absolute(v)+c)*dt*dxinv; /* local cfl for this grid point */
42  if (local_cfl > max_cfl) max_cfl = local_cfl;
43  _ArrayIncrementIndex_(ndims,dim,index,done);
44  }
45 
46  return(max_cfl);
47 }
double Euler1DComputeCFL(void *s, void *m, double dt, double t)
double gamma
Definition: euler1d.h:274
#define absolute(a)
Definition: math_ops.h:32
Contains function definitions for common mathematical functions.
Structure containing variables and parameters specific to the 1D Euler equations. This structure cont...
Definition: euler1d.h:273
double * u
Definition: hypar.h:116
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
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
1D Euler Equations (inviscid, compressible flows)
int ghosts
Definition: hypar.h:52
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _Euler1DGetFlowVar_(u, rho, v, e, P, p)
Definition: euler1d.h:81
Contains macros and function definitions for common array operations.
double * dxinv
Definition: hypar.h:110