HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
FPPowerSystem1BusDiffusion.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <basic.h>
3 #include <arrayfunctions.h>
5 #include <hypar.h>
6 
7 double FPPowerSystem1BusDissipationFunction(int,int,void*,double);
8 
9 int FPPowerSystem1BusDiffusionLaplacian(double *f,double *u,int dir,void *s,double t)
10 {
11  HyPar *solver = (HyPar*) s;
12  FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics;
13 
14  int *dim = solver->dim_local;
15  int ghosts = solver->ghosts;
16  int ndims = solver->ndims;
17  int nvars = solver->nvars;
18 
19  /* calculate total size of arrays */
20  int bounds[ndims]; _ArrayAddCopy1D_(dim,(2*ghosts),bounds,ndims);
21  int size; _ArrayProduct1D_(bounds,ndims,size); size *= nvars;
22 
23  /* calculate dissipation coefficient -- constant in x and y */
24  double dissipation = FPPowerSystem1BusDissipationFunction(dir,dir,params,t);
25 
26  /* f = dissipation * u */
27  _ArrayScaleCopy1D_(u,dissipation,f,size);
28 
29  return(0);
30 }
31 
32 int FPPowerSystem1BusDiffusionGeneral(double *f,double *u,int dir1,int dir2,void *s,double t)
33 {
34  HyPar *solver = (HyPar*) s;
35  FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics;
36 
37  int *dim = solver->dim_local;
38  int ghosts = solver->ghosts;
39  int ndims = solver->ndims;
40  int nvars = solver->nvars;
41 
42  /* calculate total size of arrays */
43  int bounds[ndims]; _ArrayAddCopy1D_(dim,(2*ghosts),bounds,ndims);
44  int size; _ArrayProduct1D_(bounds,ndims,size); size *= nvars;
45 
46  /* calculate dissipation coefficient -- constant in x and y */
47  double dissipation = FPPowerSystem1BusDissipationFunction(dir1,dir2,params,t);
48 
49  /* f = dissipation * u */
50  _ArrayScaleCopy1D_(u,dissipation,f,size);
51 
52  return(0);
53 }
int FPPowerSystem1BusDiffusionGeneral(double *f, double *u, int dir1, int dir2, void *s, double t)
int nvars
Definition: hypar.h:29
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
#define _ArrayScaleCopy1D_(x, a, y, size)
#define _ArrayAddCopy1D_(x, a, y, size)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
Contains structure definition for hypar.
int * dim_local
Definition: hypar.h:37
double FPPowerSystem1BusDissipationFunction(int, int, void *, double)
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
Fokker-Planck Model for 1-Bus Power System.
Contains macros and function definitions for common array operations.
#define _ArrayProduct1D_(x, size, p)
int FPPowerSystem1BusDiffusionLaplacian(double *f, double *u, int dir, void *s, double t)