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

Go to the source code of this file.

Data Structures

struct  FPDoubleWell
 

Macros

#define _FP_DOUBLE_WELL_   "fp-double-well"
 
#define _MODEL_NDIMS_   1
 
#define _MODEL_NVARS_   1
 
#define drift(x)   (4.0*(x)*(1.0-(x)*(x)))
 

Functions

int FPDoubleWellInitialize (void *, void *)
 
int FPDoubleWellCleanup (void *)
 

Data Structure Documentation

struct FPDoubleWell

Definition at line 26 of file fpdoublewell.h.

Data Fields
double q
double pdf_integral

Macro Definition Documentation

#define _FP_DOUBLE_WELL_   "fp-double-well"

Definition at line 18 of file fpdoublewell.h.

#define _MODEL_NDIMS_   1

Definition at line 23 of file fpdoublewell.h.

#define _MODEL_NVARS_   1

Definition at line 24 of file fpdoublewell.h.

#define drift (   x)    (4.0*(x)*(1.0-(x)*(x)))

Definition at line 31 of file fpdoublewell.h.

Function Documentation

int FPDoubleWellInitialize ( void *  ,
void *   
)

Definition at line 19 of file FPDoubleWellInitialize.c.

20 {
21  HyPar *solver = (HyPar*) s;
22  MPIVariables *mpi = (MPIVariables*) m;
23  FPDoubleWell *physics = (FPDoubleWell*) solver->physics;
24  int ferr = 0;
26 
27  static int count = 0;
28 
29  if (solver->nvars != _MODEL_NVARS_) {
30  fprintf(stderr,"Error in FPDoubleWellInitializeO(): nvars has to be %d.\n",_MODEL_NVARS_);
31  return(1);
32  }
33  if (solver->ndims != _MODEL_NDIMS_) {
34  fprintf(stderr,"Error in FPDoubleWellInitializeO(): ndims has to be %d.\n",_MODEL_NDIMS_);
35  return(1);
36  }
37 
38  /* reading physical model specific inputs - all processes */
39  if (!mpi->rank) {
40  FILE *in;
41  if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n");
42  in = fopen("physics.inp","r");
43  if (!in) {
44  fprintf(stderr,"Error: File \"physics.inp\" not found.\n");
45  return(1);
46  } else {
47  char word[_MAX_STRING_SIZE_];
48  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
49  if (!strcmp(word, "begin")){
50  while (strcmp(word, "end")){
51  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
52  if (!strcmp(word, "q")) {
53  /* read diffusion coefficient */
54  ferr = fscanf(in,"%lf",&physics->q);
55  if (ferr != 1) return(1);
56  } else if (strcmp(word,"end")) {
57  char useless[_MAX_STRING_SIZE_];
58  ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr);
59  printf("Warning: keyword %s in file \"physics.inp\" with value %s not ",word,useless);
60  printf("recognized or extraneous. Ignoring.\n");
61  }
62  }
63  } else {
64  fprintf(stderr,"Error: Illegal format in file \"physics.inp\".\n");
65  return(1);
66  }
67  }
68  fclose(in);
69  }
70 
71 #ifndef serial
72  IERR MPIBroadcast_double(&physics->q,1,0,&mpi->world); CHECKERR(ierr);
73 #endif
74 
75  if (!strcmp(solver->SplitHyperbolicFlux,"yes")) {
76  if (!mpi->rank) {
77  fprintf(stderr,"Error in FPDoubleWellInitialize: This physical model does not have a splitting ");
78  fprintf(stderr,"of the hyperbolic term defined.\n");
79  }
80  return(1);
81  }
82 
83  /* initializing physical model-specific functions */
88  solver->Upwind = FPDoubleWellUpwind;
91 
92  /* Calculate and print the PDF integral of the initial solution */
93  IERR FPDoubleWellPostStep(solver->u,solver,mpi,0.0,0);CHECKERR(ierr);
94  IERR FPDoubleWellPrintStep(solver,mpi,0.0); CHECKERR(ierr);
95 
96  count++;
97  return(0);
98 }
double(* ComputeCFL)(void *, void *, double, double)
Definition: hypar.h:269
int MPIBroadcast_double(double *, int, int, void *)
Definition: MPIBroadcast.c:9
double * u
Definition: hypar.h:116
int FPDoubleWellDiffusion(double *f, double *u, int dir, void *s, double t)
#define _MODEL_NVARS_
Definition: euler1d.h:58
void * physics
Definition: hypar.h:266
int(* Upwind)(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: hypar.h:295
int(* FFunction)(double *, double *, int, void *, double)
Definition: hypar.h:276
int FPDoubleWellAdvection(double *f, double *u, int dir, void *s, double t)
#define _MODEL_NDIMS_
Definition: euler1d.h:56
MPI_Comm world
#define _MAX_STRING_SIZE_
Definition: basic.h:14
double(* ComputeDiffNumber)(void *, void *, double, double)
Definition: hypar.h:272
int nvars
Definition: hypar.h:29
#define CHECKERR(ierr)
Definition: basic.h:18
double FPDoubleWellComputeDiffNumber(void *s, void *m, double dt, double t)
int FPDoubleWellPrintStep(void *, void *, double)
char SplitHyperbolicFlux[_MAX_STRING_SIZE_]
Definition: hypar.h:92
int(* PrintStep)(void *, void *, double)
Definition: hypar.h:344
int ndims
Definition: hypar.h:26
#define IERR
Definition: basic.h:16
int FPDoubleWellUpwind(double *, double *, double *, double *, double *, double *, int, void *, double)
int FPDoubleWellPostStep(double *, void *, void *, double, int)
Structure of MPI-related variables.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
int(* GFunction)(double *, double *, int, void *, double)
Definition: hypar.h:310
int(* PostStep)(double *, void *, void *, double, int)
Definition: hypar.h:341
#define _DECLARE_IERR_
Definition: basic.h:17
double FPDoubleWellComputeCFL(void *s, void *m, double dt, double t)
int FPDoubleWellCleanup ( void *  )

Definition at line 4 of file FPDoubleWellCleanup.c.

5 {
6  return(0);
7 }