HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
FPDoubleWellPostStep.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 FPDoubleWellPostStep(double *u,void* s,void *m,double t,int iter)
9 {
10  HyPar *solver = (HyPar*) s;
11  MPIVariables *mpi = (MPIVariables*) m;
12  FPDoubleWell *params = (FPDoubleWell*) 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 dx = 1.0 / solver->dxinv[index[0]+ghosts];
25  local_sum += (u[p] * dx);
26  _ArrayIncrementIndex_(ndims,dim,index,done);
27  }
28  double local_integral = local_sum;
29  double global_integral = 0;
30  IERR MPISum_double(&global_integral,&local_integral,1,&mpi->world); CHECKERR(ierr);
31  params->pdf_integral = global_integral;
32 
33  return(0);
34 }
#define IERR
Definition: basic.h:16
MPI related function definitions.
#define CHECKERR(ierr)
Definition: basic.h:18
double pdf_integral
Definition: fpdoublewell.h:28
int MPISum_double(double *, double *, int, void *)
Definition: MPISum.c:39
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
Contains structure definition for hypar.
MPI_Comm world
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
int FPDoubleWellPostStep(double *u, void *s, void *m, double t, int iter)
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
Structure of MPI-related variables.
#define _DECLARE_IERR_
Definition: basic.h:17
Contains macros and function definitions for common array operations.
double * dxinv
Definition: hypar.h:110