HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
FPPowerSystemDiffusion.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 FPPowerSystemDissipationFunction (int, void *, double)
 
int FPPowerSystemDiffusion (double *f, double *u, int dir, void *s, double t)
 

Function Documentation

◆ FPPowerSystemDissipationFunction()

double FPPowerSystemDissipationFunction ( int  ,
void *  ,
double   
)

Definition at line 20 of file FPPowerSystemFunctions.c.

21 {
22  FPPowerSystem *params = (FPPowerSystem*) p;
23 
24  double dissp = 0;
25  if (dir == 1) {
26  double gamma = params->D / (2.0*params->H);
27  dissp = (1.0/(2.0*params->H)) * (1.0/(2.0*params->H))
28  * ((params->l*params->q*params->q)/(params->l*gamma+1.0))
29  * (1.0 - exp(-(gamma+1.0/params->l)*t));
30  }
31 
32  return(dissp);
33 }

◆ FPPowerSystemDiffusion()

int FPPowerSystemDiffusion ( double *  f,
double *  u,
int  dir,
void *  s,
double  t 
)

Definition at line 9 of file FPPowerSystemDiffusion.c.

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
int ndims
Definition: hypar.h:26
double FPPowerSystemDissipationFunction(int, void *, double)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#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)