HydroCODE_2D 0.1
This is a implementation of fully explict forward Euler scheme for 2-D Euler equations of motion on Eulerian coordinate
bound_cond_slope_limiter.c
浏览该文件的文档.
1
5#include <stdio.h>
6#include <stdbool.h>
7#include <stdarg.h>
8
9#include "../include/var_struc.h"
10#include "../include/inter_process.h"
11
12
30_Bool bound_cond_slope_limiter(const _Bool NO_h, const int m, const int nt, struct cell_var_stru CV,
31 struct b_f_var * bfv_L, struct b_f_var * bfv_R, _Bool find_bound, const _Bool Slope, const double t_c, ...)
32{
33 va_list ap;
34 va_start(ap, t_c);
35 int const bound = (int)(config[17]);// the boundary condition in x-direction
36 double const h = config[10]; // the length of the initial x-spatial grids
37 double * X = NULL;
38 if (NO_h)
39 X = va_arg(ap, double *);
40
41 switch (bound)
42 {
43 case -1: // initial boudary conditions
44 if(find_bound)
45 break;
46 else
47 printf("Initial boudary conditions in x direction at time %g .\n", t_c);
48 bfv_L->U = CV.U[0][0]; bfv_R->U = CV.U[0][m-1];
49 bfv_L->P = CV.P[0][0]; bfv_R->P = CV.P[0][m-1];
50 bfv_L->RHO = CV.RHO[0][0]; bfv_R->RHO = CV.RHO[0][m-1];
51 break;
52 case -2: // reflective boundary conditions
53 if(!find_bound)
54 printf("Reflective boudary conditions in x direction.\n");
55 bfv_L->U = - CV.U[nt][0]; bfv_R->U = - CV.U[nt][m-1];
56 bfv_L->P = CV.P[nt][0]; bfv_R->P = CV.P[nt][m-1];
57 bfv_L->RHO = CV.RHO[nt][0]; bfv_R->RHO = CV.RHO[nt][m-1];
58 break;
59 case -4: // free boundary conditions
60 if(!find_bound)
61 printf("Free boudary conditions in x direction.\n");
62 bfv_L->U = CV.U[nt][0]; bfv_R->U = CV.U[nt][m-1];
63 bfv_L->P = CV.P[nt][0]; bfv_R->P = CV.P[nt][m-1];
64 bfv_L->RHO = CV.RHO[nt][0]; bfv_R->RHO = CV.RHO[nt][m-1];
65 break;
66 case -5: // periodic boundary conditions
67 if(!find_bound)
68 printf("Periodic boudary conditions in x direction.\n");
69 bfv_L->U = CV.U[nt][m-1]; bfv_R->U = CV.U[nt][0];
70 bfv_L->P = CV.P[nt][m-1]; bfv_R->P = CV.P[nt][0];
71 bfv_L->RHO = CV.RHO[nt][m-1]; bfv_R->RHO = CV.RHO[nt][0];
72 break;
73 case -24: // reflective + free boundary conditions
74 if(!find_bound)
75 printf("Reflective + Free boudary conditions in x direction.\n");
76 bfv_L->U = - CV.U[nt][0]; bfv_R->U = CV.U[nt][m-1];
77 bfv_L->P = CV.P[nt][0]; bfv_R->P = CV.P[nt][m-1];
78 bfv_L->RHO = CV.RHO[nt][0]; bfv_R->RHO = CV.RHO[nt][m-1];
79 break;
80 default:
81 printf("No suitable boundary coditions in x direction!\n");
82 return false;
83 }
84
85 if (NO_h)
86 {
87 switch (bound)
88 {
89 case -1: // initial boudary conditions
90 bfv_L->H = h; bfv_R->H = h;
91 break;
92 case -5: // periodic boundary conditions
93 bfv_L->H = X[m] - X[m-1];
94 bfv_R->H = X[1] - X[0];
95 break;
96 case -2: case -4: case -24:
97 bfv_L->H = X[1] - X[0];
98 bfv_R->H = X[m] - X[m-1];
99 break;
100 }
101 }
102//=================Initialize slopes=====================
103 // Reconstruct slopes
104 if (Slope)
105 {
106 if (NO_h)
107 {
108 minmod_limiter(NO_h, m, find_bound, CV.d_u, CV.U[nt], bfv_L->U, bfv_R->U, bfv_L->H, bfv_R->H, X);
109 minmod_limiter(NO_h, m, find_bound, CV.d_p, CV.P[nt], bfv_L->P, bfv_R->P, bfv_L->H, bfv_R->H, X);
110 minmod_limiter(NO_h, m, find_bound, CV.d_rho, CV.RHO[nt], bfv_L->RHO, bfv_R->RHO, bfv_L->H, bfv_R->H, X);
111 }
112 else
113 {
114 minmod_limiter(NO_h, m, find_bound, CV.d_u, CV.U[nt], bfv_L->U, bfv_R->U, h);
115 minmod_limiter(NO_h, m, find_bound, CV.d_p, CV.P[nt], bfv_L->P, bfv_R->P, h);
116 minmod_limiter(NO_h, m, find_bound, CV.d_rho, CV.RHO[nt], bfv_L->RHO, bfv_R->RHO, h);
117 }
118
119 switch(bound)
120 {
121 case -2: // reflective boundary conditions
122 bfv_L->SU = CV.d_u[0]; bfv_R->SU = CV.d_u[m-1];
123 break;
124 case -5: // periodic boundary conditions
125 bfv_L->SU = CV.d_u[m-1]; bfv_R->SU = CV.d_u[0];
126 bfv_L->SP = CV.d_p[m-1]; bfv_R->SP = CV.d_p[0];
127 bfv_L->SRHO = CV.d_rho[m-1]; bfv_R->SRHO = CV.d_rho[0];
128 break;
129 case -24: // reflective + free boundary conditions
130 bfv_L->SU = CV.d_u[0];
131 break;
132 }
133 }
134 va_end(ap);
135 return true;
136}
_Bool bound_cond_slope_limiter(const _Bool NO_h, const int m, const int nt, struct cell_var_stru CV, struct b_f_var *bfv_L, struct b_f_var *bfv_R, _Bool find_bound, const _Bool Slope, const double t_c,...)
This function apply the minmod limiter to the slope in one dimension.
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
Fluid VARiables at Boundary.
Definition: var_struc.h:63
double SRHO
Definition: var_struc.h:65
double RHO
Definition: var_struc.h:64
double U
Definition: var_struc.h:64
double P
Definition: var_struc.h:64
double SU
Definition: var_struc.h:65
double SP
Definition: var_struc.h:65
double H
H is the grid cell width.
Definition: var_struc.h:64
pointer structure of VARiables on STRUctural computational grid CELLs.
Definition: var_struc.h:35
double ** U
Definition: var_struc.h:36
double * d_u
Definition: var_struc.h:37
double ** RHO
Definition: var_struc.h:36
double * d_p
spatial derivatives in one dimension.
Definition: var_struc.h:37
double ** P
Definition: var_struc.h:36
double * d_rho
Definition: var_struc.h:37
double config[]
Initial configuration data array.
Definition: hydrocode.c:115