HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
MUSCLInitialize.c File Reference

Initialize the 2nd or 3rd order MUSCL scheme. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limiters.h>
#include <interpolation.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

int MUSCLInitialize (void *s, void *m)
 

Detailed Description

Initialize the 2nd or 3rd order MUSCL scheme.

Author
Debojyoti Ghosh

Definition in file MUSCLInitialize.c.

Function Documentation

int MUSCLInitialize ( void *  s,
void *  m 
)

Initialize the 2nd or 3rd order MUSCL scheme.

Parameters
sSolver object of type HyPar
mMPI object of type MPIVariables

Definition at line 17 of file MUSCLInitialize.c.

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 }
void * interp
Definition: hypar.h:362
int MPIBroadcast_double(double *, int, int, void *)
Definition: MPIBroadcast.c:9
double LimiterGeneralizedMinMod(double)
double LimiterSuperBee(double)
#define _LIM_SUPERBEE_
Definition: limiters.h:16
char limiter_type[_MAX_STRING_SIZE_]
double(* LimiterFunction)(double)
double LimiterMinMod(double)
Definition: LimiterMinMod.c:16
#define _LIM_VANLEER_
Definition: limiters.h:14
MPI_Comm world
#define _MAX_STRING_SIZE_
Definition: basic.h:14
double LimiterVanLeer(double)
int MPIBroadcast_character(char *, int, int, void *)
Definition: MPIBroadcast.c:37
Structure of variables/parameters needed by the MUSCL scheme.
#define _LIM_GM_
Definition: limiters.h:10
Structure of MPI-related variables.
#define _LIM_MM_
Definition: limiters.h:12
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23