HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
euler2d.h File Reference
#include <basic.h>

Go to the source code of this file.

Data Structures

struct  Euler2D
 

Macros

#define _EULER_2D_   "euler2d"
 
#define _MODEL_NDIMS_   2
 
#define _MODEL_NVARS_   4
 
#define _ROE_   "roe"
 
#define _RF_   "rf-char"
 
#define _LLF_   "llf-char"
 
#define _SWFS_   "steger-warming"
 
#define _XDIR_   0
 
#define _YDIR_   1
 
#define _Euler2DGetFlowVar_(u, rho, vx, vy, e, P, p)
 
#define _Euler2DSetFlux_(f, rho, vx, vy, e, P, p, dir)
 
#define _Euler2DRoeAverage_(uavg, uL, uR, p)
 
#define _Euler2DEigenvalues_(u, D, p, dir)
 
#define _Euler2DLeftEigenvectors_(u, L, p, dir)
 
#define _Euler2DRightEigenvectors_(u, R, p, dir)
 

Functions

int Euler2DInitialize (void *, void *)
 
int Euler2DCleanup (void *)
 

Data Structure Documentation

◆ Euler2D

struct Euler2D

Definition at line 244 of file euler2d.h.

Data Fields
double gamma
char upw_choice[_MAX_STRING_SIZE_]

Macro Definition Documentation

◆ _EULER_2D_

#define _EULER_2D_   "euler2d"

Definition at line 25 of file euler2d.h.

◆ _MODEL_NDIMS_

#define _MODEL_NDIMS_   2

Definition at line 30 of file euler2d.h.

◆ _MODEL_NVARS_

#define _MODEL_NVARS_   4

Definition at line 31 of file euler2d.h.

◆ _ROE_

#define _ROE_   "roe"

Definition at line 34 of file euler2d.h.

◆ _RF_

#define _RF_   "rf-char"

Definition at line 35 of file euler2d.h.

◆ _LLF_

#define _LLF_   "llf-char"

Definition at line 36 of file euler2d.h.

◆ _SWFS_

#define _SWFS_   "steger-warming"

Definition at line 37 of file euler2d.h.

◆ _XDIR_

#define _XDIR_   0

Definition at line 40 of file euler2d.h.

◆ _YDIR_

#define _YDIR_   1

Definition at line 41 of file euler2d.h.

◆ _Euler2DGetFlowVar_

#define _Euler2DGetFlowVar_ (   u,
  rho,
  vx,
  vy,
  e,
  P,
 
)
Value:
{ \
double gamma = p->gamma, vsq; \
rho = u[0]; \
vx = u[1] / rho; \
vy = u[2] / rho; \
e = u[3]; \
vsq = (vx*vx) + (vy*vy); \
P = (e - 0.5*rho*vsq) * (gamma-1.0); \
}

Definition at line 44 of file euler2d.h.

◆ _Euler2DSetFlux_

#define _Euler2DSetFlux_ (   f,
  rho,
  vx,
  vy,
  e,
  P,
  p,
  dir 
)
Value:
{ \
if (dir == _XDIR_) { \
f[0] = rho * vx; \
f[1] = rho * vx * vx + P; \
f[2] = rho * vx * vy; \
f[3] = (e + P) * vx; \
} else if (dir == _YDIR_) { \
f[0] = rho * vy; \
f[1] = rho * vy * vx; \
f[2] = rho * vy * vy + P; \
f[3] = (e + P) * vy; \
} \
}
#define _YDIR_
Definition: euler2d.h:41
#define _XDIR_
Definition: euler2d.h:40

Definition at line 55 of file euler2d.h.

◆ _Euler2DRoeAverage_

#define _Euler2DRoeAverage_ (   uavg,
  uL,
  uR,
 
)

Definition at line 70 of file euler2d.h.

◆ _Euler2DEigenvalues_

#define _Euler2DEigenvalues_ (   u,
  D,
  p,
  dir 
)
Value:
{ \
double gamma = p->gamma; \
double rho,vx,vy,e,P,c,vn,vsq; \
rho = u[0]; \
vx = u[1] / rho; \
vy = u[2] / rho; \
e = u[3]; \
vsq = (vx*vx) + (vy*vy); \
P = (e - 0.5*rho*vsq) * (gamma-1.0); \
c = sqrt(gamma*P/rho); \
if (dir == _XDIR_) vn = vx; \
else if (dir == _YDIR_) vn = vy; \
else vn = 0.0; \
if (dir == _XDIR_) {\
D[0*_MODEL_NVARS_+0] = vn-c; D[0*_MODEL_NVARS_+1] = 0; D[0*_MODEL_NVARS_+2] = 0; D[0*_MODEL_NVARS_+3] = 0; \
D[1*_MODEL_NVARS_+0] = 0; D[1*_MODEL_NVARS_+1] = vn+c; D[1*_MODEL_NVARS_+2] = 0; D[1*_MODEL_NVARS_+3] = 0; \
D[2*_MODEL_NVARS_+0] = 0; D[2*_MODEL_NVARS_+1] = 0; D[2*_MODEL_NVARS_+2] = vn; D[2*_MODEL_NVARS_+3] = 0; \
D[3*_MODEL_NVARS_+0] = 0; D[3*_MODEL_NVARS_+1] = 0; D[3*_MODEL_NVARS_+2] = 0; D[3*_MODEL_NVARS_+3] = vn; \
} else if (dir == _YDIR_) { \
D[0*_MODEL_NVARS_+0] = vn-c; D[0*_MODEL_NVARS_+1] = 0; D[0*_MODEL_NVARS_+2] = 0; D[0*_MODEL_NVARS_+3] = 0; \
D[1*_MODEL_NVARS_+0] = 0; D[1*_MODEL_NVARS_+1] = vn; D[1*_MODEL_NVARS_+2] = 0; D[1*_MODEL_NVARS_+3] = 0; \
D[2*_MODEL_NVARS_+0] = 0; D[2*_MODEL_NVARS_+1] = 0; D[2*_MODEL_NVARS_+2] = vn+c; D[2*_MODEL_NVARS_+3] = 0; \
D[3*_MODEL_NVARS_+0] = 0; D[3*_MODEL_NVARS_+1] = 0; D[3*_MODEL_NVARS_+2] = 0; D[3*_MODEL_NVARS_+3] = vn; \
}\
}
#define _MODEL_NVARS_
Definition: euler2d.h:31
#define _YDIR_
Definition: euler2d.h:41
#define _XDIR_
Definition: euler2d.h:40

Definition at line 108 of file euler2d.h.

◆ _Euler2DLeftEigenvectors_

#define _Euler2DLeftEigenvectors_ (   u,
  L,
  p,
  dir 
)

Definition at line 135 of file euler2d.h.

◆ _Euler2DRightEigenvectors_

#define _Euler2DRightEigenvectors_ (   u,
  R,
  p,
  dir 
)

Definition at line 189 of file euler2d.h.

Function Documentation

◆ Euler2DInitialize()

int Euler2DInitialize ( void *  ,
void *   
)

Definition at line 21 of file Euler2DInitialize.c.

22 {
23  HyPar *solver = (HyPar*) s;
24  MPIVariables *mpi = (MPIVariables*) m;
25  Euler2D *physics = (Euler2D*) solver->physics;
26  int ferr = 0;
27 
28  static int count = 0;
29 
30  if (solver->nvars != _MODEL_NVARS_) {
31  fprintf(stderr,"Error in Euler2DInitialize(): nvars has to be %d.\n",_MODEL_NVARS_);
32  return(1);
33  }
34  if (solver->ndims != _MODEL_NDIMS_) {
35  fprintf(stderr,"Error in Euler2DInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_);
36  return(1);
37  }
38 
39  /* default values */
40  physics->gamma = 1.4;
41  strcpy(physics->upw_choice,"roe");
42 
43  /* reading physical model specific inputs - all processes */
44  if (!mpi->rank) {
45  FILE *in;
46  if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n");
47  in = fopen("physics.inp","r");
48  if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n");
49  else {
50  char word[_MAX_STRING_SIZE_];
51  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
52  if (!strcmp(word, "begin")){
53  while (strcmp(word, "end")){
54  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
55  if (!strcmp(word, "gamma")) {
56  ferr = fscanf(in,"%lf",&physics->gamma); if (ferr != 1) return(1);
57  } else if (!strcmp(word,"upwinding")) {
58  ferr = fscanf(in,"%s",physics->upw_choice); if (ferr != 1) return(1);
59  } else if (strcmp(word,"end")) {
60  char useless[_MAX_STRING_SIZE_];
61  ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr);
62  printf("Warning: keyword %s in file \"physics.inp\" with value %s not ",word,useless);
63  printf("recognized or extraneous. Ignoring.\n");
64  }
65  }
66  } else {
67  fprintf(stderr,"Error: Illegal format in file \"physics.inp\".\n");
68  return(1);
69  }
70  }
71  fclose(in);
72  }
73 
74 #ifndef serial
75  IERR MPIBroadcast_double (&physics->gamma,1,0,&mpi->world); CHECKERR(ierr);
77 #endif
78 
79  if (!strcmp(solver->SplitHyperbolicFlux,"yes")) {
80  if (!mpi->rank) {
81  fprintf(stderr,"Error in Euler2DInitialize: This physical model does not have a splitting ");
82  fprintf(stderr,"of the hyperbolic term defined.\n");
83  }
84  return(1);
85  }
86 
87  /* initializing physical model-specific functions */
88  solver->ComputeCFL = Euler2DComputeCFL;
89  solver->FFunction = Euler2DFlux;
90  if (!strcmp(physics->upw_choice,_ROE_ )) solver->Upwind = Euler2DUpwindRoe;
91  else if (!strcmp(physics->upw_choice,_RF_ )) solver->Upwind = Euler2DUpwindRF;
92  else if (!strcmp(physics->upw_choice,_LLF_ )) solver->Upwind = Euler2DUpwindLLF;
93  else if (!strcmp(physics->upw_choice,_SWFS_)) solver->Upwind = Euler2DUpwindSWFS;
94  else {
95  fprintf(stderr,"Error in Euler2DInitialize(): %s is not a valid upwinding scheme.\n",
96  physics->upw_choice);
97  return(1);
98  }
102 
103  /* set the value of gamma in all the boundary objects */
104  int n;
105  DomainBoundary *boundary = (DomainBoundary*) solver->boundary;
106  for (n = 0; n < solver->nBoundaryZones; n++) boundary[n].gamma = physics->gamma;
107 
108  count++;
109  return(0);
110 }
double Euler2DComputeCFL(void *, void *, double, double)
int nvars
Definition: hypar.h:29
int Euler2DUpwindRF(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: Euler2DUpwind.c:68
#define IERR
Definition: basic.h:16
#define CHECKERR(ierr)
Definition: basic.h:18
char SplitHyperbolicFlux[_MAX_STRING_SIZE_]
Definition: hypar.h:92
void * boundary
Definition: hypar.h:159
int Euler2DFlux(double *, double *, int, void *, double)
Definition: Euler2DFlux.c:7
int Euler2DUpwindRoe(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: Euler2DUpwind.c:10
int(* AveragingFunction)(double *, double *, double *, void *)
Definition: hypar.h:354
int Euler2DUpwindLLF(double *, double *, double *, double *, double *, double *, int, void *, double)
int(* Upwind)(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: hypar.h:295
Structure containing the variables and function pointers defining a boundary.
int ndims
Definition: hypar.h:26
int MPIBroadcast_character(char *, int, int, void *)
Definition: MPIBroadcast.c:37
int(* FFunction)(double *, double *, int, void *, double)
Definition: hypar.h:276
int MPIBroadcast_double(double *, int, int, void *)
Definition: MPIBroadcast.c:9
double(* ComputeCFL)(void *, void *, double, double)
Definition: hypar.h:269
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _MAX_STRING_SIZE_
Definition: basic.h:14
#define _ROE_
Definition: euler1d.h:62
double gamma
Definition: euler2d.h:245
#define _MODEL_NDIMS_
Definition: euler1d.h:56
MPI_Comm world
int Euler2DRightEigenvectors(double *, double *, void *, int)
Definition: Euler2DEigen.c:23
char upw_choice[_MAX_STRING_SIZE_]
Definition: euler2d.h:246
int Euler2DUpwindSWFS(double *, double *, double *, double *, double *, double *, int, void *, double)
void * physics
Definition: hypar.h:266
int Euler2DRoeAverage(double *, double *, double *, void *)
#define _SWFS_
Definition: euler1d.h:68
Structure of MPI-related variables.
#define _MODEL_NVARS_
Definition: euler1d.h:58
int nBoundaryZones
Definition: hypar.h:157
int Euler2DLeftEigenvectors(double *, double *, void *, int)
Definition: Euler2DEigen.c:16
int(* GetRightEigenvectors)(double *, double *, void *, int)
Definition: hypar.h:359
#define _RF_
Definition: euler1d.h:64
int(* GetLeftEigenvectors)(double *, double *, void *, int)
Definition: hypar.h:357
#define _LLF_
Definition: euler1d.h:66

◆ Euler2DCleanup()

int Euler2DCleanup ( void *  )

Definition at line 4 of file Euler2DCleanup.c.

5 {
6  return(0);
7 }