HydroCODE_2D 0.1
This is a implementation of fully explict forward Euler scheme for 2-D Euler equations of motion on Eulerian coordinate
slope_limiter.c
浏览该文件的文档.
1
5#include <stdio.h>
6#include <stdarg.h>
7
8#include "../include/var_struc.h"
9#include "../include/tools.h"
10
11
31void minmod_limiter(const _Bool NO_h, const int m, const _Bool find_bound, double s[],
32 const double U[], const double UL, const double UR, const double HL, ...)
33{
34 va_list ap;
35 va_start(ap, HL);
36 int j;
37 double const alpha = config[41]; // the paramater in slope limiters.
38 double s_L, s_R; // spatial derivatives in coordinate x (slopes)
39 double h = HL, HR, * X;
40 if (NO_h)
41 {
42 HR = va_arg(ap, double);
43 X = va_arg(ap, double *);
44 }
45
46 for(j = 0; j < m; ++j) // Reconstruct slopes
47 { /*
48 * j-1 j j+1
49 * j-1/2 j-1 j+1/2 j j+3/2 j+1
50 * o-----X-----o-----X-----o-----X--...
51 */
52 if(j)
53 {
54 if (NO_h)
55 h = 0.5 * (X[j+1] - X[j-1]);
56 s_L = (U[j] - U[j-1]) / h;
57 }
58 else
59 {
60 if (NO_h)
61 h = 0.5 * (X[j+1] - X[j] + HL);
62 s_L = (U[j] - UL) / h;
63 }
64 if(j < m-1)
65 {
66 if (NO_h)
67 h = 0.5 * (X[j+2] - X[j]);
68 s_R = (U[j+1] - U[j]) / h;
69 }
70 else
71 {
72 if (NO_h)
73 h = 0.5 * (X[j+1] - X[j] + HR);
74 s_R = (UR - U[j]) / h;
75 }
76 if (find_bound)
77 s[j] = minmod3(alpha*s_L, alpha*s_R, s[j]);
78 else
79 s[j] = minmod2(s_L, s_R);
80 }
81 va_end(ap);
82}
void minmod_limiter(const _Bool NO_h, const int m, const _Bool find_bound, double s[], const double U[], const double UL, const double UR, const double HL,...)
This function apply the minmod limiter to the slope in one dimension.
Definition: slope_limiter.c:31
double minmod2(const double s_L, const double s_R)
Minmod limiter function of two variables.
Definition: tools.h:23
double minmod3(const double s_L, const double s_R, const double s_m)
Minmod limiter function of three variables.
Definition: tools.h:38
double config[]
Initial configuration data array.
Definition: hydrocode.c:115