HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
FPPowerSystemUpwind.c File Reference
#include <stdlib.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <physicalmodels/fppowersystem.h>
#include <hypar.h>

Go to the source code of this file.

Functions

double FPPowerSystemDriftFunction (int, void *, double, double, double)
 
int FPPowerSystemUpwind (double *fI, double *fL, double *fR, double *uL, double *uR, double *u, int dir, void *s, double t)
 

Function Documentation

◆ FPPowerSystemDriftFunction()

double FPPowerSystemDriftFunction ( int  ,
void *  ,
double  ,
double  ,
double   
)

Definition at line 4 of file FPPowerSystemFunctions.c.

5 {
6  FPPowerSystem *params = (FPPowerSystem*) p;
7 
8  double drift = 0;
9  if (dir == 0) drift = params->O_s * (y - 1.0);
10  else if (dir == 1) {
11  if (t < params->tf) params->Pmax = params->E*params->V/params->g1;
12  else if (t < params->tcl) params->Pmax = 0.0;
13  else params->Pmax = params->E*params->V/params->g2;
14  drift = (1.0/(2.0*params->H)) * (params->Pm - params->Pmax*sin(x) - params->D*(y-1.0));
15  }
16 
17  return drift;
18 }
#define drift(x)
Definition: fpdoublewell.h:31

◆ FPPowerSystemUpwind()

int FPPowerSystemUpwind ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

Definition at line 9 of file FPPowerSystemUpwind.c.

11 {
12  HyPar *solver = (HyPar*) s;
13  FPPowerSystem *params = (FPPowerSystem*)solver->physics;
14  int done,v;
15 
16  int ndims = solver->ndims;
17  int nvars = solver->nvars;
18  int ghosts = solver->ghosts;
19  int *dim = solver->dim_local;
20 
21  int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims];
22  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
23  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
24 
25  done = 0; _ArraySetValue_(index_outer,ndims,0);
26  while (!done) {
27  _ArrayCopy1D_(index_outer,index_inter,ndims);
28  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
29  int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0, p);
30  double x = 0,y = 0; /* x,y coordinates of the interface */
31  if (dir == 0) {
32  /* x-interface */
33  double x1, x2;
34  _GetCoordinate_(0,index_inter[0]-1,dim,ghosts,solver->x,x1);
35  _GetCoordinate_(0,index_inter[0] ,dim,ghosts,solver->x,x2);
36  x = 0.5 * ( x1 + x2 );
37  _GetCoordinate_(1,index_inter[1],dim,ghosts,solver->x,y);
38  } else if (dir == 1) {
39  /* y-interface */
40  _GetCoordinate_(0,index_inter[0],dim,ghosts,solver->x,x);
41  double y1, y2;
42  _GetCoordinate_(1,index_inter[1]-1,dim,ghosts,solver->x,y1);
43  _GetCoordinate_(1,index_inter[1] ,dim,ghosts,solver->x,y2);
44  y = 0.5 * ( y1 + y2 );
45  }
46  double drift = FPPowerSystemDriftFunction(dir,params,x,y,t);
47  for (v = 0; v < nvars; v++)
48  fI[nvars*p+v] = drift * (drift > 0 ? fL[nvars*p+v] : fR[nvars*p+v] );
49  }
50  _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done);
51  }
52 
53  return(0);
54 }
double FPPowerSystemDriftFunction(int, void *, double, double, double)
int nvars
Definition: hypar.h:29
double * x
Definition: hypar.h:107
#define drift(x)
Definition: fpdoublewell.h:31
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
#define _ArrayCopy1D_(x, y, size)