GRASS Programmer's Manual
6.4.2(2012)
|
00001 00002 /***************************************************************************** 00003 * 00004 * MODULE: Grass PDE Numerical Library 00005 * AUTHOR(S): Soeren Gebbert, Berlin (GER) Dec 2006 00006 * soerengebbert <at> gmx <dot> de 00007 * 00008 * PURPOSE: upwinding stabilization algorithms 00009 * part of the gpde library 00010 * 00011 * COPYRIGHT: (C) 2000 by the GRASS Development Team 00012 * 00013 * This program is free software under the GNU General Public 00014 * License (>=v2). Read the file COPYING that comes with GRASS 00015 * for details. 00016 * 00017 *****************************************************************************/ 00018 00019 #include <math.h> 00020 #include "grass/N_pde.h" 00021 00022 00033 double N_full_upwinding(double sprod, double distance, double D) 00034 { 00035 double z; 00036 00037 if (D == 0) 00038 return 0.5; 00039 00040 /*compute the local peclet number */ 00041 z = sprod * distance / D; 00042 00043 if (z > 0) 00044 return 1; 00045 if (z == 0) 00046 return 0.5; 00047 if (z < 0) 00048 return 0; 00049 00050 return 0; 00051 } 00052 00063 double N_exp_upwinding(double sprod, double distance, double D) 00064 { 00065 double z; 00066 00067 if (D == 0) 00068 return 0.5; 00069 00070 /*compute the local peclet number */ 00071 z = sprod * distance / D; 00072 00073 if (z != 0) 00074 return (1 - (1 / z) * (1 - (z / (exp(z) - 1)))); 00075 00076 return 0.5; 00077 }