HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
LinearADRComputeCFL.c File Reference

Compute the maximum CFL. More...

#include <float.h>
#include <arrayfunctions.h>
#include <physicalmodels/linearadr.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

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

Detailed Description

Compute the maximum CFL.

Author
Debojyoti Ghosh

Definition in file LinearADRComputeCFL.c.

Function Documentation

◆ LinearADRComputeCFL()

double LinearADRComputeCFL ( 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 LinearADRComputeCFL.c.

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
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
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#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
double * dxinv
Definition: hypar.h:110