Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_CalcMassFlow.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: calculate amount of inflow and outflow for a region.
26 !
27 ! Description: none.
28 !
29 ! Input: region%levels%mixt = flow variables
30 ! region%levels%grid%si/j/k = face vectors (at boundaries)
31 !
32 ! Output: global%massIn = inflow mass
33 ! global%massOut = outflow mass
34 !
35 ! Notes: mass flow is computed as a sum over all inflow/outflow/injection
36 ! boundaries of the region.
37 !
38 !******************************************************************************
39 !
40 ! $Id: RFLO_CalcMassFlow.F90,v 1.4 2008/12/06 08:44:26 mtcampbe Exp $
41 !
42 ! Copyright: (c) 2001 by the University of Illinois
43 !
44 !******************************************************************************
45 
46 SUBROUTINE rflo_calcmassflow( region )
47 
48  USE moddatatypes
49  USE modbndpatch, ONLY : t_patch
50  USE moddatastruct, ONLY : t_region
53  USE moderror
54  USE modparameters
55  IMPLICIT NONE
56 
57 #include "Indexing.h"
58 
59 ! ... parameters
60  TYPE(t_region) :: region
61 
62 ! ... loop variables
63  INTEGER :: ipatch, i, j, k
64 
65 ! ... local variables
66  INTEGER :: ilev, lbound, ibeg, iend, jbeg, jend, kbeg, kend, idir, jdir, kdir
67  INTEGER :: bctype, icoff, ijcoff, inoff, ijnoff, ijkc, ijkd, ijkn
68  INTEGER :: inode, jnode, knode
69 
70  LOGICAL :: inflow, outflow
71 
72  REAL(RFREAL) :: sgn, massin, massout, rhoua, rhova, rhowa, mass
73  REAL(RFREAL), POINTER :: cv(:,:), sface(:,:)
74 
75  TYPE(t_patch), POINTER :: patch
76 
77 !******************************************************************************
78 
79  CALL registerfunction( region%global,'RFLO_CalcMassFlow',&
80  'RFLO_CalcMassFlow.F90' )
81 
82 ! get dimensions and pointers -------------------------------------------------
83 
84  ilev = region%currLevel
85 
86  CALL rflo_getcelloffset( region,ilev,icoff,ijcoff )
87  CALL rflo_getnodeoffset( region,ilev,inoff,ijnoff )
88 
89  cv => region%levels(ilev)%mixt%cv
90 
91  massin = region%global%massIn
92  massout = region%global%massOut
93 
94 ! loop over patches -----------------------------------------------------------
95 
96  DO ipatch=1,region%nPatches
97 
98  patch => region%levels(ilev)%patches(ipatch)
99  bctype = patch%bcType
100  lbound = patch%lbound
101 
102  IF ((bctype>=bc_inflow .AND. bctype<=bc_inflow +bc_range) .OR. &
103  (bctype>=bc_outflow .AND. bctype<=bc_outflow +bc_range) .OR. &
104  (bctype>=bc_injection .AND. bctype<=bc_injection+bc_range) .OR. &
105  (bctype>=bc_farfield .AND. bctype<=bc_farfield +bc_range)) THEN
106 
107 ! --- get dimensions of the patch
108 
109  CALL rflo_getpatchindices( region,patch,ilev, &
110  ibeg,iend,jbeg,jend,kbeg,kend )
112 
113 ! --- inflow or outflow?
114 
115  inflow = .false.
116  outflow = .false.
117  IF (bctype>=bc_inflow .AND. bctype<=bc_inflow +bc_range) inflow = .true.
118  IF (bctype>=bc_injection .AND. bctype<=bc_injection+bc_range) inflow = .true.
119  IF (bctype>=bc_outflow .AND. bctype<=bc_outflow +bc_range) outflow = .true.
120  IF (bctype>=bc_farfield .AND. bctype<=bc_farfield +bc_range) outflow = .true.
121 
122 ! --- to take the right face vector and make it point outwards
123 
124  sgn = +1._rfreal
125  inode = 0
126  jnode = 0
127  knode = 0
128  IF (lbound==2 .OR. lbound==4 .OR. lbound==6) THEN
129  sgn = -1._rfreal
130  inode = -idir
131  jnode = -jdir
132  knode = -kdir
133  ENDIF
134 
135 ! --- get the appropriate face vector
136 
137  IF (lbound==1 .OR. lbound==2) sface => region%levels(ilev)%grid%si
138  IF (lbound==3 .OR. lbound==4) sface => region%levels(ilev)%grid%sj
139  IF (lbound==5 .OR. lbound==6) sface => region%levels(ilev)%grid%sk
140 
141 ! --- loop over all cells of the patch
142 
143  DO k=kbeg,kend
144  DO j=jbeg,jend
145  DO i=ibeg,iend
146  ijkc = indijk(i,j,k,icoff,ijcoff)
147  ijkd = indijk(i-idir,j-jdir,k-kdir,icoff,ijcoff)
148  ijkn = indijk(i+inode,j+jnode,k+knode,inoff,ijnoff)
149  rhoua = 0.5_rfreal*(cv(cv_mixt_xmom,ijkc)+cv(cv_mixt_xmom,ijkd))
150  rhova = 0.5_rfreal*(cv(cv_mixt_ymom,ijkc)+cv(cv_mixt_ymom,ijkd))
151  rhowa = 0.5_rfreal*(cv(cv_mixt_zmom,ijkc)+cv(cv_mixt_zmom,ijkd))
152  mass = sgn*sface(xcoord,ijkn)*rhoua + &
153  sgn*sface(ycoord,ijkn)*rhova + &
154  sgn*sface(zcoord,ijkn)*rhowa
155  IF (inflow ) massin = massin - mass
156  IF (outflow) massout = massout + mass
157  ENDDO
158  ENDDO
159  ENDDO
160 
161  ENDIF ! inflow/outflow
162 
163  ENDDO ! iPatch
164 
165 ! finalize --------------------------------------------------------------------
166 
167  region%global%massIn = massin
168  region%global%massOut = massout
169 
170  CALL deregisterfunction( region%global )
171 
172 END SUBROUTINE rflo_calcmassflow
173 
174 !******************************************************************************
175 !
176 ! RCS Revision history:
177 !
178 ! $Log: RFLO_CalcMassFlow.F90,v $
179 ! Revision 1.4 2008/12/06 08:44:26 mtcampbe
180 ! Updated license.
181 !
182 ! Revision 1.3 2008/11/19 22:17:37 mtcampbe
183 ! Added Illinois Open Source License/Copyright
184 !
185 ! Revision 1.2 2004/12/20 20:06:41 wasistho
186 ! enable mass flow computation at farfield boundary
187 !
188 ! Revision 1.1 2004/11/29 20:51:38 wasistho
189 ! lower to upper case
190 !
191 ! Revision 1.16 2003/11/20 16:40:37 mdbrandy
192 ! Backing out RocfluidMP changes from 11-17-03
193 !
194 ! Revision 1.12 2003/10/01 23:52:10 jblazek
195 ! Corrected bug in moving noslip wall BC and grid speeds.
196 !
197 ! Revision 1.11 2003/05/15 02:57:03 jblazek
198 ! Inlined index function.
199 !
200 ! Revision 1.10 2002/09/27 00:57:10 jblazek
201 ! Changed makefiles - no makelinks needed.
202 !
203 ! Revision 1.9 2002/09/05 17:40:21 jblazek
204 ! Variable global moved into regions().
205 !
206 ! Revision 1.8 2002/03/18 23:11:32 jblazek
207 ! Finished multiblock and MPI.
208 !
209 ! Revision 1.7 2002/02/21 23:25:05 jblazek
210 ! Blocks renamed as regions.
211 !
212 ! Revision 1.6 2002/02/04 15:30:25 jblazek
213 ! Added injection boundary condition.
214 !
215 ! Revision 1.5 2002/02/01 22:17:38 jblazek
216 ! Change addressing of face vectors at block boundaries.
217 !
218 ! Revision 1.4 2002/02/01 00:00:24 jblazek
219 ! Edge and corner cells defined for each level.
220 !
221 ! Revision 1.3 2002/01/31 20:56:30 jblazek
222 ! Added basic boundary conditions.
223 !
224 ! Revision 1.2 2002/01/23 03:51:25 jblazek
225 ! Added low-level time-stepping routines.
226 !
227 ! Revision 1.1 2002/01/16 22:03:35 jblazek
228 ! Added time-stepping routines.
229 !
230 !******************************************************************************
231 
232 
233 
234 
235 
236 
237 
**********************************************************************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 ibeg
subroutine rflo_getpatchdirection(patch, idir, jdir, kdir)
**********************************************************************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 inode
j indices k indices k
Definition: Indexing.h:6
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine rflo_getpatchindices(region, patch, iLev, ibeg, iend, jbeg, jend, kbeg, kend)
subroutine rflo_calcmassflow(region)
subroutine rflo_getnodeoffset(region, iLev, iNodeOffset, ijNodeOffset)
**********************************************************************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 jdir
Definition: patch.h:74
**********************************************************************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 knode iend
blockLoc i
Definition: read.cpp:79
**********************************************************************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 idir
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 knode jend
**********************************************************************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 kdir
**********************************************************************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 knode jbeg
**********************************************************************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 knode kbeg
subroutine deregisterfunction(global)
Definition: ModError.F90:469
**********************************************************************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 jnode