program test_shell_internal use fem_precision use fem_error use fem_database use fem_element_internal use fem_element_stiffness use fem_quadrature use fem_shape_functions implicit none real(rk), parameter :: TOL = 1.0e-10_rk real(rk), parameter :: YOUNG = 30.0_rk real(rk), parameter :: POISSON = 0.25_rk real(rk), parameter :: THICKNESS = 0.2_rk real(rk), parameter :: EXX = 0.01_rk real(rk), parameter :: GAMMA_XZ = 0.02_rk real(rk), parameter :: KAPPA_X = 0.03_rk call check_s3_membrane_patch() call check_s4_membrane_patch() call check_s4_j2_membrane_plastic() call check_s6_membrane_patch() call check_s8_membrane_patch() call check_shear_patch('S3', 1, 200) call check_shear_patch('S4', 4, 230) call check_shear_patch('S6', 3, 260) call check_shear_patch('S8', 9, 290) call check_bending_patch('S3', 1, 330) call check_bending_patch('S4', 4, 360) call check_bending_patch('S6', 3, 390) call check_bending_patch('S8', 9, 420) contains subroutine check_s3_membrane_patch() integer :: ierr call setup_s3(ierr) if (ierr .ne. FEM_SUCCESS) call fail(1) call apply_x_extension(EXX) call element_compute_internal_force(ierr) if (ierr .ne. FEM_SUCCESS) call fail(2) if (elem_status(1) .ne. 0) call fail(3) call check_state_shape(1, 4) call check_membrane_state(1, 10) call check_force_balance(20) call check_no_normal_or_rotation(30) call database_finalize(ierr) if (ierr .ne. FEM_SUCCESS) call fail(40) end subroutine check_s3_membrane_patch subroutine check_s4_membrane_patch() integer :: ierr call setup_s4(ierr) if (ierr .ne. FEM_SUCCESS) call fail(151) call apply_x_extension(EXX) call element_compute_internal_force(ierr) if (ierr .ne. FEM_SUCCESS) call fail(152) if (elem_status(1) .ne. 0) call fail(153) call check_state_shape(4, 154) call check_membrane_state(4, 160) call check_force_balance(170) call check_no_normal_or_rotation(180) call database_finalize(ierr) if (ierr .ne. FEM_SUCCESS) call fail(190) end subroutine check_s4_membrane_patch subroutine check_s4_j2_membrane_plastic() integer :: ierr integer, parameter :: MAX_SHELL_TEST_DOF = 60 integer :: elem_dofs(MAX_SHELL_TEST_DOF) integer :: n_elem_dof real(rk) :: ke(MAX_SHELL_TEST_DOF,MAX_SHELL_TEST_DOF) call setup_s4_j2(ierr) if (ierr .ne. FEM_SUCCESS) call fail(451) call apply_x_extension(EXX) call element_compute_internal_force(ierr, 0.1_rk) if (ierr .ne. FEM_SUCCESS) call fail(452) if (elem_status(1) .ne. 0) call fail(453) if (statev(1,1) .le. ZERO) call fail(454) if (statev(22,1) .le. ZERO) call fail(455) if (abs(stress(1,1)) .ge. YOUNG * EXX) call fail(456) call element_linear_stiffness(1, elem_dofs, n_elem_dof, ke, ierr) if (ierr .ne. FEM_SUCCESS) call fail(457) if (n_elem_dof .ne. 24) call fail(458) call check_matrix_symmetric(ke, n_elem_dof, 459) call database_finalize(ierr) if (ierr .ne. FEM_SUCCESS) call fail(460) end subroutine check_s4_j2_membrane_plastic subroutine check_s6_membrane_patch() integer :: ierr call setup_s6(ierr) if (ierr .ne. FEM_SUCCESS) call fail(51) call apply_x_extension(EXX) call element_compute_internal_force(ierr) if (ierr .ne. FEM_SUCCESS) call fail(52) if (elem_status(1) .ne. 0) call fail(53) call check_state_shape(3, 54) call check_membrane_state(3, 60) call check_force_balance(70) call check_no_normal_or_rotation(80) call database_finalize(ierr) if (ierr .ne. FEM_SUCCESS) call fail(90) end subroutine check_s6_membrane_patch subroutine check_s8_membrane_patch() integer :: ierr call setup_s8(ierr) if (ierr .ne. FEM_SUCCESS) call fail(101) call apply_x_extension(EXX) call element_compute_internal_force(ierr) if (ierr .ne. FEM_SUCCESS) call fail(102) if (elem_status(1) .ne. 0) call fail(103) call check_state_shape(9, 104) call check_membrane_state(9, 110) call check_force_balance(120) call check_no_normal_or_rotation(130) call database_finalize(ierr) if (ierr .ne. FEM_SUCCESS) call fail(140) end subroutine check_s8_membrane_patch subroutine check_shear_patch(etype, expected_ngp, code) character(len=*), intent(in) :: etype integer, intent(in) :: expected_ngp integer, intent(in) :: code integer :: ierr call setup_shell_by_type(etype, ierr) if (ierr .ne. FEM_SUCCESS) call fail(code) call apply_xz_shear(GAMMA_XZ) call element_compute_internal_force(ierr) if (ierr .ne. FEM_SUCCESS) call fail(code + 1) if (elem_status(1) .ne. 0) call fail(code + 2) call check_state_shape(expected_ngp, code + 3) call check_shear_state(expected_ngp, code + 10) call check_translational_balance(code + 20) call database_finalize(ierr) if (ierr .ne. FEM_SUCCESS) call fail(code + 21) end subroutine check_shear_patch subroutine check_bending_patch(etype, expected_ngp, code) character(len=*), intent(in) :: etype integer, intent(in) :: expected_ngp integer, intent(in) :: code integer :: ierr call setup_shell_by_type(etype, ierr) if (ierr .ne. FEM_SUCCESS) call fail(code) call apply_x_bending(KAPPA_X) call element_compute_internal_force(ierr) if (ierr .ne. FEM_SUCCESS) call fail(code + 1) if (elem_status(1) .ne. 0) call fail(code + 2) call check_state_shape(expected_ngp, code + 3) call check_bending_state(etype, expected_ngp, code + 10) call check_translational_balance(code + 20) call database_finalize(ierr) if (ierr .ne. FEM_SUCCESS) call fail(code + 21) end subroutine check_bending_patch subroutine setup_shell_by_type(etype, ierr) character(len=*), intent(in) :: etype integer, intent(out) :: ierr character(len=ELEM_TYPE_LEN) :: local_type local_type = adjustl(etype) select case (trim(local_type)) case ('S3') call setup_s3(ierr) case ('S4') call setup_s4(ierr) case ('S6') call setup_s6(ierr) case ('S8') call setup_s8(ierr) case default call fail(900) end select end subroutine setup_shell_by_type subroutine setup_s3(ierr) integer, intent(out) :: ierr call database_allocate_model(3, 1, 0, 1, 0, 1, 1, 0, 1, & 0, 0, 0, 0, 0, ierr) if (ierr .ne. FEM_SUCCESS) return node_id_ext(1) = 1 node_id_ext(2) = 2 node_id_ext(3) = 3 coord0(:,1) = (/ ZERO, ZERO, ZERO /) coord0(:,2) = (/ ONE, ZERO, ZERO /) coord0(:,3) = (/ ZERO, ONE, ZERO /) coord = coord0 elem_id_ext(1) = 1 elem_type(1) = 'S3' elem_nnode(1) = 3 elem_conn(:,1) = 0 elem_conn(1:3,1) = (/ 1, 2, 3 /) 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) = ONE mat_e(1) = YOUNG mat_nu(1) = POISSON section_type(1) = 'SHELL' section_elset_name(1) = 'EALL' section_material_name(1) = 'MAT' section_thickness(1) = THICKNESS call database_assign_dofs(ierr) end subroutine setup_s3 subroutine setup_s4(ierr) integer, intent(out) :: ierr call database_allocate_model(4, 1, 0, 1, 0, 1, 1, 0, 1, & 0, 0, 0, 0, 0, ierr) if (ierr .ne. FEM_SUCCESS) return node_id_ext(1) = 1 node_id_ext(2) = 2 node_id_ext(3) = 3 node_id_ext(4) = 4 coord0(:,1) = (/ ZERO, ZERO, ZERO /) coord0(:,2) = (/ ONE, ZERO, ZERO /) coord0(:,3) = (/ ONE, ONE, ZERO /) coord0(:,4) = (/ ZERO, ONE, ZERO /) coord = coord0 elem_id_ext(1) = 1 elem_type(1) = 'S4' elem_nnode(1) = 4 elem_conn(:,1) = 0 elem_conn(1:4,1) = (/ 1, 2, 3, 4 /) 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) = ONE mat_e(1) = YOUNG mat_nu(1) = POISSON section_type(1) = 'SHELL' section_elset_name(1) = 'EALL' section_material_name(1) = 'MAT' section_thickness(1) = THICKNESS call database_assign_dofs(ierr) end subroutine setup_s4 subroutine setup_s4_j2(ierr) integer, intent(out) :: ierr call database_allocate_model(4, 1, 0, 1, 0, 1, 1, 1, 1, & 0, 0, 0, 0, 0, ierr) if (ierr .ne. FEM_SUCCESS) return node_id_ext(1) = 1 node_id_ext(2) = 2 node_id_ext(3) = 3 node_id_ext(4) = 4 coord0(:,1) = (/ ZERO, ZERO, ZERO /) coord0(:,2) = (/ ONE, ZERO, ZERO /) coord0(:,3) = (/ ONE, ONE, ZERO /) coord0(:,4) = (/ ZERO, ONE, ZERO /) coord = coord0 elem_id_ext(1) = 1 elem_type(1) = 'S4' elem_nnode(1) = 4 elem_conn(:,1) = 0 elem_conn(1:4,1) = (/ 1, 2, 3, 4 /) 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) = ONE mat_e(1) = YOUNG mat_nu(1) = POISSON mat_plastic_model(1) = 'J2' mat_plastic_start(1) = 1 mat_plastic_count(1) = 1 mat_plastic_stress(1) = 0.05_rk mat_plastic_strain(1) = ZERO section_type(1) = 'SHELL' section_elset_name(1) = 'EALL' section_material_name(1) = 'MAT' section_thickness(1) = THICKNESS call database_assign_dofs(ierr) end subroutine setup_s4_j2 subroutine setup_s6(ierr) integer, intent(out) :: ierr call database_allocate_model(6, 1, 0, 1, 0, 1, 1, 0, 1, & 0, 0, 0, 0, 0, ierr) if (ierr .ne. FEM_SUCCESS) return node_id_ext(1) = 1 node_id_ext(2) = 2 node_id_ext(3) = 3 node_id_ext(4) = 4 node_id_ext(5) = 5 node_id_ext(6) = 6 coord0(:,1) = (/ ZERO, ZERO, ZERO /) coord0(:,2) = (/ ONE, ZERO, ZERO /) coord0(:,3) = (/ ZERO, ONE, ZERO /) coord0(:,4) = HALF * (coord0(:,1) + coord0(:,2)) coord0(:,5) = HALF * (coord0(:,2) + coord0(:,3)) coord0(:,6) = HALF * (coord0(:,3) + coord0(:,1)) coord = coord0 elem_id_ext(1) = 1 elem_type(1) = 'S6' elem_nnode(1) = 6 elem_conn(:,1) = 0 elem_conn(1:6,1) = (/ 1, 2, 3, 4, 5, 6 /) 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) = ONE mat_e(1) = YOUNG mat_nu(1) = POISSON section_type(1) = 'SHELL' section_elset_name(1) = 'EALL' section_material_name(1) = 'MAT' section_thickness(1) = THICKNESS call database_assign_dofs(ierr) end subroutine setup_s6 subroutine setup_s8(ierr) integer, intent(out) :: ierr call database_allocate_model(8, 1, 0, 1, 0, 1, 1, 0, 1, & 0, 0, 0, 0, 0, ierr) if (ierr .ne. FEM_SUCCESS) return node_id_ext(1) = 1 node_id_ext(2) = 2 node_id_ext(3) = 3 node_id_ext(4) = 4 node_id_ext(5) = 5 node_id_ext(6) = 6 node_id_ext(7) = 7 node_id_ext(8) = 8 coord0(:,1) = (/ ZERO, ZERO, ZERO /) coord0(:,2) = (/ ONE, ZERO, ZERO /) coord0(:,3) = (/ ONE, ONE, ZERO /) coord0(:,4) = (/ ZERO, ONE, ZERO /) 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)) coord = coord0 elem_id_ext(1) = 1 elem_type(1) = 'S8' elem_nnode(1) = 8 elem_conn(:,1) = 0 elem_conn(1:8,1) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /) 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) = ONE mat_e(1) = YOUNG mat_nu(1) = POISSON section_type(1) = 'SHELL' section_elset_name(1) = 'EALL' section_material_name(1) = 'MAT' section_thickness(1) = THICKNESS call database_assign_dofs(ierr) end subroutine setup_s8 subroutine apply_x_extension(exx) real(rk), intent(in) :: exx integer :: node u = ZERO do node = 1, nnode u(dof_id(1,node)) = exx * coord0(1,node) end do end subroutine apply_x_extension subroutine apply_xz_shear(gamma_xz) real(rk), intent(in) :: gamma_xz integer :: node u = ZERO do node = 1, nnode u(dof_id(3,node)) = gamma_xz * coord0(1,node) end do end subroutine apply_xz_shear subroutine apply_x_bending(kappa_x) real(rk), intent(in) :: kappa_x integer :: node u = ZERO do node = 1, nnode u(dof_id(5,node)) = kappa_x * coord0(1,node) end do end subroutine apply_x_bending subroutine check_state_shape(expected_ngp, code) integer, intent(in) :: expected_ngp integer, intent(in) :: code if (elem_gp_start(1) .ne. 1) call fail(code) if (elem_ngp(1) .ne. expected_ngp) call fail(code + 1) if (ngauss_total .ne. expected_ngp) call fail(code + 2) if (.not. allocated(stress)) call fail(code + 3) if (.not. allocated(strain)) call fail(code + 4) end subroutine check_state_shape subroutine check_membrane_state(npoint, code) integer, intent(in) :: npoint integer, intent(in) :: code real(rk) :: coeff real(rk) :: expected_stress(NSTRESS) real(rk) :: expected_strain(NSTRESS) integer :: gp coeff = YOUNG / (ONE - POISSON * POISSON) expected_strain = ZERO expected_strain(1) = EXX expected_stress = ZERO expected_stress(1) = coeff * EXX expected_stress(2) = coeff * POISSON * EXX do gp = 1, npoint call check_vector_close(strain(:,gp), expected_strain, code) call check_vector_close(stress(:,gp), expected_stress, code + 1) if (abs(statev(10,gp)) .gt. TOL) call fail(code + 2) if (abs(statev(11,gp)) .gt. TOL) call fail(code + 3) if (abs(statev(12,gp)) .gt. TOL) call fail(code + 4) end do end subroutine check_membrane_state subroutine check_shear_state(npoint, code) integer, intent(in) :: npoint integer, intent(in) :: code real(rk) :: shear_mod real(rk) :: expected_stress(NSTRESS) real(rk) :: expected_strain(NSTRESS) integer :: gp shear_mod = YOUNG / (2.0_rk * (ONE + POISSON)) expected_strain = ZERO expected_strain(5) = GAMMA_XZ expected_stress = ZERO expected_stress(5) = (5.0_rk / 6.0_rk) * shear_mod * GAMMA_XZ do gp = 1, npoint call check_vector_close(strain(:,gp), expected_strain, code) call check_vector_close(stress(:,gp), expected_stress, code + 1) if (abs(statev(10,gp)) .gt. TOL) call fail(code + 2) if (abs(statev(11,gp)) .gt. TOL) call fail(code + 3) if (abs(statev(12,gp)) .gt. TOL) call fail(code + 4) end do end subroutine check_shear_state subroutine check_bending_state(etype, npoint, code) character(len=*), intent(in) :: etype integer, intent(in) :: npoint integer, intent(in) :: code integer, parameter :: MAX_QP_TEST = 16 real(rk) :: gp_nat(NDIM,MAX_QP_TEST) real(rk) :: gp_weight(MAX_QP_TEST) real(rk) :: nshape(MAX_NEN) real(rk) :: dndr(NDIM,MAX_NEN) real(rk) :: expected_stress(NSTRESS) real(rk) :: expected_strain(NSTRESS) real(rk) :: shear_mod real(rk) :: x_gp integer :: gp integer :: nquad integer :: local_node integer :: node integer :: ierr call quadrature_get_rule(etype, MAX_QP_TEST, nquad, gp_nat, gp_weight, ierr) if (ierr .ne. FEM_SUCCESS) call fail(code) if (nquad .ne. npoint) call fail(code + 1) shear_mod = YOUNG / (2.0_rk * (ONE + POISSON)) do gp = 1, npoint call shape_evaluate(etype, gp_nat(:,gp), nshape, dndr, ierr) if (ierr .ne. FEM_SUCCESS) call fail(code + 2) x_gp = ZERO do local_node = 1, elem_nnode(1) node = elem_conn(local_node,1) x_gp = x_gp + nshape(local_node) * coord0(1,node) end do expected_strain = ZERO expected_strain(5) = KAPPA_X * x_gp expected_stress = ZERO expected_stress(5) = (5.0_rk / 6.0_rk) * shear_mod * expected_strain(5) call check_vector_close(strain(:,gp), expected_strain, code + 3) call check_vector_close(stress(:,gp), expected_stress, code + 4) if (abs(statev(10,gp) - KAPPA_X) .gt. TOL) call fail(code + 5) if (abs(statev(11,gp)) .gt. TOL) call fail(code + 6) if (abs(statev(12,gp)) .gt. TOL) call fail(code + 7) end do end subroutine check_bending_state subroutine check_force_balance(code) integer, intent(in) :: code real(rk) :: balance(NDOF_NODE) real(rk) :: max_force integer :: node integer :: idir balance = ZERO max_force = ZERO do node = 1, nnode do idir = 1, NDOF_NODE balance(idir) = balance(idir) + fint(dof_id(idir,node)) max_force = max(max_force, abs(fint(dof_id(idir,node)))) end do end do if (maxval(abs(balance)) .gt. TOL) call fail(code) if (max_force .le. TOL) call fail(code + 1) end subroutine check_force_balance subroutine check_translational_balance(code) integer, intent(in) :: code real(rk) :: balance(NDIM) real(rk) :: max_force integer :: node integer :: idir balance = ZERO max_force = ZERO do node = 1, nnode do idir = 1, NDIM balance(idir) = balance(idir) + fint(dof_id(idir,node)) end do do idir = 1, NDOF_NODE max_force = max(max_force, abs(fint(dof_id(idir,node)))) end do end do if (maxval(abs(balance)) .gt. TOL) call fail(code) if (max_force .le. TOL) call fail(code + 1) end subroutine check_translational_balance subroutine check_no_normal_or_rotation(code) integer, intent(in) :: code integer :: node integer :: idir do node = 1, nnode if (abs(fint(dof_id(3,node))) .gt. TOL) call fail(code) do idir = 4, NDOF_NODE if (abs(fint(dof_id(idir,node))) .gt. TOL) call fail(code + 1) end do end do end subroutine check_no_normal_or_rotation subroutine check_vector_close(actual, expected, code) real(rk), intent(in) :: actual(NSTRESS) real(rk), intent(in) :: expected(NSTRESS) integer, intent(in) :: code integer :: i do i = 1, NSTRESS if (abs(actual(i) - expected(i)) .gt. TOL * max(ONE, abs(expected(i)))) then call fail(code) end if end do end subroutine check_vector_close subroutine check_matrix_symmetric(mat, n, code) real(rk), intent(in) :: mat(:,:) integer, intent(in) :: n integer, intent(in) :: code integer :: i integer :: j do i = 1, n do j = 1, n if (abs(mat(i,j) - mat(j,i)) .gt. 1.0e-8_rk) call fail(code) end do end do end subroutine check_matrix_symmetric subroutine fail(code) integer, intent(in) :: code write(*,*) 'test_shell_internal failed:', code stop 1 end subroutine fail end program test_shell_internal