Prepare FemLite 0.3.1 contact and shell updates

This commit is contained in:
shenw
2026-06-23 19:45:33 +08:00
parent be02684827
commit 8710688540
16 changed files with 470 additions and 123 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ module fem_precision
integer, parameter :: FEMLITE_VERSION_MAJOR = 0
integer, parameter :: FEMLITE_VERSION_MINOR = 3
integer, parameter :: FEMLITE_VERSION_PATCH = 0
integer, parameter :: FEMLITE_VERSION_PATCH = 1
real(rk), parameter :: ZERO = 0.0_rk
real(rk), parameter :: ONE = 1.0_rk
+236 -83
View File
@@ -312,7 +312,6 @@ contains
integer :: stat
integer :: sf
integer :: mf
integer :: best
integer, allocatable :: facet_id(:)
integer, allocatable :: elem_id(:)
integer, allocatable :: face_id(:)
@@ -321,13 +320,23 @@ contains
real(rk), allocatable :: x(:,:,:)
real(rk), allocatable :: vnod(:,:,:)
real(rk), allocatable :: normal(:,:)
real(rk), allocatable :: center(:,:)
real(rk), allocatable :: velc(:,:)
real(rk), allocatable :: area(:)
real(rk), allocatable :: radius(:)
real(rk) :: gap
real(rk) :: vn
real(rk) :: best_gap
real(rk) :: best_vn
real(rk) :: force_mag
real(rk) :: normal_mag
real(rk) :: total_weight
real(rk) :: pair_weight
real(rk) :: share
real(rk) :: mu
real(rk) :: vt_norm
real(rk) :: nrm(NDIM)
real(rk) :: tdir(NDIM)
real(rk) :: force_vec(NDIM)
integer :: q
call cpl_build_facets(ierr)
if (ierr .ne. FEM_SUCCESS) return
@@ -340,7 +349,8 @@ contains
allocate(facet_id(nf), elem_id(nf), face_id(nf), fnnode(nf), &
fconn(max_nodes,nf), x(NDIM,max_nodes,nf), &
vnod(NDIM,max_nodes,nf), normal(NDIM,nf), area(nf), stat=stat)
vnod(NDIM,max_nodes,nf), normal(NDIM,nf), &
center(NDIM,nf), velc(NDIM,nf), area(nf), radius(nf), stat=stat)
if (stat .ne. 0) then
call error_set(FEM_ERR_INTERNAL, 'failed to allocate contact pair facets', ierr)
return
@@ -350,41 +360,60 @@ contains
fconn, x, vnod, normal, area, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
do q = 1, nf
call facet_center_velocity(q, nf, max_nodes, fnnode, x, vnod, &
center(:,q), velc(:,q))
radius(q) = facet_radius_value(q, nf, max_nodes, fnnode, x, center(:,q))
end do
mu = contact_pair_friction_value(pair)
do sf = 1, nf
if (.not. facet_target_matches(elem_id(sf), contact_pair_slave(pair))) cycle
best = 0
best_gap = ZERO
best_vn = ZERO
nrm = ZERO
total_weight = ZERO
do mf = 1, nf
if (sf .eq. mf) cycle
if (.not. facet_target_matches(elem_id(mf), contact_pair_master(pair))) cycle
if (.not. contact_spatial_candidate(pair, sf, mf, nf, center, radius)) cycle
if (facet_nodes_share(max_nodes, fnnode(sf), fconn(:,sf), &
fnnode(mf), fconn(:,mf))) cycle
call pair_contact_gap(pair, sf, mf, nf, max_nodes, fnnode, &
x, vnod, normal, gap, vn, ierr)
x, vnod, normal, gap, vn, pair_weight, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
if (gap .lt. ZERO) then
if (best .eq. 0 .or. gap .lt. best_gap) then
best = mf
best_gap = gap
best_vn = vn
nrm = normal(:,mf)
end if
end if
if (gap .lt. ZERO) total_weight = total_weight + pair_weight
end do
if (best .gt. 0) then
force_mag = contact_pair_penalty(pair) * (-best_gap) * area(sf)
if (best_vn .lt. ZERO) then
force_mag = force_mag + contact_pair_damping(pair) * &
(-best_vn) * area(sf)
end if
call add_contact_pair_force(max_nodes, fnnode(sf), fconn(:,sf), &
fnnode(best), fconn(:,best), &
force_mag, nrm, ierr)
if (total_weight .le. tiny(ONE)) cycle
do mf = 1, nf
if (sf .eq. mf) cycle
if (.not. facet_target_matches(elem_id(mf), contact_pair_master(pair))) cycle
if (.not. contact_spatial_candidate(pair, sf, mf, nf, center, radius)) cycle
if (facet_nodes_share(max_nodes, fnnode(sf), fconn(:,sf), &
fnnode(mf), fconn(:,mf))) cycle
call pair_contact_gap(pair, sf, mf, nf, max_nodes, fnnode, &
x, vnod, normal, gap, vn, pair_weight, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
end if
if (gap .ge. ZERO) cycle
share = pair_weight / total_weight
nrm = normalized_contact_normal(normal(:,mf), ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
normal_mag = contact_pair_penalty(pair) * (-gap) * area(sf) * share
if (vn .lt. ZERO) then
normal_mag = normal_mag + contact_pair_damping(pair) * &
(-vn) * area(sf) * share
end if
call contact_tangent_direction(sf, mf, nf, max_nodes, fnnode, &
vnod, nrm, tdir, vt_norm)
force_vec = normal_mag * nrm
if (mu .gt. ZERO .and. vt_norm .gt. tiny(ONE) .and. normal_mag .gt. ZERO) then
force_mag = mu * normal_mag
force_vec = force_vec - force_mag * tdir
end if
call add_contact_pair_force_vec(max_nodes, fnnode(sf), fconn(:,sf), &
fnnode(mf), fconn(:,mf), force_vec, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
end do
end do
ierr = FEM_SUCCESS
@@ -398,7 +427,10 @@ contains
if (allocated(x)) deallocate(x)
if (allocated(vnod)) deallocate(vnod)
if (allocated(normal)) deallocate(normal)
if (allocated(center)) deallocate(center)
if (allocated(velc)) deallocate(velc)
if (allocated(area)) deallocate(area)
if (allocated(radius)) deallocate(radius)
end subroutine apply_contact_pair_force_one
subroutine apply_contact_pair_tan_one(pair, kmat, velocity_scale, ierr)
@@ -411,7 +443,6 @@ contains
integer :: stat
integer :: sf
integer :: mf
integer :: best
integer, allocatable :: facet_id(:)
integer, allocatable :: elem_id(:)
integer, allocatable :: face_id(:)
@@ -420,13 +451,22 @@ contains
real(rk), allocatable :: x(:,:,:)
real(rk), allocatable :: vnod(:,:,:)
real(rk), allocatable :: normal(:,:)
real(rk), allocatable :: center(:,:)
real(rk), allocatable :: velc(:,:)
real(rk), allocatable :: area(:)
real(rk), allocatable :: radius(:)
real(rk) :: gap
real(rk) :: vn
real(rk) :: best_gap
real(rk) :: best_vn
real(rk) :: coeff
real(rk) :: total_weight
real(rk) :: pair_weight
real(rk) :: share
real(rk) :: mu
real(rk) :: nrm(NDIM)
real(rk) :: ktan(NDIM,NDIM)
integer :: idir
integer :: jdir
integer :: q
call cpl_build_facets(ierr)
if (ierr .ne. FEM_SUCCESS) return
@@ -439,7 +479,8 @@ contains
allocate(facet_id(nf), elem_id(nf), face_id(nf), fnnode(nf), &
fconn(max_nodes,nf), x(NDIM,max_nodes,nf), &
vnod(NDIM,max_nodes,nf), normal(NDIM,nf), area(nf), stat=stat)
vnod(NDIM,max_nodes,nf), normal(NDIM,nf), &
center(NDIM,nf), velc(NDIM,nf), area(nf), radius(nf), stat=stat)
if (stat .ne. 0) then
call error_set(FEM_ERR_INTERNAL, 'failed to allocate contact tangent facets', ierr)
return
@@ -449,39 +490,62 @@ contains
fconn, x, vnod, normal, area, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
do q = 1, nf
call facet_center_velocity(q, nf, max_nodes, fnnode, x, vnod, &
center(:,q), velc(:,q))
radius(q) = facet_radius_value(q, nf, max_nodes, fnnode, x, center(:,q))
end do
mu = contact_pair_friction_value(pair)
do sf = 1, nf
if (.not. facet_target_matches(elem_id(sf), contact_pair_slave(pair))) cycle
best = 0
best_gap = ZERO
best_vn = ZERO
nrm = ZERO
total_weight = ZERO
do mf = 1, nf
if (sf .eq. mf) cycle
if (.not. facet_target_matches(elem_id(mf), contact_pair_master(pair))) cycle
if (.not. contact_spatial_candidate(pair, sf, mf, nf, center, radius)) cycle
if (facet_nodes_share(max_nodes, fnnode(sf), fconn(:,sf), &
fnnode(mf), fconn(:,mf))) cycle
call pair_contact_gap(pair, sf, mf, nf, max_nodes, fnnode, &
x, vnod, normal, gap, vn, ierr)
x, vnod, normal, gap, vn, pair_weight, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
if (gap .lt. ZERO) then
if (best .eq. 0 .or. gap .lt. best_gap) then
best = mf
best_gap = gap
best_vn = vn
nrm = normal(:,mf)
end if
end if
if (gap .lt. ZERO) total_weight = total_weight + pair_weight
end do
if (best .gt. 0) then
coeff = contact_pair_penalty(pair) * area(sf)
if (best_vn .lt. ZERO) then
coeff = coeff + velocity_scale * contact_pair_damping(pair) * area(sf)
end if
call add_contact_pair_tan(kmat, max_nodes, fnnode(sf), fconn(:,sf), &
fnnode(best), fconn(:,best), coeff, nrm, ierr)
if (total_weight .le. tiny(ONE)) cycle
do mf = 1, nf
if (sf .eq. mf) cycle
if (.not. facet_target_matches(elem_id(mf), contact_pair_master(pair))) cycle
if (.not. contact_spatial_candidate(pair, sf, mf, nf, center, radius)) cycle
if (facet_nodes_share(max_nodes, fnnode(sf), fconn(:,sf), &
fnnode(mf), fconn(:,mf))) cycle
call pair_contact_gap(pair, sf, mf, nf, max_nodes, fnnode, &
x, vnod, normal, gap, vn, pair_weight, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
end if
if (gap .ge. ZERO) cycle
share = pair_weight / total_weight
nrm = normalized_contact_normal(normal(:,mf), ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
coeff = contact_pair_penalty(pair) * area(sf) * share
if (vn .lt. ZERO) then
coeff = coeff + velocity_scale * contact_pair_damping(pair) * area(sf) * share
end if
ktan = ZERO
do idir = 1, NDIM
do jdir = 1, NDIM
ktan(idir,jdir) = coeff * nrm(idir) * nrm(jdir)
if (mu .gt. ZERO) then
if (idir .eq. jdir) ktan(idir,jdir) = ktan(idir,jdir) + mu * coeff
ktan(idir,jdir) = ktan(idir,jdir) - mu * coeff * nrm(idir) * nrm(jdir)
end if
end do
end do
call add_contact_pair_tan_matrix(kmat, max_nodes, fnnode(sf), fconn(:,sf), &
fnnode(mf), fconn(:,mf), ktan, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
end do
end do
ierr = FEM_SUCCESS
@@ -495,7 +559,10 @@ contains
if (allocated(x)) deallocate(x)
if (allocated(vnod)) deallocate(vnod)
if (allocated(normal)) deallocate(normal)
if (allocated(center)) deallocate(center)
if (allocated(velc)) deallocate(velc)
if (allocated(area)) deallocate(area)
if (allocated(radius)) deallocate(radius)
end subroutine apply_contact_pair_tan_one
logical function facet_target_matches(elem_ext, target)
@@ -552,8 +619,89 @@ contains
end do
end function facet_nodes_share
logical function contact_spatial_candidate(pair, sf, mf, nf, center, radius)
integer, intent(in) :: pair
integer, intent(in) :: sf
integer, intent(in) :: mf
integer, intent(in) :: nf
real(rk), intent(in) :: center(NDIM,nf)
real(rk), intent(in) :: radius(nf)
real(rk) :: delta(NDIM)
real(rk) :: limit
delta = center(:,sf) - center(:,mf)
limit = radius(sf) + radius(mf)
if (allocated(contact_pair_search)) then
if (pair .ge. 1 .and. pair .le. size(contact_pair_search)) then
limit = limit + contact_pair_search(pair)
end if
end if
limit = max(limit, tiny(ONE))
contact_spatial_candidate = sum(delta * delta) .le. limit * limit + tiny(ONE)
end function contact_spatial_candidate
real(rk) function contact_pair_friction_value(pair)
integer, intent(in) :: pair
contact_pair_friction_value = ZERO
if (.not. allocated(contact_pair_friction)) return
if (pair .lt. 1 .or. pair .gt. size(contact_pair_friction)) return
contact_pair_friction_value = max(ZERO, contact_pair_friction(pair))
end function contact_pair_friction_value
function normalized_contact_normal(raw_normal, ierr) result(nrm)
real(rk), intent(in) :: raw_normal(NDIM)
integer, intent(out) :: ierr
real(rk) :: nrm(NDIM)
real(rk) :: nlen
nrm = raw_normal
nlen = sqrt(sum(nrm * nrm))
if (nlen .le. tiny(ONE)) then
call error_set(FEM_ERR_COUPLING, 'contact pair master facet normal is zero', ierr)
return
end if
nrm = nrm / nlen
ierr = FEM_SUCCESS
end function normalized_contact_normal
subroutine contact_tangent_direction(sf, mf, nf, max_nodes, fnnode, &
vnod, normal, tdir, vt_norm)
integer, intent(in) :: sf
integer, intent(in) :: mf
integer, intent(in) :: nf
integer, intent(in) :: max_nodes
integer, intent(in) :: fnnode(nf)
real(rk), intent(in) :: vnod(NDIM,max_nodes,nf)
real(rk), intent(in) :: normal(NDIM)
real(rk), intent(out) :: tdir(NDIM)
real(rk), intent(out) :: vt_norm
real(rk) :: sv(NDIM)
real(rk) :: mv(NDIM)
integer :: local_node
sv = ZERO
mv = ZERO
do local_node = 1, fnnode(sf)
sv = sv + vnod(:,local_node,sf)
end do
do local_node = 1, fnnode(mf)
mv = mv + vnod(:,local_node,mf)
end do
sv = sv / real(fnnode(sf), rk)
mv = mv / real(fnnode(mf), rk)
tdir = (sv - mv) - dot_product(sv - mv, normal) * normal
vt_norm = sqrt(sum(tdir * tdir))
if (vt_norm .gt. tiny(ONE)) then
tdir = tdir / vt_norm
else
tdir = ZERO
vt_norm = ZERO
end if
end subroutine contact_tangent_direction
subroutine pair_contact_gap(pair, sf, mf, nf, max_nodes, fnnode, x, vnod, &
normal, gap, vn, ierr)
normal, gap, vn, pair_weight, ierr)
integer, intent(in) :: pair
integer, intent(in) :: sf
integer, intent(in) :: mf
@@ -565,6 +713,7 @@ contains
real(rk), intent(in) :: normal(NDIM,nf)
real(rk), intent(out) :: gap
real(rk), intent(out) :: vn
real(rk), intent(out) :: pair_weight
integer, intent(out) :: ierr
real(rk) :: sc(NDIM)
real(rk) :: mc(NDIM)
@@ -576,7 +725,9 @@ contains
real(rk) :: radius
real(rk) :: search
real(rk) :: dist
real(rk) :: support
pair_weight = ZERO
call facet_center_velocity(sf, nf, max_nodes, fnnode, x, vnod, sc, sv)
call facet_center_velocity(mf, nf, max_nodes, fnnode, x, vnod, mc, mv)
@@ -605,7 +756,12 @@ contains
projection = sc - gap * nrm
dist = sqrt(sum((projection - mc) * (projection - mc)))
if (dist .gt. radius + max(search, tiny(ONE))) gap = ZERO
support = radius + max(search, tiny(ONE))
if (dist .gt. support) then
gap = ZERO
else
pair_weight = max(tiny(ONE), ONE - dist / max(support, tiny(ONE)))
end if
ierr = FEM_SUCCESS
end subroutine pair_contact_gap
@@ -651,15 +807,14 @@ contains
end do
end function facet_radius_value
subroutine add_contact_pair_force(max_nodes, nslave, slave_conn, nmaster, &
master_conn, force_mag, normal, ierr)
subroutine add_contact_pair_force_vec(max_nodes, nslave, slave_conn, nmaster, &
master_conn, force_vec, ierr)
integer, intent(in) :: max_nodes
integer, intent(in) :: nslave
integer, intent(in) :: nmaster
integer, intent(in) :: slave_conn(max_nodes)
integer, intent(in) :: master_conn(max_nodes)
real(rk), intent(in) :: force_mag
real(rk), intent(in) :: normal(NDIM)
real(rk), intent(in) :: force_vec(NDIM)
integer, intent(out) :: ierr
integer :: local_node
integer :: node
@@ -667,7 +822,7 @@ contains
integer :: dof
real(rk) :: weight
weight = force_mag / real(nslave, rk)
weight = ONE / real(nslave, rk)
do local_node = 1, nslave
node = database_find_node(slave_conn(local_node))
if (node .eq. 0) then
@@ -676,11 +831,11 @@ contains
end if
do idir = 1, NDIM
dof = dof_id(idir,node)
if (dof .gt. 0) fcontact(dof) = fcontact(dof) + weight * normal(idir)
if (dof .gt. 0) fcontact(dof) = fcontact(dof) + weight * force_vec(idir)
end do
end do
weight = force_mag / real(nmaster, rk)
weight = ONE / real(nmaster, rk)
do local_node = 1, nmaster
node = database_find_node(master_conn(local_node))
if (node .eq. 0) then
@@ -689,30 +844,29 @@ contains
end if
do idir = 1, NDIM
dof = dof_id(idir,node)
if (dof .gt. 0) fcontact(dof) = fcontact(dof) - weight * normal(idir)
if (dof .gt. 0) fcontact(dof) = fcontact(dof) - weight * force_vec(idir)
end do
end do
ierr = FEM_SUCCESS
end subroutine add_contact_pair_force
end subroutine add_contact_pair_force_vec
subroutine add_contact_pair_tan(kmat, max_nodes, nslave, slave_conn, &
nmaster, master_conn, coeff, normal, ierr)
subroutine add_contact_pair_tan_matrix(kmat, max_nodes, nslave, slave_conn, &
nmaster, master_conn, kmat3, ierr)
type(csr_matrix), intent(inout) :: kmat
integer, intent(in) :: max_nodes
integer, intent(in) :: nslave
integer, intent(in) :: nmaster
integer, intent(in) :: slave_conn(max_nodes)
integer, intent(in) :: master_conn(max_nodes)
real(rk), intent(in) :: coeff
real(rk), intent(in) :: normal(NDIM)
real(rk), intent(in) :: kmat3(NDIM,NDIM)
integer, intent(out) :: ierr
integer :: i
integer :: j
real(rk) :: ws
real(rk) :: wm
if (abs(coeff) .le. tiny(ONE)) then
if (maxval(abs(kmat3)) .le. tiny(ONE)) then
ierr = FEM_SUCCESS
return
end if
@@ -721,40 +875,40 @@ contains
wm = ONE / real(nmaster, rk)
do i = 1, nslave
do j = 1, nslave
call add_contact_pair_block(kmat, slave_conn(i), slave_conn(j), &
coeff * ws * ws, normal, ierr)
call add_contact_pair_mat_block(kmat, slave_conn(i), slave_conn(j), &
ws * ws, kmat3, ierr)
if (ierr .ne. FEM_SUCCESS) return
end do
do j = 1, nmaster
call add_contact_pair_block(kmat, slave_conn(i), master_conn(j), &
-coeff * ws * wm, normal, ierr)
call add_contact_pair_mat_block(kmat, slave_conn(i), master_conn(j), &
-ws * wm, kmat3, ierr)
if (ierr .ne. FEM_SUCCESS) return
end do
end do
do i = 1, nmaster
do j = 1, nslave
call add_contact_pair_block(kmat, master_conn(i), slave_conn(j), &
-coeff * wm * ws, normal, ierr)
call add_contact_pair_mat_block(kmat, master_conn(i), slave_conn(j), &
-wm * ws, kmat3, ierr)
if (ierr .ne. FEM_SUCCESS) return
end do
do j = 1, nmaster
call add_contact_pair_block(kmat, master_conn(i), master_conn(j), &
coeff * wm * wm, normal, ierr)
call add_contact_pair_mat_block(kmat, master_conn(i), master_conn(j), &
wm * wm, kmat3, ierr)
if (ierr .ne. FEM_SUCCESS) return
end do
end do
ierr = FEM_SUCCESS
end subroutine add_contact_pair_tan
end subroutine add_contact_pair_tan_matrix
subroutine add_contact_pair_block(kmat, node_a_ext, node_b_ext, scale, &
normal, ierr)
subroutine add_contact_pair_mat_block(kmat, node_a_ext, node_b_ext, scale, &
kmat3, ierr)
type(csr_matrix), intent(inout) :: kmat
integer, intent(in) :: node_a_ext
integer, intent(in) :: node_b_ext
real(rk), intent(in) :: scale
real(rk), intent(in) :: normal(NDIM)
real(rk), intent(in) :: kmat3(NDIM,NDIM)
integer, intent(out) :: ierr
integer :: node_a
integer :: node_b
@@ -776,14 +930,13 @@ contains
do jdir = 1, NDIM
col = dof_id(jdir,node_b)
if (col .gt. 0) then
call csr_add_value(kmat, row, col, &
scale * normal(idir) * normal(jdir), ierr)
call csr_add_value(kmat, row, col, scale * kmat3(idir,jdir), ierr)
if (ierr .ne. FEM_SUCCESS) return
end if
end do
end do
ierr = FEM_SUCCESS
end subroutine add_contact_pair_block
end subroutine add_contact_pair_mat_block
end module fem_contact
+40 -9
View File
@@ -217,7 +217,7 @@ contains
if (allocated(elem_gp_start)) then
if (elem .le. size(elem_gp_start)) gp = elem_gp_start(elem)
end if
call shell_apply_mem_tangent(mat, thickness, gp, dmem, ierr)
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)
@@ -257,7 +257,9 @@ contains
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)
@@ -345,16 +347,19 @@ contains
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_mem_tangent(mat, thickness, gp, dmem_gp, ierr)
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, bben)) + &
weight * matmul(transpose(bshr), matmul(dshr, bshr))
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)
@@ -388,7 +393,9 @@ contains
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)
@@ -477,16 +484,19 @@ contains
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_mem_tangent(mat, thickness, gp, dmem_gp, ierr)
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, bben)) + &
weight * matmul(transpose(bshr), matmul(dshr, bshr))
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)
@@ -939,13 +949,17 @@ contains
dshr(2,2) = coeff_shr
end subroutine shell_constitutive
subroutine shell_apply_mem_tangent(mat, thickness, gp, dmem, ierr)
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
@@ -982,8 +996,25 @@ contains
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_mem_tangent
end subroutine shell_apply_section_tangent
subroutine shell_b_matrices(nlocal, nshape, dndx, dndy, bmem, bben, bshr)
integer, intent(in) :: nlocal
+13 -1
View File
@@ -146,6 +146,7 @@ module fem_database
real(rk), allocatable :: contact_pair_penalty(:)
real(rk), allocatable :: contact_pair_damping(:)
real(rk), allocatable :: contact_pair_search(:)
real(rk), allocatable :: contact_pair_friction(:)
contains
@@ -612,13 +613,15 @@ contains
if (allocated(contact_pair_penalty)) deallocate(contact_pair_penalty)
if (allocated(contact_pair_damping)) deallocate(contact_pair_damping)
if (allocated(contact_pair_search)) deallocate(contact_pair_search)
if (allocated(contact_pair_friction)) deallocate(contact_pair_friction)
ncontact_pair = num_pairs
if (num_pairs .gt. 0) then
allocate(contact_pair_slave(num_pairs), contact_pair_master(num_pairs), &
contact_pair_penalty(num_pairs), contact_pair_damping(num_pairs), &
contact_pair_search(num_pairs), stat=stat)
contact_pair_search(num_pairs), contact_pair_friction(num_pairs), &
stat=stat)
if (stat .ne. 0) then
ncontact_pair = 0
call error_set(FEM_ERR_INTERNAL, 'failed to allocate contact pair arrays', ierr)
@@ -629,6 +632,7 @@ contains
contact_pair_penalty = ZERO
contact_pair_damping = ZERO
contact_pair_search = ZERO
contact_pair_friction = ZERO
end if
ierr = FEM_SUCCESS
@@ -823,6 +827,7 @@ contains
if (allocated(contact_pair_penalty)) contact_pair_penalty = ZERO
if (allocated(contact_pair_damping)) contact_pair_damping = ZERO
if (allocated(contact_pair_search)) contact_pair_search = ZERO
if (allocated(contact_pair_friction)) contact_pair_friction = ZERO
ierr = FEM_SUCCESS
end subroutine database_initialize
@@ -1435,6 +1440,12 @@ contains
call error_set(FEM_ERR_INPUT, 'contact pair search distance must be non-negative', ierr)
return
end if
if (allocated(contact_pair_friction)) then
if (contact_pair_friction(item) .lt. ZERO) then
call error_set(FEM_ERR_INPUT, 'contact pair friction must be non-negative', ierr)
return
end if
end if
end do
ierr = FEM_SUCCESS
@@ -1608,6 +1619,7 @@ contains
if (allocated(contact_pair_penalty)) deallocate(contact_pair_penalty)
if (allocated(contact_pair_damping)) deallocate(contact_pair_damping)
if (allocated(contact_pair_search)) deallocate(contact_pair_search)
if (allocated(contact_pair_friction)) deallocate(contact_pair_friction)
nnode = 0
nelem = 0