Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VolRatio.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 volratio(n1, n2, n3, n4, AlphaR,coor,numnp,NdMassLump)
54 
55 !!****f* Rocfrac/Rocfrac/Source/VolRatio.f90
56 !!
57 !! NAME
58 !! VolRatio
59 !!
60 !! FUNCTION
61 !! Calculates the Volume Ratio for the node based elements
62 !! using either the circumcenter of centroid.
63 !!
64 !! INPUTS
65 !! n1,n2,n3,n4 -- node number
66 !! coor -- nodeal coordinates
67 !! numnp -- number of nodes
68 !! NdMassLump -- = 1 then circumcenter method
69 !! = 0 then centroid method
70 !!
71 !! OUTPUT
72 !!
73 !! AlphaR -- Ratio of the Volume for a node
74 !!
75 !!****
76 !!
77  IMPLICIT NONE
78 
79  CHARACTER*4 :: myid_chr ! output file number (a character)
80  INTEGER :: j
81  INTEGER :: j1l, j2l, j3l, j4l
82  REAL*8 :: volel,tolv
83  INTEGER, DIMENSION(1:4,1) :: vx
84  REAL*8 :: xcn,ycn,zcn,xpt,ypt,zpt
85  INTEGER :: ncont
86  REAL*8, DIMENSION(1:3) :: circenttet,x,y,z,xmd,ymd,zmd
87  REAL*8, DIMENSION(1:4,1:3) :: circenttri
88  INTEGER :: numnp
89  REAL*8, DIMENSION(1:3,1:numnp) :: coor
90 
91  INTEGER :: n1, n2, n3, n4
92  INTEGER :: in
93  REAL*8, DIMENSION(1:4) :: alphar
94 
95  REAL*8 :: x1,x2,x3,x4,y1,y2,y3,y4,z1,z2,z3,z4
96 
97  REAL*8 :: x12mp,x13mp,x14mp,x23mp,x24mp,x34mp
98  REAL*8 :: y12mp,y13mp,y14mp,y23mp,y24mp,y34mp
99  REAL*8 :: z12mp,z13mp,z14mp,z23mp,z24mp,z34mp
100 
101 !-- Coordinate subtractions
102  REAL*8 :: x14v,x24v, x34v, y14v, y24v, y34v, z14v, z24v, z34v
103  REAL*8 :: v11,v21,v31
104  REAL*8 :: vol
105 
106  REAL*8, DIMENSION(1:3) :: norm1, norm2, norm3, norm4, normc1, normc2, normc3,centroidtet
107  REAL*8, DIMENSION(1:3) :: vnorm12, vnorm13, vnorm14, vnorm23, vnorm24, vnorm34
108  REAL*8 :: offset12, offset13, offset14, offset23, offset24, offset34
109 
110  INTEGER :: same1,same2,same3
111  REAL*8 :: offset1, offset2, offset3,offset4, offsetc1, offsetc2, offsetc3,calcoffset,offset
112  CHARACTER*61 :: qhullstat
113  INTEGER :: iopt
114  REAL*8 :: aj1, aj2, aj3, aj4
115  real*8 feasiblept(0:2)
116  REAL*8, DIMENSION(0:3,0:6) :: planes
117  integer :: ndmasslump
118 
119 !
120 ! SET TOLERANCE FOR MINIMUM VOLUME
121 !
122  tolv = 1.0e-13
123 
124  IF(ndmasslump.EQ.1)THEN
125 
126  x1 = coor(1,n1) ! get vertex coords.
127  x2 = coor(1,n2)
128  x3 = coor(1,n3)
129  x4 = coor(1,n4)
130  y1 = coor(2,n1)
131  y2 = coor(2,n2)
132  y3 = coor(2,n3)
133  y4 = coor(2,n4)
134  z1 = coor(3,n1)
135  z2 = coor(3,n2)
136  z3 = coor(3,n3)
137  z4 = coor(3,n4)
138 ! Volume of Tetrahedra
139 
140  x14v = x1 - x4
141  x24v = x2 - x4
142  x34v = x3 - x4
143  y14v = y1 - y4
144  y24v = y2 - y4
145  y34v = y3 - y4
146  z14v = z1 - z4
147  z24v = z2 - z4
148  z34v = z3 - z4
149 
150  v11 = y24v*z34v - z24v*y34v
151  v21 = -( x24v*z34v - z24v*x34v )
152  v31 = x24v*y34v - y24v*x34v
153 
154  volel = -( x14v*v11 + y14v*v21 + z14v*v31 )/6.d0
155 
156 ! Coordinates of the edge mid-points
157 
158  x12mp = 0.5d0*(x1 + x2)
159  x13mp = 0.5d0*(x1 + x3)
160  x14mp = 0.5d0*(x1 + x4)
161  x23mp = 0.5d0*(x2 + x3)
162  x24mp = 0.5d0*(x2 + x4)
163  x34mp = 0.5d0*(x3 + x4)
164  y12mp = 0.5d0*(y1 + y2)
165  y13mp = 0.5d0*(y1 + y3)
166  y14mp = 0.5d0*(y1 + y4)
167  y23mp = 0.5d0*(y2 + y3)
168  y24mp = 0.5d0*(y2 + y4)
169  y34mp = 0.5d0*(y3 + y4)
170  z12mp = 0.5d0*(z1 + z2)
171  z13mp = 0.5d0*(z1 + z3)
172  z14mp = 0.5d0*(z1 + z4)
173  z23mp = 0.5d0*(z2 + z3)
174  z24mp = 0.5d0*(z2 + z4)
175  z34mp = 0.5d0*(z3 + z4)
176 
177 ! normals of the faces
178 
179  CALL planenorm(x3,y3,z3,x2,y2,z2,x1,y1,z1,norm1(1),norm1(2),norm1(3),same1)
180  offset1 = calcoffset(norm1(1),norm1(2),norm1(3),x1,y1,z1)
181  CALL planenorm(x1,y1,z1,x2,y2,z2,x4,y4,z4,norm2(1),norm2(2),norm2(3),same1)
182  offset2 = calcoffset(norm2(1),norm2(2),norm2(3),x1,y1,z1)
183  CALL planenorm(x2,y2,z2,x3,y3,z3,x4,y4,z4,norm3(1),norm3(2),norm3(3),same1)
184  offset3 = calcoffset(norm3(1),norm3(2),norm3(3),x2,y2,z2)
185  CALL planenorm(x1,y1,z1,x4,y4,z4,x3,y3,z3,norm4(1),norm4(2),norm4(3),same1)
186  offset4 = calcoffset(norm4(1),norm4(2),norm4(3),x1,y1,z1)
187 
188  CALL planenorm3d( x1, y1, z1, x2, y2 , z2, vnorm12 )
189  offset12 = offset(vnorm12,x12mp,y12mp,z12mp)
190 
191  CALL planenorm3d( x1, y1, z1, x3, y3 , z3, vnorm13 )
192  offset13 = offset(vnorm13,x13mp,y13mp,z13mp)
193 
194  CALL planenorm3d( x1, y1, z1, x4, y4 , z4, vnorm14 )
195  offset14 = offset(vnorm14,x14mp,y14mp,z14mp)
196 
197  CALL planenorm3d( x2, y2, z2, x3, y3 , z3, vnorm23 )
198  offset23 = offset(vnorm23,x23mp,y23mp,z23mp)
199 
200  CALL planenorm3d( x2, y2, z2, x4, y4 , z4, vnorm24 )
201  offset24 = offset(vnorm24,x24mp,y24mp,z24mp)
202 
203  CALL planenorm3d( x3, y3, z3, x4, y4 , z4, vnorm34 )
204  offset34 = offset(vnorm34,x34mp,y34mp,z34mp)
205 
206  planes(0:2,0) = -norm1(1:3)
207  planes( 3,0) = offset1
208  planes(0:2,1) = -norm2(1:3)
209  planes( 3,1) = offset2
210  planes(0:2,2) = -norm3(1:3)
211  planes( 3,2) = offset3
212  planes(0:2,3) = -norm4(1:3)
213  planes( 3,3) = offset4
214 
215 ! Node 1 Volume
216 
217  planes(0:2,4) = -vnorm12(1:3)
218  planes(3,4) = offset12
219  planes(0:2,5) = -vnorm13(1:3)
220  planes(3,5) = offset13
221  planes(0:2,6) = -vnorm14(1:3)
222  planes(3,6) = offset14
223 
224  CALL volume_lasserre_file( planes(0,0), aj1 )
225 
226 ! Node 2
227 
228  planes(0:2,4) = vnorm12(1:3)
229  planes(3,4) = -offset12
230  planes(0:2,5) = -vnorm23(1:3)
231  planes(3,5) = offset23
232  planes(0:2,6) = -vnorm24(1:3)
233  planes(3,6) = offset24
234 
235  CALL volume_lasserre_file( planes(0,0), aj2 )
236 
237 ! Node 3
238 
239  planes(0:2,4) = -vnorm34(1:3)
240  planes(3,4) = offset34
241  planes(0:2,5) = vnorm13(1:3)
242  planes(3,5) = -offset13
243  planes(0:2,6) = vnorm23(1:3)
244  planes(3,6) = -offset23
245 
246  CALL volume_lasserre_file( planes(0,0), aj3)
247 
248 ! Node 4
249 
250  planes(0:2,4) = vnorm14(1:3)
251  planes(3,4) = -offset14
252  planes(0:2,5) = vnorm24(1:3)
253  planes(3,5) = -offset24
254  planes(0:2,6) = vnorm34(1:3)
255  planes(3,6) = -offset34
256 
257  CALL volume_lasserre_file( planes(0,0), aj4)
258 
259  IF((aj1+aj2+aj3+aj4)/volel.GT.1.0005.OR.&
260  (aj1+aj2+aj3+aj4)/volel.LT.0.995)THEN
261  print*,'ERROR: Node Volume Calculation Incorrect'
262  print*,(aj1+aj2+aj3+aj4)/volel
263  stop
264  ENDIF
265 
266  alphar(1) = aj1/volel
267  alphar(2) = aj2/volel
268  alphar(3) = aj3/volel
269  alphar(4) = aj4/volel
270 ! Option 1
271 
272  ELSE IF(ndmasslump.EQ.0)THEN
273 
274  alphar(1) = 0.25d0
275  alphar(2) = 0.25d0
276  alphar(3) = 0.25d0
277  alphar(4) = 0.25d0
278 
279  ENDIF
280 
281  RETURN
282  END SUBROUTINE volratio
283 
real *8 function calcoffset(x1, y1, z1, x2, y2, z2)
Definition: PlaneNorm.f90:175
void int int REAL REAL * y
Definition: read.cpp:74
real *8 function offset(vNorm, x2, y2, z2)
Definition: PlaneNorm.f90:211
subroutine planenorm(x1, y1, z1, x2, y2, z2, x3, y3, z3, xn, yn, zn, same)
Definition: PlaneNorm.f90:53
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
subroutine volratio(n1, n2, n3, n4, AlphaR, coor, numnp, NdMassLump)
Definition: VolRatio.f90:53
virtual std::ostream & print(std::ostream &os) const
subroutine planenorm3d(ax, ay, az, bx, by, bz, vNorm)
Definition: PlaneNorm3D.f90:54
j indices j
Definition: Indexing.h:6
void volume_lasserre_file(double planes2[7][4], rational *volume)
Definition: vinci_lass.c:800