HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BurgersComputeCFL.c File Reference

Contains the function to compute maximum CFL over the domain for the Burgers equation. More...

#include <basic.h>
#include <arrayfunctions.h>
#include <physicalmodels/burgers.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

double BurgersComputeCFL (void *s, void *m, double dt, double t)
 

Detailed Description

Contains the function to compute maximum CFL over the domain for the Burgers equation.

Author
Debojyoti Ghosh

Definition in file BurgersComputeCFL.c.

Function Documentation

double BurgersComputeCFL ( void *  s,
void *  m,
double  dt,
double  t 
)

Computes the maximum CFL number over the domain. Note that the CFL is computed over the local domain on this processor only.

Parameters
sSolver object of type HyPar
mMPI object of type MPIVariables
dtTime step size for which to compute the CFL
tTime

Definition at line 15 of file BurgersComputeCFL.c.

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 }
#define _ArraySetValue_(x, size, value)
double * u
Definition: hypar.h:116
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int * dim_local
Definition: hypar.h:37
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
int ghosts
Definition: hypar.h:52
#define _ArrayIndex1D_(N, imax, i, ghost, index)
int nvars
Definition: hypar.h:29
double * dxinv
Definition: hypar.h:110
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23