HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FPPowerSystem1BusPostStep.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <basic.h>
3 #include <arrayfunctions.h>
4 #include <mpivars.h>
6 #include <hypar.h>
7 
8 int FPPowerSystem1BusPostStep(double *u,void* s,void *m,double t,int iter)
9 {
10  HyPar *solver = (HyPar*) s;
11  MPIVariables *mpi = (MPIVariables*) m;
12  FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics;
14 
15  int *dim = solver->dim_local;
16  int ghosts = solver->ghosts;
17  int ndims = solver->ndims;
18  int index[ndims];
19 
20  double local_sum = 0;
21  int done = 0; _ArraySetValue_(index,ndims,0);
22  while (!done) {
23  int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p);
24  double dxinv; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv);
25  double dyinv; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv);
26  local_sum += (u[p] / (dxinv * dyinv));
27  _ArrayIncrementIndex_(ndims,dim,index,done);
28  }
29  double local_integral = local_sum;
30  double global_integral = 0;
31  IERR MPISum_double(&global_integral,&local_integral,1,&mpi->world); CHECKERR(ierr);
32  params->pdf_integral = global_integral;
33 
34  return(0);
35 }
#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
MPI related function definitions.
int MPISum_double(double *, double *, int, void *)
Definition: MPISum.c:39
int FPPowerSystem1BusPostStep(double *, void *, void *, double, int)
#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)
MPI_Comm world
#define CHECKERR(ierr)
Definition: basic.h:18
Contains structure definition for hypar.
double * dxinv
Definition: hypar.h:110
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Contains macros and function definitions for common array operations.
#define IERR
Definition: basic.h:16
Structure of MPI-related variables.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
Fokker-Planck Model for 1-Bus Power System.
#define _XDIR_
Definition: euler1d.h:75
#define _DECLARE_IERR_
Definition: basic.h:17