forked from truongdangqe/Unstruct2D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvergence.f90
96 lines (82 loc) · 2.85 KB
/
convergence.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
!> @file convergence.f90
!!
!! Output of the convergence history.
!
! *****************************************************************************
!
! (c) J. Blazek, CFD Consulting & Analysis, www.cfd-ca.de
! Created February 25, 2014
! Last modification: June 3, 2014
!
! *****************************************************************************
!
! This program 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 2
! of the License, or (at your option) any later version.
!
! This program 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 this program; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
!
! *****************************************************************************
!> Monitors the convergence, prints it out and stores it in a file. For external
!! flow, it also prints out the lift, the drag and the moment coefficients. For
!! internal flow, it prints out the mass flow and the mass flow ratio.
!!
subroutine Convergence
use ModDataTypes
use ModFiles
use ModControl
use ModGeometry
use ModNumerics
use ModPhysics
use ModPlotQuant
use ModInterfaces, only : Forces, Massflow
implicit none
! local variables
integer :: i, idr
real(rtype) :: dr, drmax
! *****************************************************************************
! compute the residual
drho = 0.D0
drmax = 0.D0
do i=1,nndint
dr = cv(1,i) - cvold(1,i)
drho = drho + dr*dr
if (Abs(dr) >= drmax) then
drmax = Abs(dr)
idr = i
endif
enddo
if (iter == 1) then
drho1 = Sqrt(drho) + 1.D-32
drho = 1.D0
else
drho = Sqrt(drho)/drho1
endif
! compute forces & moments (external flow)
if (kflow == "E") then
call Forces
! compute mass flow and mass flow ratio (internal flow)
else
call Massflow
endif
! print out / store
if (kflow == "E") then
write(ifConv,1000) iter,Log10(drho),drmax,idr,cl,cd,cm
write(*,1005) iter,Log10(drho),drmax,idr,cl,cd,cm
else
write(ifConv,1010) iter,Log10(drho),drmax,idr,mflow,mfratio
write(*,1015) iter,Log10(drho),drmax,idr,mflow,mfratio
endif
1000 format(I5,1P,2X,E12.5,2X,E12.5,0P,I8,1P,3(2X,E12.5))
1005 format(I5,1P,2X,E11.4,2X,E10.4,0P,I8,1P,3(2X,E10.3))
1010 format(I5,1P,2X,E12.5,2X,E12.5,0P,I8,1X,1P,2(2X,E12.5))
1015 format(I5,1P,2X,E11.4,2X,E10.4,0P,I8,1X,1P,2(2X,E10.4))
end subroutine Convergence