HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
VlasovComputeCFL.c
Go to the documentation of this file.
1 
6 #include <float.h>
7 #include <math.h>
8 #include <basic.h>
9 #include <arrayfunctions.h>
10 #include <physicalmodels/vlasov.h>
11 #include <mpivars.h>
12 #include <hypar.h>
13 
14 double VlasovAdvectionCoeff(int*, int, void*);
15 
19 double VlasovComputeCFL( void *s,
20  void *m,
21  double dt,
22  double t
23  )
24 {
25  HyPar *solver = (HyPar*) s;
26  Vlasov *params = (Vlasov*) solver->physics;
27 
28  int ndims = solver->ndims;
29  int ghosts = solver->ghosts;
30  int *dim = solver->dim_local;
31  double *u = solver->u;
32 
33  double max_cfl = 0;
34  int done = 0;
35  int index[ndims];
36  _ArraySetValue_(index,ndims,0);
37 
38  while (!done) {
39 
40  for (int dir=0; dir<ndims; dir++) {
41  double dxinv;
42  _GetCoordinate_(dir,index[dir],dim,ghosts,solver->dxinv,dxinv);
43  double eig = VlasovAdvectionCoeff(index, dir, solver);
44  double local_cfl = eig*dt*dxinv;
45  if (local_cfl > max_cfl) max_cfl = local_cfl;
46  }
47 
48  _ArrayIncrementIndex_(ndims,dim,index,done);
49  }
50 
51  return(max_cfl);
52 }
Definition: vlasov.h:57
MPI related function definitions.
double * u
Definition: hypar.h:116
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Vlasov Equation.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
double VlasovComputeCFL(void *s, void *m, double dt, double t)
Contains structure definition for hypar.
#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
double VlasovAdvectionCoeff(int *, int, void *)
Contains macros and function definitions for common array operations.
double * dxinv
Definition: hypar.h:110