forked from dattv/QTAdaptive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMODULE_CFD_DATA.f90
193 lines (167 loc) · 7.2 KB
/
MODULE_CFD_DATA.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
!=================================================================================================
!> CARTESIAN QUADTREE ADAPTIVE MESH REFINEMENT LIBRARY
!> AUTHOR: VAN-DAT THANG
!> E-MAIL: [email protected]
!> E-MAIL: [email protected]
!> SOURCE CODE LINK: https://github.com/dattv/QTAdaptive
!=================================================================================================
MODULE MODULE_CFD_DATA
use MODULE_PRECISION
use MODULE_CONSTANTS
type :: reconstruction_data
real(rp), dimension(4) :: x_r
end type reconstruction_data
type :: cfd_data
integer(ip) :: NQ ! total equations
real(rp), dimension(:), allocatable :: u ! conservative variables
real(rp), dimension(:), allocatable :: w ! primative variables
real(rp), dimension(:), allocatable :: u_old ! conservative variables
real(rp), dimension(:), allocatable :: u_new ! conservative variables
real(rp), dimension(:), allocatable :: res ! residual
real(rp) :: wsn ! wave speed
real(rp) :: dt
! ===> reconstruction data <=====================================
type(reconstruction_data), dimension(:), allocatable :: recons
contains
procedure :: new => new_cfd_data
procedure :: delete => delete_cfd_data
procedure :: add_cfd_data
generic :: operator (+) => add_cfd_data
end type cfd_data
!=================== INTERFACE =====================
interface assignment(=)
module procedure asign_cfd
end interface
contains
!=================================================================================================
subroutine new_cfd_data(this, NQ)
implicit none
class(cfd_data), intent(inout) :: this
integer(ip), intent(in) :: NQ
integer(ip) :: temp_NQ
! body
this%NQ = NQ
if (.not. allocated(this%u)) then
allocate(this%u(NQ))
else
temp_NQ = sizeof(this%u)
if (temp_NQ /= NQ) then
deallocate(this%u)
allocate(this%u(NQ))
end if
end if
if (.not. allocated(this%w)) then
allocate(this%w(NQ))
else
temp_NQ = sizeof(this%w)
if (temp_NQ /= NQ) then
deallocate(this%w)
allocate(this%w(NQ))
end if
end if
if (.not. allocated(this%u_old)) then
allocate(this%u_old(NQ))
else
temp_NQ = sizeof(this%u_old)
if (temp_NQ /= NQ) then
deallocate(this%u_old)
allocate(this%u_old(NQ))
end if
end if
if (.not. allocated(this%u_new)) then
allocate(this%u_new(NQ))
else
temp_NQ = sizeof(this%u_new)
if (temp_NQ /= NQ) then
deallocate(this%u_new)
allocate(this%u_new(NQ))
end if
end if
if (.not. allocated(this%res)) then
allocate(this%res(NQ))
else
temp_NQ = sizeof(this%res)
if (temp_NQ /= NQ) then
deallocate(this%res)
allocate(this%res(NQ))
end if
end if
if (.not. allocated(this%recons)) then
allocate(this%recons(NQ))
else
temp_NQ = sizeof(this%recons)
if (temp_NQ /= NQ) then
deallocate(this%recons)
allocate(this%recons(NQ))
end if
end if
this%u = zero
this%w = zero
this%u_old = zero
this%u_new = zero
this%res = zero
this%wsn = zero
this%recons%x_r(1) = zero
this%recons%x_r(2) = zero
this%recons%x_r(3) = zero
this%recons%x_r(4) = zero
return
end subroutine new_cfd_data
!=================================================================================================
subroutine delete_cfd_data(this)
implicit none
class(cfd_data), intent(inout) :: this
! body
if (allocated(this%u )) deallocate(this%u ) ! conservative variables
if (allocated(this%w )) deallocate(this%w ) ! primative variables
if (allocated(this%u_old )) deallocate(this%u_old ) ! conservative variables
if (allocated(this%u_new )) deallocate(this%u_new ) ! conservative variables
if (allocated(this%res )) deallocate(this%res ) ! residual
if (allocated(this%recons)) deallocate(this%recons)
return
end subroutine delete_cfd_data
!=================================================================================================
subroutine asign_cfd(out_cfd_data, in_cfd_data)
implicit none
type(cfd_data), intent(out) :: out_cfd_data
type(cfd_data), intent(in) :: in_cfd_data
! body
call out_cfd_data%new(in_cfd_data%NQ)
out_cfd_data%NQ = in_cfd_data%NQ ! total equations
out_cfd_data%u = in_cfd_data%u ! conservative variables
out_cfd_data%w = in_cfd_data%w ! primative variables
out_cfd_data%u_old = in_cfd_data%u_old ! conservative variables
out_cfd_data%u_new = in_cfd_data%u_new ! conservative variables
out_cfd_data%res = in_cfd_data%res ! residual
out_cfd_data%wsn = in_cfd_data%wsn ! wave speed
out_cfd_data%recons%x_r(1) = in_cfd_data%recons%x_r(1)
out_cfd_data%recons%x_r(2) = in_cfd_data%recons%x_r(2)
out_cfd_data%recons%x_r(3) = in_cfd_data%recons%x_r(3)
out_cfd_data%recons%x_r(4) = in_cfd_data%recons%x_r(4)
return
end subroutine asign_cfd
!=================================================================================================
function add_cfd_data(this, in_cfd_data) result(res)
implicit none
class(cfd_data), intent(in) :: this
type(cfd_data), intent(in) :: in_cfd_data
type(cfd_data) :: res
call res%new(in_cfd_data%NQ)
res%NQ = in_cfd_data%NQ ! total equations
res%u = this%u + in_cfd_data%u ! conservative variables
res%w = this%w + in_cfd_data%w ! primative variables
res%u_old = this%u_old + in_cfd_data%u_old ! conservative variables
res%u_new = this%u_new + in_cfd_data%u_new ! conservative variables
res%res = this%res + in_cfd_data%res ! residual
res%wsn = this%wsn + in_cfd_data%wsn ! wave speed
res%recons%x_r(1) = this%recons%x_r(1) + in_cfd_data%recons%x_r(1)
res%recons%x_r(2) = this%recons%x_r(2) + in_cfd_data%recons%x_r(2)
res%recons%x_r(3) = this%recons%x_r(3) + in_cfd_data%recons%x_r(3)
res%recons%x_r(4) = this%recons%x_r(4) + in_cfd_data%recons%x_r(4)
return
end function add_cfd_data
!=================================================================================================
!=================================================================================================
!=================================================================================================
!=================================================================================================
END MODULE MODULE_CFD_DATA