-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMODULE_RIGHTHANDSIDE.f90
209 lines (170 loc) · 9.45 KB
/
MODULE_RIGHTHANDSIDE.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
MODULE MODULE_RIGHTHANDSIDE
USE MODULE_PRECISION
USE MODULE_ELEMENT
USE MODULE_RIEMANNFLUX
USE MODULE_DFDU
CONTAINS
SUBROUTINE COMPUTE_RIGHTHANDSIDE_ADV(FIRST, LAST, NELE, ELE)
IMPLICIT NONE
INTEGER(IP), INTENT(IN) :: FIRST, LAST, NELE
TYPE(ELEMENT), DIMENSION(1:NELE), INTENT(INOUT) :: ELE
INTEGER(IP) :: IELE, N1
REAL(WP), DIMENSION(ELE(1)%ORDER + 1) :: DF1
REAL(WP) :: RHO_L, U_L, U_R, RHO_R
REAL(WP) :: NF1_L, NF1_R
REAL(WP) :: F1_L, F1_R
DO IELE = FIRST, LAST, 1
N1 = ELE(IELE)%ORDER + 1
!COMPUTE LEFT STAGE
RHO_L = ELE(IELE)%LEFT(1)%CONSERVATIVE(N1, 1)
U_L = ELE(IELE)%LEFT(1)%PRIMATIVE(N1, 2)
RHO_R = ELE(IELE)%CONSERVATIVE(1, 1)
U_R = ELE(IELE)%PRIMATIVE(1, 2)
NF1_L = 0.5_WP*(RHO_L*U_L + RHO_R*U_R - (RHO_R - RHO_L))
F1_L = RHO_R
! COMPUTE RIGHT STAGE
RHO_L = ELE(IELE)%CONSERVATIVE(N1, 1)
U_L = ELE(IELE)%PRIMATIVE(N1, 2)
RHO_R = ELE(IELE)%RIGHT(1)%CONSERVATIVE(1, 1)
U_R = ELE(IELE)%RIGHT(1)%PRIMATIVE(1, 2)
NF1_R = 0.5_WP*(RHO_L*U_L + RHO_R*U_R - (RHO_R - RHO_L))
F1_R = RHO_L
DF1 = MATMUL(ELE(IELE)%COMSYS(1)%DR, ELE(IELE)%CONSERVATIVE(:,1))
WRITE(*, *) ELE(IELE)%COMSYS(1)%DR
! FLUX RECONSTRUCTION SCHEME
ELE(IELE)%CONS_RHS(:, 1) = -(DF1(:) + ELE(IELE)%CP_COEF(1)%GLB(:)*(NF1_L - F1_L) + ELE(IELE)%CP_COEF(1)%GRB(:)*(NF1_R - F1_R))*ELE(IELE)%RX(:)
ELE(IELE)%CONS_RHS(:, 2) =0.0
ELE(IELE)%CONS_RHS(:, 3) =0.0
!WRITE(*, 10) ELE(IELE)%CONS_RHS(:, 1)
!WRITE(*, 10) ELE(IELE)%CONS_RHS(:, 2)
!WRITE(*, 10) ELE(IELE)%CONS_RHS(:, 3)
!CONTINUE
10 FORMAT(7F30.23)
END DO
END SUBROUTINE
SUBROUTINE COMPUTE_RIGHTHANDSIDE(FIRST, LAST, NELE, ELE)
IMPLICIT NONE
INTEGER(IP), INTENT(IN) :: FIRST, LAST, NELE
TYPE(ELEMENT), DIMENSION(1:NELE), INTENT(INOUT) :: ELE
INTEGER(IP) :: IELE
REAL(WP) :: RHO_L, RHO_R, U_L, U_R, RHOE_L, RHOE_R, RHOU_L, RHOU_R, P_L, P_R
REAL(WP) :: NF1_L, NF1_R, NF2_L, NF2_R, NF3_L, NF3_R
REAL(WP) :: F1_L, F1_R, F2_L, F2_R, F3_L, F3_R
INTEGER(IP) :: N1
REAL(WP), DIMENSION(ELE(1)%ORDER + 1) :: DF1, DF2, DF3
REAL(WP), DIMENSION(ELE(1)%ORDER + 1) :: A11, A12, A13, A21, A22, A23, A31,A32, A33
DO IELE = FIRST, LAST, 1
N1 = ELE(IELE)%ORDER + 1
!COMPUTE LEFT STAGE
RHO_L = ELE(IELE)%LEFT(1)%CONSERVATIVE(N1, 1)
RHOU_L = ELE(IELE)%LEFT(1)%CONSERVATIVE(N1, 2)
RHOE_L = ELE(IELE)%LEFT(1)%CONSERVATIVE(N1, 3)
P_L = ELE(IELE)%LEFT(1)%PRIMATIVE(N1, 1)
U_L = ELE(IELE)%LEFT(1)%PRIMATIVE(N1, 2)
RHO_R = ELE(IELE)%CONSERVATIVE(1, 1)
RHOU_R = ELE(IELE)%CONSERVATIVE(1, 2)
RHOE_R = ELE(IELE)%CONSERVATIVE(1, 3)
P_R = ELE(IELE)%PRIMATIVE(1, 1)
U_R = ELE(IELE)%PRIMATIVE(1, 2)
CALL RUSANOV(ELE(IELE)%MATERIALINFO(1)%GAMMA, ELE(IELE)%MATERIALINFO(1)%GAMMA, RHO_L, RHO_R, U_L, U_R, RHOE_L, RHOE_R, RHOU_L, RHOU_R, P_L, P_R, NF1_L, NF2_L, NF3_L)
F1_L = RHOU_R
F2_L = RHOU_R*RHOU_R/RHO_R + P_R
F3_L = U_R*(RHOE_R + P_R)
! COMPUTE RIGHT STAGE
RHO_L = ELE(IELE)%CONSERVATIVE(N1, 1)
RHOU_L = ELE(IELE)%CONSERVATIVE(N1, 2)
RHOE_L = ELE(IELE)%CONSERVATIVE(N1, 3)
P_L = ELE(IELE)%PRIMATIVE(N1, 1)
U_L = ELE(IELE)%PRIMATIVE(N1, 2)
RHO_R = ELE(IELE)%RIGHT(1)%CONSERVATIVE(1, 1)
RHOU_R = ELE(IELE)%RIGHT(1)%CONSERVATIVE(1, 2)
RHOE_R = ELE(IELE)%RIGHT(1)%CONSERVATIVE(1, 3)
P_R = ELE(IELE)%RIGHT(1)%PRIMATIVE(1, 1)
U_R = ELE(IELE)%RIGHT(1)%PRIMATIVE(1, 2)
CALL RUSANOV(ELE(IELE)%MATERIALINFO(1)%GAMMA, ELE(IELE)%MATERIALINFO(1)%GAMMA, RHO_L, RHO_R, U_L, U_R, RHOE_L, RHOE_R, RHOU_L, RHOU_R, P_L, P_R, NF1_R, NF2_R, NF3_R)
F1_R = RHOU_L
F2_R = RHOU_L*RHOU_L/RHO_L + P_L
F3_R = U_L*(RHOE_L + P_L)
CALL COMPUTE_A11(N1, ELE(IELE)%MATERIALINFO(1)%GAMMA, &
ELE(IELE)%CONSERVATIVE(:,1), ELE(IELE)%CONSERVATIVE(:,2), ELE(IELE)%CONSERVATIVE(:,3), &
ELE(IELE)%PRIMATIVE(:,1), ELE(IELE)%PRIMATIVE(:,2), ELE(IELE)%PRIMATIVE(:,3), A11)
CALL COMPUTE_A12(N1, ELE(IELE)%MATERIALINFO(1)%GAMMA, &
ELE(IELE)%CONSERVATIVE(:,1), ELE(IELE)%CONSERVATIVE(:,2), ELE(IELE)%CONSERVATIVE(:,3), &
ELE(IELE)%PRIMATIVE(:,1), ELE(IELE)%PRIMATIVE(:,2), ELE(IELE)%PRIMATIVE(:,3), A12)
CALL COMPUTE_A13(N1, ELE(IELE)%MATERIALINFO(1)%GAMMA, &
ELE(IELE)%CONSERVATIVE(:,1), ELE(IELE)%CONSERVATIVE(:,2), ELE(IELE)%CONSERVATIVE(:,3), &
ELE(IELE)%PRIMATIVE(:,1), ELE(IELE)%PRIMATIVE(:,2), ELE(IELE)%PRIMATIVE(:,3), A13)
CALL COMPUTE_A21(N1, ELE(IELE)%MATERIALINFO(1)%GAMMA, &
ELE(IELE)%CONSERVATIVE(:,1), ELE(IELE)%CONSERVATIVE(:,2), ELE(IELE)%CONSERVATIVE(:,3), &
ELE(IELE)%PRIMATIVE(:,1), ELE(IELE)%PRIMATIVE(:,2), ELE(IELE)%PRIMATIVE(:,3), A21)
CALL COMPUTE_A22(N1, ELE(IELE)%MATERIALINFO(1)%GAMMA, &
ELE(IELE)%CONSERVATIVE(:,1), ELE(IELE)%CONSERVATIVE(:,2), ELE(IELE)%CONSERVATIVE(:,3), &
ELE(IELE)%PRIMATIVE(:,1), ELE(IELE)%PRIMATIVE(:,2), ELE(IELE)%PRIMATIVE(:,3), A22)
CALL COMPUTE_A23(N1, ELE(IELE)%MATERIALINFO(1)%GAMMA, &
ELE(IELE)%CONSERVATIVE(:,1), ELE(IELE)%CONSERVATIVE(:,2), ELE(IELE)%CONSERVATIVE(:,3), &
ELE(IELE)%PRIMATIVE(:,1), ELE(IELE)%PRIMATIVE(:,2), ELE(IELE)%PRIMATIVE(:,3), A23)
CALL COMPUTE_A31(N1, ELE(IELE)%MATERIALINFO(1)%GAMMA, &
ELE(IELE)%CONSERVATIVE(:,1), ELE(IELE)%CONSERVATIVE(:,2), ELE(IELE)%CONSERVATIVE(:,3), &
ELE(IELE)%PRIMATIVE(:,1), ELE(IELE)%PRIMATIVE(:,2), ELE(IELE)%PRIMATIVE(:,3), A31)
CALL COMPUTE_A32(N1, ELE(IELE)%MATERIALINFO(1)%GAMMA, &
ELE(IELE)%CONSERVATIVE(:,1), ELE(IELE)%CONSERVATIVE(:,2), ELE(IELE)%CONSERVATIVE(:,3), &
ELE(IELE)%PRIMATIVE(:,1), ELE(IELE)%PRIMATIVE(:,2), ELE(IELE)%PRIMATIVE(:,3), A32)
CALL COMPUTE_A33(N1, ELE(IELE)%MATERIALINFO(1)%GAMMA, &
ELE(IELE)%CONSERVATIVE(:,1), ELE(IELE)%CONSERVATIVE(:,2), ELE(IELE)%CONSERVATIVE(:,3), &
ELE(IELE)%PRIMATIVE(:,1), ELE(IELE)%PRIMATIVE(:,2), ELE(IELE)%PRIMATIVE(:,3), A33)
ELE(IELE)%C(:) = DSQRT(ELE(IELE)%MATERIALINFO(1)%GAMMA*ELE(IELE)%PRIMATIVE(:,1)/ELE(IELE)%CONSERVATIVE(:,1))
DF1(:) = A11(:)*ELE(IELE)%CONSERVATIVE(:,1) + A12(:)*ELE(IELE)%CONSERVATIVE(:,2) + A13(:)*ELE(IELE)%CONSERVATIVE(:,3)
DF2(:) = A21(:)*ELE(IELE)%CONSERVATIVE(:,1) + A22(:)*ELE(IELE)%CONSERVATIVE(:,2) + A23(:)*ELE(IELE)%CONSERVATIVE(:,3)
DF3(:) = A31(:)*ELE(IELE)%CONSERVATIVE(:,1) + A32(:)*ELE(IELE)%CONSERVATIVE(:,2) + A33(:)*ELE(IELE)%CONSERVATIVE(:,3)
DF1 = MATMUL(ELE(IELE)%COMSYS(1)%DR, DF1)
DF2 = MATMUL(ELE(IELE)%COMSYS(1)%DR, DF2)
DF3 = MATMUL(ELE(IELE)%COMSYS(1)%DR, DF3)
!PRINT*, ELE(IELE)%INDEX
! FLUX RECONSTRUCTION SCHEME
ELE(IELE)%CONS_RHS(:, 1) = -(DF1(:) + ELE(IELE)%CP_COEF(1)%GLB(:)*(NF1_L - F1_L) + ELE(IELE)%CP_COEF(1)%GRB(:)*(NF1_R - F1_R))*ELE(IELE)%RX(:)
ELE(IELE)%CONS_RHS(:, 2) = -(DF2(:) + ELE(IELE)%CP_COEF(1)%GLB(:)*(NF2_L - F2_L) + ELE(IELE)%CP_COEF(1)%GRB(:)*(NF2_R - F2_R))*ELE(IELE)%RX(:)
ELE(IELE)%CONS_RHS(:, 3) = -(DF3(:) + ELE(IELE)%CP_COEF(1)%GLB(:)*(NF3_L - F3_L) + ELE(IELE)%CP_COEF(1)%GRB(:)*(NF3_R - F3_R))*ELE(IELE)%RX(:)
!WRITE(*, 10) ELE(IELE)%CONS_RHS(:, 1)
!WRITE(*, 10) ELE(IELE)%CONS_RHS(:, 2)
!WRITE(*, 10) ELE(IELE)%CONS_RHS(:, 3)
!CONTINUE
10 FORMAT(7F30.23)
END DO
END SUBROUTINE COMPUTE_RIGHTHANDSIDE
SUBROUTINE ADD_ARTIFICALVISCOSITY2RHS(IVAL, FIRST, LAST, NELE, ELE)
IMPLICIT NONE
INTEGER(IP), INTENT(IN) :: IVAL, FIRST, LAST, NELE
TYPE(ELEMENT), DIMENSION(1:NELE), INTENT(INOUT), TARGET :: ELE
INTEGER(IP) :: SIZE, IELE
DO IELE = FIRST, LAST, 1
!IF (IVAL == 3) THEN
!WRITE(*, *) "============================================", IELE
!WRITE(*, *) "CONSERVATIVE ===============================>"
!WRITE(*, 10) ELE(IELE)%CONSERVATIVE(:,1)
!WRITE(*, 10) ELE(IELE)%CONSERVATIVE(:,2)
!WRITE(*, 10) ELE(IELE)%CONSERVATIVE(:,3)
!WRITE(*, *) "RHS ===============================> "
!WRITE(*, 10) ELE(IELE)%CONS_RHS(:,1)
!WRITE(*, 10) ELE(IELE)%CONS_RHS(:,2)
!WRITE(*, 10) ELE(IELE)%CONS_RHS(:,3)
!
!WRITE(*, *) "U_XX ===============================>"
!WRITE(*, 10) ELE(IELE)%U_XX(:, 1)
!WRITE(*, 10) ELE(IELE)%U_XX(:, 2)
!WRITE(*, 10) ELE(IELE)%U_XX(:, 3)
!CONTINUE
!END IF
SIZE = ELE(IELE)%ORDER + 1
ELE(IELE)%CONS_RHS(1:SIZE,IVAL) = ELE(IELE)%CONS_RHS(1:SIZE, IVAL) + ELE(IELE)%U_XX(1:SIZE, IVAL)
!IF (IVAL == 3) THEN
!PRINT*, ele(iele)%index
!PRINT*, ele(iele)%cons_rhs(1:size, 1)
!PRINT*, ele(iele)%cons_rhs(1:size, 2)
!PRINT*, ele(iele)%cons_rhs(1:size, 3)
!continue
!END IF
END DO
RETURN
10 FORMAT(7F30.23)
END SUBROUTINE ADD_ARTIFICALVISCOSITY2RHS
END MODULE MODULE_RIGHTHANDSIDE