Loading [MathJax]/extensions/tex2jax.js
HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
fppowersystem.h File Reference

Go to the source code of this file.

Data Structures

struct  FPPowerSystem
 

Macros

#define _FP_POWER_SYSTEM_   "fp-power-system"
 
#define _MODEL_NDIMS_   2
 
#define _MODEL_NVARS_   1
 

Functions

int FPPowerSystemInitialize (void *, void *)
 
int FPPowerSystemCleanup (void *)
 

Data Structure Documentation

◆ FPPowerSystem

struct FPPowerSystem

Definition at line 52 of file fppowersystem.h.

Data Fields
double O_s
double H
double E
double V
double g1
double g2
double D
double Pm
double l
double q
double tf
double tcl
double Pmax
double pdf_integral

Macro Definition Documentation

◆ _FP_POWER_SYSTEM_

#define _FP_POWER_SYSTEM_   "fp-power-system"

Definition at line 44 of file fppowersystem.h.

◆ _MODEL_NDIMS_

#define _MODEL_NDIMS_   2

Definition at line 49 of file fppowersystem.h.

◆ _MODEL_NVARS_

#define _MODEL_NVARS_   1

Definition at line 50 of file fppowersystem.h.

Function Documentation

◆ FPPowerSystemInitialize()

int FPPowerSystemInitialize ( void *  ,
void *   
)

Definition at line 20 of file FPPowerSystemInitialize.c.

21 {
22  HyPar *solver = (HyPar*) s;
23  MPIVariables *mpi = (MPIVariables*) m;
24  FPPowerSystem *physics = (FPPowerSystem*) solver->physics;
25  int ferr;
27 
28  static int count = 0;
29 
30  if (solver->nvars != _MODEL_NVARS_) {
31  fprintf(stderr,"Error in FPPowerSystemInitialize(): nvars has to be %d.\n",_MODEL_NVARS_);
32  return(1);
33  }
34  if (solver->ndims != _MODEL_NDIMS_) {
35  fprintf(stderr,"Error in FPPowerSystemInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_);
36  return(1);
37  }
38 
39  /* default values of model parameters */
40  physics->H = 5.0;
41  physics->D = 5.0;
42  physics->E = 1.1358;
43  physics->V = 1.0;
44  physics->g1 = 0.545;
45  physics->g2 = 0.745;
46  physics->Pm = 0.9;
47  physics->l = 0.1;
48  physics->q = 1.0;
49  physics->O_s = 120*(4.0*atan(1.0));
50  physics->tf = 0.1;
51  physics->tcl = 0.2;
52 
53  /* reading physical model specific inputs - all processes */
54  FILE *in;
55  if ((!mpi->rank) && (!count)) printf("Reading physical model inputs from file \"physics.inp\".\n");
56  in = fopen("physics.inp","r");
57  if (!in) {
58  fprintf(stderr,"Error: File \"physics.inp\" not found.\n");
59  return(1);
60  } else {
61  char word[_MAX_STRING_SIZE_];
62  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
63  if (!strcmp(word, "begin")){
64  while (strcmp(word, "end")){
65  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
66  if (!strcmp(word, "inertia")) {ferr=fscanf(in,"%lf",&physics->H );if(ferr!=1)return(1);}
67  else if (!strcmp(word, "omega_s")) {ferr=fscanf(in,"%lf",&physics->O_s);if(ferr!=1)return(1);}
68  else if (!strcmp(word, "E" )) {ferr=fscanf(in,"%lf",&physics->E );if(ferr!=1)return(1);}
69  else if (!strcmp(word, "V" )) {ferr=fscanf(in,"%lf",&physics->V );if(ferr!=1)return(1);}
70  else if (!strcmp(word, "g1" )) {ferr=fscanf(in,"%lf",&physics->g1 );if(ferr!=1)return(1);}
71  else if (!strcmp(word, "g2" )) {ferr=fscanf(in,"%lf",&physics->g2 );if(ferr!=1)return(1);}
72  else if (!strcmp(word, "D" )) {ferr=fscanf(in,"%lf",&physics->D );if(ferr!=1)return(1);}
73  else if (!strcmp(word, "PM_min" )) {ferr=fscanf(in,"%lf",&physics->Pm );if(ferr!=1)return(1);}
74  else if (!strcmp(word, "lambda" )) {ferr=fscanf(in,"%lf",&physics->l );if(ferr!=1)return(1);}
75  else if (!strcmp(word, "q" )) {ferr=fscanf(in,"%lf",&physics->q );if(ferr!=1)return(1);}
76  else if (!strcmp(word, "tf" )) {ferr=fscanf(in,"%lf",&physics->tf );if(ferr!=1)return(1);}
77  else if (!strcmp(word, "tcl" )) {ferr=fscanf(in,"%lf",&physics->tcl);if(ferr!=1)return(1);}
78  }
79  } else {
80  fprintf(stderr,"Error: Illegal format in file \"physics.inp\".\n");
81  return(1);
82  }
83  }
84  fclose(in);
85 
86  if (!strcmp(solver->SplitHyperbolicFlux,"yes")) {
87  if (!mpi->rank) {
88  fprintf(stderr,"Error in FPPowerSystemInitialize: This physical model does not have a splitting ");
89  fprintf(stderr,"of the hyperbolic term defined.\n");
90  }
91  return(1);
92  }
93 
94  /* initializing physical model-specific functions */
99  solver->Upwind = FPPowerSystemUpwind;
102 
103  /* Calculate and print the PDF integral of the initial solution */
104  IERR FPPowerSystemPostStep(solver->u,solver,mpi,0.0,0); CHECKERR(ierr);
105  if (!mpi->rank) IERR FPPowerSystemPrintStep(solver,mpi,0.0); CHECKERR(ierr);
106 
107  count++;
108  return(0);
109 }
int(* PrintStep)(void *, void *, double)
Definition: hypar.h:344
double FPPowerSystemComputeCFL(void *, void *, double, double)
double FPPowerSystemComputeDiffNumber(void *, void *, double, double)
int(* GFunction)(double *, double *, int, void *, double)
Definition: hypar.h:310
int nvars
Definition: hypar.h:29
#define IERR
Definition: basic.h:16
#define CHECKERR(ierr)
Definition: basic.h:18
char SplitHyperbolicFlux[_MAX_STRING_SIZE_]
Definition: hypar.h:92
double * u
Definition: hypar.h:116
int(* Upwind)(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: hypar.h:295
int FPPowerSystemPrintStep(void *, void *, double)
int ndims
Definition: hypar.h:26
int(* FFunction)(double *, double *, int, void *, double)
Definition: hypar.h:276
int FPPowerSystemDiffusion(double *, double *, int, void *, double)
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 _MODEL_NDIMS_
Definition: euler1d.h:56
int FPPowerSystemPostStep(double *, void *, void *, double, int)
double(* ComputeDiffNumber)(void *, void *, double, double)
Definition: hypar.h:272
int FPPowerSystemAdvection(double *, double *, int, void *, double)
int(* PostStep)(double *, void *, void *, double, int)
Definition: hypar.h:341
void * physics
Definition: hypar.h:266
Structure of MPI-related variables.
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _DECLARE_IERR_
Definition: basic.h:17
int FPPowerSystemUpwind(double *, double *, double *, double *, double *, double *, int, void *, double)

◆ FPPowerSystemCleanup()

int FPPowerSystemCleanup ( void *  )

Definition at line 4 of file FPPowerSystemCleanup.c.

5 {
6  return(0);
7 }