~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/gpde/n_upwind.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}