FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
dynamic_mass.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
2 ! Copyright (c) 2019 FrontISTR Commons
3 ! This software is released under the MIT License, see LICENSE.txt
4 !-------------------------------------------------------------------------------
7  use m_fstr
8 
9 contains
10 
11  subroutine mass_c2(etype, nn, ecoord, gausses, sec_opt, thick, mass, lumped, temperature)
12  use mmechgauss
13  use m_matmatrix
14  use elementinfo
15  implicit none
16  type(tgaussstatus), intent(in) :: gausses(:)
17  integer(kind=kint), intent(in) :: etype
18  integer(kind=kint), intent(in) :: nn
19  real(kind=kreal), intent(in) :: ecoord(2,nn)
20  real(kind=kreal), intent(out) :: mass(:,:)
21  real(kind=kreal), intent(out) :: lumped(:)
22  real(kind=kreal), intent(in), optional :: temperature(nn)
23  type(tmaterial), pointer :: matl
24  integer(kind=kint), parameter :: ndof = 2
25  integer(kind=kint) :: i, j, lx, sec_opt
26  real(kind=kreal) :: naturalcoord(2)
27  real(kind=kreal) :: func(nn), thick
28  real(kind=kreal) :: det, wg, rho
29  real(kind=kreal) :: d(2,2), n(2, nn*ndof), dn(2, nn*ndof)
30  real(kind=kreal) :: gderiv(nn,2)
31  logical :: is_lumped
32 
33  mass(:,:) = 0.0d0
34  lumped = 0.0d0
35  matl => gausses(1)%pMaterial
36 
37  if(sec_opt == 2) thick = 1.0d0
38 
39  do lx = 1, numofquadpoints(etype)
40  call getquadpoint(etype, lx, naturalcoord)
41  call getshapefunc(etype, naturalcoord, func)
42  call getglobalderiv(etype, nn, naturalcoord, ecoord, det, gderiv)
43 
44  if(present(temperature))then
45  !ina(1) = temperature
46  !call fetch_TableData(MC_ISOELASTIC, matl%dict, outa, ierr, ina)
47  !if(ierr)then
48  rho = matl%variables(m_density)
49  !else
50  ! rho = outa(1)
51  !endif
52  else
53  !call fetch_TableData(MC_ISOELASTIC, matl%dict, outa, ierr)
54  !if(ierr)then
55  rho = matl%variables(m_density)
56  !else
57  ! rho = outa(1)
58  !endif
59  endif
60 
61  d = 0.0d0
62  d(1,1) = rho*thick
63  d(2,2) = rho*thick
64 
65  wg = getweight(etype, lx)*det
66 
67  n = 0.0d0
68  do i = 1, nn
69  n(1,2*i-1) = func(i)
70  n(2,2*i ) = func(i)
71  enddo
72 
73  dn(1:2, 1:nn*ndof) = matmul(d, n(1:2, 1:nn*ndof))
74  do j = 1,nn*ndof
75  do i = 1,nn*ndof
76  mass(i,j) = mass(i,j) + dot_product(n(:,i), dn(:,j))*wg
77  enddo
78  enddo
79  enddo
80 
81  is_lumped = .true.
82  if(is_lumped) call get_lumped_mass(nn, ndof, mass, lumped)
83  end subroutine mass_c2
84 
85  subroutine mass_c3(etype, nn, ecoord, gausses, mass, lumped, temperature)
86  use mmechgauss
87  use m_matmatrix
88  use elementinfo
89  implicit none
90  type(tgaussstatus), intent(in) :: gausses(:)
91  integer(kind=kint), intent(in) :: etype
92  integer(kind=kint), intent(in) :: nn
93  real(kind=kreal), intent(in) :: ecoord(3,nn)
94  real(kind=kreal), intent(out) :: mass(:,:)
95  real(kind=kreal), intent(out) :: lumped(:)
96  real(kind=kreal), intent(in), optional :: temperature(nn)
97  type(tmaterial), pointer :: matl
98  integer(kind=kint), parameter :: ndof = 3
99  integer(kind=kint) :: i, j, lx
100  real(kind=kreal) :: naturalcoord(3)
101  real(kind=kreal) :: func(nn)
102  real(kind=kreal) :: det, wg, rho
103  real(kind=kreal) :: d(3, 3), n(3, nn*ndof), dn(3, nn*ndof)
104  real(kind=kreal) :: gderiv(nn, 3)
105  logical :: is_lumped
106 
107  mass(:,:) = 0.0d0
108  lumped = 0.0d0
109  matl => gausses(1)%pMaterial
110 
111  do lx = 1, numofquadpoints(etype)
112  call getquadpoint(etype, lx, naturalcoord)
113  call getshapefunc(etype, naturalcoord, func)
114  call getglobalderiv(etype, nn, naturalcoord, ecoord, det, gderiv)
115 
116  if(present(temperature))then
117  !ina(1) = temperature
118  !call fetch_TableData(MC_ISOELASTIC, matl%dict, outa, ierr, ina)
119  !if(ierr)then
120  rho = matl%variables(m_density)
121  !else
122  ! rho = outa(1)
123  !endif
124  else
125  !call fetch_TableData(MC_ISOELASTIC, matl%dict, outa, ierr)
126  !if(ierr)then
127  rho = matl%variables(m_density)
128  !else
129  ! rho = outa(1)
130  !endif
131  endif
132 
133  d = 0.0d0
134  d(1,1) = rho
135  d(2,2) = rho
136  d(3,3) = rho
137 
138  wg = getweight(etype,lx)*det
139 
140  n = 0.0d0
141  do i = 1, nn
142  n(1,3*i-2) = func(i)
143  n(2,3*i-1) = func(i)
144  n(3,3*i ) = func(i)
145  enddo
146 
147  dn(1:3, 1:nn*ndof) = matmul(d, n(1:3, 1:nn*ndof))
148  do j = 1,nn*ndof
149  do i = 1,nn*ndof
150  mass(i,j) = mass(i,j) + dot_product(n(:,i), dn(:,j))*wg
151  enddo
152  enddo
153  enddo
154 
155  is_lumped = .true.
156  if(is_lumped) call get_lumped_mass(nn, ndof, mass, lumped)
157  end subroutine mass_c3
158 
159  subroutine mass_s3(surf, thick, rho, mass)
160  implicit none
161  real(kind=kreal) :: surf
162  real(kind=kreal) :: thick
163  real(kind=kreal) :: rho
164  real(kind=kreal), intent(out) :: mass(:,:)
165  integer(kint) :: i
166  mass = 0.0d0
167  do i = 1, 9
168  mass(i,i) = surf*thick*rho/3.0d0
169  enddo
170  end subroutine mass_s3
171 
172  subroutine mass_s4(surf, thick, rho, mass)
173  implicit none
174  real(kind=kreal) :: surf
175  real(kind=kreal) :: thick
176  real(kind=kreal) :: rho
177  real(kind=kreal), intent(out) :: mass(:,:)
178  integer(kint) :: i
179  mass = 0.0d0
180  do i = 1, 12
181  mass(i,i) = surf*thick*rho/4.0d0
182  enddo
183  end subroutine mass_s4
184 
185  subroutine mass_beam(surf, length, rho, mass)
186  implicit none
187  real(kind=kreal) :: surf
188  real(kind=kreal) :: length
189  real(kind=kreal) :: rho
190  real(kind=kreal), intent(out) :: mass(:,:)
191  integer(kint) :: i
192  mass = 0.0d0
193  do i = 1, 12
194  mass(i,i) = 0.5d0*surf*length*rho
195  enddo
196  end subroutine mass_beam
197 
198  subroutine mass_beam_33(surf, length, rho, mass)
199  implicit none
200  real(kind=kreal) :: surf
201  real(kind=kreal) :: length
202  real(kind=kreal) :: rho
203  real(kind=kreal), intent(out) :: mass(:,:)
204  integer(kint) :: i
205  mass = 0.0d0
206  do i = 1, 12
207  mass(i,i) = 0.5d0*surf*length*rho
208  enddo
209  end subroutine mass_beam_33
210 
211  subroutine get_lumped_mass(nn, ndof, mass, lumped)
212  use hecmw
213  implicit none
214  integer(kind=kint) :: i, j, nn, ndof
215  real(kind=kreal) :: lumped(:), mass(:,:)
216  real(kind=kreal) :: diag_mass, total_mass
217 
218  total_mass = 0.0d0
219  do i = 1, nn*ndof, ndof
220  do j = 1, nn*ndof, ndof
221  total_mass = total_mass + mass(j,i)
222  enddo
223  enddo
224 
225  diag_mass = 0.0d0
226  do i = 1, nn*ndof, ndof
227  diag_mass = diag_mass + mass(i,i)
228  enddo
229 
230  diag_mass = 1.0d0/diag_mass
231  do i = 1, nn*ndof
232  lumped(i) = lumped(i) + mass(i,i)*total_mass*diag_mass
233  enddo
234 
235  mass = 0.0d0
236  do i = 1, nn*ndof
237  mass(i,i) = lumped(i)
238  enddo
239  end subroutine get_lumped_mass
240 
241  function get_length(ecoord)
242  use hecmw
243  implicit none
244  real(kind=kreal) :: get_length, ecoord(3,20)
245 
246  get_length = dsqrt( &
247  (ecoord(1,2) - ecoord(1,1))**2 + &
248  (ecoord(2,2) - ecoord(2,1))**2 + &
249  (ecoord(3,2) - ecoord(3,1))**2 )
250  end function get_length
251 
252  function get_face3(ecoord)
253  use hecmw
254  implicit none
255  real(kind=kreal) :: get_face3, ecoord(3,20)
256  real(kind=kreal) :: a1, a2, a3
257  real(kind=kreal) :: x(3), y(3), z(3)
258 
259  x(1) = ecoord(1,1); y(1) = ecoord(2,1); z(1) = ecoord(3,1)
260  x(2) = ecoord(1,2); y(2) = ecoord(2,2); z(2) = ecoord(3,2)
261  x(3) = ecoord(1,3); y(3) = ecoord(2,3); z(3) = ecoord(3,3)
262 
263  a1 = (x(2) - x(1))**2 + (y(2) - y(1))**2 + (z(2) - z(1))**2
264  a2 = (x(1) - x(3))*(x(2) - x(1)) &
265  & + (y(1) - y(3))*(y(2) - y(1)) &
266  & + (z(1) - z(3))*(z(2) - z(1))
267  a3 = (x(3) - x(1))**2 + (y(3) - y(1))**2 + (z(3) - z(1))**2
268 
269  get_face3 = 0.5d0*dsqrt(a1*a3 - a2*a2)
270  end function get_face3
271 
272  function get_face4(ecoord)
273  use hecmw
274  implicit none
275  integer(kind=kint) :: lx, ly
276  real(kind=kreal) :: get_face4, ecoord(3,20)
277  real(kind=kreal) :: xg(2), ri, si, rp, sp, rm, sm, hr(4), hs(4)
278  real(kind=kreal) :: xr, xs, yr, ys, zr, zs
279  real(kind=kreal) :: x(4), y(4), z(4), det
280 
281  x(1) = ecoord(1,1); y(1) = ecoord(2,1); z(1) = ecoord(3,1)
282  x(2) = ecoord(1,2); y(2) = ecoord(2,2); z(2) = ecoord(3,2)
283  x(3) = ecoord(1,3); y(3) = ecoord(2,3); z(3) = ecoord(3,3)
284  x(4) = ecoord(1,4); y(4) = ecoord(2,4); z(4) = ecoord(3,4)
285 
286  xg(1) = -0.5773502691896258d0
287  xg(2) = -xg(1)
288  get_face4 = 0.0d0
289 
290  do lx = 1, 2
291  ri = xg(lx)
292  do ly = 1, 2
293  si = xg(ly)
294  rp = 1.0d0 + ri
295  sp = 1.0d0 + si
296  rm = 1.0d0 - ri
297  sm = 1.0d0 - si
298 
299  !C* FOR R-COORDINATE
300  hr(1) = 0.25d0*sp
301  hr(2) = -0.25d0*sp
302  hr(3) = -0.25d0*sm
303  hr(4) = 0.25d0*sm
304 
305  !C* FOR S-COORDINATE
306  hs(1) = 0.25d0*rp
307  hs(2) = 0.25d0*rm
308  hs(3) = -0.25d0*rm
309  hs(4) = -0.25d0*rp
310 
311  !C*JACOBI MATRIX
312  xr = hr(1)*x(1) + hr(2)*x(2) + hr(3)*x(3) + hr(4)*x(4)
313  xs = hs(1)*x(1) + hs(2)*x(2) + hs(3)*x(3) + hs(4)*x(4)
314  yr = hr(1)*y(1) + hr(2)*y(2) + hr(3)*y(3) + hr(4)*y(4)
315  ys = hs(1)*y(1) + hs(2)*y(2) + hs(3)*y(3) + hs(4)*y(4)
316  zr = hr(1)*z(1) + hr(2)*z(2) + hr(3)*z(3) + hr(4)*z(4)
317  zs = hs(1)*z(1) + hs(2)*z(2) + hs(3)*z(3) + hs(4)*z(4)
318 
319  det = (yr*zs - zr*ys)**2 + (zr*xs - xr*zs)**2 + (xr*ys - yr*xs)**2
320  det = dsqrt(det)
321 
322  get_face4 = get_face4 + det
323  enddo
324  enddo
325  end function get_face4
326 
327 end module m_dynamic_mass
This module encapsulate the basic functions of all elements provide by this software.
Definition: element.f90:43
subroutine getshapefunc(fetype, localcoord, func)
Calculate the shape function in natural coordinate system.
Definition: element.f90:647
subroutine getquadpoint(fetype, np, pos)
Fetch the coordinate of gauss point.
Definition: element.f90:489
subroutine getglobalderiv(fetype, nn, localcoord, elecoord, det, gderiv)
Calculate shape derivative in global coordinate system.
Definition: element.f90:741
real(kind=kreal) function getweight(fetype, np)
Fetch the weight value in given gauss point.
Definition: element.f90:535
integer function numofquadpoints(fetype)
Obtains the number of quadrature points of the element.
Definition: element.f90:450
Definition: hecmw.f90:6
This module contains subroutines used in 3d eigen analysis for.
Definition: dynamic_mass.f90:6
real(kind=kreal) function get_length(ecoord)
subroutine mass_beam_33(surf, length, rho, mass)
subroutine mass_c2(etype, nn, ecoord, gausses, sec_opt, thick, mass, lumped, temperature)
real(kind=kreal) function get_face4(ecoord)
subroutine mass_s3(surf, thick, rho, mass)
real(kind=kreal) function get_face3(ecoord)
subroutine mass_c3(etype, nn, ecoord, gausses, mass, lumped, temperature)
subroutine mass_beam(surf, length, rho, mass)
subroutine mass_s4(surf, thick, rho, mass)
subroutine get_lumped_mass(nn, ndof, mass, lumped)
This module defines common data and basic structures for analysis.
Definition: m_fstr.F90:15
This module manages calculation relates with materials.
Definition: calMatMatrix.f90:6
This modules defines a structure to record history dependent parameter in static analysis.
Definition: mechgauss.f90:6
All data should be recorded in every quadrature points.
Definition: mechgauss.f90:16