Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ainv.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 ainv(ajac,ajacin,det,ndim)
54 
55  IMPLICIT NONE
56 
57 !!****f* Rocfrac/Rocfrac/Source/ainv.f90
58 !!
59 !! NAME
60 !! ainv
61 !!
62 !! FUNCTION
63 !! Computes the det and inverse of a (3x3) matrix
64 !!
65 !! USED BY
66 !! shcalc, shcalc_3d10
67 !!
68 !! INPUTS
69 !! ndim -- size of input array (must be 3)
70 !! ajac -- Input array (ndim x ndim)
71 !!
72 !! OUTPUT
73 !! ajacin -- inverse of ajac
74 !! det -- determinate of ajac
75 !!
76 !!***
77 
78  INTEGER :: ndim
79  REAL*8, DIMENSION(ndim,ndim) :: ajac, ajacin
80  REAL*8 :: det, asmall
81 
82  asmall = 1.d-15
83 
84  det = ajac(1,1)*( ajac(2,2)*ajac(3,3) - ajac(2,3)* &
85  ajac(3,2) ) &
86  - ajac(1,2)*( ajac(2,1)*ajac(3,3) - ajac(2,3)* &
87  ajac(3,1) ) &
88  + ajac(1,3)*( ajac(2,1)*ajac(3,2) - ajac(2,2)* &
89  ajac(3,1) )
90 
91  IF(dabs(det).LT.asmall) THEN
92  print*, 'cannot invert matrix in ainv'
93  print*,'ABS(det) =', dabs(det)
94  stop
95  END IF
96 
97 
98  det = 1.d0/det
99 
100 ! construct inverse
101 
102  ajacin(1,1) = det*( ajac(2,2)*ajac(3,3) &
103  - ajac(2,3)*ajac(3,2) )
104  ajacin(1,2) = -det*( ajac(1,2)*ajac(3,3) &
105  - ajac(1,3)*ajac(3,2) )
106  ajacin(1,3) = det*( ajac(1,2)*ajac(2,3) &
107  - ajac(1,3)*ajac(2,2) )
108  ajacin(2,1) = -det*( ajac(2,1)*ajac(3,3) &
109  - ajac(2,3)*ajac(3,1) )
110  ajacin(2,2) = det*( ajac(1,1)*ajac(3,3) &
111  - ajac(1,3)*ajac(3,1) )
112  ajacin(2,3) = -det*( ajac(1,1)*ajac(2,3) &
113  - ajac(1,3)*ajac(2,1) )
114  ajacin(3,1) = det*( ajac(2,1)*ajac(3,2) &
115  - ajac(2,2)*ajac(3,1) )
116  ajacin(3,2) = -det*( ajac(1,1)*ajac(3,2) &
117  - ajac(1,2)*ajac(3,1) )
118  ajacin(3,3) = det*( ajac(1,1)*ajac(2,2) &
119  - ajac(1,2)*ajac(2,1) )
120 
121  det = 1.d0/det
122 
123  RETURN
124 END SUBROUTINE ainv
125 
const NT & d
subroutine ainv(ajac, ajacin, det, ndim)
Definition: ainv.f90:53
virtual std::ostream & print(std::ostream &os) const