Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_ResidualNorm.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: compute the 2-norm of the residual.
26 !
27 ! Description: none.
28 !
29 ! Input: blck = data of current region.
30 !
31 ! Output: global%residual = norm (all regions, all processors).
32 !
33 ! Notes: none.
34 !
35 !******************************************************************************
36 !
37 ! $Id: RFLO_ResidualNorm.F90,v 1.3 2008/12/06 08:44:27 mtcampbe Exp $
38 !
39 ! Copyright: (c) 2001 by the University of Illinois
40 !
41 !******************************************************************************
42 
43 SUBROUTINE rflo_residualnorm( regions )
44 
45  USE moddatatypes
46  USE modglobal, ONLY : t_global
47  USE moddatastruct, ONLY : t_region
49  USE moderror
50  USE modmpi
51  USE modparameters
52  IMPLICIT NONE
53 
54 #include "Indexing.h"
55 
56 ! ... parameters
57  TYPE(t_region), POINTER :: regions(:)
58 
59 ! ... loop variables
60  INTEGER :: ireg, i, j, k
61 
62 ! ... local variables
63  INTEGER :: ipcbeg, ipcend, jpcbeg, jpcend, kpcbeg, kpcend
64  INTEGER :: ilev, ijkc, icoff, ijcoff
65 
66  REAL(RFREAL) :: dr, drho, drhotot
67  REAL(RFREAL), POINTER :: cv(:,:), cvold(:,:)
68 
69  TYPE(t_global), POINTER :: global
70 
71 !******************************************************************************
72 
73  global => regions(1)%global
74 
75  CALL registerfunction( global,'RFLO_ResidualNorm',&
76  'RFLO_ResidualNorm.F90' )
77 
78 ! sum drho for all regions on this processor ----------------------------------
79 
80  drho = 0._rfreal
81 
82  DO ireg=1,global%nRegions
83  IF (regions(ireg)%procid==global%myProcid .AND. & ! region active and
84  regions(ireg)%active==active) THEN ! on my processor
85 
86 ! --- get dimensions and pointers
87 
88  ilev = regions(ireg)%currLevel
89 
90  CALL rflo_getdimensphys( regions(ireg),ilev,ipcbeg,ipcend, &
91  jpcbeg,jpcend,kpcbeg,kpcend )
92  CALL rflo_getcelloffset( regions(ireg),ilev,icoff,ijcoff )
93 
94  cv => regions(ireg)%levels(ilev)%mixt%cv
95  cvold => regions(ireg)%levels(ilev)%mixt%cvOld
96 
97 ! --- add to the sum
98 
99  DO k=kpcbeg,kpcend
100  DO j=jpcbeg,jpcend
101  DO i=ipcbeg,ipcend
102  ijkc = indijk(i,j,k,icoff,ijcoff)
103  dr = cv(cv_mixt_dens,ijkc) - cvold(cv_mixt_dens,ijkc)
104  drho = drho + dr*dr
105  ENDDO
106  ENDDO
107  ENDDO
108 
109  ENDIF ! active
110  ENDDO ! iReg
111 
112 ! exchange between processors -------------------------------------------------
113 
114 #ifdef MPI
115  CALL mpi_allreduce( drho,drhotot,1,mpi_rfreal,mpi_sum, &
116  global%mpiComm,global%mpierr )
117  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
118 #else
119  drhotot = drho
120 #endif
121 
122  global%residual = sqrt(drhotot)
123 
124  IF (global%currentIter == 1) THEN
125  global%resInit = global%residual
126  ENDIF
127 
128 ! finalize --------------------------------------------------------------------
129 
130  CALL deregisterfunction( global )
131 
132 END SUBROUTINE rflo_residualnorm
133 
134 !******************************************************************************
135 !
136 ! RCS Revision history:
137 !
138 ! $Log: RFLO_ResidualNorm.F90,v $
139 ! Revision 1.3 2008/12/06 08:44:27 mtcampbe
140 ! Updated license.
141 !
142 ! Revision 1.2 2008/11/19 22:17:38 mtcampbe
143 ! Added Illinois Open Source License/Copyright
144 !
145 ! Revision 1.1 2004/11/29 20:51:40 wasistho
146 ! lower to upper case
147 !
148 ! Revision 1.10 2003/11/20 16:40:40 mdbrandy
149 ! Backing out RocfluidMP changes from 11-17-03
150 !
151 ! Revision 1.6 2003/05/15 02:57:04 jblazek
152 ! Inlined index function.
153 !
154 ! Revision 1.5 2002/09/20 22:22:36 jblazek
155 ! Finalized integration into GenX.
156 !
157 ! Revision 1.4 2002/09/05 17:40:22 jblazek
158 ! Variable global moved into regions().
159 !
160 ! Revision 1.3 2002/02/21 23:25:06 jblazek
161 ! Blocks renamed as regions.
162 !
163 ! Revision 1.2 2002/01/31 20:56:30 jblazek
164 ! Added basic boundary conditions.
165 !
166 ! Revision 1.1 2002/01/23 03:51:25 jblazek
167 ! Added low-level time-stepping routines.
168 !
169 !******************************************************************************
170 
171 
172 
173 
174 
175 
176 
j indices k indices k
Definition: Indexing.h:6
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE kpcbeg
subroutine rflo_residualnorm(regions)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
double sqrt(double d)
Definition: double.h:73
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE jpcbeg
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE ipcend
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE ipcbeg
blockLoc i
Definition: read.cpp:79
subroutine rflo_getcelloffset(region, iLev, iCellOffset, ijCellOffset)
j indices j
Definition: Indexing.h:6
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE jpcend
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine rflo_getdimensphys(region, iLev, ipcbeg, ipcend, jpcbeg, jpcend, kpcbeg, kpcend)