-
-
Notifications
You must be signed in to change notification settings - Fork 288
/
n_upwind.c
77 lines (64 loc) · 2 KB
/
n_upwind.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*****************************************************************************
*
* MODULE: Grass PDE Numerical Library
* AUTHOR(S): Soeren Gebbert, Berlin (GER) Dec 2006
* soerengebbert <at> gmx <dot> de
*
* PURPOSE: upwinding stabilization algorithms
* part of the gpde library
*
* COPYRIGHT: (C) 2000 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
*****************************************************************************/
#include <math.h>
#include <grass/N_pde.h>
/*! \brief full upwinding stabilization algorithm
*
* The arguments are values to compute the local peclet number
*
* \param sprod double -- the scalar produkt between the velocity vector and the normal vector between two points
* \param distance double -- distance between two points
* \param D double -- diffusion/dispersion tensor part between two points
*
* \return the weighting factor
* */
double N_full_upwinding(double sprod, double distance, double D)
{
double z;
if (D == 0)
return 0.5;
/*compute the local peclet number */
z = sprod * distance / D;
if (z > 0)
return 1;
if (z == 0)
return 0.5;
if (z < 0)
return 0;
return 0;
}
/*! \brief exponential upwinding stabilization algorithm
*
* The arguments are values to compute the local peclet number
*
* \param sprod double -- the scalar produkt between the velocity vector and the normal vector between two points
* \param distance double -- distance between two points
* \param D double -- diffusion/dispersion tensor part between two points
*
* \return the weighting factor
* */
double N_exp_upwinding(double sprod, double distance, double D)
{
double z;
if (D == 0)
return 0.5;
/*compute the local peclet number */
z = sprod * distance / D;
if (z != 0)
return (1 - (1 / z) * (1 - (z / (exp(z) - 1))));
return 0.5;
}