GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-535c39c9fc
n_upwind.c
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * MODULE: Grass PDE Numerical Library
4  * AUTHOR(S): Soeren Gebbert, Berlin (GER) Dec 2006
5  * soerengebbert <at> gmx <dot> de
6  *
7  * PURPOSE: upwinding stabilization algorithms
8  * part of the gpde library
9  *
10  * COPYRIGHT: (C) 2000 by the GRASS Development Team
11  *
12  * This program is free software under the GNU General Public
13  * License (>=v2). Read the file COPYING that comes with GRASS
14  * for details.
15  *
16  *****************************************************************************/
17 
18 #include <math.h>
19 #include <grass/N_pde.h>
20 
21 /*! \brief full upwinding stabilization algorithm
22  *
23  * The arguments are values to compute the local peclet number
24  *
25  * \param sprod double -- the scalar product between the velocity vector and the
26  * normal vector between two points \param distance double -- distance between
27  * two points \param D double -- diffusion/dispersion tensor part between two
28  * points
29  *
30  * \return the weighting factor
31  * */
32 double N_full_upwinding(double sprod, double distance, double D)
33 {
34  double z;
35 
36  if (D == 0)
37  return 0.5;
38 
39  /*compute the local peclet number */
40  z = sprod * distance / D;
41 
42  if (z > 0)
43  return 1;
44  if (z == 0)
45  return 0.5;
46  if (z < 0)
47  return 0;
48 
49  return 0;
50 }
51 
52 /*! \brief exponential upwinding stabilization algorithm
53  *
54  * The arguments are values to compute the local peclet number
55  *
56  * \param sprod double -- the scalar product between the velocity vector and the
57  * normal vector between two points \param distance double -- distance between
58  * two points \param D double -- diffusion/dispersion tensor part between two
59  * points
60  *
61  * \return the weighting factor
62  * */
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:72
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:32