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