GRASS 8 Programmer's Manual 8.6.0dev(2026)-c83afef6d3
Loading...
Searching...
No Matches
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 * SPDX-FileCopyrightText: 2000 GRASS Development Team
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 *
13 *****************************************************************************/
14
15#include <math.h>
16#include <grass/N_pde.h>
17
18/*! \brief full upwinding stabilization algorithm
19 *
20 * The arguments are values to compute the local peclet number
21 *
22 * \param sprod double -- the scalar product between the velocity vector and the
23 * normal vector between two points \param distance double -- distance between
24 * two points \param D double -- diffusion/dispersion tensor part between two
25 * points
26 *
27 * \return the weighting factor
28 * */
29double N_full_upwinding(double sprod, double distance, double D)
30{
31 double z;
32
33 if (D == 0)
34 return 0.5;
35
36 /*compute the local peclet number */
37 z = sprod * distance / D;
38
39 if (z > 0)
40 return 1;
41 if (z == 0)
42 return 0.5;
43 if (z < 0)
44 return 0;
45
46 return 0;
47}
48
49/*! \brief exponential upwinding stabilization algorithm
50 *
51 * The arguments are values to compute the local peclet number
52 *
53 * \param sprod double -- the scalar product between the velocity vector and the
54 * normal vector between two points \param distance double -- distance between
55 * two points \param D double -- diffusion/dispersion tensor part between two
56 * points
57 *
58 * \return the weighting factor
59 * */
60double N_exp_upwinding(double sprod, double distance, double D)
61{
62 double z;
63
64 if (D == 0)
65 return 0.5;
66
67 /*compute the local peclet number */
68 z = sprod * distance / D;
69
70 if (z != 0)
71 return (1 - (1 / z) * (1 - (z / (exp(z) - 1))));
72
73 return 0.5;
74}
#define D
double N_exp_upwinding(double sprod, double distance, double D)
exponential upwinding stabilization algorithm
Definition n_upwind.c:60
double N_full_upwinding(double sprod, double distance, double D)
full upwinding stabilization algorithm
Definition n_upwind.c:29