HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FPPowerSystem1BusUpwind.c File Reference
#include <stdlib.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <physicalmodels/fppowersystem1bus.h>
#include <hypar.h>

Go to the source code of this file.

Functions

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

Function Documentation

double FPPowerSystem1BusDriftFunction ( int  ,
void *  ,
double  ,
double  ,
double   
)

Definition at line 4 of file FPPowerSystem1BusFunctions.c.

5 {
7 
8  double drift = 0;
9  if (dir == _XDIR_) {
10  drift = params->omegaB * (y - params->omegaS);
11  } else if (dir == _YDIR_) {
12  drift = (params->omegaS/(2*params->H))
13  * (params->Pm_avg - params->Pmax*sin(x) - params->D*(y-params->omegaS));
14  }
15 
16  return drift;
17 }
#define _YDIR_
Definition: euler2d.h:41
#define drift(x)
Definition: fpdoublewell.h:31
#define _XDIR_
Definition: euler1d.h:75
int FPPowerSystem1BusUpwind ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

Definition at line 9 of file FPPowerSystem1BusUpwind.c.

11 {
12  HyPar *solver = (HyPar*) s;
13  FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) 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_(_XDIR_,index_inter[_XDIR_]-1,dim,ghosts,solver->x,x1);
35  _GetCoordinate_(_XDIR_,index_inter[_XDIR_] ,dim,ghosts,solver->x,x2);
36  x = 0.5 * ( x1 + x2 );
37  _GetCoordinate_(_YDIR_,index_inter[_YDIR_],dim,ghosts,solver->x,y);
38  } else if (dir == 1) {
39  /* y-interface */
40  _GetCoordinate_(_XDIR_,index_inter[_XDIR_],dim,ghosts,solver->x,x);
41  double y1, y2;
42  _GetCoordinate_(_YDIR_,index_inter[_YDIR_]-1,dim,ghosts,solver->x,y1);
43  _GetCoordinate_(_YDIR_,index_inter[_YDIR_] ,dim,ghosts,solver->x,y2);
44  y = 0.5 * ( y1 + y2 );
45  }
46  double drift = FPPowerSystem1BusDriftFunction(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 }
#define _YDIR_
Definition: euler2d.h:41
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int * dim_local
Definition: hypar.h:37
#define drift(x)
Definition: fpdoublewell.h:31
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
int ghosts
Definition: hypar.h:52
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArrayCopy1D_(x, y, size)
int nvars
Definition: hypar.h:29
int ndims
Definition: hypar.h:26
double * x
Definition: hypar.h:107
double FPPowerSystem1BusDriftFunction(int, void *, double, double, double)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _XDIR_
Definition: euler1d.h:75