GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
N_upwind.c
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * MODULE: Grass PDE Numerical Library
5 * AUTHOR(S): Soeren Gebbert, Berlin (GER) Dec 2006
6 * soerengebbert <at> gmx <dot> de
7 *
8 * PURPOSE: upwinding stabilization algorithms
9 * part of the gpde library
10 *
11 * COPYRIGHT: (C) 2000 by the GRASS Development Team
12 *
13 * This program is free software under the GNU General Public
14 * License (>=v2). Read the file COPYING that comes with GRASS
15 * for details.
16 *
17 *****************************************************************************/
18 
19 #include <math.h>
20 #include "grass/N_pde.h"
21 
22 
33 double N_full_upwinding(double sprod, double distance, double D)
34 {
35  double z;
36 
37  if (D == 0)
38  return 0.5;
39 
40  /*compute the local peclet number */
41  z = sprod * distance / D;
42 
43  if (z > 0)
44  return 1;
45  if (z == 0)
46  return 0.5;
47  if (z < 0)
48  return 0;
49 
50  return 0;
51 }
52 
63 double N_exp_upwinding(double sprod, double distance, double D)
64 {
65  double z;
66 
67  if (D == 0)
68  return 0.5;
69 
70  /*compute the local peclet number */
71  z = sprod * distance / D;
72 
73  if (z != 0)
74  return (1 - (1 / z) * (1 - (z / (exp(z) - 1))));
75 
76  return 0.5;
77 }
#define D
Definition: gis/intersect.c:74
double N_exp_upwinding(double sprod, double distance, double D)
exponential upwinding stabilization algorithm
Definition: N_upwind.c:63
double N_full_upwinding(double sprod, double distance, double D)
full upwinding stabilization algorithm
Definition: N_upwind.c:33