HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Numa3DComputeCFL.c File Reference
#include <stdlib.h>
#include <math.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <mathfunctions.h>
#include <physicalmodels/numa3d.h>
#include <hypar.h>

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 9 of file Numa3DComputeCFL.c.

10 {
11  HyPar *solver = (HyPar*) s;
12  Numa3D *param = (Numa3D*) solver->physics;
13 
14  int *dim = solver->dim_local;
15  int ghosts = solver->ghosts;
16  int ndims = solver->ndims;
17  double *u = solver->u;
18  int index[ndims];
19 
20  double max_cfl = 0;
21  int done = 0; _ArraySetValue_(index,ndims,0);
22  while (!done) {
23  int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p);
24  double drho,uvel,vvel,wvel,dT,rho0,T0,P0,EP,c,zcoord;
25 
26  _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->x,zcoord);
27  param->StandardAtmosphere(param,zcoord,&EP,&P0,&rho0,&T0);
28  _Numa3DGetFlowVars_ ((u+_MODEL_NVARS_*p),drho,uvel,vvel,wvel,dT,rho0);
29  _Numa3DComputeSpeedofSound_ (param->gamma,param->R,T0,dT,rho0,drho,EP,c);
30 
31  double dxinv, dyinv, dzinv;
32  _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */
33  _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); /* 1/dy */
34  _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->dxinv,dzinv); /* 1/dz */
35 
36  double local_cfl[3];
37  local_cfl[_XDIR_] = (absolute(uvel)+c)*dt*dxinv; /* local cfl for this grid point (x) */
38  local_cfl[_YDIR_] = (absolute(vvel)+c)*dt*dyinv; /* local cfl for this grid point (y) */
39  local_cfl[_ZDIR_] = (absolute(wvel)+c)*dt*dzinv; /* local cfl for this grid point (z) */
40  if (local_cfl[_XDIR_] > max_cfl) max_cfl = local_cfl[_XDIR_];
41  if (local_cfl[_YDIR_] > max_cfl) max_cfl = local_cfl[_YDIR_];
42  if (local_cfl[_ZDIR_] > max_cfl) max_cfl = local_cfl[_ZDIR_];
43 
44  _ArrayIncrementIndex_(ndims,dim,index,done);
45  }
46 
47  return(max_cfl);
48 }
#define _YDIR_
Definition: euler2d.h:41
#define _ArraySetValue_(x, size, value)
double * u
Definition: hypar.h:116
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _MODEL_NVARS_
Definition: euler1d.h:58
void * physics
Definition: hypar.h:266
double R
Definition: numa3d.h:130
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)
#define _ZDIR_
Definition: numa3d.h:128
#define _Numa3DComputeSpeedofSound_(gamma, R, T0, dT, rho0, drho, EP, c)
Definition: numa3d.h:118
void(* StandardAtmosphere)(void *, double, double *, double *, double *, double *)
Definition: numa3d.h:139
double gamma
Definition: numa3d.h:129
double * dxinv
Definition: hypar.h:110
int ndims
Definition: hypar.h:26
#define absolute(a)
Definition: math_ops.h:32
#define _Numa3DGetFlowVars_(u, drho, uvel, vvel, wvel, dT, rho0)
Definition: numa3d.h:39
double * x
Definition: hypar.h:107
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _XDIR_
Definition: euler1d.h:75