HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FPDoubleWellComputeCFL.c
Go to the documentation of this file.
1 #include <basic.h>
2 #include <mathfunctions.h>
4 #include <mpivars.h>
5 #include <hypar.h>
6 
7 double FPDoubleWellComputeCFL(void *s,void *m,double dt,double t)
8 {
9  HyPar *solver = (HyPar*) s;
10  int d, i, v;
11 
12  int ndims = solver->ndims;
13  int nvars = solver->nvars;
14  int ghosts = solver->ghosts;
15  int *dim = solver->dim_local;
16  double *dxinv = solver->dxinv;
17 
18  int offset = 0;
19  double max_cfl = 0;
20  for (d = 0; d < ndims; d++) {
21  for (i = 0; i < dim[d]; i++) {
22  for (v = 0; v < nvars; v++) {
23  double x; _GetCoordinate_(0,i,dim,ghosts,solver->x,x);
24  double local_cfl = absolute(drift(x)) * dt
25  * dxinv[offset+ghosts+i];
26  if (local_cfl > max_cfl) max_cfl = local_cfl;
27  }
28  }
29  offset += dim[d] + 2*ghosts;
30  }
31 
32  return(max_cfl);
33 }
int * dim_local
Definition: hypar.h:37
MPI related function definitions.
#define drift(x)
Definition: fpdoublewell.h:31
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
int ghosts
Definition: hypar.h:52
Contains function definitions for common mathematical functions.
int nvars
Definition: hypar.h:29
Contains structure definition for hypar.
double * dxinv
Definition: hypar.h:110
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
#define absolute(a)
Definition: math_ops.h:32
double * x
Definition: hypar.h:107
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
double FPDoubleWellComputeCFL(void *s, void *m, double dt, double t)