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

Go to the source code of this file.

Functions

double Numa3DComputeCFL (void *, void *, double, double)
 
int Numa3DFlux (double *, double *, int, void *, double)
 
int Numa3DStiffFlux (double *, double *, int, void *, double)
 
int Numa3DSource (double *, double *, void *, void *, double)
 
int Numa3DRusanovFlux (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int Numa3DRusanovLinearFlux (double *, double *, double *, double *, double *, double *, int, void *, double)
 
void Numa3DCalculateStandardAtmosphere_1 (void *, double, double *, double *, double *, double *)
 
void Numa3DCalculateStandardAtmosphere_2 (void *, double, double *, double *, double *, double *)
 
int Numa3DInitialize (void *s, void *m)
 

Function Documentation

double Numa3DComputeCFL ( void *  ,
void *  ,
double  ,
double   
)

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
int Numa3DFlux ( double *  ,
double *  ,
int  ,
void *  ,
double   
)

Definition at line 7 of file Numa3DFlux.c.

8 {
9  HyPar *solver = (HyPar*) s;
10  Numa3D *param = (Numa3D*) solver->physics;
11  int i;
12 
13  int *dim = solver->dim_local;
14  int ghosts = solver->ghosts;
15  int ndims = solver->ndims;
16  int index[ndims], bounds[ndims], offset[ndims];
17 
18  /* set bounds for array index to include ghost points */
19  _ArrayCopy1D_(dim,bounds,ndims);
20  for (i=0; i<ndims; i++) bounds[i] += 2*ghosts;
21 
22  /* set offset such that index is compatible with ghost point arrangement */
23  _ArraySetValue_(offset,ndims,-ghosts);
24 
25  int done = 0; _ArraySetValue_(index,ndims,0);
26  while (!done) {
27  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
28  double drho,uvel,vvel,wvel,dT,dP,rho0,T0,P0,EP,zcoord;
29 
30  _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->x,zcoord);
31  param->StandardAtmosphere(param,zcoord,&EP,&P0,&rho0,&T0);
32 
33  _Numa3DGetFlowVars_ ((u+_MODEL_NVARS_*p),drho,uvel,vvel,wvel,dT,rho0);
34  _Numa3DComputePressure_ (param,T0,dT,P0,dP);
35  _Numa3DSetFlux_ ((f+_MODEL_NVARS_*p),dir,drho,uvel,vvel,wvel,dT,dP,rho0,T0);
36 
37  _ArrayIncrementIndex_(ndims,bounds,index,done);
38  }
39 
40  return(0);
41 }
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _Numa3DSetFlux_(f, dir, drho, uvel, vvel, wvel, dT, dP, rho0, T0)
Definition: numa3d.h:48
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 _ZDIR_
Definition: numa3d.h:128
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArrayCopy1D_(x, y, size)
void(* StandardAtmosphere)(void *, double, double *, double *, double *, double *)
Definition: numa3d.h:139
#define _Numa3DComputePressure_(params, T0, dT, P0, dP)
Definition: numa3d.h:103
int ndims
Definition: hypar.h:26
#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
int Numa3DStiffFlux ( double *  ,
double *  ,
int  ,
void *  ,
double   
)

Definition at line 43 of file Numa3DFlux.c.

44 {
45  HyPar *solver = (HyPar*) s;
46  Numa3D *param = (Numa3D*) solver->physics;
47  int i;
48 
49  int *dim = solver->dim_local;
50  int ghosts = solver->ghosts;
51  int ndims = solver->ndims;
52  int index[ndims], bounds[ndims], offset[ndims];
53 
54  /* set bounds for array index to include ghost points */
55  _ArrayCopy1D_(dim,bounds,ndims);
56  for (i=0; i<ndims; i++) bounds[i] += 2*ghosts;
57 
58  /* set offset such that index is compatible with ghost point arrangement */
59  _ArraySetValue_(offset,ndims,-ghosts);
60 
61  int done = 0; _ArraySetValue_(index,ndims,0);
62  while (!done) {
63  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
64  double drho,uvel,vvel,wvel,dT,dP,rho0,T0,P0,EP,zcoord;
65 
66  _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->x,zcoord);
67  param->StandardAtmosphere(param,zcoord,&EP,&P0,&rho0,&T0);
68 
69  _Numa3DGetFlowVars_ ((u+_MODEL_NVARS_*p),drho,uvel,vvel,wvel,dT,rho0);
70  _Numa3DComputeLinearizedPressure_ (param,T0,dT,P0,dP);
71  _Numa3DSetLinearFlux_ ((f+_MODEL_NVARS_*p),dir,drho,uvel,vvel,wvel,dT,dP,rho0,T0);
72 
73  _ArrayIncrementIndex_(ndims,bounds,index,done);
74  }
75 
76  return(0);
77 }
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _MODEL_NVARS_
Definition: euler1d.h:58
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
#define _Numa3DComputeLinearizedPressure_(params, T0, dT, P0, dP)
Definition: numa3d.h:112
int ghosts
Definition: hypar.h:52
#define _ZDIR_
Definition: numa3d.h:128
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArrayCopy1D_(x, y, size)
void(* StandardAtmosphere)(void *, double, double *, double *, double *, double *)
Definition: numa3d.h:139
#define _Numa3DSetLinearFlux_(f, dir, drho, uvel, vvel, wvel, dT, dP, rho0, T0)
Definition: numa3d.h:71
int ndims
Definition: hypar.h:26
#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
int Numa3DSource ( double *  ,
double *  ,
void *  ,
void *  ,
double   
)

Definition at line 7 of file Numa3DSource.c.

8 {
9  HyPar *solver = (HyPar*) s;
10  Numa3D *param = (Numa3D*) solver->physics;
11  int i;
12 
13  int *dim = solver->dim_local;
14  int ghosts = solver->ghosts;
15  int ndims = solver->ndims;
16  int index[ndims], bounds[ndims], offset[ndims];
17 
18  /* set bounds for array index to include ghost points */
19  _ArrayCopy1D_(dim,bounds,ndims);
20  for (i=0; i<ndims; i++) bounds[i] += 2*ghosts;
21 
22  /* set offset such that index is compatible with ghost point arrangement */
23  _ArraySetValue_(offset,ndims,-ghosts);
24 
25  int done = 0; _ArraySetValue_(index,ndims,0);
26  while (!done) {
27  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
28  double drho,uvel,vvel,wvel,dT,rho0,P0,EP,T0,zcoord;
29 
30  _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->x,zcoord);
31  param->StandardAtmosphere(param,zcoord,&EP,&P0,&rho0,&T0);
32  _Numa3DGetFlowVars_((u+_MODEL_NVARS_*p),drho,uvel,vvel,wvel,dT,rho0);
33  _Numa3DSetSource_ ((S+_MODEL_NVARS_*p),param,uvel,vvel,drho,rho0);
34 
35  _ArrayIncrementIndex_(ndims,bounds,index,done);
36 
37  /* some useless statements to avoid compiler warnings */
38  dT = wvel;
39  wvel = dT;
40  }
41 
42  return(0);
43 }
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _MODEL_NVARS_
Definition: euler1d.h:58
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
#define _Numa3DSetSource_(s, param, uvel, vvel, drho, rho0)
Definition: numa3d.h:94
int ghosts
Definition: hypar.h:52
#define _ZDIR_
Definition: numa3d.h:128
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArrayCopy1D_(x, y, size)
void(* StandardAtmosphere)(void *, double, double *, double *, double *, double *)
Definition: numa3d.h:139
int ndims
Definition: hypar.h:26
#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
int Numa3DRusanovFlux ( double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
int  ,
void *  ,
double   
)

Definition at line 9 of file Numa3DUpwind.c.

10 {
11  HyPar *solver = (HyPar*) s;
12  Numa3D *param = (Numa3D*) solver->physics;
13  int done;
14 
15  int *dim = solver->dim_local;
16  int ghosts = solver->ghosts;
17 
18  int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_];
19  _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1;
20  _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1;
21 
22  done = 0; int index_outer[3] = {0,0,0}, index_inter[3];
23  while (!done) {
24  _ArrayCopy1D3_(index_outer,index_inter,_MODEL_NDIMS_);
25  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
26  int p; _ArrayIndex1D3_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
27  double udiff[_MODEL_NVARS_],drho,vel[3],dT,rho0,P0,T0,EP,c;
28  double zcoordL, zcoordR;
29 
30  if (dir == _ZDIR_) {
31  _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_]-1),dim,ghosts,solver->x,zcoordL);
32  _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->x,zcoordR);
33  } else {
34  _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->x,zcoordL);
35  zcoordR = zcoordL;
36  }
37 
38  /* Rusanov's upwinding scheme */
39 
40  udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]);
41  udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]);
42  udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]);
43  udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]);
44  udiff[4] = 0.5 * (uR[_MODEL_NVARS_*p+4] - uL[_MODEL_NVARS_*p+4]);
45 
46  /* left of the interface */
47  param->StandardAtmosphere(param,zcoordL,&EP,&P0,&rho0,&T0);
48  _Numa3DGetFlowVars_ ((uL+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0);
49  _Numa3DComputeSpeedofSound_ (param->gamma,param->R,T0,dT,rho0,drho,EP,c);
50  double alphaL = c + absolute(vel[dir]);
51 
52  /* right of the interface */
53  param->StandardAtmosphere(param,zcoordR,&EP,&P0,&rho0,&T0);
54  _Numa3DGetFlowVars_ ((uR+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0);
55  _Numa3DComputeSpeedofSound_ (param->gamma,param->R,T0,dT,rho0,drho,EP,c);
56  double alphaR = c + absolute(vel[dir]);
57 
58  double alpha = max(alphaL,alphaR);
59  fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0])-alpha*udiff[0];
60  fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1])-alpha*udiff[1];
61  fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2])-alpha*udiff[2];
62  fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3])-alpha*udiff[3];
63  fI[_MODEL_NVARS_*p+4] = 0.5*(fL[_MODEL_NVARS_*p+4]+fR[_MODEL_NVARS_*p+4])-alpha*udiff[4];
64  }
65  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
66  }
67 
68  return(0);
69 }
#define _ArrayIndex1D3_(N, imax, i, ghost, index)
#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 _ArrayCopy1D3_(x, y, size)
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
#define _MODEL_NDIMS_
Definition: euler1d.h:56
int ghosts
Definition: hypar.h:52
#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
#define absolute(a)
Definition: math_ops.h:32
#define max(a, b)
Definition: math_ops.h:18
#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
int Numa3DRusanovLinearFlux ( double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
int  ,
void *  ,
double   
)

Definition at line 71 of file Numa3DUpwind.c.

72 {
73  HyPar *solver = (HyPar*) s;
74  Numa3D *param = (Numa3D*) solver->physics;
75  int done;
76 
77  int *dim = solver->dim_local;
78  int ghosts = solver->ghosts;
79 
80  int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_];
81  _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1;
82  _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1;
83 
84  done = 0; int index_outer[3] = {0,0,0}, index_inter[3];
85  while (!done) {
86  _ArrayCopy1D3_(index_outer,index_inter,_MODEL_NDIMS_);
87  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
88  int p; _ArrayIndex1D3_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
89  double udiff[_MODEL_NVARS_],drho,vel[3],dT,rho0,P0,T0,EP,c;
90  double zcoordL, zcoordR;
91 
92  if (dir == _ZDIR_) {
93  _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_]-1),dim,ghosts,solver->x,zcoordL);
94  _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->x,zcoordR);
95  } else {
96  _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->x,zcoordL);
97  zcoordR = zcoordL;
98  }
99 
100  /* Rusanov's upwinding scheme */
101 
102  udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]);
103  udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]);
104  udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]);
105  udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]);
106  udiff[4] = 0.5 * (uR[_MODEL_NVARS_*p+4] - uL[_MODEL_NVARS_*p+4]);
107 
108  /* left of the interface */
109  param->StandardAtmosphere (param,zcoordL,&EP,&P0,&rho0,&T0);
110  _Numa3DGetFlowVars_ ((uL+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0);
111  _Numa3DComputeLinearizedSpeedofSound_ (param->gamma,param->R,T0,rho0,EP,c);
112  double alphaL = c + absolute(vel[dir]);
113 
114  /* right of the interface */
115  param->StandardAtmosphere(param,zcoordR,&EP,&P0,&rho0,&T0);
116  _Numa3DGetFlowVars_ ((uR+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0);
117  _Numa3DComputeLinearizedSpeedofSound_ (param->gamma,param->R,T0,rho0,EP,c);
118  double alphaR = c + absolute(vel[dir]);
119 
120  double alpha = max(alphaL,alphaR);
121  fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0])-alpha*udiff[0];
122  fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1])-alpha*udiff[1];
123  fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2])-alpha*udiff[2];
124  fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3])-alpha*udiff[3];
125  fI[_MODEL_NVARS_*p+4] = 0.5*(fL[_MODEL_NVARS_*p+4]+fR[_MODEL_NVARS_*p+4])-alpha*udiff[4];
126 
127  vel[0] = dT; /* useless statement to avoid compiler warning */
128  }
129  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
130  }
131 
132  return(0);
133 }
#define _ArrayIndex1D3_(N, imax, i, ghost, index)
#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 _ArrayCopy1D3_(x, y, size)
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
#define _MODEL_NDIMS_
Definition: euler1d.h:56
int ghosts
Definition: hypar.h:52
#define _ZDIR_
Definition: numa3d.h:128
void(* StandardAtmosphere)(void *, double, double *, double *, double *, double *)
Definition: numa3d.h:139
double gamma
Definition: numa3d.h:129
#define _Numa3DComputeLinearizedSpeedofSound_(gamma, R, T0, rho0, EP, c)
Definition: numa3d.h:123
#define absolute(a)
Definition: math_ops.h:32
#define max(a, b)
Definition: math_ops.h:18
#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
void Numa3DCalculateStandardAtmosphere_1 ( void *  ,
double  ,
double *  ,
double *  ,
double *  ,
double *   
)

Definition at line 5 of file Numa3DFunctions.c.

6 {
7  Numa3D *physics = (Numa3D*) p;
8 
9  double R = physics->R;
10  double gamma = physics->gamma;
11  double g = physics->g;
12 
13  /* reference quantities at zero altitude */
14  double P0, T0;
15  P0 = physics->Pref;
16  T0 = physics->Tref;
17 
18  double inv_gamma_m1 = 1.0/(gamma-1.0);
19  double Cp = gamma * inv_gamma_m1 * R;
20 
21  double theta = T0;
22  *ExnerP = 1.0 - (g/(Cp*theta))*z;
23  *P = P0 * raiseto((*ExnerP),gamma*inv_gamma_m1);
24  *rho = (P0/(R*theta)) * raiseto((*ExnerP),inv_gamma_m1);
25  *T = (*rho) * theta;
26 
27  return(0);
28 }
#define raiseto(x, a)
Definition: math_ops.h:37
double Tref
Definition: numa3d.h:136
double R
Definition: numa3d.h:130
double Pref
Definition: numa3d.h:136
Definition: numa3d.h:128
double gamma
Definition: numa3d.h:129
double g
Definition: numa3d.h:132
void Numa3DCalculateStandardAtmosphere_2 ( void *  ,
double  ,
double *  ,
double *  ,
double *  ,
double *   
)

Definition at line 30 of file Numa3DFunctions.c.

31 {
32  Numa3D *physics = (Numa3D*) p;
33 
34  double R = physics->R;
35  double gamma = physics->gamma;
36  double g = physics->g;
37 
38  /* reference quantities at zero altitude */
39  double P0, T0;
40  P0 = physics->Pref;
41  T0 = physics->Tref;
42 
43  double BV = 0.01; /* Brunt-Vaisala frequency */
44  double inv_gamma_m1 = 1.0/(gamma-1.0);
45  double Cp = gamma * inv_gamma_m1 * R;
46 
47  double term = BV*BV*z/g;
48  double theta = T0 * exp(term);
49  *ExnerP = 1.0 + (g*g/(Cp*T0*BV*BV)) * (exp(-term) - 1.0);
50  *P = P0 * raiseto((*ExnerP),gamma*inv_gamma_m1);
51  *rho = (P0/(R*theta)) * raiseto((*ExnerP),inv_gamma_m1);
52  *T = (*rho) * theta;
53 
54  return(0);
55 }
#define raiseto(x, a)
Definition: math_ops.h:37
double Tref
Definition: numa3d.h:136
double R
Definition: numa3d.h:130
double Pref
Definition: numa3d.h:136
Definition: numa3d.h:128
double gamma
Definition: numa3d.h:129
double g
Definition: numa3d.h:132
int Numa3DInitialize ( void *  s,
void *  m 
)

Definition at line 24 of file Numa3DInitialize.c.

25 {
26  HyPar *solver = (HyPar*) s;
27  MPIVariables *mpi = (MPIVariables*) m;
28  Numa3D *physics = (Numa3D*) solver->physics;
29  int ferr = 0;
30 
31  static int count = 0;
32 
33  if (solver->nvars != _MODEL_NVARS_) {
34  fprintf(stderr,"Error in Numa3DInitialize(): nvars has to be %d.\n",_MODEL_NVARS_);
35  return(1);
36  }
37  if (solver->ndims != _MODEL_NDIMS_) {
38  fprintf(stderr,"Error in Numa3DInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_);
39  return(1);
40  }
41 
42  /* default values */
43  physics->gamma = 1.4;
44  physics->R = 287.058; /* J kg^{-1} K^{-1} */
45  physics->Omega = 7.2921150E-05; /* rad s^{-1} */
46  physics->g = 9.8; /* m s^{-2} */
47 
48  physics->Pref = 101327.0; /* N m^{-2} */
49  physics->Tref = 288.15; /* Kelvin */
50 
51  strcpy(physics->upwind,_RUSANOV_UPWINDING_);
52 
53  /* default choice of initial atmosphere */
54  physics->init_atmos = 1;
55 
56  /* reading physical model specific inputs - all processes */
57  if (!mpi->rank) {
58  FILE *in;
59  if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n");
60  in = fopen("physics.inp","r");
61  if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n");
62  else {
63  char word[_MAX_STRING_SIZE_];
64  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
65  if (!strcmp(word, "begin")){
66  while (strcmp(word, "end")){
67  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
68  if (!strcmp(word, "gamma")) {
69  ferr = fscanf(in,"%lf",&physics->gamma); if (ferr != 1) return(1);
70  } else if (!strcmp(word,"R")) {
71  ferr = fscanf(in,"%lf",&physics->R); if (ferr != 1) return(1);
72  } else if (!strcmp(word,"g")) {
73  ferr = fscanf(in,"%lf",&physics->g); if (ferr != 1) return(1);
74  } else if (!strcmp(word,"Omega")) {
75  ferr = fscanf(in,"%lf",&physics->Omega); if (ferr != 1) return(1);
76  } else if (!strcmp(word,"Pref")) {
77  ferr = fscanf(in,"%lf",&physics->Pref); if (ferr != 1) return(1);
78  } else if (!strcmp(word,"Tref")) {
79  ferr = fscanf(in,"%lf",&physics->Tref); if (ferr != 1) return(1);
80  } else if (!strcmp(word,"init_atmos")) {
81  ferr = fscanf(in,"%d",&physics->init_atmos); if (ferr != 1) return(1);
82  } else if (!strcmp(word,"upwinding")) {
83  ferr = fscanf(in,"%s",physics->upwind); if (ferr != 1) return(1);
84  } else if (strcmp(word,"end")) {
85  char useless[_MAX_STRING_SIZE_];
86  ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr);
87  printf("Warning: keyword %s in file \"physics.inp\" with value %s not ",word,useless);
88  printf("recognized or extraneous. Ignoring.\n");
89  }
90  }
91  } else {
92  fprintf(stderr,"Error: Illegal format in file \"physics.inp\".\n");
93  return(1);
94  }
95  }
96  fclose(in);
97  }
98 
99 #ifndef serial
100  IERR MPIBroadcast_double (&physics->gamma ,1 ,0,&mpi->world); CHECKERR(ierr);
101  IERR MPIBroadcast_double (&physics->R ,1 ,0,&mpi->world); CHECKERR(ierr);
102  IERR MPIBroadcast_double (&physics->g ,1 ,0,&mpi->world); CHECKERR(ierr);
103  IERR MPIBroadcast_double (&physics->Omega ,1 ,0,&mpi->world); CHECKERR(ierr);
104  IERR MPIBroadcast_double (&physics->Pref ,1 ,0,&mpi->world); CHECKERR(ierr);
105  IERR MPIBroadcast_double (&physics->Tref ,1 ,0,&mpi->world); CHECKERR(ierr);
106  IERR MPIBroadcast_integer (&physics->init_atmos ,1 ,0,&mpi->world); CHECKERR(ierr);
108 #endif
109 
110  /* calculate the mean hydrostatic atmosphere as a function of altitude */
111  if (physics->init_atmos == 1) {
113  } else if (physics->init_atmos == 2) {
115  } else {
116  if (!mpi->rank) {
117  fprintf(stderr,"Error in Numa3DInitialize(): invalid choice of initial atmosphere (init_atmos).\n");
118  return(1);
119  }
120  }
121  CHECKERR(ierr);
122 
123  /* initializing physical model-specific functions */
124  if (!strcmp(solver->SplitHyperbolicFlux,"yes"))
125  solver->dFFunction = Numa3DStiffFlux;
126  else solver->dFFunction = NULL;
127  solver->FFunction = Numa3DFlux;
128  solver->ComputeCFL = Numa3DComputeCFL;
129  solver->SFunction = Numa3DSource;
130  if (!strcmp(physics->upwind,_RUSANOV_UPWINDING_)) {
131  solver->Upwind = Numa3DRusanovFlux;
132  if (!strcmp(solver->SplitHyperbolicFlux,"yes"))
134  else solver->UpwinddF = NULL;
135  } else {
136  if (!mpi->rank) fprintf(stderr,"Error in Numa3DInitialize(): Invalid choice of upwinding scheme.\n");
137  return(1);
138  }
139 
140  /* set the value of gamma in all the boundary objects */
141  int n;
142  DomainBoundary *boundary = (DomainBoundary*) solver->boundary;
143  for (n = 0; n < solver->nBoundaryZones; n++) boundary[n].gamma = physics->gamma;
144 
145  count++;
146  return(0);
147 }
int(* dFFunction)(double *, double *, int, void *, double)
Definition: hypar.h:280
double(* ComputeCFL)(void *, void *, double, double)
Definition: hypar.h:269
int Numa3DSource(double *, double *, void *, void *, double)
Definition: Numa3DSource.c:7
int MPIBroadcast_double(double *, int, int, void *)
Definition: MPIBroadcast.c:9
#define _MODEL_NVARS_
Definition: euler1d.h:58
double Tref
Definition: numa3d.h:136
int Numa3DRusanovLinearFlux(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: Numa3DUpwind.c:71
void * physics
Definition: hypar.h:266
int(* Upwind)(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: hypar.h:295
int(* UpwinddF)(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: hypar.h:300
double R
Definition: numa3d.h:130
int(* FFunction)(double *, double *, int, void *, double)
Definition: hypar.h:276
#define _MODEL_NDIMS_
Definition: euler1d.h:56
MPI_Comm world
double Pref
Definition: numa3d.h:136
#define _MAX_STRING_SIZE_
Definition: basic.h:14
int Numa3DFlux(double *f, double *u, int dir, void *s, double t)
Definition: Numa3DFlux.c:7
int Numa3DCalculateStandardAtmosphere_2(void *p, double z, double *ExnerP, double *P, double *rho, double *T)
Definition: numa3d.h:128
int Numa3DRusanovFlux(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: Numa3DUpwind.c:9
void * boundary
Definition: hypar.h:159
Structure containing the variables and function pointers defining a boundary.
int Numa3DStiffFlux(double *f, double *u, int dir, void *s, double t)
Definition: Numa3DFlux.c:43
int nBoundaryZones
Definition: hypar.h:157
double Numa3DComputeCFL(void *s, void *m, double dt, double t)
double Omega
Definition: numa3d.h:131
void(* StandardAtmosphere)(void *, double, double *, double *, double *, double *)
Definition: numa3d.h:139
int(* SFunction)(double *, double *, void *, void *, double)
Definition: hypar.h:317
double gamma
Definition: numa3d.h:129
int nvars
Definition: hypar.h:29
char upwind[_MAX_STRING_SIZE_]
Definition: numa3d.h:142
#define CHECKERR(ierr)
Definition: basic.h:18
double g
Definition: numa3d.h:132
int MPIBroadcast_character(char *, int, int, void *)
Definition: MPIBroadcast.c:37
char SplitHyperbolicFlux[_MAX_STRING_SIZE_]
Definition: hypar.h:92
int ndims
Definition: hypar.h:26
#define IERR
Definition: basic.h:16
int Numa3DCalculateStandardAtmosphere_1(void *p, double z, double *ExnerP, double *P, double *rho, double *T)
Structure of MPI-related variables.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _RUSANOV_UPWINDING_
Definition: numa2d.h:130
int MPIBroadcast_integer(int *, int, int, void *)
Definition: MPIBroadcast.c:23
int init_atmos
Definition: numa3d.h:133