HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
BurgersComputeCFL.c
Go to the documentation of this file.
1 
6 #include <basic.h>
7 #include <arrayfunctions.h>
9 #include <mpivars.h>
10 #include <hypar.h>
11 
15 double BurgersComputeCFL( void *s,
16  void *m,
17  double dt,
18  double t
19  )
20 {
21  HyPar *solver = (HyPar*) s;
22  Burgers *params = (Burgers*) solver->physics;
23 
24  int ndims = solver->ndims;
25  int nvars = solver->nvars;
26  int ghosts = solver->ghosts;
27  int *dim = solver->dim_local;
28  double *u = solver->u;
29 
30  int index[ndims], dir, v;
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  for (v=0; v<nvars; v++) {
37  for (dir=0; dir<ndims; dir++) {
38  double dxinv;
39  _GetCoordinate_(dir,index[dir],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */
40  double local_cfl = u[nvars*p+v]*dt*dxinv;
41  if (local_cfl > max_cfl) max_cfl = local_cfl;
42  }
43  }
44  _ArrayIncrementIndex_(ndims,dim,index,done);
45  }
46 
47  return(max_cfl);
48 }
int nvars
Definition: hypar.h:29
MPI related function definitions.
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.
double BurgersComputeCFL(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
int ghosts
Definition: hypar.h:52
Contains macros and function definitions for common array operations.
double * dxinv
Definition: hypar.h:110