HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
LinearADRComputeCFL.c
Go to the documentation of this file.
1 
6 #include <float.h>
7 #include <arrayfunctions.h>
9 #include <mpivars.h>
10 #include <hypar.h>
11 
15 double LinearADRComputeCFL( void *s,
16  void *m,
17  double dt,
18  double t
19  )
20 {
21  HyPar *solver = (HyPar*) s;
22  LinearADR *params = (LinearADR*) 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 
29  double max_cfl = 0;
30  if (params->constant_advection == 1) {
31 
32  int d, i, v;
33  for (d = 0; d < ndims; d++) {
34  for (i = 0; i < dim[d]; i++) {
35  for (v = 0; v < nvars; v++) {
36  double dxinv; _GetCoordinate_(d,i,dim,ghosts,solver->dxinv,dxinv);
37  double local_cfl = params->a[nvars*d+v]*dt*dxinv;
38  if (local_cfl > max_cfl) max_cfl = local_cfl;
39  }
40  }
41  }
42 
43  } else if (params->constant_advection == 0) {
44 
45  int d;
46  for (d = 0; d < ndims; d++) {
47  int index[ndims];
48  int done = 0; _ArraySetValue_(index,ndims,0);
49  while (!done) {
50  int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p);
51  double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv);
52  int v;
53  for (v = 0; v < nvars; v++) {
54  double a = params->a[nvars*ndims*p+nvars*d+v];
55  double local_cfl = a*dt*dxinv;
56  if (local_cfl > max_cfl) max_cfl = local_cfl;
57  }
58  _ArrayIncrementIndex_(ndims,dim,index,done);
59  }
60  }
61 
62  }
63 
64  return(max_cfl);
65 }
int constant_advection
Definition: linearadr.h:40
int nvars
Definition: hypar.h:29
MPI related function definitions.
int ndims
Definition: hypar.h:26
Structure containing variables and parameters specific to the linear advection-diffusion-reaction mod...
Definition: linearadr.h:37
double * a
Definition: linearadr.h:50
double LinearADRComputeCFL(void *s, void *m, double dt, double t)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
Contains structure definition for hypar.
#define _ArrayIndex1D_(N, imax, i, ghost, index)
Linear Advection-Diffusion-Reaction model.
#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