Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModSTL.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 write grids in STL format.
26 !
27 ! Description: None.
28 !
29 ! Notes: None.
30 !
31 ! ******************************************************************************
32 !
33 ! $Id: RFLU_ModSTL.F90,v 1.4 2008/12/06 08:44:55 mtcampbe Exp $
34 !
35 ! Copyright: (c) 2005 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 modgrid, ONLY: t_grid
46  USE modbndpatch, ONLY: t_patch
47  USE moddatastruct, ONLY: t_region
48  USE modmpi
49 
51 
52  IMPLICIT NONE
53 
54 ! ******************************************************************************
55 ! Declarations and definitions
56 ! ******************************************************************************
57 
58  PRIVATE
59 
60 ! ==============================================================================
61 ! Data
62 ! ==============================================================================
63 
64  CHARACTER(CHRLEN) :: &
65  RCSIdentString = '$RCSfile: RFLU_ModSTL.F90,v $ $Revision: 1.4 $'
66 
67 ! ==============================================================================
68 ! Public procedures
69 ! ==============================================================================
70 
72 
73 ! ******************************************************************************
74 ! Routines
75 ! ******************************************************************************
76 
77  CONTAINS
78 
79 
80 
81 
82 
83 ! ******************************************************************************
84 !
85 ! Purpose: Write surface grid in ASCII STL format.
86 !
87 ! Description: None.
88 !
89 ! Input:
90 ! pRegion Pointer to region
91 !
92 ! Output: None.
93 !
94 ! Notes: None.
95 !
96 ! ******************************************************************************
97 
98  SUBROUTINE rflu_stl_writesurfgridascii(pRegion)
99 
100  IMPLICIT NONE
101 
102 ! ******************************************************************************
103 ! Declarations and definitions
104 ! ******************************************************************************
105 
106 ! ==============================================================================
107 ! Arguments
108 ! ==============================================================================
109 
110  TYPE(t_region), POINTER :: pregion
111 
112 ! ==============================================================================
113 ! Local variables
114 ! ==============================================================================
115 
116  LOGICAL :: writepatchflag
117  CHARACTER(1) :: writepatchchar
118  CHARACTER(CHRLEN) :: ifilename
119  INTEGER :: errorflag,ifl,ifile,ipatch,ivg,ivl,ivl2
120  TYPE(t_grid), POINTER :: pgrid
121  TYPE(t_global), POINTER :: global
122  TYPE(t_patch), POINTER :: ppatch
123 
124 ! ******************************************************************************
125 ! Start
126 ! ******************************************************************************
127 
128  global => pregion%global
129 
130  CALL registerfunction(global,'RFLU_STL_WriteSurfGridASCII', &
131  'RFLU_ModSTL.F90')
132 
133  IF ( global%verbLevel > verbose_none ) THEN
134  WRITE(stdout,'(A,1X,A)') solver_name, &
135  'Writing surface grid in ASCII STL format...'
136  END IF ! global%verbLevel
137 
138 ! ==============================================================================
139 ! Set pointers and variables
140 ! ==============================================================================
141 
142  pgrid => pregion%grid
143 
144 ! ******************************************************************************
145 ! Writing file
146 ! ******************************************************************************
147 
148 ! ==============================================================================
149 ! Open file
150 ! ==============================================================================
151 
152  ifile = if_grid
153 
154  CALL buildfilenameplain(global,filedest_indir,'.stl',ifilename)
155 
156  OPEN(ifile,file=ifilename,form="FORMATTED",status="UNKNOWN", &
157  iostat=errorflag)
158  global%error = errorflag
159  IF ( global%error /= err_none ) THEN
160  CALL errorstop(global,err_file_open,__line__,ifilename)
161  END IF ! global%error
162 
163 ! ==============================================================================
164 ! Write file by looping over patches
165 ! ==============================================================================
166 
167  WRITE(ifile,'(A)') 'solid'
168 
169  DO ipatch = 1,pgrid%nPatches
170  ppatch => pregion%patches(ipatch)
171 
172 ! ------------------------------------------------------------------------------
173 ! Determine whether patch is to be written
174 ! ------------------------------------------------------------------------------
175 
176  WRITE(stdout,'(A,3X,A,1X,I2,1X,A)') solver_name,'Write patch', &
177  ipatch,'to STL file? (y/n)'
178  READ(stdin,'(A)',iostat=errorflag) writepatchchar
179 
180  IF ( errorflag == err_none ) THEN
181  IF ( writepatchchar == 'y' ) THEN
182  writepatchflag = .true.
183  ELSE
184  writepatchflag = .false.
185  END IF ! choice
186  ELSE
187  writepatchflag = .false.
188  END IF ! errorFlag
189 
190 ! ------------------------------------------------------------------------------
191 ! Write patch. NOTE quadrilateral faces written as two triangles.
192 ! ------------------------------------------------------------------------------
193 
194  IF ( writepatchflag .EQV. .true. ) THEN
195  IF ( global%verbLevel > verbose_none ) THEN
196  WRITE(stdout,'(A,5X,A,1X,I2,1X,A)') solver_name,'Writing patch', &
197  ipatch,'to STL file...'
198  END IF ! global%verbLevel
199 
200 ! ----- Triangles --------------------------------------------------------------
201 
202  DO ifl = 1,ppatch%nBTris
203  WRITE(ifile,'(A,3(1X,E13.6))') 'facet normal', &
204  ppatch%fn(xcoord:zcoord,ifl)
205  WRITE(ifile,'(A)') 'outer loop'
206 
207  DO ivl = 1,3
208  ivg = ppatch%bTri2v(ivl,ifl)
209 
210  WRITE(ifile,'(A,3(1X,E13.6))') 'vertex',pgrid%xyz(xcoord:zcoord,ivg)
211  END DO ! ivl
212 
213  WRITE(ifile,'(A)') 'endloop'
214  WRITE(ifile,'(A)') 'endfacet'
215  END DO ! ifl
216 
217 ! ---- Quadrilaterals ---------------------------------------------------------
218 
219  DO ifl = 1,ppatch%nBQuads
220 
221 ! ------- Triangle 1
222 
223  WRITE(ifile,'(A,3(1X,E13.6))') 'facet normal', &
224  ppatch%fn(xcoord:zcoord,ifl)
225  WRITE(ifile,'(A)') 'outer loop'
226 
227  DO ivl = 1,3
228  ivg = ppatch%bQuad2v(ivl,ifl)
229 
230  WRITE(ifile,'(A,3(1X,E13.6))') 'vertex',pgrid%xyz(xcoord:zcoord,ivg)
231  END DO ! ivl
232 
233  WRITE(ifile,'(A)') 'endloop'
234  WRITE(ifile,'(A)') 'endfacet'
235 
236 ! ------- Triangle 2
237 
238  WRITE(ifile,'(A,3(1X,E13.6))') 'facet normal', &
239  ppatch%fn(xcoord:zcoord,ifl)
240  WRITE(ifile,'(A)') 'outer loop'
241 
242  DO ivl = 3,5
243  IF ( ivl == 5 ) THEN
244  ivl2 = 1
245  ELSE
246  ivl2 = ivl
247  END IF ! ivl
248 
249  ivg = ppatch%bQuad2v(ivl2,ifl)
250 
251  WRITE(ifile,'(A,3(1X,E13.6))') 'vertex',pgrid%xyz(xcoord:zcoord,ivg)
252  END DO ! ivl
253 
254  WRITE(ifile,'(A)') 'endloop'
255  WRITE(ifile,'(A)') 'endfacet'
256  END DO ! ifl
257 
258  IF ( global%verbLevel > verbose_none ) THEN
259  WRITE(stdout,'(A,5X,A,1X,I2,1X,A)') solver_name,'Writing patch', &
260  ipatch,'to STL file done.'
261  END IF ! global%verbLevel
262  END IF ! writePatchFlag
263  END DO ! iPatch
264 
265  WRITE(ifile,'(A)') 'endsolid'
266 
267 ! ==============================================================================
268 ! Close file
269 ! ==============================================================================
270 
271  CLOSE(ifile,iostat=errorflag)
272  global%error = errorflag
273  IF ( global%myProcid == masterproc .AND. &
274  global%error /= err_none ) THEN
275  CALL errorstop(global,err_file_close,__line__,ifilename)
276  END IF ! global%error
277 
278 ! ******************************************************************************
279 ! End
280 ! ******************************************************************************
281 
282  IF ( global%verbLevel > verbose_none ) THEN
283  WRITE(stdout,'(A,1X,A)') solver_name, &
284  'Writing surface grid in ASCII STL format done.'
285  END IF ! global%verbLevel
286 
287  CALL deregisterfunction(global)
288 
289  END SUBROUTINE rflu_stl_writesurfgridascii
290 
291 
292 
293 
294 
295 
296 ! ******************************************************************************
297 ! End
298 ! ******************************************************************************
299 
300 
301 END MODULE rflu_modstl
302 
303 ! ******************************************************************************
304 !
305 ! RCS Revision history:
306 !
307 ! $Log: RFLU_ModSTL.F90,v $
308 ! Revision 1.4 2008/12/06 08:44:55 mtcampbe
309 ! Updated license.
310 !
311 ! Revision 1.3 2008/11/19 22:18:05 mtcampbe
312 ! Added Illinois Open Source License/Copyright
313 !
314 ! Revision 1.2 2005/07/07 18:01:14 haselbac
315 ! Bug fix (found on alc) for loop index
316 !
317 ! Revision 1.1 2005/07/07 03:51:55 haselbac
318 ! Initial revision
319 !
320 ! ******************************************************************************
321 
322 
323 
324 
325 
326 
327 
328 
329 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
subroutine buildfilenameplain(global, dest, ext, fileName)
**********************************************************************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, public rflu_stl_writesurfgridascii(pRegion)
Definition: RFLU_ModSTL.F90:98
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469