This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
accelerate_kernel.f90
122 lines (95 loc) · 3.98 KB
/
accelerate_kernel.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
!Crown Copyright 2012 AWE.
!
! This file is part of CloverLeaf.
!
! CloverLeaf is free software: you can redistribute it and/or modify it under
! the terms of the GNU General Public License as published by the
! Free Software Foundation, either version 3 of the License, or (at your option)
! any later version.
!
! CloverLeaf is distributed in the hope that it will be useful, but
! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
! FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
! details.
!
! You should have received a copy of the GNU General Public License along with
! CloverLeaf. If not, see http://www.gnu.org/licenses/.
!> @brief Fortran acceleration kernel
!> @author Wayne Gaudin
!> @details The pressure and viscosity gradients are used to update the
!> velocity field.
MODULE accelerate_kernel_module
CONTAINS
SUBROUTINE accelerate_kernel(x_min,x_max,y_min,y_max,dt, &
xarea,yarea, &
volume, &
density0, &
pressure, &
viscosity, &
xvel0, &
yvel0, &
xvel1, &
yvel1, &
stepbymass )
IMPLICIT NONE
INTEGER :: x_min,x_max,y_min,y_max
REAL(KIND=8) :: dt
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: density0
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: volume
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+2) :: xarea
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+3) :: yarea
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: pressure
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: viscosity
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: xvel0,yvel0
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: xvel1,yvel1
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: stepbymass
INTEGER :: j,k
REAL(KIND=8) :: nodal_mass
!$OMP PARALLEL
!$OMP DO PRIVATE(nodal_mass)
DO k=y_min,y_max+1
DO j=x_min,x_max+1
nodal_mass=(density0(j-1,k-1)*volume(j-1,k-1) &
+density0(j ,k-1)*volume(j ,k-1) &
+density0(j ,k )*volume(j ,k ) &
+density0(j-1,k )*volume(j-1,k )) &
*0.25_8
stepbymass(j,k)=0.5_8*dt/nodal_mass
ENDDO
ENDDO
!$OMP END DO
!$OMP DO
DO k=y_min,y_max+1
DO j=x_min,x_max+1
xvel1(j,k)=xvel0(j,k)-stepbymass(j,k)*(xarea(j ,k )*(pressure(j ,k )-pressure(j-1,k )) &
+xarea(j ,k-1)*(pressure(j ,k-1)-pressure(j-1,k-1)))
ENDDO
ENDDO
!$OMP END DO
!$OMP DO
DO k=y_min,y_max+1
DO j=x_min,x_max+1
yvel1(j,k)=yvel0(j,k)-stepbymass(j,k)*(yarea(j ,k )*(pressure(j ,k )-pressure(j ,k-1)) &
+yarea(j-1,k )*(pressure(j-1,k )-pressure(j-1,k-1)))
ENDDO
ENDDO
!$OMP END DO
!$OMP DO
DO k=y_min,y_max+1
DO j=x_min,x_max+1
xvel1(j,k)=xvel1(j,k)-stepbymass(j,k)*(xarea(j ,k )*(viscosity(j ,k )-viscosity(j-1,k )) &
+xarea(j ,k-1)*(viscosity(j ,k-1)-viscosity(j-1,k-1)))
ENDDO
ENDDO
!$OMP END DO
!$OMP DO
DO k=y_min,y_max+1
DO j=x_min,x_max+1
yvel1(j,k)=yvel1(j,k)-stepbymass(j,k)*(yarea(j ,k )*(viscosity(j ,k )-viscosity(j ,k-1)) &
+yarea(j-1,k )*(viscosity(j-1,k )-viscosity(j-1,k-1)))
ENDDO
ENDDO
!$OMP END DO
!$OMP END PARALLEL
END SUBROUTINE accelerate_kernel
END MODULE accelerate_kernel_module