Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
jacobi.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 jacobi(btens,stret,princ)
54 
55 !!****f* Rocfrac/Rocfrac/Source/jacobi.f90
56 !!
57 !! NAME
58 !! jacobi
59 !!
60 !! FUNCTION
61 !!
62 !! Evaluates the stretches and principal directions given the b matrix
63 !! using the Jacobi iteration. Adapted from numerical recpies
64 !!
65 !! INPUTS
66 !!
67 !! btens --> left Cauchy-Green tensor
68 !!
69 !! OUTPUT
70 !! stret --> vector containing the stretches
71 !! princ --> matrix containing the three principal column vectors
72 !!
73 !!****
74 
75  IMPLICIT DOUBLE PRECISION (a-h,o-z)
76  dimension btens(3,3),stret(3),princ(3,3)
77 !
78 !
79 ! Initialise princ to the identity
80 !
81  DO i=1,3
82  DO j=1,3
83  princ(i,j)=0.d0
84  ENDDO
85  princ(i,i)=1.d0
86  stret(i)=btens(i,i)
87  ENDDO
88 !
89 ! Starts sweeping.
90 !
91  DO is=1,50
92  sum=0.d0
93  DO ip=1,2
94  DO iq=ip+1,3
95  sum=sum+abs(btens(ip,iq))
96  ENDDO
97  ENDDO
98 !
99 ! IF the sum of off-diagonal terms is zero evaluates the
100 ! stretches and returns
101 !
102  IF(sum.EQ.0.d0) THEN
103  DO i=1,3
104  stret(i)=sqrt(stret(i))
105  ENDDO
106  RETURN
107  ENDIF
108 !
109 ! Performs the sweep in three rotations. One per off diagonal term
110 !
111  DO ip=1,2
112  DO iq=ip+1,3
113  od=100.d0*abs(btens(ip,iq))
114  IF((od+abs(stret(ip)).NE.abs(stret(ip))).AND. &
115  (od+abs(stret(iq)).NE.abs(stret(iq)))) THEN
116  hd=stret(iq)-stret(ip)
117 !
118 ! Evaluates the rotation angle
119 !
120  IF(abs(hd)+od.EQ.abs(hd)) THEN
121  t=btens(ip,iq)/hd
122  ELSE
123  theta=0.5d0*hd/btens(ip,iq)
124  t=1.d0/(abs(theta)+sqrt(1.d0+theta**2))
125  IF(theta.LT.0.d0) t=-t
126  ENDIF
127 !
128 ! Re-evaluates the diagonal terms
129 !
130  c=1.d0/sqrt(1.d0+t**2)
131  s=t*c
132  tau=s/(1.d0+c)
133  h=t*btens(ip,iq)
134  stret(ip)=stret(ip)-h
135  stret(iq)=stret(iq)+h
136 !
137 ! Re-evaluates the remaining off-diagonal terms
138 !
139  ir=6-ip-iq
140  g=btens(min(ir,ip),max(ir,ip))
141  h=btens(min(ir,iq),max(ir,iq))
142  btens(min(ir,ip),max(ir,ip))=g-s*(h+g*tau)
143  btens(min(ir,iq),max(ir,iq))=h+s*(g-h*tau)
144 !
145 ! Rotates the eigenvectors
146 !
147  DO ir=1,3
148  g=princ(ir,ip)
149  h=princ(ir,iq)
150  princ(ir,ip)=g-s*(h+g*tau)
151  princ(ir,iq)=h+s*(g-h*tau)
152  ENDDO
153  ENDIF
154  btens(ip,iq)=0.d0
155  ENDDO
156  ENDDO
157  ENDDO
158 !
159 ! IF convergence is not achieved stops
160 !
161  WRITE(6,100)
162  stop
163  100 FORMAT(' Jacobi iteration unable to converge')
164  END
165 
Tfloat sum() const
Return the sum of all the pixel values in an image.
Definition: CImg.h:13022
double s
Definition: blastest.C:80
int dimension() const
Get the dimension of the mesh.
Definition: Connectivity.h:125
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
double sqrt(double d)
Definition: double.h:73
RT c() const
Definition: Line_2.h:150
void int int int REAL REAL REAL * z
Definition: write.cpp:76
blockLoc i
Definition: read.cpp:79
subroutine jacobi(btens, stret, princ)
Definition: jacobi.f90:53
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
j indices j
Definition: Indexing.h:6
RT a() const
Definition: Line_2.h:140
unsigned char g() const
Definition: Color.h:69