HydroCODE_1D 0.1
This is a implementation of fully explict forward Euler scheme for 1-D Euler equations of motion on Lagrangian/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 i_f_var_get, 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 double const alpha = config[41]; // the paramater in slope limiters.
37 double s_L, s_R; // spatial derivatives in coordinate x (slopes)
38 double h = HL, HR, * X;
39 if (NO_h)
40 {
41 HR = va_arg(ap, double);
42 X = va_arg(ap, double *);
43 }
44#ifdef _OPENACC
45#pragma acc parallel loop private(s_L, s_R, h)
46#endif
47 for(int j = 0; j < m; ++j) // Reconstruct slopes
48 { /*
49 * j-1 j j+1
50 * j-1/2 j-1 j+1/2 j j+3/2 j+1
51 * o-----X-----o-----X-----o-----X--...
52 */
53 if(j)
54 {
55 if (NO_h)
56 h = 0.5 * (X[j+1] - X[j-1]);
57 s_L = (U[j] - U[j-1]) / h;
58 }
59 else
60 {
61 if (NO_h)
62 h = 0.5 * (X[j+1] - X[j] + HL);
63 s_L = (U[j] - UL) / h;
64 }
65 if(j < m-1)
66 {
67 if (NO_h)
68 h = 0.5 * (X[j+2] - X[j]);
69 s_R = (U[j+1] - U[j]) / h;
70 }
71 else
72 {
73 if (NO_h)
74 h = 0.5 * (X[j+1] - X[j] + HR);
75 s_R = (UR - U[j]) / h;
76 }
77 if (i_f_var_get)
78 s[j] = minmod3(alpha*s_L, alpha*s_R, s[j]);
79 else
80 s[j] = minmod2(s_L, s_R);
81 } // End of parallel region
82 va_end(ap);
83}
double config[N_CONF]
Initial configuration data array.
Definition: hydrocode.c:111
void minmod_limiter(const _Bool NO_h, const int m, const _Bool i_f_var_get, 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:44
double minmod3(const double s_L, const double s_R, const double s_m)
Minmod limiter function of three variables.
Definition: tools.h:59