1 module module_hexa
! testing only
6 subroutine hexa(A
,X
,u0
,Kloc
,Floc
,Jg
,iflag
)
7 ! purpose: create local stiffness matrix etc for hexa 3d element
9 ! A coefficient matrix size 3x3, symmetric positive definite
10 ! X nodes coordinates size 3x8, one each column is one node
11 ! u0 column vector of input wind at the center of the element
12 ! iflags iflags = 1 compute Kloc, iflag = 2 compute Floc, iflag = 3 compute Jg
14 ! Kloc local stiffness matrix
15 ! Floc local divergence load vector
16 ! Jg gradient at center of function with values V is V'*Jg
22 real, intent(in
):: A(3,3), X(3,8), u0(3) ! fortran is not case sensitive
23 integer, intent(in
)::iflag
24 real, intent(out
):: Kloc(8,8), Floc(8), Jg(8,3)
26 !real, parameter :: g = 0.5773502691896257
27 real,dimension(9,3),save :: ib
= reshape((/-1,-1,-1,-1,1,1,1,1,0,-1,-1,1,1,-1,-1,1,1,0,-1,1,-1,1,-1,1,-1,1,0/),(/9,3/))
28 real,dimension(9,3),save :: s
= reshape((/-0.5773502691896257,-0.5773502691896257,-0.5773502691896257,-0.5773502691896257&
29 ,0.5773502691896257,0.5773502691896257,0.5773502691896257,0.5773502691896257,0.0,-0.5773502691896257,-0.5773502691896257&
30 ,0.5773502691896257,0.5773502691896257,-0.5773502691896257,-0.5773502691896257,0.5773502691896257,0.5773502691896257&
31 ,0.0,-0.5773502691896257,0.5773502691896257,-0.5773502691896257,0.5773502691896257,-0.5773502691896257,0.5773502691896257&
32 ,-0.5773502691896257,0.5773502691896257,0.0/),(/9,3/))
33 real :: gradf(8,3), Jg_tmp(8,3)
34 real :: Jx(3,3), Jx_inv(3,3)
35 real :: Jg_tran(3,8), A_tmp(3,8)
59 if (iflag
.eq
. 3) then
64 !first column of gradf
66 gradf(j
,1) = (ib(j
,1)*(1+ib(j
,2)*s(i
,2))*(1+ib(j
,3)*s(i
,3)))/8
68 !second coumn of gradf
70 gradf(j
,2) = ((1+ib(j
,1)*s(i
,1))*ib(j
,2)*(1+ib(j
,3)*s(i
,3)))/8
72 !third column of gradf
74 gradf(j
,3) = ((1+ib(j
,1)*s(i
,1))*(1+ib(j
,2)*s(i
,2))*ib(j
,3))/8
80 detJx
= (Jx(1,1)*Jx(2,2)*Jx(3,3) - Jx(1,1)*Jx(2,3)*Jx(3,2)-&
81 Jx(1,2)*Jx(2,1)*Jx(3,3) + Jx(1,2)*Jx(2,3)*Jx(3,1)+&
82 Jx(1,3)*Jx(2,1)*Jx(3,2) - Jx(1,3)*Jx(2,2)*Jx(3,1))
84 if(abs(detJx
).lt
.tiny(detJx
))then
85 print *,'detJx=',detJx
86 call crash('The Jacobian is (numerically) singular')
89 Jx_inv(1,1) = +(1/detJx
) * (Jx(2,2)*Jx(3,3) - Jx(2,3)*Jx(3,2))
90 Jx_inv(2,1) = -(1/detJx
) * (Jx(2,1)*Jx(3,3) - Jx(2,3)*Jx(3,1))
91 Jx_inv(3,1) = +(1/detJx
) * (Jx(2,1)*Jx(3,2) - Jx(2,2)*Jx(3,1))
92 Jx_inv(1,2) = -(1/detJx
) * (Jx(1,2)*Jx(3,3) - Jx(1,3)*Jx(3,2))
93 Jx_inv(2,2) = +(1/detJx
) * (Jx(1,1)*Jx(3,3) - Jx(1,3)*Jx(3,1))
94 Jx_inv(3,2) = -(1/detJx
) * (Jx(1,1)*Jx(3,2) - Jx(1,2)*Jx(3,1))
95 Jx_inv(1,3) = +(1/detJx
) * (Jx(1,2)*Jx(2,3) - Jx(1,3)*Jx(2,2))
96 Jx_inv(2,3) = -(1/detJx
) * (Jx(1,1)*Jx(2,3) - Jx(1,3)*Jx(2,1))
97 Jx_inv(3,3) = +(1/detJx
) * (Jx(1,1)*Jx(2,2) - Jx(1,2)*Jx(2,1))
99 Jg
= matmul(gradf
,Jx_inv
)
102 endif !end for computing Jg
105 if (iflag
.eq
. 1) then
110 !first column of gradf
112 gradf(j
,1) = (ib(j
,1)*(1+ib(j
,2)*s(i
,2))*(1+ib(j
,3)*s(i
,3)))/8
114 !second coumn of gradf
116 gradf(j
,2) = ((1+ib(j
,1)*s(i
,1))*ib(j
,2)*(1+ib(j
,3)*s(i
,3)))/8
118 !third column of gradf
120 gradf(j
,3) = ((1+ib(j
,1)*s(i
,1))*(1+ib(j
,2)*s(i
,2))*ib(j
,3))/8
126 detJx
= (Jx(1,1)*Jx(2,2)*Jx(3,3) - Jx(1,1)*Jx(2,3)*Jx(3,2)-&
127 Jx(1,2)*Jx(2,1)*Jx(3,3) + Jx(1,2)*Jx(2,3)*Jx(3,1)+&
128 Jx(1,3)*Jx(2,1)*Jx(3,2) - Jx(1,3)*Jx(2,2)*Jx(3,1))
130 if(abs(detJx
).lt
.tiny(detJx
))then
131 print *,'detJx=',detJx
132 call crash('The Jacobian is (numerically) singular')
135 Jx_inv(1,1) = +(1/detJx
) * (Jx(2,2)*Jx(3,3) - Jx(2,3)*Jx(3,2))
136 Jx_inv(2,1) = -(1/detJx
) * (Jx(2,1)*Jx(3,3) - Jx(2,3)*Jx(3,1))
137 Jx_inv(3,1) = +(1/detJx
) * (Jx(2,1)*Jx(3,2) - Jx(2,2)*Jx(3,1))
138 Jx_inv(1,2) = -(1/detJx
) * (Jx(1,2)*Jx(3,3) - Jx(1,3)*Jx(3,2))
139 Jx_inv(2,2) = +(1/detJx
) * (Jx(1,1)*Jx(3,3) - Jx(1,3)*Jx(3,1))
140 Jx_inv(3,2) = -(1/detJx
) * (Jx(1,1)*Jx(3,2) - Jx(1,2)*Jx(3,1))
141 Jx_inv(1,3) = +(1/detJx
) * (Jx(1,2)*Jx(2,3) - Jx(1,3)*Jx(2,2))
142 Jx_inv(2,3) = -(1/detJx
) * (Jx(1,1)*Jx(2,3) - Jx(1,3)*Jx(2,1))
143 Jx_inv(3,3) = +(1/detJx
) * (Jx(1,1)*Jx(2,2) - Jx(1,2)*Jx(2,1))
144 Jg
= matmul(gradf
,Jx_inv
)
150 Jg_tran(k
,j
) = Jg(j
,k
)
154 A_tmp
= matmul(A
, Jg_tran
)
155 K_at_s
= matmul(Jg
,A_tmp
)
156 Kloc
= Kloc
+(K_at_s
*abs(detJx
))
157 end if !end for computing Kloc
158 end do !end of outter most do loop
159 end if !end for computing Kloc
163 if (iflag
.eq
. 2) then
168 !first column of gradf
170 gradf(j
,1) = (ib(j
,1)*(1+ib(j
,2)*s(i
,2))*(1+ib(j
,3)*s(i
,3)))/8
172 !second coumn of gradf
174 gradf(j
,2) = ((1+ib(j
,1)*s(i
,1))*ib(j
,2)*(1+ib(j
,3)*s(i
,3)))/8
176 !third column of gradf
178 gradf(j
,3) = ((1+ib(j
,1)*s(i
,1))*(1+ib(j
,2)*s(i
,2))*ib(j
,3))/8
184 detJx
= (Jx(1,1)*Jx(2,2)*Jx(3,3) - Jx(1,1)*Jx(2,3)*Jx(3,2)-&
185 Jx(1,2)*Jx(2,1)*Jx(3,3) + Jx(1,2)*Jx(2,3)*Jx(3,1)+&
186 Jx(1,3)*Jx(2,1)*Jx(3,2) - Jx(1,3)*Jx(2,2)*Jx(3,1))
188 if(abs(detJx
).lt
.tiny(detJx
))then
189 print *,'detJx=',detJx
190 call crash('The Jacobian is (numerically) singular')
193 Jx_inv(1,1) = +(1/detJx
) * (Jx(2,2)*Jx(3,3) - Jx(2,3)*Jx(3,2))
194 Jx_inv(2,1) = -(1/detJx
) * (Jx(2,1)*Jx(3,3) - Jx(2,3)*Jx(3,1))
195 Jx_inv(3,1) = +(1/detJx
) * (Jx(2,1)*Jx(3,2) - Jx(2,2)*Jx(3,1))
196 Jx_inv(1,2) = -(1/detJx
) * (Jx(1,2)*Jx(3,3) - Jx(1,3)*Jx(3,2))
197 Jx_inv(2,2) = +(1/detJx
) * (Jx(1,1)*Jx(3,3) - Jx(1,3)*Jx(3,1))
198 Jx_inv(3,2) = -(1/detJx
) * (Jx(1,1)*Jx(3,2) - Jx(1,2)*Jx(3,1))
199 Jx_inv(1,3) = +(1/detJx
) * (Jx(1,2)*Jx(2,3) - Jx(1,3)*Jx(2,2))
200 Jx_inv(2,3) = -(1/detJx
) * (Jx(1,1)*Jx(2,3) - Jx(1,3)*Jx(2,1))
201 Jx_inv(3,3) = +(1/detJx
) * (Jx(1,1)*Jx(2,2) - Jx(1,2)*Jx(2,1))
203 Jg
= matmul(gradf
,Jx_inv
)
211 tmp
= tmp
+Jg(j
,k
)*u0_tmp(k
)
218 end if !end for computing Floc
222 end module module_hexa