Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
v3d4_volume.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 v3d4_volume(coor,lmcstet,matcstet, &
54  rho,numnp,numcstet,numat_vol,disp,nstart,nend,totalmass,totalgeomvolp,totalgeomundefvolp,&
55  numvertx)
56 
57 !!****f* Rocfrac/Rocfrac/Source/vol_elem_mat.f90
58 !!
59 !! NAME
60 !! VOL_ELEM_MAT
61 !!
62 !! FUNCTION
63 !! Caluculates the volume and surface area for tetraderal
64 !! elements
65 !!
66 !!****
67 
68  IMPLICIT NONE
69  integer :: numvertx ! order of tetrahedral 4 or 10
70  INTEGER :: numnp ! number of nodes
71  INTEGER :: numcstet ! number of CSTets
72  INTEGER :: numat_vol ! number of materials
73  REAL*8 :: dt
74 !-- densities
75  REAL*8, DIMENSION(1:numat_vol) :: rho
76 !-- material number for CSTet element
77  INTEGER, DIMENSION(1:numcstet) :: matcstet
78 !-- connectivity table for CSTet elem
79  INTEGER, DIMENSION(1:NumVertx,1:numcstet) :: lmcstet
80 !-- global coordinates
81  REAL*8, DIMENSION(1:3,1:numnp) :: coor
82 !-- Displacement
83  REAL*8, DIMENSION(1:3*numnp) :: disp
84 
85  REAL*8 :: aa ! determinant of jacobian (2*area)
86  REAL*8 :: x !,x1,x2,x3 ! dummy variable
87  INTEGER :: n1,n2,n3,n4,n5,n6 ! nodes, and dummy vars
88  INTEGER :: n7,n8,n9,n10
89  INTEGER :: i,nstart,nend ! loop counter
90 !-- Coordinate holding variable
91  REAL*8 :: x1,x2,x3,x4,y1,y2,y3,y4,z1,z2,z3,z4
92 !-- Coordinate subtractions
93  REAL*8 :: x14, x24, x34, y14, y24, y34, z14, z24, z34
94 !--
95  REAL*8 :: c11, c21, c31
96 !-- 6*volume and the volume
97  REAL*8 :: vx6,volume,vx6def
98  REAL*8 :: totalmass,totalgeomvolp,totalgeomundefvolp
99  real*8,SAVE :: cnt
100 
101  totalgeomundefvolp = 0.
102  totalgeomvolp = 0.
103 
104  DO i = nstart, nend
105 
106  n1 = lmcstet(1,i)
107  n2 = lmcstet(2,i)
108  n3 = lmcstet(3,i)
109  n4 = lmcstet(4,i)
110 
111  x1 = coor(1,n1)
112  x2 = coor(1,n2)
113  x3 = coor(1,n3)
114  x4 = coor(1,n4)
115  y1 = coor(2,n1)
116  y2 = coor(2,n2)
117  y3 = coor(2,n3)
118  y4 = coor(2,n4)
119  z1 = coor(3,n1)
120  z2 = coor(3,n2)
121  z3 = coor(3,n3)
122  z4 = coor(3,n4)
123 
124  x14 = x1 - x4
125  x24 = x2 - x4
126  x34 = x3 - x4
127  y14 = y1 - y4
128  y24 = y2 - y4
129  y34 = y3 - y4
130  z14 = z1 - z4
131  z24 = z2 - z4
132  z34 = z3 - z4
133 
134  c11 = y24*z34 - z24*y34
135  c21 = -( x24*z34 - z24*x34 )
136  c31 = x24*y34 - y24*x34
137 
138  vx6 = -( x14*c11 + y14*c21 + z14*c31 )
139 
140 ! Vx6 = x2*y3*z4 - x2*y4*z3 - y2*x3*z4 + y2*x4*z3 + z2*x3*y4
141 ! $ - z2*x4*y3 - x1*y3*z4 + x1*y4*z3 + x1*y2*z4 - x1*y2*z3
142 ! $ - x1*z2*y4 + x1*z2*y3 + y1*x3*z4 - y1*x4*z3 - y1*x2*z4
143 ! $ + y1*x2*z3 + y1*z2*x4 - y1*z2*x3 - z1*x3*y4 + z1*x4*y3
144 ! $ + z1*x2*y4 - z1*x2*y3 - z1*y2*x4 + z1*y2*x3
145 
146  totalgeomundefvolp = totalgeomundefvolp + vx6/6.d0
147 
148 !!$ IF(x.LT.0.d0)THEN
149 !!$ PRINT*,'ERROR'
150 !!$ PRINT*,'NEG, Volume... STOPPING'
151 !!$ PRINT*,' ELEMENT =',i
152 !!$ PRINT*,' NODES=',n1,n2,n3,n4
153 !!$ PRINT*,' x-Coordinates:',x1,x2,x3,x4
154 !!$ PRINT*,' y-Coordinates:',y1,y2,y3,y4
155 !!$ PRINT*,' z-Coordinates:',z1,z2,z3,z4
156 !!$ STOP
157 !!$ ENDIF
158 
159  x1 = coor(1,n1) + disp(3*n1-2)
160  x2 = coor(1,n2) + disp(3*n2-2)
161  x3 = coor(1,n3) + disp(3*n3-2)
162  x4 = coor(1,n4) + disp(3*n4-2)
163  y1 = coor(2,n1) + disp(3*n1-1)
164  y2 = coor(2,n2) + disp(3*n2-1)
165  y3 = coor(2,n3) + disp(3*n3-1)
166  y4 = coor(2,n4) + disp(3*n4-1)
167  z1 = coor(3,n1) + disp(3*n1)
168  z2 = coor(3,n2) + disp(3*n2)
169  z3 = coor(3,n3) + disp(3*n3)
170  z4 = coor(3,n4) + disp(3*n4)
171 
172  x14 = x1 - x4
173  x24 = x2 - x4
174  x34 = x3 - x4
175  y14 = y1 - y4
176  y24 = y2 - y4
177  y34 = y3 - y4
178  z14 = z1 - z4
179  z24 = z2 - z4
180  z34 = z3 - z4
181 
182  c11 = y24*z34 - z24*y34
183  c21 = -( x24*z34 - z24*x34 )
184  c31 = x24*y34 - y24*x34
185 
186  vx6def = -( x14*c11 + y14*c21 + z14*c31 )
187 
188 ! Note: The total mass is the TOTAL mass OF all components (not just the propellent)
189 
190  totalgeomvolp = totalgeomvolp + vx6def/6.d0
191 
192  ENDDO
193 
194  totalmass = rho(1) * totalgeomundefvolp ! assuming propellent is property 1
195 
196 
197 ! WRITE(545,*) cnt*0.00000095367431640625, &
198 ! (TotalGeomVolp/(4.d0-cnt*0.00000095367431640625d0*0.0625d0)-1.d0)*100.d0
199 
200 ! print*,cnt*0.00000095367431640625, &
201 ! (TotalGeomVolp/(4.d0-cnt*0.00000095367431640625d0*0.0625d0)-1.d0)*100.d0
202 
203  cnt = cnt + 1
204 
205  RETURN
206 END SUBROUTINE v3d4_volume
207 
208 SUBROUTINE triangle_area_3d ( x1, y1, z1, x2, y2, z2, x3, y3, z3, area )
209 
210  IMPLICIT NONE
211 !
212  REAL*8 area
213  REAL*8 enorm_3d
214  REAL*8 norm
215  REAL*8 x1
216  REAL*8 x2
217  REAL*8 x3
218  REAL*8 x4
219  REAL*8 y1
220  REAL*8 y2
221  REAL*8 y3
222  REAL*8 y4
223  REAL*8 z1
224  REAL*8 z2
225  REAL*8 z3
226  REAL*8 z4
227 !
228  CALL cross_3d( x2 - x1, y2 - y1, z2 - z1, x3 - x1, y3 - y1, z3 - z1, &
229  x4, y4, z4 )
230 
231 
232  norm = enorm_3d( x4, y4, z4 )
233 
234  area = 0.5d0 * norm
235 
236  RETURN
237 END SUBROUTINE triangle_area_3d
238 
239  SUBROUTINE cross_3d ( x1, y1, z1, x2, y2, z2, x3, y3, z3 )
240 !
241 !*******************************************************************************
242 !
243 !! CROSS_3D computes the cross product of two vectors in 3D.
244 !
245 !
246 ! Definition:
247 !
248 ! The cross product in 3D can be regarded as the determinant of the
249 ! symbolic matrix:
250 !
251 ! | i j k |
252 ! det | x1 y1 z1 |
253 ! | x2 y2 z2 |
254 !
255 ! = ( y1 * z2 - z1 * y2 ) * i
256 ! + ( z1 * x2 - x1 * z2 ) * j
257 ! + ( x1 * y2 - y1 * x2 ) * k
258 !
259 ! Modified:
260 !
261 ! 19 April 1999
262 !
263 ! Author:
264 !
265 ! John Burkardt
266 !
267 ! Parameters:
268 !
269 ! Input, real X1, Y1, Z1, X2, Y2, Z2, the coordinates of the vectors.
270 !
271 ! Output, real X3, Y3, Z3, the cross product vector.
272 !
273  IMPLICIT NONE
274 !
275  REAL*8 x1
276  REAL*8 x2
277  REAL*8 x3
278  REAL*8 y1
279  REAL*8 y2
280  REAL*8 y3
281  REAL*8 z1
282  REAL*8 z2
283  REAL*8 z3
284 !
285  x3 = y1 * z2 - z1 * y2
286  y3 = z1 * x2 - x1 * z2
287  z3 = x1 * y2 - y1 * x2
288 
289  RETURN
290 END SUBROUTINE cross_3d
291 
292 FUNCTION enorm_3d ( x1, y1, z1 )
293 !
294 !*******************************************************************************
295 !
296 !! ENORM_3D computes the Euclidean norm of a vector in 3D.
297 !
298 !
299 ! Modified:
300 !
301 ! 27 July 1998
302 !
303 ! Author:
304 !
305 ! John Burkardt
306 !
307 ! Parameters:
308 !
309 ! Input, real X1, Y1, Z1, the coordinates of the vector.
310 !
311 ! Output, real ENORM_3D, the Euclidean norm of the vector.
312 !
313  implicit none
314 !
315  real*8 enorm_3d
316  real*8 x1
317  real*8 y1
318  real*8 z1
319 !
320  enorm_3d = sqrt( x1 * x1 + y1 * y1 + z1 * z1 )
321 
322  return
323 END FUNCTION enorm_3d
324 
double sqrt(double d)
Definition: double.h:73
int volume(const block *b)
Definition: split.cpp:181
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
real *8 function enorm_3d(x1, y1, z1)
subroutine triangle_area_3d(x1, y1, z1, x2, y2, z2, x3, y3, z3, area)
subroutine cross_3d(x1, y1, z1, x2, y2, z2, x3, y3, z3)
subroutine v3d4_volume(coor, lmcstet, matcstet, rho, numnp, numcstet, numat_vol, Disp, nstart, nend, TotalMass, TotalGeomVolp, TotalGeomUndefVolp, NumVertx)
Definition: v3d4_volume.f90:53