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

Go to the source code of this file.

Functions

double FPPowerSystemDissipationFunction (int, void *, double)
 
double FPPowerSystemComputeDiffNumber (void *s, void *m, double dt, 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 }

◆ FPPowerSystemComputeDiffNumber()

double FPPowerSystemComputeDiffNumber ( void *  s,
void *  m,
double  dt,
double  t 
)

Definition at line 11 of file FPPowerSystemComputeDiffNumber.c.

12 {
13  HyPar *solver = (HyPar*) s;
14  FPPowerSystem *params = (FPPowerSystem*)solver->physics;
15 
16  int ndims = solver->ndims;
17  int ghosts = solver->ghosts;
18  int *dim = solver->dim_local;
19 
20  double max_diff = 0;
21  int index[ndims];
22  int done = 0; _ArraySetValue_(index,ndims,0);
23  while (!done) {
24  double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv);
25  double dyinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->dxinv,dyinv);
26  double dissp_x= FPPowerSystemDissipationFunction(0,params,t);
27  double dissp_y= FPPowerSystemDissipationFunction(1,params,t);
28 
29  double local_diff_x = absolute(dissp_x) * dt * dxinv * dxinv;
30  double local_diff_y = absolute(dissp_y) * dt * dyinv * dyinv;
31 
32  if (local_diff_x > max_diff) max_diff = local_diff_x;
33  if (local_diff_y > max_diff) max_diff = local_diff_y;
34 
35  _ArrayIncrementIndex_(ndims,dim,index,done);
36  }
37 
38  return(max_diff);
39 }
#define absolute(a)
Definition: math_ops.h:32
int ndims
Definition: hypar.h:26
double FPPowerSystemDissipationFunction(int, void *, double)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#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
double * dxinv
Definition: hypar.h:110