Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
max_dt_solid.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 max_dt_solid(dt_courant,glb)
54 
55 !!****f* Rocfrac/Rocfrac/Source/max_dt_solid.f90
56 !!
57 !! NAME
58 !! max_dt_solid
59 !!
60 !! FUNCTION
61 !! Determines the maximum time step
62 !!
63 !! INPUTS
64 !! glb -- global array
65 !!
66 !! OUTPUT
67 !! dt_courant -- maximum time step
68 !!****
69 
70  USE rocstar_rocfrac
71  IMPLICIT NONE
72 
73  include 'mpif.h'
74 
75  TYPE(rocfrac_global) :: glb
76 
77  REAL*8 :: xx,yy,zz,size1,size2,size3,size4,size5,size6,size7,size8,size9,size10,size11,size12
78  REAL*8 :: dhmin,dhminp,dt_courant, dt_courantp,dt_courantht
79 
80  INTEGER :: i, ierr
81 
82  dhminp = 1000000000.d0
83 
84  IF(glb%iElType.EQ.8)THEN
85  DO i = 1, glb%NumElVol
86  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(1,i), glb%ElConnVol(4,i), size1)
87  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(5,i), glb%ElConnVol(8,i), size2)
88  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(6,i), glb%ElConnVol(7,i), size3)
89  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(2,i), glb%ElConnVol(3,i), size4)
90 
91  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(4,i), glb%ElConnVol(8,i), size5)
92  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(8,i), glb%ElConnVol(7,i), size6)
93  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(7,i), glb%ElConnVol(3,i), size7)
94  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(3,i), glb%ElConnVol(4,i), size8)
95 
96  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(1,i), glb%ElConnVol(5,i), size9)
97  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(5,i), glb%ElConnVol(6,i), size10)
98  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(6,i), glb%ElConnVol(2,i), size11)
99  call smallestelement(glb%NumNP, glb%MeshCoor, glb%ElConnVol(2,i), glb%ElConnVol(1,i), size12)
100 
101  dhminp = min(size1, size2, size3, size4, size5, size6, size7, size8, size9, size10, size11, size12, dhminp)
102  enddo
103 
104  ELSE
105 
106  DO i = 1, glb%NumElVol
107 !
108 ! -- Find the size of the smallest element
109 !
110  xx = glb%MeshCoor(1,glb%ElConnVol(1,i)) - glb%MeshCoor(1,glb%ElConnVol(2,i))
111  yy = glb%MeshCoor(2,glb%ElConnVol(1,i)) - glb%MeshCoor(2,glb%ElConnVol(2,i))
112  zz = glb%MeshCoor(3,glb%ElConnVol(1,i)) - glb%MeshCoor(3,glb%ElConnVol(2,i))
113  size1 = sqrt(xx*xx+yy*yy+zz*zz)
114  xx = glb%MeshCoor(1,glb%ElConnVol(2,i)) - glb%MeshCoor(1,glb%ElConnVol(3,i))
115  yy = glb%MeshCoor(2,glb%ElConnVol(2,i)) - glb%MeshCoor(2,glb%ElConnVol(3,i))
116  zz = glb%MeshCoor(3,glb%ElConnVol(2,i)) - glb%MeshCoor(3,glb%ElConnVol(3,i))
117  size2 = sqrt(xx*xx+yy*yy+zz*zz)
118  xx = glb%MeshCoor(1,glb%ElConnVol(3,i)) - glb%MeshCoor(1,glb%ElConnVol(1,i))
119  yy = glb%MeshCoor(2,glb%ElConnVol(3,i)) - glb%MeshCoor(2,glb%ElConnVol(1,i))
120  zz = glb%MeshCoor(3,glb%ElConnVol(3,i)) - glb%MeshCoor(3,glb%ElConnVol(1,i))
121  size3 = sqrt(xx*xx+yy*yy+zz*zz)
122  xx = glb%MeshCoor(1,glb%ElConnVol(4,i)) - glb%MeshCoor(1,glb%ElConnVol(1,i))
123  yy = glb%MeshCoor(2,glb%ElConnVol(4,i)) - glb%MeshCoor(2,glb%ElConnVol(1,i))
124  zz = glb%MeshCoor(3,glb%ElConnVol(4,i)) - glb%MeshCoor(3,glb%ElConnVol(1,i))
125  size4 = sqrt(xx*xx+yy*yy+zz*zz)
126  xx = glb%MeshCoor(1,glb%ElConnVol(4,i)) - glb%MeshCoor(1,glb%ElConnVol(2,i))
127  yy = glb%MeshCoor(2,glb%ElConnVol(4,i)) - glb%MeshCoor(2,glb%ElConnVol(2,i))
128  zz = glb%MeshCoor(3,glb%ElConnVol(4,i)) - glb%MeshCoor(3,glb%ElConnVol(2,i))
129  size5 = sqrt(xx*xx+yy*yy+zz*zz)
130  xx = glb%MeshCoor(1,glb%ElConnVol(4,i)) - glb%MeshCoor(1,glb%ElConnVol(3,i))
131  yy = glb%MeshCoor(2,glb%ElConnVol(4,i)) - glb%MeshCoor(2,glb%ElConnVol(3,i))
132  zz = glb%MeshCoor(3,glb%ElConnVol(4,i)) - glb%MeshCoor(3,glb%ElConnVol(3,i))
133  size6 = sqrt(xx*xx+yy*yy+zz*zz)
134  dhminp = min(size1,size2,size3,size4,size5,size6,dhminp)
135 
136  ENDDO
137  ENDIF
138 
139 !fix parallel, need to min across all processors
140 
141 
142  CALL mpi_allreduce(dhminp,dhmin,1,mpi_double_precision, &
143  mpi_min,glb%MPI_COMM_ROCFRAC,ierr)
144 
145  dt_courant = dhmin/glb%cd_fastest
146 
147  IF(glb%HeatTransSoln)THEN
148 
149  dt_courantht = dhmin**2/glb%ThermalDiffusivity/6. ! is this 6., 3. or 2. ?
150 
151  IF(glb%ThermalExpansion)THEN
152 
153  dt_courant = min( dt_courant, dt_courantht)
154 
155  ELSE
156  dt_courant = dt_courantht
157  ENDIF
158 
159  Endif
160 
161  dt_courant = dt_courant*glb%CourantRatio
162 
163 
164  RETURN
165 END SUBROUTINE max_dt_solid
166 
double sqrt(double d)
Definition: double.h:73
blockLoc i
Definition: read.cpp:79
subroutine max_dt_solid(dt_courant, glb)
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
subroutine smallestelement(NumNP, coor, Node1, Node2, lngth)