HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BurgersInitialize.c
Go to the documentation of this file.
1 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <basic.h>
10 #include <arrayfunctions.h>
11 #include <bandedmatrix.h>
12 #include <physicalmodels/burgers.h>
13 #include <mpivars.h>
14 #include <hypar.h>
15 
16 double BurgersComputeCFL (void*,void*,double,double);
17 int BurgersAdvection (double*,double*,int,void*,double);
18 int BurgersUpwind (double*,double*,double*,double*,
19  double*,double*,int,void*,double);
20 
25 int BurgersInitialize(void *s,
26  void *m
27  )
28 {
29  HyPar *solver = (HyPar*) s;
30  MPIVariables *mpi = (MPIVariables*) m;
31  Burgers *physics = (Burgers*) solver->physics;
32  int i, ferr;
33 
34  static int count = 0;
35 
36  /* reading physical model specific inputs - all processes */
37  if (!mpi->rank) {
38  FILE *in;
39  in = fopen("physics.inp","r");
40  if (in) {
41  if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n");
42  char word[_MAX_STRING_SIZE_];
43  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
44  if (!strcmp(word, "begin")){
45  while (strcmp(word, "end")){
46  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
47  if (strcmp(word,"end")) {
48  char useless[_MAX_STRING_SIZE_];
49  ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr);
50  printf("Warning: keyword %s in file \"physics.inp\" with value %s not ",
51  word, useless);
52  printf("recognized or extraneous. Ignoring.\n");
53  }
54  }
55  } else {
56  fprintf(stderr,"Error: Illegal format in file \"physics.inp\".\n");
57  return(1);
58  }
59  }
60  fclose(in);
61  }
62 
63  if (!strcmp(solver->SplitHyperbolicFlux,"yes")) {
64  if (!mpi->rank) {
65  fprintf(stderr,"Error in BurgersInitialize: This physical model does not have a splitting ");
66  fprintf(stderr,"of the hyperbolic term defined.\n");
67  }
68  return(1);
69  }
70 
71 #ifndef serial
72 #endif
73 
74  /* initializing physical model-specific functions */
75  solver->ComputeCFL = BurgersComputeCFL;
76  solver->FFunction = BurgersAdvection;
77  solver->Upwind = BurgersUpwind;
78 
79  count++;
80  return(0);
81 }
double(* ComputeCFL)(void *, void *, double, double)
Definition: hypar.h:269
void * physics
Definition: hypar.h:266
int(* Upwind)(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: hypar.h:295
MPI related function definitions.
int(* FFunction)(double *, double *, int, void *, double)
Definition: hypar.h:276
#define _MAX_STRING_SIZE_
Definition: basic.h:14
Data structure and some function declarations for banded block matrices.
double BurgersComputeCFL(void *s, void *m, double dt, double t)
int BurgersInitialize(void *, void *)
Contains structure definition for hypar.
char SplitHyperbolicFlux[_MAX_STRING_SIZE_]
Definition: hypar.h:92
Some basic definitions and macros.
int BurgersAdvection(double *f, double *u, int dir, void *s, double t)
Contains macros and function definitions for common array operations.
int BurgersUpwind(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: BurgersUpwind.c:15
Structure of MPI-related variables.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23