Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WriteConvergence.F90
Go to the documentation of this file.
1 ! *********************************************************************
2 ! * Rocstar Simulation Suite *
3 ! * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4 ! * *
5 ! * Illinois Rocstar LLC *
6 ! * Champaign, IL *
7 ! * www.illinoisrocstar.com *
8 ! * sales@illinoisrocstar.com *
9 ! * *
10 ! * License: See LICENSE file in top level of distribution package or *
11 ! * http://opensource.org/licenses/NCSA *
12 ! *********************************************************************
13 ! *********************************************************************
14 ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15 ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16 ! * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17 ! * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18 ! * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 ! * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20 ! * Arising FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21 ! * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22 ! *********************************************************************
23 !******************************************************************************
24 !
25 ! Purpose: write convergence history to screen and to file.
26 !
27 ! Description: none.
28 !
29 ! Input: global%forceX/Y/Z = forces in x-, y- and z-direction
30 ! global%massIn/Out = mass flow in and out of domain
31 ! global%residual = actual density residual
32 ! global%resInit = initial residual (for normalization purposes)
33 !
34 ! Output: to screen and file.
35 !
36 ! Notes: none.
37 !
38 !******************************************************************************
39 !
40 ! $Id: WriteConvergence.F90,v 1.4 2008/12/06 08:44:10 mtcampbe Exp $
41 !
42 ! Copyright: (c) 2001 by the University of Illinois
43 !
44 !******************************************************************************
45 
46 SUBROUTINE writeconvergence( global )
47 
48  USE moddatatypes
49  USE moderror
50  USE modglobal, ONLY : t_global
51  USE modtools, ONLY : makenonzero
52  USE modmpi
53  USE modparameters
54 
55  IMPLICIT NONE
56 
57 ! ... parameters
58  TYPE(t_global), POINTER :: global
59 
60 ! ... local variables
61  REAL(RFREAL) :: resnorm
62 #ifdef MPI
63  REAL(RFREAL) :: localvals(6), globalvals(6)
64 #endif
65 
66 !******************************************************************************
67 
68  CALL registerfunction( global,'WriteConvergence',&
69  'WriteConvergence.F90' )
70 
71 ! sum up data from other processors -------------------------------------------
72 
73 #ifdef MPI
74  localvals(1) = global%forceX
75  localvals(2) = global%forceY
76  localvals(3) = global%forceZ
77  localvals(4) = global%massIn
78  localvals(5) = global%massOut
79  localvals(6) = global%stopRun
80 
81 ! CALL MPI_Reduce( localVals,globalVals,6,MPI_RFREAL,MPI_SUM,MASTERPROC, &
82 ! global%mpiComm,global%mpierr )
83  CALL mpi_allreduce( localvals,globalvals,6,mpi_rfreal,mpi_sum, &
84  global%mpiComm,global%mpierr )
85  IF (global%mpierr /= 0) CALL errorstop( global,err_mpi_trouble,__line__ )
86 
87  global%forceX = globalvals(1)
88  global%forceY = globalvals(2)
89  global%forceZ = globalvals(3)
90  global%massIn = globalvals(4)
91  global%massOut = globalvals(5)
92  global%stopRun = globalvals(6)
93 #endif
94 
95 ! steady flow -----------------------------------------------------------------
96 
97  IF (global%flowType==flow_steady .AND. global%myProcid==masterproc) THEN
98  IF (global%currentIter == 1) THEN
99  resnorm = 1._rfreal
100  ELSE
101  resnorm = global%residual/makenonzero(global%resInit)
102  resnorm = makenonzero(resnorm)
103  ENDIF
104 
105  IF (global%verbLevel /= verbose_none) &
106  WRITE(stdout,1000) solver_name,global%currentIter,log10(resnorm), &
107  global%forceX,global%forceY,global%forceZ, &
108  global%massIn,global%massOut
109 
110  WRITE(if_conver,1010,err=10) global%currentIter,log10(resnorm), &
111  global%forceX,global%forceY,global%forceZ, &
112  global%massIn,global%massOut
113 
114 ! unsteady flow ---------------------------------------------------------------
115 
116  ELSE IF (global%flowType==flow_unsteady .AND. global%myProcid==masterproc) THEN
117  IF (global%verbLevel /= verbose_none) &
118  WRITE(stdout,2000) solver_name,global%currentTime,global%dtMin, &
119  global%forceX,global%forceY,global%forceZ, &
120  global%massIn,global%massOut
121 
122  WRITE(if_conver,2010,err=10) global%currentTime,global%dtMin, &
123  global%forceX,global%forceY,global%forceZ, &
124  global%massIn,global%massOut
125  ENDIF
126 
127 ! finalize --------------------------------------------------------------------
128 
129  CALL deregisterfunction( global )
130  goto 999
131 
132 10 CONTINUE
133  CALL errorstop( global,err_file_write,__line__,'Convergence file.' )
134 
135 1000 FORMAT(a,1x,i6,1pe13.4,5e13.4)
136 1010 FORMAT( i6,1pe13.4,5e13.4)
137 2000 FORMAT(a,1x,1pe12.5,6e13.4)
138 2010 FORMAT( 1pe12.5,6e13.4)
139 
140 999 CONTINUE
141 
142 END SUBROUTINE writeconvergence
143 
144 !******************************************************************************
145 !
146 ! RCS Revision history:
147 !
148 ! $Log: WriteConvergence.F90,v $
149 ! Revision 1.4 2008/12/06 08:44:10 mtcampbe
150 ! Updated license.
151 !
152 ! Revision 1.3 2008/11/19 22:17:24 mtcampbe
153 ! Added Illinois Open Source License/Copyright
154 !
155 ! Revision 1.2 2005/04/15 15:06:07 haselbac
156 ! Removed Charm/FEM stuff, routine no longer called by RFLU
157 !
158 ! Revision 1.1 2004/12/01 16:52:21 haselbac
159 ! Initial revision after changing case
160 !
161 ! Revision 1.16 2003/05/19 21:18:21 jblazek
162 ! Automated switch to 0th-order extrapolation at slip walls and injection boundaries.
163 !
164 ! Revision 1.15 2003/05/15 02:57:02 jblazek
165 ! Inlined index function.
166 !
167 ! Revision 1.14 2003/02/06 01:33:38 jblazek
168 ! Taken resNorm out of conditional compilation.
169 !
170 ! Revision 1.13 2003/02/05 21:07:30 jblazek
171 ! Coordinated stop of a run works now for MPI.
172 !
173 ! Revision 1.12 2002/09/20 22:22:35 jblazek
174 ! Finalized integration into GenX.
175 !
176 ! Revision 1.11 2002/09/05 17:40:20 jblazek
177 ! Variable global moved into regions().
178 !
179 ! Revision 1.10 2002/08/30 01:47:58 jblazek
180 ! Added support for moving grids.
181 !
182 ! Revision 1.9 2002/07/25 14:49:31 haselbac
183 ! Added FEM call to get force and mass flows for parallel runs
184 !
185 ! Revision 1.8 2002/06/17 13:32:55 haselbac
186 ! Prefixed SOLVER_NAME to all screen output
187 !
188 ! Revision 1.7 2002/05/04 16:19:23 haselbac
189 ! Added MakeNonZero function and ModTools
190 !
191 ! Revision 1.6 2002/03/18 22:25:45 jblazek
192 ! Finished multiblock and MPI.
193 !
194 ! Revision 1.5 2002/02/21 23:25:05 jblazek
195 ! Blocks renamed as regions.
196 !
197 ! Revision 1.4 2002/02/16 07:16:00 jblazek
198 ! Added implicit residual smoothing.
199 !
200 ! Revision 1.3 2002/02/09 01:47:01 jblazek
201 ! Added multi-probe option, residual smoothing, physical time step.
202 !
203 ! Revision 1.2 2002/01/31 20:56:30 jblazek
204 ! Added basic boundary conditions.
205 !
206 ! Revision 1.1 2002/01/30 02:16:24 jblazek
207 ! Convergence output moved to common library.
208 !
209 !******************************************************************************
210 
211 
212 
213 
214 
215 
216 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
void int int REAL * x
Definition: read.cpp:74
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine writeconvergence(global)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
RT a() const
Definition: Line_2.h:140
real(rfreal) function makenonzero(x)
Definition: ModTools.F90:85