Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModReadWriteBcDataFile.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: Collection of routines to read boundary condition data file.
26 !
27 ! Description: None.
28 !
29 ! Notes: None.
30 !
31 ! ******************************************************************************
32 !
33 ! $Id: RFLU_ModReadWriteBcDataFile.F90,v 1.6 2008/12/06 08:44:23 mtcampbe Exp $
34 !
35 ! Copyright: (c) 2004 by the University of Illinois
36 !
37 ! ******************************************************************************
38 
40 
41  USE modparameters
42  USE moddatatypes
43  USE moderror
44  USE modglobal, ONLY: t_global
45  USE modbndpatch, ONLY: t_patch
46  USE moddatastruct, ONLY: t_region
47  USE modgrid, ONLY: t_grid
48  USE modmpi
49 
50  IMPLICIT NONE
51 
52  PRIVATE
53  PUBLIC :: rflu_decidereadwritebcdatafile, &
56 
57 ! ******************************************************************************
58 ! Declarations and definitions
59 ! ******************************************************************************
60 
61  CHARACTER(CHRLEN) :: RCSIdentString = &
62  '$RCSfile: RFLU_ModReadWriteBcDataFile.F90,v $ $Revision: 1.6 $'
63 
64 ! ******************************************************************************
65 ! Routines
66 ! ******************************************************************************
67 
68  CONTAINS
69 
70 
71 
72 
73 
74 
75 
76 ! ******************************************************************************
77 !
78 ! Purpose: Decide whether need to read and/or write boundary-condition data
79 ! file.
80 !
81 ! Description: None.
82 !
83 ! Input:
84 ! pRegion Pointer to region data
85 !
86 ! Output: None.
87 !
88 ! Notes: None.
89 !
90 ! ******************************************************************************
91 
92  LOGICAL FUNCTION rflu_decidereadwritebcdatafile(pRegion)
93 
94  IMPLICIT NONE
95 
96 ! ******************************************************************************
97 ! Declarations and definitions
98 ! ******************************************************************************
99 
100 ! ==============================================================================
101 ! Arguments
102 ! ==============================================================================
103 
104  TYPE(t_region), POINTER :: pregion
105 
106 ! ==============================================================================
107 ! Local variables
108 ! ==============================================================================
109 
110  CHARACTER(CHRLEN) :: rcsidentstring
111  INTEGER :: ipatch
112  TYPE(t_global), POINTER :: global
113  TYPE(t_grid), POINTER :: pgrid
114  TYPE(t_patch), POINTER :: ppatch
115 
116 ! ******************************************************************************
117 ! Start
118 ! ******************************************************************************
119 
120  global => pregion%global
121 
122  CALL registerfunction(global,'RFLU_DecideReadWriteBcDataFile',&
123  'RFLU_ModReadWriteBcDataFile.F90')
124 
125 ! ******************************************************************************
126 ! Set pointers and initialize
127 ! ******************************************************************************
128 
129  pgrid => pregion%grid
130 
132 
133 ! ******************************************************************************
134 ! Loop over patches
135 ! ******************************************************************************
136 
137  DO ipatch = 1,pgrid%nPatches
138  ppatch => pregion%patches(ipatch)
139 
140 ! ==============================================================================
141 ! If not coupled and have distribution, write data
142 ! ==============================================================================
143 
144  IF ( (ppatch%bcCoupled == bc_not_coupled) .AND. &
145  (ppatch%mixt%distrib == bcdat_distrib) ) THEN
146 ! TEMPORARY
147 ! RFLU_DecideReadWriteBcDataFile = .TRUE.
149 ! END TEMPORARY
150 
151  EXIT
152  END IF ! pPatch%bcCoupled
153  END DO ! iPatch
154 
155 ! ******************************************************************************
156 ! End
157 ! ******************************************************************************
158 
159  CALL deregisterfunction(global)
160 
161  END FUNCTION rflu_decidereadwritebcdatafile
162 
163 
164 
165 
166 
167 
168 
169 
170 ! ******************************************************************************
171 !
172 ! Purpose: Read boundary-condition data file.
173 !
174 ! Description: None.
175 !
176 ! Input:
177 ! pRegion Pointer to region data
178 !
179 ! Output: None.
180 !
181 ! Notes:
182 ! 1. At present restricted to mixture. Best way to extend to MP not clear.
183 !
184 ! ******************************************************************************
185 
186  SUBROUTINE rflu_readbcdatafile(pRegion)
187 
189 
190  IMPLICIT NONE
191 
192 ! ******************************************************************************
193 ! Declarations and definitions
194 ! ******************************************************************************
195 
196 ! ==============================================================================
197 ! Arguments
198 ! ==============================================================================
199 
200  TYPE(t_region), POINTER :: pregion
201 
202 ! ==============================================================================
203 ! Local variables
204 ! ==============================================================================
205 
206  CHARACTER(CHRLEN) :: errorstring,ifilename,sectionstring
207  INTEGER :: dummyinteger,errorflag,idata,ifile,ifl,ipatch,ipatchglobal, &
208  loopcounter,nbfaces,ndata
209  TYPE(t_global), POINTER :: global
210  TYPE(t_grid), POINTER :: pgrid
211  TYPE(t_patch), POINTER :: ppatch
212 
213 ! ******************************************************************************
214 ! Start
215 ! ******************************************************************************
216 
217  global => pregion%global
218 
219  CALL registerfunction(global,'RFLU_ReadBcDataFile',&
220  'RFLU_ModReadWriteBcDataFile.F90')
221 
222  IF ( global%myProcid == masterproc .AND. &
223  global%verbLevel > verbose_none ) THEN
224  WRITE(stdout,'(A,1X,A)') solver_name,'Reading boundary-condition data...'
225  END IF ! global%verbLevel
226 
227 ! ******************************************************************************
228 ! Set pointers
229 ! ******************************************************************************
230 
231  pgrid => pregion%grid
232 
233 ! ******************************************************************************
234 ! Open file
235 ! ******************************************************************************
236 
237  ifile = if_distr
238 
239  CALL buildfilenamebasic(global,filedest_indir,'.bcd', &
240  pregion%iRegionGlobal,ifilename)
241 
242  OPEN(ifile,file=ifilename,form='FORMATTED',status='OLD',iostat=errorflag)
243  global%error = errorflag
244  IF ( global%error /= err_none ) THEN
245  CALL errorstop(global,err_file_open,__line__,'File: '//trim(ifilename))
246  END IF ! global%error
247 
248 ! ******************************************************************************
249 ! Read header
250 ! ******************************************************************************
251 
252  READ(ifile,'(A)') sectionstring
253  IF ( trim(sectionstring) /= '# ROCFLU boundary-condition data file' ) THEN
254  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
255  END IF ! TRIM
256 
257 ! ******************************************************************************
258 ! Read data
259 ! ******************************************************************************
260 
261  loopcounter = 0
262 
263  DO ! set up infinite loop
264  loopcounter = loopcounter + 1
265 
266  READ(ifile,'(A)') sectionstring
267 
268  SELECT CASE ( trim(sectionstring) )
269 
270 ! ==============================================================================
271 ! Patch data
272 ! ==============================================================================
273 
274  CASE ( '# Patch data' )
275  IF ( global%myProcid == masterproc .AND. &
276  global%verbLevel > verbose_low ) THEN
277  WRITE(stdout,'(A,3X,A)') solver_name,'Patch data...'
278  END IF ! global%verbLevel
279 
280  READ(ifile,*) ipatch,ipatchglobal,nbfaces,ndata
281 
282 ! ------------------------------------------------------------------------------
283 ! Check that input correct
284 ! ------------------------------------------------------------------------------
285 
286  IF ( ipatch > pgrid%nPatches ) THEN
287  WRITE(errorstring,'(A,1X,I3)') 'Patch index invalid:',ipatch
288  CALL errorstop(global,err_bcdata_value_invalid,__line__, &
289  trim(errorstring))
290  END IF ! iPatch
291 
292  ppatch => pregion%patches(ipatch)
293 
294  IF ( nbfaces /= ppatch%nBFaces ) THEN
295  WRITE(errorstring,'(A,1X,I6)') 'Number of faces invalid:',nbfaces
296  CALL errorstop(global,err_bcdata_value_invalid,__line__, &
297  trim(errorstring))
298  END IF ! nBFaces
299 
300  IF ( ipatchglobal /= ppatch%iPatchGlobal ) THEN
301  WRITE(errorstring,'(A,1X,I3)') 'Global patch index invalid:', &
302  ipatchglobal
303  CALL errorstop(global,err_bcdata_value_invalid,__line__, &
304  trim(errorstring))
305  END IF ! iPatchGlobal
306 
307  IF ( ndata /= ppatch%mixt%nData ) THEN
308  WRITE(errorstring,'(A,1X,I3)') &
309  'Number of pieces of data invalid:',ndata
310  CALL errorstop(global,err_bcdata_value_invalid,__line__, &
311  trim(errorstring))
312  END IF ! iPatchGlobal
313 
314 ! ------------------------------------------------------------------------------
315 ! Read data
316 ! ------------------------------------------------------------------------------
317 
318  DO ifl = 1,ppatch%nBFaces
319  DO idata = 1,ppatch%mixt%nData
320  READ(ifile,'(1X,I6,1X,I2,1X,E23.16)') &
321  dummyinteger,dummyinteger,ppatch%mixt%vals(idata,ifl)
322  END DO ! iData
323  END DO ! ifl
324 
325 ! ==============================================================================
326 ! End marker
327 ! ==============================================================================
328 
329  CASE ( '# End' )
330  IF ( global%myProcid == masterproc .AND. &
331  global%verbLevel > verbose_low ) THEN
332  WRITE(stdout,'(A,3X,A)') solver_name,'End marker...'
333  END IF ! global%verbLevel
334 
335  EXIT
336 
337 ! ==============================================================================
338 ! Invalid section string
339 ! ==============================================================================
340 
341  CASE default
342  IF ( global%verbLevel > verbose_low ) THEN
343  WRITE(stdout,'(A,3X,A)') solver_name,sectionstring
344  END IF ! verbosityLevel
345 
346  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
347 
348  END SELECT ! TRIM
349 
350 ! ==============================================================================
351 ! Guard against infinite loop - might be unnecessary because of read errors?
352 ! ==============================================================================
353 
354  IF ( loopcounter >= limit_infinite_loop ) THEN
355  CALL errorstop(global,err_infinite_loop,__line__)
356  END IF ! loopCounter
357 
358  END DO ! <empty>
359 
360 ! ******************************************************************************
361 ! Close file
362 ! ******************************************************************************
363 
364  CLOSE(ifile,iostat=errorflag)
365  global%error = errorflag
366  IF ( global%error /= err_none ) THEN
367  CALL errorstop(global,err_file_close,__line__,'File: '//trim(ifilename))
368  END IF ! global%error
369 
370 ! ******************************************************************************
371 ! End
372 ! ******************************************************************************
373 
374  IF ( global%myProcid == masterproc .AND. &
375  global%verbLevel > verbose_none ) THEN
376  WRITE(stdout,'(A,1X,A)') solver_name,'Reading boundary-condition data done.'
377  END IF ! global%verbLevel
378 
379  CALL deregisterfunction(global)
380 
381  END SUBROUTINE rflu_readbcdatafile
382 
383 
384 
385 
386 
387 
388 
389 
390 ! ******************************************************************************
391 !
392 ! Purpose: Write boundary-condition data file.
393 !
394 ! Description: None.
395 !
396 ! Input:
397 ! pRegion Pointer to region data
398 !
399 ! Output: None.
400 !
401 ! Notes:
402 ! 1. At present restricted to mixture. Best way to extend to MP not clear.
403 !
404 ! ******************************************************************************
405 
406  SUBROUTINE rflu_writebcdatafile(pRegion)
407 
409 
410  IMPLICIT NONE
411 
412 ! ******************************************************************************
413 ! Declarations and definitions
414 ! ******************************************************************************
415 
416 ! ==============================================================================
417 ! Arguments
418 ! ==============================================================================
419 
420  TYPE(t_region), POINTER :: pregion
421 
422 ! ==============================================================================
423 ! Local variables
424 ! ==============================================================================
425 
426  CHARACTER(CHRLEN) :: ifilename,sectionstring
427  INTEGER :: dummyinteger,errorflag,idata,ifile,ifl,ipatch
428  TYPE(t_global), POINTER :: global
429  TYPE(t_grid), POINTER :: pgrid
430  TYPE(t_patch), POINTER :: ppatch
431 
432 ! ******************************************************************************
433 ! Start
434 ! ******************************************************************************
435 
436  global => pregion%global
437 
438  CALL registerfunction(global,'RFLU_WriteBcDataFile',&
439  'RFLU_ModReadWriteBcDataFile.F90')
440 
441  IF ( global%myProcid == masterproc .AND. &
442  global%verbLevel > verbose_none ) THEN
443  WRITE(stdout,'(A,1X,A)') solver_name,'Writing boundary-condition data...'
444  END IF ! global%verbLevel
445 
446 ! ******************************************************************************
447 ! Set pointers
448 ! ******************************************************************************
449 
450  pgrid => pregion%grid
451 
452 ! ******************************************************************************
453 ! Open file
454 ! ******************************************************************************
455 
456  ifile = if_distr
457 
458  CALL buildfilenamebasic(global,filedest_indir,'.bcd', &
459  pregion%iRegionGlobal,ifilename)
460 
461  OPEN(ifile,file=ifilename,form='FORMATTED',status='UNKNOWN', &
462  iostat=errorflag)
463  global%error = errorflag
464  IF ( global%error /= err_none ) THEN
465  CALL errorstop(global,err_file_open,__line__,'File: '//trim(ifilename))
466  END IF ! global%error
467 
468 ! ******************************************************************************
469 ! Write header
470 ! ******************************************************************************
471 
472  sectionstring = '# ROCFLU boundary-condition data file'
473  WRITE(ifile,'(A)') sectionstring
474 
475 ! ******************************************************************************
476 ! Loop over patches
477 ! ******************************************************************************
478 
479  DO ipatch = 1,pgrid%nPatches
480  ppatch => pregion%patches(ipatch)
481 
482 ! ==============================================================================
483 ! If not coupled and have distribution, write data
484 ! ==============================================================================
485 
486  IF ( (ppatch%bcCoupled == bc_not_coupled) .AND. &
487  (ppatch%mixt%distrib == bcdat_distrib) ) THEN
488  WRITE(ifile,'(A)') '# Patch data'
489  WRITE(ifile,'(2(1X,I3),1X,I6,1X,I2)') ipatch,ppatch%iPatchGlobal, &
490  ppatch%nBFaces, &
491  ppatch%mixt%nData
492 
493  DO ifl = 1,ppatch%nBFaces
494  DO idata = 1,ppatch%mixt%nData
495  WRITE(ifile,'(1X,I6,1X,I2,1X,E23.16)') ifl,idata, &
496  ppatch%mixt%vals(idata,ifl)
497  END DO ! iData
498  END DO ! ifl
499  END IF ! pPatch%bcCoupled
500  END DO ! iPatch
501 
502 ! ******************************************************************************
503 ! Write footer
504 ! ******************************************************************************
505 
506  sectionstring = '# End'
507  WRITE(ifile,'(A)') sectionstring
508 
509 ! ******************************************************************************
510 ! Close file
511 ! ******************************************************************************
512 
513  CLOSE(ifile,iostat=errorflag)
514  global%error = errorflag
515  IF ( global%error /= err_none ) THEN
516  CALL errorstop(global,err_file_close,__line__,'File: '//trim(ifilename))
517  END IF ! global%error
518 
519 ! ******************************************************************************
520 ! End
521 ! ******************************************************************************
522 
523  IF ( global%myProcid == masterproc .AND. &
524  global%verbLevel > verbose_none ) THEN
525  WRITE(stdout,'(A,1X,A)') solver_name, &
526  'Writing boundary-condition data done.'
527  END IF ! global%verbLevel
528 
529  CALL deregisterfunction(global)
530 
531  END SUBROUTINE rflu_writebcdatafile
532 
533 
534 
535 
536 
537 
538 
539 
540 
541 ! ******************************************************************************
542 ! End
543 ! ******************************************************************************
544 
546 
547 
548 ! ******************************************************************************
549 !
550 ! RCS Revision history:
551 !
552 ! $Log: RFLU_ModReadWriteBcDataFile.F90,v $
553 ! Revision 1.6 2008/12/06 08:44:23 mtcampbe
554 ! Updated license.
555 !
556 ! Revision 1.5 2008/11/19 22:17:34 mtcampbe
557 ! Added Illinois Open Source License/Copyright
558 !
559 ! Revision 1.4 2006/08/19 15:39:14 mparmar
560 ! Renamed patch variables
561 !
562 ! Revision 1.3 2006/04/07 15:19:20 haselbac
563 ! Removed tabs
564 !
565 ! Revision 1.2 2005/12/23 13:47:01 haselbac
566 ! Temporarily disable bc data files to avoid hardcoding for runs with tbc
567 !
568 ! Revision 1.1 2004/07/06 15:14:30 haselbac
569 ! Initial revision
570 !
571 ! ******************************************************************************
572 
573 
574 
575 
576 
577 
578 
579 
580 
subroutine buildfilenamebasic(global, dest, ext, id, fileName)
subroutine, public rflu_readbcdatafile(pRegion)
subroutine, public rflu_writebcdatafile(pRegion)
LOGICAL function, public rflu_decidereadwritebcdatafile(pRegion)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
**********************************************************************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 form
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469