Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FindProbe.f90
Go to the documentation of this file.
1 !*********************************************************************
2 !* Illinois Open Source License *
3 !* *
4 !* University of Illinois/NCSA *
5 !* Open Source License *
6 !* *
7 !* Copyright@2008, University of Illinois. All rights reserved. *
8 !* *
9 !* Developed by: *
10 !* *
11 !* Center for Simulation of Advanced Rockets *
12 !* *
13 !* University of Illinois *
14 !* *
15 !* www.csar.uiuc.edu *
16 !* *
17 !* Permission is hereby granted, free of charge, to any person *
18 !* obtaining a copy of this software and associated documentation *
19 !* files (the "Software"), to deal with the Software without *
20 !* restriction, including without limitation the rights to use, *
21 !* copy, modify, merge, publish, distribute, sublicense, and/or *
22 !* sell copies of the Software, and to permit persons to whom the *
23 !* Software is furnished to do so, subject to the following *
24 !* conditions: *
25 !* *
26 !* *
27 !* @ Redistributions of source code must retain the above copyright *
28 !* notice, this list of conditions and the following disclaimers. *
29 !* *
30 !* @ Redistributions in binary form must reproduce the above *
31 !* copyright notice, this list of conditions and the following *
32 !* disclaimers in the documentation and/or other materials *
33 !* provided with the distribution. *
34 !* *
35 !* @ Neither the names of the Center for Simulation of Advanced *
36 !* Rockets, the University of Illinois, nor the names of its *
37 !* contributors may be used to endorse or promote products derived *
38 !* from this Software without specific prior written permission. *
39 !* *
40 !* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
41 !* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
42 !* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
43 !* NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
44 !* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
45 !* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
46 !* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
47 !* USE OR OTHER DEALINGS WITH THE SOFTWARE. *
48 !*********************************************************************
49 !* Please acknowledge The University of Illinois Center for *
50 !* Simulation of Advanced Rockets in works and publications *
51 !* resulting from this software or its derivatives. *
52 !*********************************************************************
53 SUBROUTINE findprobe(glb, myid)
54 
55  USE rocstar_rocfrac
56 
57 !!****f* Rocfrac/Source/FindProbe.f90
58 !!
59 !! NAME
60 !! FindProbe
61 !!
62 !! FUNCTION
63 !!
64 !! READ INPUT INFORMATION (i.e. Analysis Deck File)
65 !!
66 !! INPUTS
67 !! glb -- global array
68 !! myid -- processor id (starting at 0)
69 !!
70 !!****
71 
72  IMPLICIT NONE
73 
74  TYPE(rocfrac_global) :: glb
75 
76  INTEGER :: myid
77 
78  REAL*8 :: xx,yy,zz,size1,size2,size3,size4,size5,size6,size7,size8,size9,size10,size11,size12
79  REAL*8 :: longestedge
80 
81  CHARACTER*4 :: ichr1, ichr2
82 
83  INTEGER :: i, j, ierr
84  LOGICAL :: inside
85  LOGICAL :: pointonproc
86 
87  longestedge = 0.d0
88 
89  IF(glb%iElType.EQ.8)THEN
90  DO i = 1, glb%NumElVol
91  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(1,i), glb%ElConnVol(4,i), size1)
92  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(5,i), glb%ElConnVol(8,i), size2)
93  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(6,i), glb%ElConnVol(7,i), size3)
94  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(2,i), glb%ElConnVol(3,i), size4)
95 
96  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(4,i), glb%ElConnVol(8,i), size5)
97  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(8,i), glb%ElConnVol(7,i), size6)
98  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(7,i), glb%ElConnVol(3,i), size7)
99  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(3,i), glb%ElConnVol(4,i), size8)
100 
101  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(1,i), glb%ElConnVol(5,i), size9)
102  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(5,i), glb%ElConnVol(6,i), size10)
103  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(6,i), glb%ElConnVol(2,i), size11)
104  CALL smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(2,i), glb%ElConnVol(1,i), size12)
105 
106  longestedge = max(size1, size2, size3, size4, size5, size6, size7, size8, size9, size10, size11, size12, longestedge)
107  ENDDO
108 
109  ELSE
110 
111  DO i = 1, glb%NumElVol
112 !
113 ! -- Find the size of the smallest element
114 !
115  xx = glb%MeshCoor(1,glb%ElConnVol(1,i)) - glb%MeshCoor(1,glb%ElConnVol(2,i))
116  yy = glb%MeshCoor(2,glb%ElConnVol(1,i)) - glb%MeshCoor(2,glb%ElConnVol(2,i))
117  zz = glb%MeshCoor(3,glb%ElConnVol(1,i)) - glb%MeshCoor(3,glb%ElConnVol(2,i))
118  size1 = sqrt(xx*xx+yy*yy+zz*zz)
119  xx = glb%MeshCoor(1,glb%ElConnVol(2,i)) - glb%MeshCoor(1,glb%ElConnVol(3,i))
120  yy = glb%MeshCoor(2,glb%ElConnVol(2,i)) - glb%MeshCoor(2,glb%ElConnVol(3,i))
121  zz = glb%MeshCoor(3,glb%ElConnVol(2,i)) - glb%MeshCoor(3,glb%ElConnVol(3,i))
122  size2 = sqrt(xx*xx+yy*yy+zz*zz)
123  xx = glb%MeshCoor(1,glb%ElConnVol(3,i)) - glb%MeshCoor(1,glb%ElConnVol(1,i))
124  yy = glb%MeshCoor(2,glb%ElConnVol(3,i)) - glb%MeshCoor(2,glb%ElConnVol(1,i))
125  zz = glb%MeshCoor(3,glb%ElConnVol(3,i)) - glb%MeshCoor(3,glb%ElConnVol(1,i))
126  size3 = sqrt(xx*xx+yy*yy+zz*zz)
127  xx = glb%MeshCoor(1,glb%ElConnVol(4,i)) - glb%MeshCoor(1,glb%ElConnVol(1,i))
128  yy = glb%MeshCoor(2,glb%ElConnVol(4,i)) - glb%MeshCoor(2,glb%ElConnVol(1,i))
129  zz = glb%MeshCoor(3,glb%ElConnVol(4,i)) - glb%MeshCoor(3,glb%ElConnVol(1,i))
130  size4 = sqrt(xx*xx+yy*yy+zz*zz)
131  xx = glb%MeshCoor(1,glb%ElConnVol(4,i)) - glb%MeshCoor(1,glb%ElConnVol(2,i))
132  yy = glb%MeshCoor(2,glb%ElConnVol(4,i)) - glb%MeshCoor(2,glb%ElConnVol(2,i))
133  zz = glb%MeshCoor(3,glb%ElConnVol(4,i)) - glb%MeshCoor(3,glb%ElConnVol(2,i))
134  size5 = sqrt(xx*xx+yy*yy+zz*zz)
135  xx = glb%MeshCoor(1,glb%ElConnVol(4,i)) - glb%MeshCoor(1,glb%ElConnVol(3,i))
136  yy = glb%MeshCoor(2,glb%ElConnVol(4,i)) - glb%MeshCoor(2,glb%ElConnVol(3,i))
137  zz = glb%MeshCoor(3,glb%ElConnVol(4,i)) - glb%MeshCoor(3,glb%ElConnVol(3,i))
138  size6 = sqrt(xx*xx+yy*yy+zz*zz)
139  longestedge = max(size1,size2,size3,size4,size5,size6,longestedge)
140 
141  ENDDO
142  ENDIF
143 
144  ALLOCATE(glb%PointOnProc(1:glb%NumProbesNd))
145 
146  DO i = 1, glb%NumProbesNd
147 
148  glb%PointOnProc(i) = .false.
149 
150  DO j = 1, glb%NumNP
151 
152  CALL sphere_imp_contains_point_3d( longestedge, glb%ProbeCoorNd(:,i), glb%MeshCoor(:,j), inside )
153 
154  IF(inside)THEN
155 
156  glb%PointOnProc(i) = .true.
157  glb%ProbeNd(i) = j
158  longestedge = sqrt( sum( ( glb%ProbeCoorNd(1:3,i) - glb%MeshCoor(1:3,j) )**2 ) )
159  ENDIF
160 
161  ENDDO
162 
163  IF(glb%PointOnProc(i))THEN
164  WRITE(ichr1,'(i4.4)') i
165  WRITE(ichr2,'(I4.4)') myid
166 
167  OPEN(440+i,file='Rocfrac/Rocout/Probe.'//ichr1//'.'//ichr2,position='REWIND')
168  WRITE(440+i,*) '# Probe Data Coordinate', glb%MeshCoor(1:3,glb%ProbeNd(i))
169  CLOSE(440+i)
170  ENDIF
171 
172  ENDDO
173 
174 END SUBROUTINE findprobe
175 
176 
177 SUBROUTINE sphere_imp_contains_point_3d ( r, center, p, inside )
178 
179 !*******************************************************************************
180 !
181 !! SPHERE_IMP_CONTAINS_POINT_3D: point in implicit sphere in 3D?
182 !
183 ! Discussion:
184 !
185 ! An implicit sphere in 3D satisfies the equation:
186 !
187 ! sum ( ( P(1:NDIM) - CENTER(1:NDIM) )**2 ) = R**2
188 !
189 ! Modified:
190 !
191 ! 05 February 1999
192 !
193 ! Author:
194 !
195 ! John Burkardt
196 !
197 ! Parameters:
198 !
199 ! Input, real ( kind = 8 ) R, the radius of the sphere.
200 !
201 ! Input, real ( kind = 8 ) CENTER(3), the center of the sphere.
202 !
203 ! Input, real ( kind = 8 ) P(3), the point to be checked.
204 !
205 ! Output, logical INSIDE, is TRUE if the point is inside the sphere.
206 !
207  IMPLICIT NONE
208 
209  INTEGER, PARAMETER :: ndim = 3
210 
211  REAL ( kind = 8 ) center(ndim)
212  LOGICAL inside
213  REAL ( kind = 8 ) p(ndim)
214  REAL ( kind = 8 ) r
215 
216  IF ( sum( ( p(1:ndim) - center(1:ndim) )**2 ) <= r * r ) THEN
217  inside = .true.
218  ELSE
219  inside = .false.
220  END IF
221 
222  RETURN
223  END SUBROUTINE sphere_imp_contains_point_3d
224 
unsigned char r() const
Definition: Color.h:68
Tfloat sum() const
Return the sum of all the pixel values in an image.
Definition: CImg.h:13022
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
subroutine sphere_imp_contains_point_3d(r, center, p, inside)
Definition: FindProbe.f90:177
double sqrt(double d)
Definition: double.h:73
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
subroutine smallestelement(NumNP, coor, Node1, Node2, lngth)
subroutine findprobe(glb, myid)
Definition: FindProbe.f90:53