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

Go to the source code of this file.

Data Structures

struct  Numa3D
 

Macros

#define _NUMA3D_   "numa3d"
 
#define _MODEL_NDIMS_   3
 
#define _MODEL_NVARS_   5
 
#define _XDIR_   0
 
#define _YDIR_   1
 
#define _ZDIR_   2
 
#define _Numa3DGetFlowVars_(u, drho, uvel, vvel, wvel, dT, rho0)
 
#define _Numa3DSetFlux_(f, dir, drho, uvel, vvel, wvel, dT, dP, rho0, T0)
 
#define _Numa3DSetLinearFlux_(f, dir, drho, uvel, vvel, wvel, dT, dP, rho0, T0)
 
#define _Numa3DSetSource_(s, param, uvel, vvel, drho, rho0)
 
#define _Numa3DComputePressure_(params, T0, dT, P0, dP)
 
#define _Numa3DComputeLinearizedPressure_(params, T0, dT, P0, dP)
 
#define _Numa3DComputeSpeedofSound_(gamma, R, T0, dT, rho0, drho, EP, c)
 
#define _Numa3DComputeLinearizedSpeedofSound_(gamma, R, T0, rho0, EP, c)
 
#define _RUSANOV_UPWINDING_   "rusanov"
 
#define _RF_CHAR_UPWINDING_   "rf-char" /* does not work! */
 

Functions

int Numa3DInitialize (void *, void *)
 
int Numa3DCleanup (void *)
 

Macro Definition Documentation

#define _NUMA3D_   "numa3d"

Definition at line 26 of file numa3d.h.

#define _MODEL_NDIMS_   3

Definition at line 31 of file numa3d.h.

#define _MODEL_NVARS_   5

Definition at line 32 of file numa3d.h.

#define _XDIR_   0

Definition at line 35 of file numa3d.h.

#define _YDIR_   1

Definition at line 36 of file numa3d.h.

#define _ZDIR_   2

Definition at line 37 of file numa3d.h.

#define _Numa3DGetFlowVars_ (   u,
  drho,
  uvel,
  vvel,
  wvel,
  dT,
  rho0 
)
Value:
{ \
drho = u[0]; \
uvel = u[1]/(rho0+drho); \
vvel = u[2]/(rho0+drho); \
wvel = u[3]/(rho0+drho); \
dT = u[4]; \
}

Definition at line 39 of file numa3d.h.

#define _Numa3DSetFlux_ (   f,
  dir,
  drho,
  uvel,
  vvel,
  wvel,
  dT,
  dP,
  rho0,
  T0 
)
Value:
{ \
if (dir == _XDIR_) { \
f[0] = (rho0+drho) * uvel; \
f[1] = (rho0+drho)*uvel*uvel + dP; \
f[2] = (rho0+drho)*uvel*vvel; \
f[3] = (rho0+drho)*uvel*wvel; \
f[4] = uvel*(dT+T0); \
} else if (dir == _YDIR_) { \
f[0] = (rho0+drho) * vvel; \
f[1] = (rho0+drho)*uvel*vvel; \
f[2] = (rho0+drho)*vvel*vvel + dP; \
f[3] = (rho0+drho)*wvel*vvel; \
f[4] = vvel*(dT+T0); \
} else if (dir == _ZDIR_) { \
f[0] = (rho0+drho) * wvel; \
f[1] = (rho0+drho)*uvel*wvel; \
f[2] = (rho0+drho)*vvel*wvel; \
f[3] = (rho0+drho)*wvel*wvel + dP; \
f[4] = wvel*(dT+T0); \
} \
}
#define _YDIR_
Definition: numa3d.h:36
#define _ZDIR_
Definition: numa3d.h:37
#define _XDIR_
Definition: numa3d.h:35

Definition at line 48 of file numa3d.h.

#define _Numa3DSetLinearFlux_ (   f,
  dir,
  drho,
  uvel,
  vvel,
  wvel,
  dT,
  dP,
  rho0,
  T0 
)
Value:
{ \
if (dir == _XDIR_) { \
f[0] = (rho0+drho) * uvel; \
f[1] = dP; \
f[2] = 0.0; \
f[3] = 0.0; \
f[4] = (rho0+drho)*uvel*T0/rho0; \
} else if (dir == _YDIR_) { \
f[0] = (rho0+drho) * vvel; \
f[1] = 0.0; \
f[2] = dP; \
f[3] = 0.0; \
f[4] = (rho0+drho)*vvel*T0/rho0; \
} else if (dir == _ZDIR_) { \
f[0] = (rho0+drho) * wvel; \
f[1] = 0.0; \
f[2] = 0.0; \
f[3] = dP; \
f[4] = (rho0+drho)*wvel*T0/rho0; \
} \
}
#define _YDIR_
Definition: numa3d.h:36
#define _ZDIR_
Definition: numa3d.h:37
#define _XDIR_
Definition: numa3d.h:35

Definition at line 71 of file numa3d.h.

#define _Numa3DSetSource_ (   s,
  param,
  uvel,
  vvel,
  drho,
  rho0 
)
Value:
{ \
s[0] = 0.0; \
s[1] = 2.0*param->Omega*vvel*(rho0+drho); \
s[2] = -2.0*param->Omega*uvel*(rho0+drho); \
s[3] = -param->g*drho; \
s[4] = 0.0; \
}

Definition at line 94 of file numa3d.h.

#define _Numa3DComputePressure_ (   params,
  T0,
  dT,
  P0,
  dP 
)
Value:
{ \
double gamma = params->gamma; \
double Pref = params->Pref; \
double R = params->R; \
double P_total = Pref * raiseto((R*(T0+dT)/Pref),gamma); \
dP = P_total - P0; \
}
#define raiseto(x, a)
Definition: math_ops.h:37

Definition at line 103 of file numa3d.h.

#define _Numa3DComputeLinearizedPressure_ (   params,
  T0,
  dT,
  P0,
  dP 
)
Value:
{ \
double gamma = params->gamma; \
dP = (gamma*P0/T0) * dT; \
}

Definition at line 112 of file numa3d.h.

#define _Numa3DComputeSpeedofSound_ (   gamma,
  R,
  T0,
  dT,
  rho0,
  drho,
  EP,
 
)
Value:
{ \
c = sqrt(gamma*R*(T0+dT)*EP/(rho0+drho)); \
}

Definition at line 118 of file numa3d.h.

#define _Numa3DComputeLinearizedSpeedofSound_ (   gamma,
  R,
  T0,
  rho0,
  EP,
 
)
Value:
{ \
c = sqrt(gamma*R*T0*EP/rho0); \
}

Definition at line 123 of file numa3d.h.

#define _RUSANOV_UPWINDING_   "rusanov"

Definition at line 149 of file numa3d.h.

#define _RF_CHAR_UPWINDING_   "rf-char" /* does not work! */

Definition at line 150 of file numa3d.h.

Function Documentation

int Numa3DInitialize ( void *  ,
void *   
)

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
int Numa3DCleanup ( void *  )

Definition at line 5 of file Numa3DCleanup.c.

6 {
7  return(0);
8 }