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 File Reference

Compute the conservation error. More...

#include <math.h>
#include <basic.h>
#include <mathfunctions.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

int CalculateConservationError (void *s, void *m)
 

Detailed Description

Compute the conservation error.

Author
Debojyoti Ghosh

Definition in file CalculateConservationError.c.

Function Documentation

int CalculateConservationError ( void *  s,
void *  m 
)

Calculates the error (L2) in conservation by computing the difference between the initial volume integral of the solution, and the sum of the current volume integral and the time integral of the boundary flux from the start of the simulation to the current simulation time.

Parameters
sSolver object of type HyPar
mMPI object of type MPIVariables

Definition at line 16 of file CalculateConservationError.c.

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 }
double * TotalBoundaryIntegral
Definition: hypar.h:386
double * VolumeIntegral
Definition: hypar.h:378
int nvars
Definition: hypar.h:29
double * VolumeIntegralInitial
Definition: hypar.h:380
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