HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
FPPowerSystemDiffusion.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 FPPowerSystemDissipationFunction(int,void*,double);
8 
9 int FPPowerSystemDiffusion(double *f,double *u,int dir,void *s,double t)
10 {
11  HyPar *solver = (HyPar*) s;
12  FPPowerSystem *params = (FPPowerSystem*) solver->physics;
13  int i, v;
14 
15  int *dim = solver->dim_local;
16  int ghosts = solver->ghosts;
17  int ndims = solver->ndims;
18  int nvars = solver->nvars;
19  int index[ndims], bounds[ndims], offset[ndims];
20 
21  /* set bounds for array index to include ghost points */
22  _ArrayCopy1D_(dim,bounds,ndims);
23  for (i=0; i<ndims; i++) bounds[i] += 2*ghosts;
24 
25  /* set offset such that index is compatible with ghost point arrangement */
26  _ArraySetValue_(offset,ndims,-ghosts);
27 
28  int done = 0; _ArraySetValue_(index,ndims,0);
29  while (!done) {
30  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
31  double dissipation = FPPowerSystemDissipationFunction(dir,params,t);
32  for (v = 0; v < nvars; v++) f[nvars*p+v] = dissipation * u[nvars*p+v];
33  _ArrayIncrementIndex_(ndims,bounds,index,done);
34  }
35 
36  return(0);
37 }
int nvars
Definition: hypar.h:29
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
double FPPowerSystemDissipationFunction(int, void *, double)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
Contains structure definition for hypar.
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
int FPPowerSystemDiffusion(double *f, double *u, int dir, void *s, double t)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
#define _ArrayCopy1D_(x, y, size)
Contains macros and function definitions for common array operations.