GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
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 
23 /*! \brief full upwinding stabilization algorithm
24  *
25  * The arguments are values to compute the local peclet number
26  *
27  * \param sprod double -- the scalar produkt between the velocity vector and the normal vector between two points
28  * \param distance double -- distance between two points
29  * \param D double -- diffusion/dispersion tensor part between two points
30  *
31  * \return the weighting factor
32  * */
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 
53 /*! \brief exponential upwinding stabilization algorithm
54  *
55  * The arguments are values to compute the local peclet number
56  *
57  * \param sprod double -- the scalar produkt between the velocity vector and the normal vector between two points
58  * \param distance double -- distance between two points
59  * \param D double -- diffusion/dispersion tensor part between two 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 }
double N_full_upwinding(double sprod, double distance, double D)
full upwinding stabilization algorithm
Definition: n_upwind.c:33
#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