HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
MUSCLInitialize.c
Go to the documentation of this file.
1 
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <string.h>
9 #include <limiters.h>
10 #include <interpolation.h>
11 #include <mpivars.h>
12 #include <hypar.h>
13 
18  void *s,
19  void *m
20  )
21 {
22  HyPar *solver = (HyPar*) s;
23  MPIVariables *mpi = (MPIVariables*) m;
24  MUSCLParameters *muscl = (MUSCLParameters*) solver->interp;
25 
26  /* default values */
27  muscl->eps = 1e-3;
28  strcpy(muscl->limiter_type, _LIM_GM_);
29 
30  if (!mpi->rank) {
31  FILE *in;
32  int ferr;
33  in = fopen("muscl.inp","r");
34  if (!in) printf("Warning: File muscl.inp not found. Using default parameters for muscl2/muscl3 scheme.\n");
35  else {
36  printf("Reading MUSCL parameters from muscl.inp.\n");
37  char word[_MAX_STRING_SIZE_];
38  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
39  if (!strcmp(word, "begin")){
40  while (strcmp(word, "end")){
41  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
42  if (!strcmp(word,"epsilon")) { ferr = fscanf(in,"%lf",&muscl->eps); if (ferr != 1) return(1); }
43  else if (!strcmp(word,"limiter")) { ferr = fscanf(in,"%s" ,muscl->limiter_type); if (ferr != 1) return(1); }
44  else if (strcmp(word,"end")) {
45  char useless[_MAX_STRING_SIZE_];
46  ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr);
47  printf("Warning: keyword %s in file \"muscl.inp\" with value %s not ",word,useless);
48  printf("recognized or extraneous. Ignoring.\n");
49  }
50  }
51  } else {
52  fprintf(stderr,"Error: Illegal format in file \"muscl.inp\".\n");
53  return(1);
54  }
55  fclose(in);
56  }
57  }
58 
59  MPIBroadcast_double(&muscl->eps, 1, 0, &mpi->world);
61 
62  if (!strcmp(muscl->limiter_type, _LIM_GM_)) {
64  } else if (!strcmp(muscl->limiter_type, _LIM_MM_)) {
66  } else if (!strcmp(muscl->limiter_type, _LIM_VANLEER_)) {
68  } else if (!strcmp(muscl->limiter_type, _LIM_SUPERBEE_)) {
70  } else {
71  if (!mpi->rank) {
72  fprintf(stderr, "Warning: %s is an invalid limiter type. Using default (Generalized MinMod).\n",
73  muscl->limiter_type);
74  }
76  }
77 
78  return(0);
79 }
double LimiterGeneralizedMinMod(double)
MPI related function definitions.
#define _LIM_GM_
Definition: limiters.h:10
#define _LIM_VANLEER_
Definition: limiters.h:14
Definitions for limiter functions used in MUSCL-type reconstruction schemes.
double(* LimiterFunction)(double)
int MPIBroadcast_character(char *, int, int, void *)
Definition: MPIBroadcast.c:37
#define _LIM_MM_
Definition: limiters.h:12
int MPIBroadcast_double(double *, int, int, void *)
Definition: MPIBroadcast.c:9
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _MAX_STRING_SIZE_
Definition: basic.h:14
double LimiterVanLeer(double)
Contains structure definition for hypar.
MPI_Comm world
char limiter_type[_MAX_STRING_SIZE_]
void * interp
Definition: hypar.h:362
int MUSCLInitialize(void *s, void *m)
Structure of variables/parameters needed by the MUSCL scheme.
Structure of MPI-related variables.
Definitions for the functions computing the interpolated value of the primitive at the cell interface...
double LimiterSuperBee(double)
#define _LIM_SUPERBEE_
Definition: limiters.h:16
double LimiterMinMod(double)
Definition: LimiterMinMod.c:16