HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SparseGridsInitializationWrapup.cpp File Reference

Wrap up all initializations. More...

Go to the source code of this file.

Functions

int VolumeIntegral (double *, double *, void *, void *)
 

Detailed Description

Wrap up all initializations.

Author
Debojyoti Ghosh, John Loffeld, Lee Ricketson

Definition in file SparseGridsInitializationWrapup.cpp.

Function Documentation

int VolumeIntegral ( double *  VolumeIntegral,
double *  u,
void *  s,
void *  m 
)

Compute the volume integral of the solution.

Parameters
VolumeIntegralThe computed volume integral
uSolution
sSolver object of type HyPar
mMPI object of type MPIVariables

Definition at line 14 of file VolumeIntegral.c.

20 {
21  HyPar *solver = (HyPar*) s;
22  MPIVariables *mpi = (MPIVariables*) m;
23 
24  int ndims = solver->ndims;
25  int nvars = solver->nvars;
26  int *dim = solver->dim_local;
27  int ghosts = solver->ghosts;
28  int d,v;
29 
30  /* calculate local volume integral of the solution */
31  int index[ndims], done = 0;
32  double *local_integral = (double*) calloc (nvars,sizeof(double));
33  _ArraySetValue_(local_integral,nvars,0.0);
34  _ArraySetValue_(index,ndims,0);
35  while (!done) {
36  int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p);
37  double dxinv[ndims];
38  for (d=0; d<ndims; d++) { _GetCoordinate_(d,index[d],dim,ghosts,solver->dxinv,dxinv[d]); }
39  double dV = 1.0; for (d=0; d<ndims; d++) dV *= (1.0/dxinv[d]);
40  for (v=0; v<nvars; v++) local_integral[v] += (u[p*nvars+v]*dV);
41  _ArrayIncrementIndex_(ndims,dim,index,done);
42  }
43  /* sum over all processors to get global integral of the solution */
44  IERR MPISum_double(VolumeIntegral,local_integral,nvars,&mpi->world); CHECKERR(ierr);
45  free(local_integral);
46 
47  return(0);
48 }
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
int * dim_local
Definition: hypar.h:37
int MPISum_double(double *, double *, int, void *)
Definition: MPISum.c:39
#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
int nvars
Definition: hypar.h:29
#define CHECKERR(ierr)
Definition: basic.h:18
double * dxinv
Definition: hypar.h:110
int ndims
Definition: hypar.h:26
#define IERR
Definition: basic.h:16
Structure of MPI-related variables.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
int VolumeIntegral(double *VolumeIntegral, double *u, void *s, void *m)