Files
FemLite/src/element/fem_element_stiffness.f90
T

1204 lines
39 KiB
Fortran

module fem_element_stiffness
use fem_precision
use fem_error
use fem_database
use fem_element_topology
use fem_quadrature
use fem_shape_functions
use fem_material_j2
implicit none
private
public :: element_linear_stiffness
contains
subroutine element_linear_stiffness(elem, elem_dofs, n_elem_dof, ke, ierr)
integer, intent(in) :: elem
integer, intent(out) :: elem_dofs(:)
integer, intent(out) :: n_elem_dof
real(rk), intent(out) :: ke(:,:)
integer, intent(out) :: ierr
character(len=ELEM_TYPE_LEN) :: etype
elem_dofs = 0
n_elem_dof = 0
ke = ZERO
if (elem .lt. 1 .or. elem .gt. nelem) then
call error_set(FEM_ERR_MESH, 'linear stiffness element index is out of range', ierr)
return
end if
etype = adjustl(elem_type(elem))
select case (trim(etype))
case ('C3D4', 'C3D8', 'C3D10', 'C3D20')
call solid_linear_stiffness(elem, elem_dofs, n_elem_dof, ke, ierr)
case ('S3')
call shell3_linear_stiffness(elem, elem_dofs, n_elem_dof, ke, ierr)
case ('S4')
call shell4_linear_stiffness(elem, elem_dofs, n_elem_dof, ke, ierr)
case ('S6')
call shell_general_linear_stiffness(elem, 6, 'S6', elem_dofs, &
n_elem_dof, ke, ierr)
case ('S8')
call shell_general_linear_stiffness(elem, 8, 'S8', elem_dofs, &
n_elem_dof, ke, ierr)
case default
call error_set(FEM_ERR_MESH, 'linear stiffness element type is not implemented', ierr)
end select
end subroutine element_linear_stiffness
subroutine solid_linear_stiffness(elem, elem_dofs, n_elem_dof, ke, ierr)
integer, intent(in) :: elem
integer, intent(out) :: elem_dofs(:)
integer, intent(out) :: n_elem_dof
real(rk), intent(out) :: ke(:,:)
integer, intent(out) :: ierr
real(rk) :: dmat(NSTRESS,NSTRESS)
real(rk) :: gp_nat(NDIM,27)
real(rk) :: gp_weight(27)
real(rk) :: natural(NDIM)
real(rk) :: nshape(MAX_NEN)
real(rk) :: dndr(NDIM,MAX_NEN)
real(rk) :: dndx(NDIM,MAX_NEN)
real(rk) :: bmat(NSTRESS,MAX_NEN*3)
real(rk) :: db(NSTRESS,MAX_NEN*3)
real(rk) :: detj
real(rk) :: factor
integer :: q
integer :: npoint
integer :: nlocal
integer :: gp
real(rk) :: stress_cur(NSTRESS)
real(rk) :: state_cur(NSTATEV_MAX)
nlocal = elem_nnode(elem)
n_elem_dof = 3 * nlocal
if (size(elem_dofs) .lt. n_elem_dof) then
call error_set(FEM_ERR_INTERNAL, 'linear stiffness dof buffer is too small', ierr)
return
end if
if (size(ke,1) .lt. n_elem_dof .or. size(ke,2) .lt. n_elem_dof) then
call error_set(FEM_ERR_INTERNAL, 'linear stiffness matrix buffer is too small', ierr)
return
end if
call fill_solid_dofs(elem, elem_dofs, n_elem_dof, ierr)
if (ierr .ne. FEM_SUCCESS) return
call quadrature_get_rule(elem_type(elem), 27, npoint, gp_nat, gp_weight, ierr)
if (ierr .ne. FEM_SUCCESS) return
do q = 1, npoint
stress_cur = ZERO
state_cur = ZERO
if (allocated(elem_gp_start) .and. allocated(stress) .and. &
allocated(statev)) then
gp = elem_gp_start(elem) + q - 1
if (gp .ge. 1 .and. gp .le. size(stress,2)) then
stress_cur = stress(:,gp)
state_cur = statev(:,gp)
end if
end if
call material_tangent_small_strain(elem_mat(elem), stress_cur, &
state_cur, dmat, ierr)
if (ierr .ne. FEM_SUCCESS) return
natural = gp_nat(:,q)
call shape_evaluate(elem_type(elem), natural, nshape, dndr, ierr)
if (ierr .ne. FEM_SUCCESS) return
call shape_gradients_current(elem, nlocal, dndr, dndx, detj, ierr)
if (ierr .ne. FEM_SUCCESS) return
call build_solid_b(nlocal, dndx, bmat)
db(:,1:n_elem_dof) = matmul(dmat, bmat(:,1:n_elem_dof))
factor = gp_weight(q) * detj
ke(1:n_elem_dof,1:n_elem_dof) = ke(1:n_elem_dof,1:n_elem_dof) + &
factor * matmul(transpose(bmat(:,1:n_elem_dof)), db(:,1:n_elem_dof))
end do
ierr = FEM_SUCCESS
end subroutine solid_linear_stiffness
subroutine shell3_linear_stiffness(elem, elem_dofs, n_elem_dof, ke, ierr)
integer, intent(in) :: elem
integer, intent(out) :: elem_dofs(:)
integer, intent(out) :: n_elem_dof
real(rk), intent(out) :: ke(:,:)
integer, intent(out) :: ierr
integer, parameter :: NLOCAL = 3
integer, parameter :: NQDOF = 5 * NLOCAL
integer, parameter :: NGDOF = 6 * NLOCAL
real(rk) :: basis(NDIM,NDIM)
real(rk) :: xloc(2,NLOCAL)
real(rk) :: nshape(NLOCAL)
real(rk) :: dndx(NLOCAL)
real(rk) :: dndy(NLOCAL)
real(rk) :: bmem(3,NQDOF)
real(rk) :: bben(3,NQDOF)
real(rk) :: bshr(2,NQDOF)
real(rk) :: dmem(3,3)
real(rk) :: dben(3,3)
real(rk) :: dshr(2,2)
real(rk) :: klocal(NQDOF,NQDOF)
real(rk) :: transform(NQDOF,NGDOF)
real(rk) :: tmp(NQDOF,NGDOF)
real(rk) :: young
real(rk) :: poisson
real(rk) :: thickness
real(rk) :: shear_mod
real(rk) :: coeff_mem
real(rk) :: coeff_ben
real(rk) :: coeff_shr
real(rk) :: detj
real(rk) :: weight
integer :: mat
integer :: sec
integer :: gp
n_elem_dof = NGDOF
if (elem_nnode(elem) .ne. NLOCAL) then
call error_set(FEM_ERR_MESH, 'S3 linear stiffness requires 3 nodes', ierr)
return
end if
if (size(elem_dofs) .lt. n_elem_dof) then
call error_set(FEM_ERR_INTERNAL, 'S3 stiffness dof buffer is too small', ierr)
return
end if
if (size(ke,1) .lt. n_elem_dof .or. size(ke,2) .lt. n_elem_dof) then
call error_set(FEM_ERR_INTERNAL, 'S3 stiffness matrix buffer is too small', ierr)
return
end if
call fill_shell_dofs(elem, elem_dofs, n_elem_dof, ierr)
if (ierr .ne. FEM_SUCCESS) return
mat = elem_mat(elem)
sec = elem_sec(elem)
if (mat .lt. 1 .or. mat .gt. n_material) then
call error_set(FEM_ERR_MATERIAL, 'S3 stiffness has invalid material index', ierr)
return
end if
if (sec .lt. 1 .or. sec .gt. n_section) then
call error_set(FEM_ERR_INPUT, 'S3 stiffness has invalid section index', ierr)
return
end if
young = mat_e(mat)
poisson = mat_nu(mat)
thickness = section_thickness(sec)
if (young .le. ZERO) then
call error_set(FEM_ERR_MATERIAL, 'S3 stiffness requires positive elastic modulus', ierr)
return
end if
if (poisson .le. -ONE .or. poisson .ge. HALF) then
call error_set(FEM_ERR_MATERIAL, 'S3 stiffness Poisson ratio must be in (-1,0.5)', ierr)
return
end if
if (thickness .le. ZERO) then
call error_set(FEM_ERR_INPUT, 'S3 stiffness requires positive thickness', ierr)
return
end if
call shell3_basis_linear(elem, basis, xloc, ierr)
if (ierr .ne. FEM_SUCCESS) return
call shell3_shape_xy_linear(xloc, nshape, dndx, dndy, detj, ierr)
if (ierr .ne. FEM_SUCCESS) return
shear_mod = young / (2.0_rk * (ONE + poisson))
coeff_mem = young * thickness / (ONE - poisson * poisson)
coeff_ben = young * thickness**3 / &
(12.0_rk * (ONE - poisson * poisson))
coeff_shr = (5.0_rk / 6.0_rk) * shear_mod * thickness
call shell_constitutive(coeff_mem, coeff_ben, coeff_shr, poisson, &
dmem, dben, dshr)
gp = 0
if (allocated(elem_gp_start)) then
if (elem .le. size(elem_gp_start)) gp = elem_gp_start(elem)
end if
call shell_apply_section_tangent(mat, thickness, gp, dmem, dben, dshr, ierr)
if (ierr .ne. FEM_SUCCESS) return
call shell_b_matrices(NLOCAL, nshape, dndx, dndy, bmem, bben, bshr)
weight = HALF * detj
klocal = weight * matmul(transpose(bmem), matmul(dmem, bmem)) + &
weight * matmul(transpose(bben), matmul(dben, bben)) + &
weight * matmul(transpose(bshr), matmul(dshr, bshr))
call shell_transform_matrix(NLOCAL, basis, transform)
tmp = matmul(klocal, transform)
ke(1:n_elem_dof,1:n_elem_dof) = matmul(transpose(transform), tmp)
call add_shell_drilling_stiffness(NLOCAL, basis, coeff_mem * weight * 1.0e-8_rk, &
ke)
ierr = FEM_SUCCESS
end subroutine shell3_linear_stiffness
subroutine shell4_linear_stiffness(elem, elem_dofs, n_elem_dof, ke, ierr)
integer, intent(in) :: elem
integer, intent(out) :: elem_dofs(:)
integer, intent(out) :: n_elem_dof
real(rk), intent(out) :: ke(:,:)
integer, intent(out) :: ierr
integer, parameter :: NLOCAL = 4
integer, parameter :: NQDOF = 5 * NLOCAL
integer, parameter :: NGDOF = 6 * NLOCAL
real(rk) :: basis(NDIM,NDIM)
real(rk) :: xloc(2,NLOCAL)
real(rk) :: gp_nat(NDIM,4)
real(rk) :: gp_weight(4)
real(rk) :: nshape(NLOCAL)
real(rk) :: dndx(NLOCAL)
real(rk) :: dndy(NLOCAL)
real(rk) :: bmem(3,NQDOF)
real(rk) :: bben(3,NQDOF)
real(rk) :: bshr(2,NQDOF)
real(rk) :: dmem(3,3)
real(rk) :: dmem_gp(3,3)
real(rk) :: dben(3,3)
real(rk) :: dben_gp(3,3)
real(rk) :: dshr(2,2)
real(rk) :: dshr_gp(2,2)
real(rk) :: klocal(NQDOF,NQDOF)
real(rk) :: transform(NQDOF,NGDOF)
real(rk) :: tmp(NQDOF,NGDOF)
real(rk) :: young
real(rk) :: poisson
real(rk) :: thickness
real(rk) :: shear_mod
real(rk) :: coeff_mem
real(rk) :: coeff_ben
real(rk) :: coeff_shr
real(rk) :: detj
real(rk) :: weight
real(rk) :: area
integer :: q
integer :: npoint
integer :: gp
integer :: mat
integer :: sec
n_elem_dof = NGDOF
if (elem_nnode(elem) .ne. NLOCAL) then
call error_set(FEM_ERR_MESH, 'S4 linear stiffness requires 4 nodes', ierr)
return
end if
if (size(elem_dofs) .lt. n_elem_dof) then
call error_set(FEM_ERR_INTERNAL, 'S4 stiffness dof buffer is too small', ierr)
return
end if
if (size(ke,1) .lt. n_elem_dof .or. size(ke,2) .lt. n_elem_dof) then
call error_set(FEM_ERR_INTERNAL, 'S4 stiffness matrix buffer is too small', ierr)
return
end if
call fill_shell_dofs(elem, elem_dofs, n_elem_dof, ierr)
if (ierr .ne. FEM_SUCCESS) return
mat = elem_mat(elem)
sec = elem_sec(elem)
if (mat .lt. 1 .or. mat .gt. n_material) then
call error_set(FEM_ERR_MATERIAL, 'S4 stiffness has invalid material index', ierr)
return
end if
if (sec .lt. 1 .or. sec .gt. n_section) then
call error_set(FEM_ERR_INPUT, 'S4 stiffness has invalid section index', ierr)
return
end if
young = mat_e(mat)
poisson = mat_nu(mat)
thickness = section_thickness(sec)
if (young .le. ZERO) then
call error_set(FEM_ERR_MATERIAL, 'S4 stiffness requires positive elastic modulus', ierr)
return
end if
if (poisson .le. -ONE .or. poisson .ge. HALF) then
call error_set(FEM_ERR_MATERIAL, 'S4 stiffness Poisson ratio must be in (-1,0.5)', ierr)
return
end if
if (thickness .le. ZERO) then
call error_set(FEM_ERR_INPUT, 'S4 stiffness requires positive thickness', ierr)
return
end if
call shell4_basis_linear(elem, basis, xloc, ierr)
if (ierr .ne. FEM_SUCCESS) return
shear_mod = young / (2.0_rk * (ONE + poisson))
coeff_mem = young * thickness / (ONE - poisson * poisson)
coeff_ben = young * thickness**3 / &
(12.0_rk * (ONE - poisson * poisson))
coeff_shr = (5.0_rk / 6.0_rk) * shear_mod * thickness
call shell_constitutive(coeff_mem, coeff_ben, coeff_shr, poisson, &
dmem, dben, dshr)
call quadrature_get_rule('S4', 4, npoint, gp_nat, gp_weight, ierr)
if (ierr .ne. FEM_SUCCESS) return
klocal = ZERO
area = ZERO
do q = 1, npoint
call shell4_shape_xy_linear(xloc, gp_nat(1,q), gp_nat(2,q), &
nshape, dndx, dndy, detj, ierr)
if (ierr .ne. FEM_SUCCESS) return
weight = gp_weight(q) * detj
area = area + weight
call shell_b_matrices(NLOCAL, nshape, dndx, dndy, bmem, bben, bshr)
dmem_gp = dmem
dben_gp = dben
dshr_gp = dshr
gp = 0
if (allocated(elem_gp_start)) then
if (elem .le. size(elem_gp_start)) gp = elem_gp_start(elem) + q - 1
end if
call shell_apply_section_tangent(mat, thickness, gp, dmem_gp, dben_gp, &
dshr_gp, ierr)
if (ierr .ne. FEM_SUCCESS) return
klocal = klocal + weight * matmul(transpose(bmem), matmul(dmem_gp, bmem)) + &
weight * matmul(transpose(bben), matmul(dben_gp, bben)) + &
weight * matmul(transpose(bshr), matmul(dshr_gp, bshr))
end do
call shell_transform_matrix(NLOCAL, basis, transform)
tmp = matmul(klocal, transform)
ke(1:n_elem_dof,1:n_elem_dof) = matmul(transpose(transform), tmp)
call add_shell_drilling_stiffness(NLOCAL, basis, coeff_mem * area * 1.0e-8_rk, &
ke)
ierr = FEM_SUCCESS
end subroutine shell4_linear_stiffness
subroutine shell_general_linear_stiffness(elem, nlocal, etype, elem_dofs, &
n_elem_dof, ke, ierr)
integer, intent(in) :: elem
integer, intent(in) :: nlocal
character(len=*), intent(in) :: etype
integer, intent(out) :: elem_dofs(:)
integer, intent(out) :: n_elem_dof
real(rk), intent(out) :: ke(:,:)
integer, intent(out) :: ierr
real(rk) :: basis(NDIM,NDIM)
real(rk) :: xloc(2,MAX_NEN)
real(rk) :: gp_nat(NDIM,27)
real(rk) :: gp_weight(27)
real(rk) :: nshape(nlocal)
real(rk) :: dndx(nlocal)
real(rk) :: dndy(nlocal)
real(rk) :: bmem(3,5*nlocal)
real(rk) :: bben(3,5*nlocal)
real(rk) :: bshr(2,5*nlocal)
real(rk) :: dmem(3,3)
real(rk) :: dmem_gp(3,3)
real(rk) :: dben(3,3)
real(rk) :: dben_gp(3,3)
real(rk) :: dshr(2,2)
real(rk) :: dshr_gp(2,2)
real(rk) :: klocal(5*nlocal,5*nlocal)
real(rk) :: transform(5*nlocal,6*nlocal)
real(rk) :: tmp(5*nlocal,6*nlocal)
real(rk) :: young
real(rk) :: poisson
real(rk) :: thickness
real(rk) :: shear_mod
real(rk) :: coeff_mem
real(rk) :: coeff_ben
real(rk) :: coeff_shr
real(rk) :: detj
real(rk) :: weight
real(rk) :: area
integer :: q
integer :: npoint
integer :: gp
integer :: mat
integer :: sec
n_elem_dof = 6 * nlocal
if (elem_nnode(elem) .ne. nlocal) then
call error_set(FEM_ERR_MESH, 'shell linear stiffness node count mismatch', ierr)
return
end if
if (size(elem_dofs) .lt. n_elem_dof) then
call error_set(FEM_ERR_INTERNAL, 'shell stiffness dof buffer is too small', ierr)
return
end if
if (size(ke,1) .lt. n_elem_dof .or. size(ke,2) .lt. n_elem_dof) then
call error_set(FEM_ERR_INTERNAL, 'shell stiffness matrix buffer is too small', ierr)
return
end if
call fill_shell_dofs(elem, elem_dofs, n_elem_dof, ierr)
if (ierr .ne. FEM_SUCCESS) return
mat = elem_mat(elem)
sec = elem_sec(elem)
if (mat .lt. 1 .or. mat .gt. n_material) then
call error_set(FEM_ERR_MATERIAL, 'shell stiffness has invalid material index', ierr)
return
end if
if (sec .lt. 1 .or. sec .gt. n_section) then
call error_set(FEM_ERR_INPUT, 'shell stiffness has invalid section index', ierr)
return
end if
young = mat_e(mat)
poisson = mat_nu(mat)
thickness = section_thickness(sec)
if (young .le. ZERO) then
call error_set(FEM_ERR_MATERIAL, 'shell stiffness requires positive elastic modulus', ierr)
return
end if
if (poisson .le. -ONE .or. poisson .ge. HALF) then
call error_set(FEM_ERR_MATERIAL, 'shell stiffness Poisson ratio must be in (-1,0.5)', ierr)
return
end if
if (thickness .le. ZERO) then
call error_set(FEM_ERR_INPUT, 'shell stiffness requires positive thickness', ierr)
return
end if
call shell_general_basis_linear(elem, nlocal, trim(etype) .eq. 'S8', &
basis, xloc, ierr)
if (ierr .ne. FEM_SUCCESS) return
shear_mod = young / (2.0_rk * (ONE + poisson))
coeff_mem = young * thickness / (ONE - poisson * poisson)
coeff_ben = young * thickness**3 / &
(12.0_rk * (ONE - poisson * poisson))
coeff_shr = (5.0_rk / 6.0_rk) * shear_mod * thickness
call shell_constitutive(coeff_mem, coeff_ben, coeff_shr, poisson, &
dmem, dben, dshr)
call quadrature_get_rule(etype, 27, npoint, gp_nat, gp_weight, ierr)
if (ierr .ne. FEM_SUCCESS) return
klocal = ZERO
area = ZERO
do q = 1, npoint
call shell_general_shape_xy_linear(etype, nlocal, xloc, gp_nat(:,q), &
nshape, dndx, dndy, detj, ierr)
if (ierr .ne. FEM_SUCCESS) return
weight = gp_weight(q) * detj
area = area + weight
call shell_b_matrices(nlocal, nshape, dndx, dndy, bmem, bben, bshr)
dmem_gp = dmem
dben_gp = dben
dshr_gp = dshr
gp = 0
if (allocated(elem_gp_start)) then
if (elem .le. size(elem_gp_start)) gp = elem_gp_start(elem) + q - 1
end if
call shell_apply_section_tangent(mat, thickness, gp, dmem_gp, dben_gp, &
dshr_gp, ierr)
if (ierr .ne. FEM_SUCCESS) return
klocal = klocal + weight * matmul(transpose(bmem), matmul(dmem_gp, bmem)) + &
weight * matmul(transpose(bben), matmul(dben_gp, bben)) + &
weight * matmul(transpose(bshr), matmul(dshr_gp, bshr))
end do
call shell_transform_matrix(nlocal, basis, transform)
tmp = matmul(klocal, transform)
ke(1:n_elem_dof,1:n_elem_dof) = matmul(transpose(transform), tmp)
call add_shell_drilling_stiffness(nlocal, basis, coeff_mem * area * 1.0e-8_rk, &
ke)
ierr = FEM_SUCCESS
end subroutine shell_general_linear_stiffness
subroutine fill_solid_dofs(elem, elem_dofs, n_elem_dof, ierr)
integer, intent(in) :: elem
integer, intent(out) :: elem_dofs(:)
integer, intent(in) :: n_elem_dof
integer, intent(out) :: ierr
integer :: local_node
integer :: node
integer :: idir
integer :: pos
integer :: dof
if (.not. allocated(dof_id)) then
call error_set(FEM_ERR_INTERNAL, 'linear stiffness requires assigned dof_id table', ierr)
return
end if
pos = 0
do local_node = 1, elem_nnode(elem)
node = elem_conn(local_node, elem)
if (node .lt. 1 .or. node .gt. nnode) then
call error_set(FEM_ERR_MESH, 'linear stiffness element references invalid node', ierr)
return
end if
do idir = 1, NDIM
dof = dof_id(idir,node)
if (dof .le. 0) then
call error_set(FEM_ERR_MESH, 'linear stiffness element has inactive translation dof', ierr)
return
end if
pos = pos + 1
if (pos .gt. n_elem_dof) then
call error_set(FEM_ERR_INTERNAL, 'linear stiffness dof list overflow', ierr)
return
end if
elem_dofs(pos) = dof
end do
end do
ierr = FEM_SUCCESS
end subroutine fill_solid_dofs
subroutine fill_shell_dofs(elem, elem_dofs, n_elem_dof, ierr)
integer, intent(in) :: elem
integer, intent(out) :: elem_dofs(:)
integer, intent(in) :: n_elem_dof
integer, intent(out) :: ierr
integer :: local_node
integer :: node
integer :: idir
integer :: pos
integer :: dof
if (.not. allocated(dof_id)) then
call error_set(FEM_ERR_INTERNAL, 'shell stiffness requires assigned dof_id table', ierr)
return
end if
pos = 0
do local_node = 1, elem_nnode(elem)
node = elem_conn(local_node, elem)
if (node .lt. 1 .or. node .gt. nnode) then
call error_set(FEM_ERR_MESH, 'shell stiffness element references invalid node', ierr)
return
end if
do idir = 1, NDOF_NODE
dof = dof_id(idir,node)
if (dof .le. 0) then
call error_set(FEM_ERR_MESH, 'shell stiffness element has inactive dof', ierr)
return
end if
pos = pos + 1
if (pos .gt. n_elem_dof) then
call error_set(FEM_ERR_INTERNAL, 'shell stiffness dof list overflow', ierr)
return
end if
elem_dofs(pos) = dof
end do
end do
ierr = FEM_SUCCESS
end subroutine fill_shell_dofs
subroutine shell3_basis_linear(elem, basis, xloc, ierr)
integer, intent(in) :: elem
real(rk), intent(out) :: basis(NDIM,NDIM)
real(rk), intent(out) :: xloc(2,3)
integer, intent(out) :: ierr
real(rk) :: origin(NDIM)
real(rk) :: x1(NDIM)
real(rk) :: x2(NDIM)
real(rk) :: x3(NDIM)
real(rk) :: v12(NDIM)
real(rk) :: v13(NDIM)
real(rk) :: normal(NDIM)
real(rk) :: tmp(NDIM)
real(rk) :: len1
real(rk) :: lenn
integer :: local_node
integer :: node
x1 = coord0(:, elem_conn(1,elem))
x2 = coord0(:, elem_conn(2,elem))
x3 = coord0(:, elem_conn(3,elem))
origin = x1
v12 = x2 - x1
v13 = x3 - x1
len1 = sqrt(sum(v12 * v12))
if (len1 .le. ZERO) then
call error_set(FEM_ERR_MESH, 'S3 stiffness has coincident first edge nodes', ierr)
return
end if
basis(:,1) = v12 / len1
call cross3_linear(v12, v13, normal)
lenn = sqrt(sum(normal * normal))
if (lenn .le. ZERO) then
call error_set(FEM_ERR_MESH, 'S3 stiffness local basis is singular', ierr)
return
end if
basis(:,3) = normal / lenn
call cross3_linear(basis(:,3), basis(:,1), basis(:,2))
do local_node = 1, 3
node = elem_conn(local_node, elem)
tmp = coord0(:,node) - origin
xloc(1,local_node) = dot_product(tmp, basis(:,1))
xloc(2,local_node) = dot_product(tmp, basis(:,2))
end do
ierr = FEM_SUCCESS
end subroutine shell3_basis_linear
subroutine shell3_shape_xy_linear(xloc, nshape, dndx, dndy, detj, ierr)
real(rk), intent(in) :: xloc(2,3)
real(rk), intent(out) :: nshape(3)
real(rk), intent(out) :: dndx(3)
real(rk), intent(out) :: dndy(3)
real(rk), intent(out) :: detj
integer, intent(out) :: ierr
real(rk) :: dndr(3)
real(rk) :: dnds(3)
real(rk) :: jac(2,2)
real(rk) :: invj(2,2)
integer :: local_node
nshape = (/ ONE / 3.0_rk, ONE / 3.0_rk, ONE / 3.0_rk /)
dndr = (/ -ONE, ONE, ZERO /)
dnds = (/ -ONE, ZERO, ONE /)
jac = ZERO
do local_node = 1, 3
jac(1,1) = jac(1,1) + xloc(1,local_node) * dndr(local_node)
jac(1,2) = jac(1,2) + xloc(1,local_node) * dnds(local_node)
jac(2,1) = jac(2,1) + xloc(2,local_node) * dndr(local_node)
jac(2,2) = jac(2,2) + xloc(2,local_node) * dnds(local_node)
end do
detj = jac(1,1) * jac(2,2) - jac(1,2) * jac(2,1)
if (detj .le. ZERO) then
call error_set(FEM_ERR_MESH, 'S3 stiffness has non-positive Jacobian', ierr)
return
end if
invj(1,1) = jac(2,2) / detj
invj(1,2) = -jac(1,2) / detj
invj(2,1) = -jac(2,1) / detj
invj(2,2) = jac(1,1) / detj
do local_node = 1, 3
dndx(local_node) = dndr(local_node) * invj(1,1) + &
dnds(local_node) * invj(2,1)
dndy(local_node) = dndr(local_node) * invj(1,2) + &
dnds(local_node) * invj(2,2)
end do
ierr = FEM_SUCCESS
end subroutine shell3_shape_xy_linear
subroutine shell4_basis_linear(elem, basis, xloc, ierr)
integer, intent(in) :: elem
real(rk), intent(out) :: basis(NDIM,NDIM)
real(rk), intent(out) :: xloc(2,4)
integer, intent(out) :: ierr
real(rk) :: origin(NDIM)
real(rk) :: x1(NDIM)
real(rk) :: x2(NDIM)
real(rk) :: x3(NDIM)
real(rk) :: x4(NDIM)
real(rk) :: v12(NDIM)
real(rk) :: v14(NDIM)
real(rk) :: normal(NDIM)
real(rk) :: tmp(NDIM)
real(rk) :: len1
real(rk) :: lenn
integer :: local_node
integer :: node
x1 = coord0(:, elem_conn(1,elem))
x2 = coord0(:, elem_conn(2,elem))
x3 = coord0(:, elem_conn(3,elem))
x4 = coord0(:, elem_conn(4,elem))
origin = x1
v12 = x2 - x1
v14 = x4 - x1
len1 = sqrt(sum(v12 * v12))
if (len1 .le. ZERO) then
call error_set(FEM_ERR_MESH, 'S4 stiffness has coincident first edge nodes', ierr)
return
end if
basis(:,1) = v12 / len1
call cross3_linear(v12, v14, normal)
lenn = sqrt(sum(normal * normal))
if (lenn .le. ZERO) then
tmp = x3 - x1
call cross3_linear(v12, tmp, normal)
lenn = sqrt(sum(normal * normal))
end if
if (lenn .le. ZERO) then
call error_set(FEM_ERR_MESH, 'S4 stiffness local basis is singular', ierr)
return
end if
basis(:,3) = normal / lenn
call cross3_linear(basis(:,3), basis(:,1), basis(:,2))
do local_node = 1, 4
node = elem_conn(local_node, elem)
tmp = coord0(:,node) - origin
xloc(1,local_node) = dot_product(tmp, basis(:,1))
xloc(2,local_node) = dot_product(tmp, basis(:,2))
end do
ierr = FEM_SUCCESS
end subroutine shell4_basis_linear
subroutine shell4_shape_xy_linear(xloc, r, s, nshape, dndx, dndy, detj, ierr)
real(rk), intent(in) :: xloc(2,4)
real(rk), intent(in) :: r
real(rk), intent(in) :: s
real(rk), intent(out) :: nshape(4)
real(rk), intent(out) :: dndx(4)
real(rk), intent(out) :: dndy(4)
real(rk), intent(out) :: detj
integer, intent(out) :: ierr
real(rk) :: dndr(4)
real(rk) :: dnds(4)
real(rk) :: jac(2,2)
real(rk) :: invj(2,2)
integer :: local_node
nshape(1) = 0.25_rk * (ONE - r) * (ONE - s)
nshape(2) = 0.25_rk * (ONE + r) * (ONE - s)
nshape(3) = 0.25_rk * (ONE + r) * (ONE + s)
nshape(4) = 0.25_rk * (ONE - r) * (ONE + s)
dndr(1) = -0.25_rk * (ONE - s)
dndr(2) = 0.25_rk * (ONE - s)
dndr(3) = 0.25_rk * (ONE + s)
dndr(4) = -0.25_rk * (ONE + s)
dnds(1) = -0.25_rk * (ONE - r)
dnds(2) = -0.25_rk * (ONE + r)
dnds(3) = 0.25_rk * (ONE + r)
dnds(4) = 0.25_rk * (ONE - r)
jac = ZERO
do local_node = 1, 4
jac(1,1) = jac(1,1) + xloc(1,local_node) * dndr(local_node)
jac(1,2) = jac(1,2) + xloc(1,local_node) * dnds(local_node)
jac(2,1) = jac(2,1) + xloc(2,local_node) * dndr(local_node)
jac(2,2) = jac(2,2) + xloc(2,local_node) * dnds(local_node)
end do
detj = jac(1,1) * jac(2,2) - jac(1,2) * jac(2,1)
if (detj .le. ZERO) then
call error_set(FEM_ERR_MESH, 'S4 stiffness has non-positive Jacobian', ierr)
return
end if
invj(1,1) = jac(2,2) / detj
invj(1,2) = -jac(1,2) / detj
invj(2,1) = -jac(2,1) / detj
invj(2,2) = jac(1,1) / detj
do local_node = 1, 4
dndx(local_node) = dndr(local_node) * invj(1,1) + &
dnds(local_node) * invj(2,1)
dndy(local_node) = dndr(local_node) * invj(1,2) + &
dnds(local_node) * invj(2,2)
end do
ierr = FEM_SUCCESS
end subroutine shell4_shape_xy_linear
subroutine shell_general_basis_linear(elem, nlocal, use_quad, basis, xloc, ierr)
integer, intent(in) :: elem
integer, intent(in) :: nlocal
logical, intent(in) :: use_quad
real(rk), intent(out) :: basis(NDIM,NDIM)
real(rk), intent(out) :: xloc(2,MAX_NEN)
integer, intent(out) :: ierr
real(rk) :: origin(NDIM)
real(rk) :: x1(NDIM)
real(rk) :: x2(NDIM)
real(rk) :: x3(NDIM)
real(rk) :: x4(NDIM)
real(rk) :: v12(NDIM)
real(rk) :: vnormal(NDIM)
real(rk) :: normal(NDIM)
real(rk) :: tmp(NDIM)
real(rk) :: len1
real(rk) :: lenn
integer :: local_node
integer :: node
x1 = coord0(:, elem_conn(1,elem))
x2 = coord0(:, elem_conn(2,elem))
x3 = coord0(:, elem_conn(3,elem))
origin = x1
v12 = x2 - x1
if (use_quad) then
x4 = coord0(:, elem_conn(4,elem))
vnormal = x4 - x1
else
vnormal = x3 - x1
end if
len1 = sqrt(sum(v12 * v12))
if (len1 .le. ZERO) then
call error_set(FEM_ERR_MESH, 'shell stiffness has coincident first edge nodes', ierr)
return
end if
basis(:,1) = v12 / len1
call cross3_linear(v12, vnormal, normal)
lenn = sqrt(sum(normal * normal))
if (lenn .le. ZERO .and. use_quad) then
tmp = x3 - x1
call cross3_linear(v12, tmp, normal)
lenn = sqrt(sum(normal * normal))
end if
if (lenn .le. ZERO) then
call error_set(FEM_ERR_MESH, 'shell stiffness local basis is singular', ierr)
return
end if
basis(:,3) = normal / lenn
call cross3_linear(basis(:,3), basis(:,1), basis(:,2))
xloc = ZERO
do local_node = 1, nlocal
node = elem_conn(local_node, elem)
tmp = coord0(:,node) - origin
xloc(1,local_node) = dot_product(tmp, basis(:,1))
xloc(2,local_node) = dot_product(tmp, basis(:,2))
end do
ierr = FEM_SUCCESS
end subroutine shell_general_basis_linear
subroutine shell_general_shape_xy_linear(etype, nlocal, xloc, natural, &
nshape, dndx, dndy, detj, ierr)
character(len=*), intent(in) :: etype
integer, intent(in) :: nlocal
real(rk), intent(in) :: xloc(2,MAX_NEN)
real(rk), intent(in) :: natural(NDIM)
real(rk), intent(out) :: nshape(nlocal)
real(rk), intent(out) :: dndx(nlocal)
real(rk), intent(out) :: dndy(nlocal)
real(rk), intent(out) :: detj
integer, intent(out) :: ierr
real(rk) :: nbuf(MAX_NEN)
real(rk) :: dndr(NDIM,MAX_NEN)
real(rk) :: jac(2,2)
real(rk) :: invj(2,2)
integer :: local_node
call shape_evaluate(etype, natural, nbuf, dndr, ierr)
if (ierr .ne. FEM_SUCCESS) return
jac = ZERO
do local_node = 1, nlocal
jac(1,1) = jac(1,1) + xloc(1,local_node) * dndr(1,local_node)
jac(1,2) = jac(1,2) + xloc(1,local_node) * dndr(2,local_node)
jac(2,1) = jac(2,1) + xloc(2,local_node) * dndr(1,local_node)
jac(2,2) = jac(2,2) + xloc(2,local_node) * dndr(2,local_node)
end do
detj = jac(1,1) * jac(2,2) - jac(1,2) * jac(2,1)
if (detj .le. ZERO) then
call error_set(FEM_ERR_MESH, 'shell stiffness has non-positive Jacobian', ierr)
return
end if
invj(1,1) = jac(2,2) / detj
invj(1,2) = -jac(1,2) / detj
invj(2,1) = -jac(2,1) / detj
invj(2,2) = jac(1,1) / detj
do local_node = 1, nlocal
nshape(local_node) = nbuf(local_node)
dndx(local_node) = dndr(1,local_node) * invj(1,1) + &
dndr(2,local_node) * invj(2,1)
dndy(local_node) = dndr(1,local_node) * invj(1,2) + &
dndr(2,local_node) * invj(2,2)
end do
ierr = FEM_SUCCESS
end subroutine shell_general_shape_xy_linear
subroutine shell_constitutive(coeff_mem, coeff_ben, coeff_shr, poisson, &
dmem, dben, dshr)
real(rk), intent(in) :: coeff_mem
real(rk), intent(in) :: coeff_ben
real(rk), intent(in) :: coeff_shr
real(rk), intent(in) :: poisson
real(rk), intent(out) :: dmem(3,3)
real(rk), intent(out) :: dben(3,3)
real(rk), intent(out) :: dshr(2,2)
dmem = ZERO
dben = ZERO
dshr = ZERO
dmem(1,1) = coeff_mem
dmem(1,2) = coeff_mem * poisson
dmem(2,1) = coeff_mem * poisson
dmem(2,2) = coeff_mem
dmem(3,3) = coeff_mem * HALF * (ONE - poisson)
dben(1,1) = coeff_ben
dben(1,2) = coeff_ben * poisson
dben(2,1) = coeff_ben * poisson
dben(2,2) = coeff_ben
dben(3,3) = coeff_ben * HALF * (ONE - poisson)
dshr(1,1) = coeff_shr
dshr(2,2) = coeff_shr
end subroutine shell_constitutive
subroutine shell_apply_section_tangent(mat, thickness, gp, dmem, dben, dshr, ierr)
integer, intent(in) :: mat
real(rk), intent(in) :: thickness
integer, intent(in) :: gp
real(rk), intent(inout) :: dmem(3,3)
real(rk), intent(inout) :: dben(3,3)
real(rk), intent(inout) :: dshr(2,2)
integer, intent(out) :: ierr
real(rk) :: d3d(NSTRESS,NSTRESS)
real(rk) :: h3
real(rk) :: hshear
if (gp .le. 0) then
ierr = FEM_SUCCESS
return
end if
if (.not. allocated(stress) .or. .not. allocated(statev)) then
ierr = FEM_SUCCESS
return
end if
if (gp .gt. size(stress,2) .or. gp .gt. size(statev,2)) then
call error_set(FEM_ERR_INTERNAL, 'shell tangent integration point is out of range', ierr)
return
end if
if (trim(mat_plastic_model(mat)) .ne. 'J2' .and. &
trim(mat_plastic_model(mat)) .ne. 'J2_JC') then
ierr = FEM_SUCCESS
return
end if
if (statev(4,gp) .lt. HALF .and. statev(22,gp) .le. tiny(ONE)) then
ierr = FEM_SUCCESS
return
end if
call material_tangent_small_strain(mat, stress(:,gp), statev(:,gp), d3d, ierr)
if (ierr .ne. FEM_SUCCESS) return
dmem(1,1) = thickness * d3d(1,1)
dmem(1,2) = thickness * d3d(1,2)
dmem(1,3) = thickness * d3d(1,4)
dmem(2,1) = thickness * d3d(2,1)
dmem(2,2) = thickness * d3d(2,2)
dmem(2,3) = thickness * d3d(2,4)
dmem(3,1) = thickness * d3d(4,1)
dmem(3,2) = thickness * d3d(4,2)
dmem(3,3) = thickness * d3d(4,4)
h3 = thickness**3 / 12.0_rk
dben(1,1) = h3 * d3d(1,1)
dben(1,2) = h3 * d3d(1,2)
dben(1,3) = h3 * d3d(1,4)
dben(2,1) = h3 * d3d(2,1)
dben(2,2) = h3 * d3d(2,2)
dben(2,3) = h3 * d3d(2,4)
dben(3,1) = h3 * d3d(4,1)
dben(3,2) = h3 * d3d(4,2)
dben(3,3) = h3 * d3d(4,4)
hshear = (5.0_rk / 6.0_rk) * thickness
dshr(1,1) = hshear * d3d(5,5)
dshr(1,2) = hshear * d3d(5,6)
dshr(2,1) = hshear * d3d(6,5)
dshr(2,2) = hshear * d3d(6,6)
ierr = FEM_SUCCESS
end subroutine shell_apply_section_tangent
subroutine shell_b_matrices(nlocal, nshape, dndx, dndy, bmem, bben, bshr)
integer, intent(in) :: nlocal
real(rk), intent(in) :: nshape(nlocal)
real(rk), intent(in) :: dndx(nlocal)
real(rk), intent(in) :: dndy(nlocal)
real(rk), intent(out) :: bmem(3,5*nlocal)
real(rk), intent(out) :: bben(3,5*nlocal)
real(rk), intent(out) :: bshr(2,5*nlocal)
integer :: local_node
integer :: base
bmem = ZERO
bben = ZERO
bshr = ZERO
do local_node = 1, nlocal
base = 5 * (local_node - 1)
bmem(1,base+1) = dndx(local_node)
bmem(2,base+2) = dndy(local_node)
bmem(3,base+1) = dndy(local_node)
bmem(3,base+2) = dndx(local_node)
bben(1,base+5) = dndx(local_node)
bben(2,base+4) = -dndy(local_node)
bben(3,base+4) = -dndx(local_node)
bben(3,base+5) = dndy(local_node)
bshr(1,base+3) = dndx(local_node)
bshr(1,base+5) = nshape(local_node)
bshr(2,base+3) = dndy(local_node)
bshr(2,base+4) = -nshape(local_node)
end do
end subroutine shell_b_matrices
subroutine shell_transform_matrix(nlocal, basis, transform)
integer, intent(in) :: nlocal
real(rk), intent(in) :: basis(NDIM,NDIM)
real(rk), intent(out) :: transform(5*nlocal,6*nlocal)
integer :: local_node
integer :: i
integer :: qbase
integer :: gbase
transform = ZERO
do local_node = 1, nlocal
qbase = 5 * (local_node - 1)
gbase = 6 * (local_node - 1)
do i = 1, NDIM
transform(qbase+1,gbase+i) = basis(i,1)
transform(qbase+2,gbase+i) = basis(i,2)
transform(qbase+3,gbase+i) = basis(i,3)
transform(qbase+4,gbase+3+i) = basis(i,1)
transform(qbase+5,gbase+3+i) = basis(i,2)
end do
end do
end subroutine shell_transform_matrix
subroutine add_shell_drilling_stiffness(nlocal, basis, kdrill, ke)
integer, intent(in) :: nlocal
real(rk), intent(in) :: basis(NDIM,NDIM)
real(rk), intent(in) :: kdrill
real(rk), intent(inout) :: ke(:,:)
integer :: local_node
integer :: i
integer :: j
integer :: base
if (kdrill .le. ZERO) return
do local_node = 1, nlocal
base = 6 * (local_node - 1)
do i = 1, NDIM
do j = 1, NDIM
ke(base+3+i,base+3+j) = ke(base+3+i,base+3+j) + &
kdrill * basis(i,3) * basis(j,3)
end do
end do
end do
end subroutine add_shell_drilling_stiffness
subroutine shape_gradients_current(elem, nlocal, dndr, dndx, detj, ierr)
integer, intent(in) :: elem
integer, intent(in) :: nlocal
real(rk), intent(in) :: dndr(NDIM,MAX_NEN)
real(rk), intent(out) :: dndx(NDIM,MAX_NEN)
real(rk), intent(out) :: detj
integer, intent(out) :: ierr
real(rk) :: jac(NDIM,NDIM)
real(rk) :: invj(NDIM,NDIM)
integer :: local_node
integer :: node
integer :: i
integer :: j
integer :: k
jac = ZERO
dndx = ZERO
do local_node = 1, nlocal
node = elem_conn(local_node, elem)
do i = 1, NDIM
do j = 1, NDIM
jac(i,j) = jac(i,j) + coord0(i,node) * dndr(j,local_node)
end do
end do
end do
call inverse3(jac, invj, detj, ierr)
if (ierr .ne. FEM_SUCCESS) return
if (detj .le. ZERO) then
call error_set(FEM_ERR_MESH, 'linear stiffness element has non-positive Jacobian', ierr)
return
end if
do local_node = 1, nlocal
do i = 1, NDIM
dndx(i,local_node) = ZERO
do k = 1, NDIM
dndx(i,local_node) = dndx(i,local_node) + invj(k,i) * dndr(k,local_node)
end do
end do
end do
ierr = FEM_SUCCESS
end subroutine shape_gradients_current
subroutine build_solid_b(nlocal, dndx, bmat)
integer, intent(in) :: nlocal
real(rk), intent(in) :: dndx(NDIM,MAX_NEN)
real(rk), intent(out) :: bmat(NSTRESS,MAX_NEN*3)
integer :: local_node
integer :: base
bmat = ZERO
do local_node = 1, nlocal
base = 3 * (local_node - 1)
bmat(1,base+1) = dndx(1,local_node)
bmat(2,base+2) = dndx(2,local_node)
bmat(3,base+3) = dndx(3,local_node)
bmat(4,base+1) = dndx(2,local_node)
bmat(4,base+2) = dndx(1,local_node)
bmat(5,base+1) = dndx(3,local_node)
bmat(5,base+3) = dndx(1,local_node)
bmat(6,base+2) = dndx(3,local_node)
bmat(6,base+3) = dndx(2,local_node)
end do
end subroutine build_solid_b
subroutine inverse3(a, ainv, det, ierr)
real(rk), intent(in) :: a(NDIM,NDIM)
real(rk), intent(out) :: ainv(NDIM,NDIM)
real(rk), intent(out) :: det
integer, intent(out) :: ierr
det = a(1,1) * (a(2,2) * a(3,3) - a(2,3) * a(3,2)) - &
a(1,2) * (a(2,1) * a(3,3) - a(2,3) * a(3,1)) + &
a(1,3) * (a(2,1) * a(3,2) - a(2,2) * a(3,1))
if (abs(det) .le. tiny(ONE)) then
call error_set(FEM_ERR_MESH, 'linear stiffness element Jacobian is singular', ierr)
return
end if
ainv(1,1) = (a(2,2) * a(3,3) - a(2,3) * a(3,2)) / det
ainv(1,2) = -(a(1,2) * a(3,3) - a(1,3) * a(3,2)) / det
ainv(1,3) = (a(1,2) * a(2,3) - a(1,3) * a(2,2)) / det
ainv(2,1) = -(a(2,1) * a(3,3) - a(2,3) * a(3,1)) / det
ainv(2,2) = (a(1,1) * a(3,3) - a(1,3) * a(3,1)) / det
ainv(2,3) = -(a(1,1) * a(2,3) - a(1,3) * a(2,1)) / det
ainv(3,1) = (a(2,1) * a(3,2) - a(2,2) * a(3,1)) / det
ainv(3,2) = -(a(1,1) * a(3,2) - a(1,2) * a(3,1)) / det
ainv(3,3) = (a(1,1) * a(2,2) - a(1,2) * a(2,1)) / det
ierr = FEM_SUCCESS
end subroutine inverse3
subroutine cross3_linear(a, b, c)
real(rk), intent(in) :: a(NDIM)
real(rk), intent(in) :: b(NDIM)
real(rk), intent(out) :: c(NDIM)
c(1) = a(2) * b(3) - a(3) * b(2)
c(2) = a(3) * b(1) - a(1) * b(3)
c(3) = a(1) * b(2) - a(2) * b(1)
end subroutine cross3_linear
end module fem_element_stiffness