200 lines
5.8 KiB
Fortran
200 lines
5.8 KiB
Fortran
program test_shell_mass
|
|
use fem_precision
|
|
use fem_error
|
|
use fem_database
|
|
use fem_element_mass
|
|
implicit none
|
|
|
|
real(rk), parameter :: TOL = 1.0e-10_rk
|
|
real(rk), parameter :: DENSITY = 12.0_rk
|
|
real(rk), parameter :: THICKNESS = 0.5_rk
|
|
|
|
call check_shell('S3', 3, HALF, 10)
|
|
call check_shell('S4', 4, ONE, 30)
|
|
call check_shell('S6', 6, HALF, 50)
|
|
call check_shell('S8', 8, ONE, 70)
|
|
|
|
contains
|
|
|
|
subroutine check_shell(etype, nlocal, expected_area, code)
|
|
character(len=*), intent(in) :: etype
|
|
integer, intent(in) :: nlocal
|
|
real(rk), intent(in) :: expected_area
|
|
integer, intent(in) :: code
|
|
integer :: ierr
|
|
real(rk) :: elem_mass
|
|
real(rk) :: nodal_mass
|
|
real(rk) :: rot_inertia
|
|
real(rk) :: nodal_inertia
|
|
real(rk) :: mass_x
|
|
real(rk) :: mass_y
|
|
real(rk) :: mass_z
|
|
real(rk) :: rot_x
|
|
real(rk) :: rot_y
|
|
real(rk) :: rot_z
|
|
|
|
call setup_shell(etype, nlocal, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(code)
|
|
|
|
call element_compute_lumped_mass(ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(code + 1)
|
|
|
|
elem_mass = DENSITY * expected_area * THICKNESS
|
|
nodal_mass = elem_mass / real(nlocal, rk)
|
|
rot_inertia = DENSITY * expected_area * THICKNESS**3 / 12.0_rk
|
|
nodal_inertia = rot_inertia / real(nlocal, rk)
|
|
|
|
call collect_directional_mass(mass_x, mass_y, mass_z, rot_x, rot_y, rot_z)
|
|
call check_close(mass_x, elem_mass, code + 2)
|
|
call check_close(mass_y, elem_mass, code + 3)
|
|
call check_close(mass_z, elem_mass, code + 4)
|
|
call check_close(rot_x, rot_inertia, code + 5)
|
|
call check_close(rot_y, rot_inertia, code + 6)
|
|
call check_close(rot_z, rot_inertia, code + 7)
|
|
call check_close(mass_diag(dof_id(1,1)), nodal_mass, code + 8)
|
|
call check_close(mass_diag(dof_id(4,1)), nodal_inertia, code + 9)
|
|
call check_close(mass_diag(dof_id(3,nlocal)), nodal_mass, code + 10)
|
|
call check_close(mass_diag(dof_id(6,nlocal)), nodal_inertia, code + 11)
|
|
|
|
call database_finalize(ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(code + 12)
|
|
end subroutine check_shell
|
|
|
|
subroutine setup_shell(etype, nlocal, ierr)
|
|
character(len=*), intent(in) :: etype
|
|
integer, intent(in) :: nlocal
|
|
integer, intent(out) :: ierr
|
|
|
|
call database_allocate_model(nlocal, 1, 0, 1, 0, 1, 1, 0, 1, &
|
|
0, 0, 0, 0, 0, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call fill_common_model(etype, nlocal)
|
|
call fill_shell_coordinates(etype)
|
|
coord = coord0
|
|
|
|
call database_assign_dofs(ierr)
|
|
end subroutine setup_shell
|
|
|
|
subroutine fill_common_model(etype, nlocal)
|
|
character(len=*), intent(in) :: etype
|
|
integer, intent(in) :: nlocal
|
|
integer :: i
|
|
|
|
do i = 1, nlocal
|
|
node_id_ext(i) = i
|
|
coord0(:,i) = ZERO
|
|
coord(:,i) = ZERO
|
|
elem_conn(i,1) = i
|
|
end do
|
|
|
|
elem_id_ext(1) = 1
|
|
elem_type(1) = etype
|
|
elem_nnode(1) = nlocal
|
|
elem_mat(1) = 1
|
|
elem_sec(1) = 1
|
|
|
|
elset_name(1) = 'EALL'
|
|
elset_start(1) = 1
|
|
elset_count(1) = 1
|
|
elset_items(1) = 1
|
|
|
|
mat_name(1) = 'MAT'
|
|
mat_density(1) = DENSITY
|
|
mat_e(1) = ONE
|
|
mat_nu(1) = 0.25_rk
|
|
|
|
section_type(1) = 'SHELL'
|
|
section_elset_name(1) = 'EALL'
|
|
section_material_name(1) = 'MAT'
|
|
section_thickness(1) = THICKNESS
|
|
end subroutine fill_common_model
|
|
|
|
subroutine fill_shell_coordinates(etype)
|
|
character(len=*), intent(in) :: etype
|
|
character(len=ELEM_TYPE_LEN) :: local_type
|
|
|
|
local_type = adjustl(etype)
|
|
select case (trim(local_type))
|
|
case ('S3')
|
|
call fill_triangle3()
|
|
case ('S4')
|
|
call fill_quad4()
|
|
case ('S6')
|
|
call fill_triangle6()
|
|
case ('S8')
|
|
call fill_quad8()
|
|
case default
|
|
call fail(900)
|
|
end select
|
|
end subroutine fill_shell_coordinates
|
|
|
|
subroutine fill_triangle3()
|
|
coord0(:,1) = (/ ZERO, ZERO, ZERO /)
|
|
coord0(:,2) = (/ ONE, ZERO, ZERO /)
|
|
coord0(:,3) = (/ ZERO, ONE, ZERO /)
|
|
end subroutine fill_triangle3
|
|
|
|
subroutine fill_triangle6()
|
|
call fill_triangle3()
|
|
coord0(:,4) = HALF * (coord0(:,1) + coord0(:,2))
|
|
coord0(:,5) = HALF * (coord0(:,2) + coord0(:,3))
|
|
coord0(:,6) = HALF * (coord0(:,3) + coord0(:,1))
|
|
end subroutine fill_triangle6
|
|
|
|
subroutine fill_quad4()
|
|
coord0(:,1) = (/ ZERO, ZERO, ZERO /)
|
|
coord0(:,2) = (/ ONE, ZERO, ZERO /)
|
|
coord0(:,3) = (/ ONE, ONE, ZERO /)
|
|
coord0(:,4) = (/ ZERO, ONE, ZERO /)
|
|
end subroutine fill_quad4
|
|
|
|
subroutine fill_quad8()
|
|
call fill_quad4()
|
|
coord0(:,5) = HALF * (coord0(:,1) + coord0(:,2))
|
|
coord0(:,6) = HALF * (coord0(:,2) + coord0(:,3))
|
|
coord0(:,7) = HALF * (coord0(:,3) + coord0(:,4))
|
|
coord0(:,8) = HALF * (coord0(:,4) + coord0(:,1))
|
|
end subroutine fill_quad8
|
|
|
|
subroutine collect_directional_mass(mass_x, mass_y, mass_z, rot_x, rot_y, rot_z)
|
|
real(rk), intent(out) :: mass_x
|
|
real(rk), intent(out) :: mass_y
|
|
real(rk), intent(out) :: mass_z
|
|
real(rk), intent(out) :: rot_x
|
|
real(rk), intent(out) :: rot_y
|
|
real(rk), intent(out) :: rot_z
|
|
integer :: node
|
|
|
|
mass_x = ZERO
|
|
mass_y = ZERO
|
|
mass_z = ZERO
|
|
rot_x = ZERO
|
|
rot_y = ZERO
|
|
rot_z = ZERO
|
|
do node = 1, nnode
|
|
mass_x = mass_x + mass_diag(dof_id(1,node))
|
|
mass_y = mass_y + mass_diag(dof_id(2,node))
|
|
mass_z = mass_z + mass_diag(dof_id(3,node))
|
|
rot_x = rot_x + mass_diag(dof_id(4,node))
|
|
rot_y = rot_y + mass_diag(dof_id(5,node))
|
|
rot_z = rot_z + mass_diag(dof_id(6,node))
|
|
end do
|
|
end subroutine collect_directional_mass
|
|
|
|
subroutine check_close(actual, expected, code)
|
|
real(rk), intent(in) :: actual
|
|
real(rk), intent(in) :: expected
|
|
integer, intent(in) :: code
|
|
|
|
if (abs(actual - expected) .gt. TOL * max(ONE, abs(expected))) call fail(code)
|
|
end subroutine check_close
|
|
|
|
subroutine fail(code)
|
|
integer, intent(in) :: code
|
|
|
|
write(*,*) 'test_shell_mass failed:', code
|
|
stop 1
|
|
end subroutine fail
|
|
|
|
end program test_shell_mass
|