HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
CalculateConservationError.c
Go to the documentation of this file.
1 
5 #include <math.h>
6 #include <basic.h>
7 #include <mathfunctions.h>
8 #include <mpivars.h>
9 #include <hypar.h>
10 
17  void *s,
18  void *m
19  )
20 {
21  HyPar *solver = (HyPar*) s;
22  int v,nvars = solver->nvars;
23  double error;
24 
25  double base[nvars];
26  for (v=0; v<nvars; v++) {
27  if (absolute(solver->VolumeIntegralInitial[v]) > 1.0)
28  base[v] = absolute(solver->VolumeIntegralInitial[v]);
29  else base[v] = 1.0;
30  }
31 
32  for (v=0; v<nvars; v++) {
33  error = (solver->VolumeIntegral[v]+solver->TotalBoundaryIntegral[v]-solver->VolumeIntegralInitial[v])
34  * (solver->VolumeIntegral[v]+solver->TotalBoundaryIntegral[v]-solver->VolumeIntegralInitial[v]);
35  solver->ConservationError[v] = sqrt(error)/base[v];
36  }
37 
38  return(0);
39 }
#define absolute(a)
Definition: math_ops.h:32
int nvars
Definition: hypar.h:29
MPI related function definitions.
Contains function definitions for common mathematical functions.
Some basic definitions and macros.
double * ConservationError
Definition: hypar.h:374
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
int CalculateConservationError(void *s, void *m)
Contains structure definition for hypar.
double * TotalBoundaryIntegral
Definition: hypar.h:386
double * VolumeIntegral
Definition: hypar.h:378
double * VolumeIntegralInitial
Definition: hypar.h:380