HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 }
int CalculateConservationError(void *s, void *m)
MPI related function definitions.
double * TotalBoundaryIntegral
Definition: hypar.h:386
Contains function definitions for common mathematical functions.
double * VolumeIntegral
Definition: hypar.h:378
int nvars
Definition: hypar.h:29
Contains structure definition for hypar.
double * VolumeIntegralInitial
Definition: hypar.h:380
Some basic definitions and macros.
double * ConservationError
Definition: hypar.h:374
#define absolute(a)
Definition: math_ops.h:32
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23