Add analytical rigid plane contact
This commit is contained in:
@@ -5,6 +5,7 @@ module fem_contact
|
||||
use fem_sparse_csr
|
||||
use fem_coupling
|
||||
use fem_contact_state
|
||||
use fem_database_surface, only: db_surface_node_count, db_get_surface_nodes
|
||||
use fem_contact_force, only: apply_contact_pair_forces
|
||||
use fem_contact_tangent, only: apply_contact_pair_tangent
|
||||
implicit none
|
||||
@@ -32,6 +33,8 @@ contains
|
||||
call apply_contact_plane(plane, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end do
|
||||
call apply_analytic_pair_forces(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
call apply_contact_pair_forces(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
@@ -48,6 +51,8 @@ contains
|
||||
call apply_contact_plane_tangent(plane, kmat, velocity_scale, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end do
|
||||
call apply_analytic_pair_tangents(kmat, velocity_scale, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
call apply_contact_pair_tangent(kmat, velocity_scale, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
@@ -286,6 +291,339 @@ contains
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine apply_contact_node_tangent
|
||||
|
||||
subroutine apply_analytic_pair_forces(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
integer :: pair
|
||||
real(rk) :: normal(NDIM)
|
||||
real(rk) :: offset
|
||||
|
||||
do pair = 1, ncontact_pair
|
||||
if (.not. pair_has_analytic_master(pair)) cycle
|
||||
call pair_analytic_plane(pair, normal, offset, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
call apply_analytic_force_target(pair, normal, offset, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end do
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine apply_analytic_pair_forces
|
||||
|
||||
subroutine apply_analytic_pair_tangents(kmat, velocity_scale, ierr)
|
||||
type(csr_matrix), intent(inout) :: kmat
|
||||
real(rk), intent(in) :: velocity_scale
|
||||
integer, intent(out) :: ierr
|
||||
integer :: pair
|
||||
real(rk) :: normal(NDIM)
|
||||
real(rk) :: offset
|
||||
|
||||
do pair = 1, ncontact_pair
|
||||
if (.not. pair_has_analytic_master(pair)) cycle
|
||||
call pair_analytic_plane(pair, normal, offset, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
call apply_analytic_tangent_target(pair, normal, offset, kmat, &
|
||||
velocity_scale, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end do
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine apply_analytic_pair_tangents
|
||||
|
||||
logical function pair_has_analytic_master(pair)
|
||||
integer, intent(in) :: pair
|
||||
integer :: surface_id
|
||||
|
||||
pair_has_analytic_master = .false.
|
||||
if (pair .lt. 1 .or. pair .gt. ncontact_pair) return
|
||||
surface_id = database_find_surface(contact_pair_master(pair))
|
||||
if (surface_id .le. 0) return
|
||||
pair_has_analytic_master = trim(surface_type(surface_id)) .eq. 'ANALYTICAL'
|
||||
end function pair_has_analytic_master
|
||||
|
||||
subroutine pair_analytic_plane(pair, normal, offset, ierr)
|
||||
integer, intent(in) :: pair
|
||||
real(rk), intent(out) :: normal(NDIM)
|
||||
real(rk), intent(out) :: offset
|
||||
integer, intent(out) :: ierr
|
||||
integer :: surface_id
|
||||
real(rk) :: norm_n
|
||||
|
||||
surface_id = database_find_surface(contact_pair_master(pair))
|
||||
if (surface_id .le. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'analytical contact pair has unknown master', ierr)
|
||||
return
|
||||
end if
|
||||
normal = surface_plane_normal(:,surface_id)
|
||||
norm_n = sqrt(sum(normal * normal))
|
||||
if (norm_n .le. tiny(ONE)) then
|
||||
call error_set(FEM_ERR_INPUT, 'analytical contact normal must be non-zero', ierr)
|
||||
return
|
||||
end if
|
||||
normal = normal / norm_n
|
||||
offset = surface_plane_offset(surface_id) / norm_n
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine pair_analytic_plane
|
||||
|
||||
subroutine apply_analytic_force_target(pair, normal, offset, ierr)
|
||||
integer, intent(in) :: pair
|
||||
real(rk), intent(in) :: normal(NDIM)
|
||||
real(rk), intent(in) :: offset
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
call apply_analytic_target_nodes(pair, normal, offset, .false., &
|
||||
0.0_rk, ierr)
|
||||
end subroutine apply_analytic_force_target
|
||||
|
||||
subroutine apply_analytic_tangent_target(pair, normal, offset, kmat, &
|
||||
velocity_scale, ierr)
|
||||
integer, intent(in) :: pair
|
||||
real(rk), intent(in) :: normal(NDIM)
|
||||
real(rk), intent(in) :: offset
|
||||
type(csr_matrix), intent(inout) :: kmat
|
||||
real(rk), intent(in) :: velocity_scale
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
call apply_analytic_target_nodes(pair, normal, offset, .true., &
|
||||
velocity_scale, ierr, kmat)
|
||||
end subroutine apply_analytic_tangent_target
|
||||
|
||||
subroutine apply_analytic_target_nodes(pair, normal, offset, tangent_mode, &
|
||||
velocity_scale, ierr, kmat)
|
||||
integer, intent(in) :: pair
|
||||
real(rk), intent(in) :: normal(NDIM)
|
||||
real(rk), intent(in) :: offset
|
||||
logical, intent(in) :: tangent_mode
|
||||
real(rk), intent(in) :: velocity_scale
|
||||
integer, intent(out) :: ierr
|
||||
type(csr_matrix), intent(inout), optional :: kmat
|
||||
character(len=NAME_LEN) :: target
|
||||
|
||||
target = adjustl(contact_pair_slave(pair))
|
||||
if (len_trim(target) .eq. 0 .or. trim(target) .eq. 'ALL' .or. &
|
||||
trim(target) .eq. 'all') then
|
||||
call apply_analytic_all_nodes(pair, normal, offset, tangent_mode, &
|
||||
velocity_scale, ierr, kmat)
|
||||
else
|
||||
call apply_analytic_named_target(pair, target, normal, offset, &
|
||||
tangent_mode, velocity_scale, ierr, kmat)
|
||||
end if
|
||||
end subroutine apply_analytic_target_nodes
|
||||
|
||||
subroutine apply_analytic_all_nodes(pair, normal, offset, tangent_mode, &
|
||||
velocity_scale, ierr, kmat)
|
||||
integer, intent(in) :: pair
|
||||
real(rk), intent(in) :: normal(NDIM)
|
||||
real(rk), intent(in) :: offset
|
||||
logical, intent(in) :: tangent_mode
|
||||
real(rk), intent(in) :: velocity_scale
|
||||
integer, intent(out) :: ierr
|
||||
type(csr_matrix), intent(inout), optional :: kmat
|
||||
integer :: node
|
||||
|
||||
do node = 1, nnode
|
||||
call apply_analytic_node(pair, node, normal, offset, tangent_mode, &
|
||||
velocity_scale, ierr, kmat)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end do
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine apply_analytic_all_nodes
|
||||
|
||||
subroutine apply_analytic_named_target(pair, target, normal, offset, &
|
||||
tangent_mode, velocity_scale, ierr, kmat)
|
||||
integer, intent(in) :: pair
|
||||
character(len=*), intent(in) :: target
|
||||
real(rk), intent(in) :: normal(NDIM)
|
||||
real(rk), intent(in) :: offset
|
||||
logical, intent(in) :: tangent_mode
|
||||
real(rk), intent(in) :: velocity_scale
|
||||
integer, intent(out) :: ierr
|
||||
type(csr_matrix), intent(inout), optional :: kmat
|
||||
integer :: external_id
|
||||
integer :: ios
|
||||
integer :: node
|
||||
integer :: set_id
|
||||
|
||||
read(target,*,iostat=ios) external_id
|
||||
if (ios .eq. 0) then
|
||||
node = database_find_node(external_id)
|
||||
if (node .eq. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'analytical contact slave node is unknown', ierr)
|
||||
return
|
||||
end if
|
||||
call apply_analytic_node(pair, node, normal, offset, tangent_mode, &
|
||||
velocity_scale, ierr, kmat)
|
||||
return
|
||||
end if
|
||||
|
||||
set_id = database_find_nset(target)
|
||||
if (set_id .ne. 0) then
|
||||
call apply_analytic_nset(pair, set_id, normal, offset, tangent_mode, &
|
||||
velocity_scale, ierr, kmat)
|
||||
else
|
||||
call apply_analytic_node_surface(pair, target, normal, offset, &
|
||||
tangent_mode, velocity_scale, ierr, kmat)
|
||||
end if
|
||||
end subroutine apply_analytic_named_target
|
||||
|
||||
subroutine apply_analytic_nset(pair, set_id, normal, offset, tangent_mode, &
|
||||
velocity_scale, ierr, kmat)
|
||||
integer, intent(in) :: pair
|
||||
integer, intent(in) :: set_id
|
||||
real(rk), intent(in) :: normal(NDIM)
|
||||
real(rk), intent(in) :: offset
|
||||
logical, intent(in) :: tangent_mode
|
||||
real(rk), intent(in) :: velocity_scale
|
||||
integer, intent(out) :: ierr
|
||||
type(csr_matrix), intent(inout), optional :: kmat
|
||||
integer :: pos
|
||||
integer :: node
|
||||
|
||||
do pos = nset_start(set_id), nset_start(set_id) + nset_count(set_id) - 1
|
||||
node = database_find_node(nset_items(pos))
|
||||
if (node .eq. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'analytical contact nset has unknown node', ierr)
|
||||
return
|
||||
end if
|
||||
call apply_analytic_node(pair, node, normal, offset, tangent_mode, &
|
||||
velocity_scale, ierr, kmat)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end do
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine apply_analytic_nset
|
||||
|
||||
subroutine apply_analytic_node_surface(pair, target, normal, offset, &
|
||||
tangent_mode, velocity_scale, ierr, kmat)
|
||||
integer, intent(in) :: pair
|
||||
character(len=*), intent(in) :: target
|
||||
real(rk), intent(in) :: normal(NDIM)
|
||||
real(rk), intent(in) :: offset
|
||||
logical, intent(in) :: tangent_mode
|
||||
real(rk), intent(in) :: velocity_scale
|
||||
integer, intent(out) :: ierr
|
||||
type(csr_matrix), intent(inout), optional :: kmat
|
||||
integer, allocatable :: node_ids(:)
|
||||
integer :: count
|
||||
integer :: out_count
|
||||
integer :: item
|
||||
integer :: node
|
||||
integer :: stat
|
||||
|
||||
call db_surface_node_count(target, count, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
allocate(node_ids(max(1, count)), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'failed to allocate analytical contact nodes', ierr)
|
||||
return
|
||||
end if
|
||||
call db_get_surface_nodes(target, count, node_ids, out_count, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
do item = 1, out_count
|
||||
node = database_find_node(node_ids(item))
|
||||
call apply_analytic_node(pair, node, normal, offset, tangent_mode, &
|
||||
velocity_scale, ierr, kmat)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
end do
|
||||
900 continue
|
||||
deallocate(node_ids)
|
||||
end subroutine apply_analytic_node_surface
|
||||
|
||||
subroutine apply_analytic_node(pair, node, normal, offset, tangent_mode, &
|
||||
velocity_scale, ierr, kmat)
|
||||
integer, intent(in) :: pair
|
||||
integer, intent(in) :: node
|
||||
real(rk), intent(in) :: normal(NDIM)
|
||||
real(rk), intent(in) :: offset
|
||||
logical, intent(in) :: tangent_mode
|
||||
real(rk), intent(in) :: velocity_scale
|
||||
integer, intent(out) :: ierr
|
||||
type(csr_matrix), intent(inout), optional :: kmat
|
||||
real(rk) :: gap
|
||||
real(rk) :: velocity(NDIM)
|
||||
real(rk) :: position(NDIM)
|
||||
integer :: idir
|
||||
integer :: dof
|
||||
|
||||
position = coord0(:,node)
|
||||
velocity = ZERO
|
||||
do idir = 1, NDIM
|
||||
dof = dof_id(idir,node)
|
||||
if (dof .gt. 0) then
|
||||
position(idir) = position(idir) + u(dof)
|
||||
if (allocated(v)) velocity(idir) = v(dof)
|
||||
end if
|
||||
end do
|
||||
gap = dot_product(normal, position) - offset
|
||||
if (gap .lt. ZERO) then
|
||||
if (tangent_mode) then
|
||||
call add_analytic_node_tangent(pair, node, normal, velocity, &
|
||||
velocity_scale, kmat, ierr)
|
||||
else
|
||||
call add_analytic_node_force(pair, node, normal, velocity, -gap, ierr)
|
||||
end if
|
||||
return
|
||||
end if
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine apply_analytic_node
|
||||
|
||||
subroutine add_analytic_node_force(pair, node, normal, velocity, penetration, ierr)
|
||||
integer, intent(in) :: pair
|
||||
integer, intent(in) :: node
|
||||
real(rk), intent(in) :: normal(NDIM)
|
||||
real(rk), intent(in) :: velocity(NDIM)
|
||||
real(rk), intent(in) :: penetration
|
||||
integer, intent(out) :: ierr
|
||||
real(rk) :: force_mag
|
||||
real(rk) :: force_vec(NDIM)
|
||||
real(rk) :: vn
|
||||
integer :: idir
|
||||
integer :: dof
|
||||
|
||||
vn = dot_product(normal, velocity)
|
||||
force_mag = contact_pair_penalty(pair) * penetration
|
||||
if (vn .lt. ZERO) force_mag = force_mag + contact_pair_damping(pair) * (-vn)
|
||||
force_vec = force_mag * normal
|
||||
do idir = 1, NDIM
|
||||
dof = dof_id(idir,node)
|
||||
if (dof .gt. 0) fcontact(dof) = fcontact(dof) + force_vec(idir)
|
||||
end do
|
||||
call contact_record_status(pair, penetration, force_vec)
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine add_analytic_node_force
|
||||
|
||||
subroutine add_analytic_node_tangent(pair, node, normal, velocity, &
|
||||
velocity_scale, kmat, ierr)
|
||||
integer, intent(in) :: pair
|
||||
integer, intent(in) :: node
|
||||
real(rk), intent(in) :: normal(NDIM)
|
||||
real(rk), intent(in) :: velocity(NDIM)
|
||||
real(rk), intent(in) :: velocity_scale
|
||||
type(csr_matrix), intent(inout), optional :: kmat
|
||||
integer, intent(out) :: ierr
|
||||
real(rk) :: coeff
|
||||
integer :: idir
|
||||
integer :: jdir
|
||||
integer :: row
|
||||
integer :: col
|
||||
|
||||
if (.not. present(kmat)) then
|
||||
ierr = FEM_SUCCESS
|
||||
return
|
||||
end if
|
||||
coeff = contact_pair_penalty(pair)
|
||||
if (dot_product(normal, velocity) .lt. ZERO) then
|
||||
coeff = coeff + velocity_scale * contact_pair_damping(pair)
|
||||
end if
|
||||
do idir = 1, NDIM
|
||||
row = dof_id(idir,node)
|
||||
if (row .le. 0) cycle
|
||||
do jdir = 1, NDIM
|
||||
col = dof_id(jdir,node)
|
||||
if (col .gt. 0) then
|
||||
call csr_add_value(kmat, row, col, coeff * normal(idir) * normal(jdir), ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end if
|
||||
end do
|
||||
end do
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine add_analytic_node_tangent
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ subroutine start_nset(set_index, item_pos, set_name_value)
|
||||
|
||||
surface_name(surface_index) = surface_name_value
|
||||
if (allocated(surface_type)) surface_type(surface_index) = surface_type_value
|
||||
if (allocated(surface_plane_normal)) surface_plane_normal(:,surface_index) = ZERO
|
||||
if (allocated(surface_plane_offset)) surface_plane_offset(surface_index) = ZERO
|
||||
surface_start(surface_index) = item_pos + 1
|
||||
surface_count(surface_index) = 0
|
||||
end subroutine start_surface
|
||||
@@ -84,6 +86,10 @@ subroutine start_nset(set_index, item_pos, set_name_value)
|
||||
call error_set(FEM_ERR_INPUT, '*SURFACE has more data lines than counted', ierr)
|
||||
return
|
||||
end if
|
||||
if (trim(surface_type(surface_index)) .eq. 'ANALYTICAL') then
|
||||
call add_analytical_surface_line(line, surface_index, item_pos, ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call csv_token(line, 1, token)
|
||||
if (len_trim(token) .eq. 0) then
|
||||
@@ -109,6 +115,66 @@ subroutine start_nset(set_index, item_pos, set_name_value)
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine add_surface_line
|
||||
|
||||
subroutine add_analytical_surface_line(line, surface_index, item_pos, ierr)
|
||||
character(len=*), intent(in) :: line
|
||||
integer, intent(in) :: surface_index
|
||||
integer, intent(inout) :: item_pos
|
||||
integer, intent(out) :: ierr
|
||||
character(len=LINE_LEN) :: token
|
||||
character(len=NAME_LEN) :: kind
|
||||
real(rk) :: normal(NDIM)
|
||||
real(rk) :: offset
|
||||
integer :: idir
|
||||
|
||||
if (surface_count(surface_index) .gt. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'analytical surface supports one plane line', ierr)
|
||||
return
|
||||
end if
|
||||
call csv_token(line, 1, token)
|
||||
call strip_keyword_quotes(token)
|
||||
call to_upper(token, kind)
|
||||
if (trim(kind) .ne. 'PLANE') then
|
||||
call error_set(FEM_ERR_INPUT, 'analytical surface line must start with PLANE', ierr)
|
||||
return
|
||||
end if
|
||||
do idir = 1, NDIM
|
||||
call read_surface_real(line, idir + 1, normal(idir), ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end do
|
||||
call read_surface_real(line, 5, offset, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
item_pos = item_pos + 1
|
||||
if (allocated(surface_owner)) surface_owner(item_pos) = surface_index
|
||||
surface_target(item_pos) = 'PLANE'
|
||||
surface_face(item_pos) = ' '
|
||||
surface_plane_normal(:,surface_index) = normal
|
||||
surface_plane_offset(surface_index) = offset
|
||||
surface_count(surface_index) = surface_count(surface_index) + 1
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine add_analytical_surface_line
|
||||
|
||||
subroutine read_surface_real(line, field_index, value, ierr)
|
||||
character(len=*), intent(in) :: line
|
||||
integer, intent(in) :: field_index
|
||||
real(rk), intent(out) :: value
|
||||
integer, intent(out) :: ierr
|
||||
character(len=LINE_LEN) :: token
|
||||
integer :: ios
|
||||
|
||||
call csv_token(line, field_index, token)
|
||||
if (len_trim(token) .eq. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'analytical surface plane data is incomplete', ierr)
|
||||
return
|
||||
end if
|
||||
read(token,*,iostat=ios) value
|
||||
if (ios .ne. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'failed to parse analytical surface plane data', ierr)
|
||||
return
|
||||
end if
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine read_surface_real
|
||||
|
||||
subroutine add_set_line(line, generate_mode, set_index, item_pos, is_node_set, ierr)
|
||||
character(len=*), intent(in) :: line
|
||||
logical, intent(in) :: generate_mode
|
||||
|
||||
@@ -924,8 +924,10 @@ contains
|
||||
end if
|
||||
call get_keyword_value(line, 'TYPE', type_value)
|
||||
if (len_trim(type_value) .eq. 0) type_value = 'ELEMENT'
|
||||
if (trim(type_value) .ne. 'ELEMENT' .and. trim(type_value) .ne. 'NODE') then
|
||||
call error_set(FEM_ERR_INPUT, 'only *SURFACE TYPE=ELEMENT/NODE is supported', ierr)
|
||||
if (trim(type_value) .ne. 'ELEMENT' .and. trim(type_value) .ne. 'NODE' .and. &
|
||||
trim(type_value) .ne. 'ANALYTICAL') then
|
||||
call error_set(FEM_ERR_INPUT, &
|
||||
'only *SURFACE TYPE=ELEMENT/NODE/ANALYTICAL is supported', ierr)
|
||||
return
|
||||
end if
|
||||
call get_keyword_value(line, 'OP', op_value)
|
||||
|
||||
+80
-85
@@ -548,7 +548,7 @@ contains
|
||||
return
|
||||
end if
|
||||
|
||||
call db_free_contact_property_arrays()
|
||||
call db_state_free_contact_props()
|
||||
n_contact_property = num_props
|
||||
|
||||
if (num_props .gt. 0) then
|
||||
@@ -591,13 +591,7 @@ contains
|
||||
return
|
||||
end if
|
||||
|
||||
if (allocated(surface_name)) deallocate(surface_name)
|
||||
if (allocated(surface_start)) deallocate(surface_start)
|
||||
if (allocated(surface_count)) deallocate(surface_count)
|
||||
if (allocated(surface_owner)) deallocate(surface_owner)
|
||||
if (allocated(surface_type)) deallocate(surface_type)
|
||||
if (allocated(surface_target)) deallocate(surface_target)
|
||||
if (allocated(surface_face)) deallocate(surface_face)
|
||||
call db_state_free_surface_arrays()
|
||||
|
||||
n_surface = num_surfaces
|
||||
n_surface_item = num_items
|
||||
@@ -605,6 +599,8 @@ contains
|
||||
if (num_surfaces .gt. 0) then
|
||||
allocate(surface_name(num_surfaces), surface_start(num_surfaces), &
|
||||
surface_count(num_surfaces), surface_type(num_surfaces), &
|
||||
surface_plane_normal(NDIM,num_surfaces), &
|
||||
surface_plane_offset(num_surfaces), &
|
||||
stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
n_surface = 0
|
||||
@@ -616,6 +612,8 @@ contains
|
||||
surface_start = 0
|
||||
surface_count = 0
|
||||
surface_type = 'ELEMENT'
|
||||
surface_plane_normal = ZERO
|
||||
surface_plane_offset = ZERO
|
||||
end if
|
||||
|
||||
if (num_items .gt. 0) then
|
||||
@@ -749,13 +747,7 @@ contains
|
||||
if (allocated(elset_start)) elset_start = 0
|
||||
if (allocated(elset_count)) elset_count = 0
|
||||
if (allocated(elset_items)) elset_items = 0
|
||||
if (allocated(surface_name)) surface_name = ' '
|
||||
if (allocated(surface_start)) surface_start = 0
|
||||
if (allocated(surface_count)) surface_count = 0
|
||||
if (allocated(surface_owner)) surface_owner = 0
|
||||
if (allocated(surface_type)) surface_type = 'ELEMENT'
|
||||
if (allocated(surface_target)) surface_target = ' '
|
||||
if (allocated(surface_face)) surface_face = ' '
|
||||
call db_state_init_surface_arrays()
|
||||
if (allocated(mat_name)) mat_name = ' '
|
||||
if (allocated(mat_plastic_model)) mat_plastic_model = 'ELASTIC'
|
||||
if (allocated(mat_rate_model)) mat_rate_model = 'NONE'
|
||||
@@ -1572,7 +1564,19 @@ contains
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
if (contact_target_is_node_surface(contact_pair_slave(item))) then
|
||||
if (contact_target_is_analytic(contact_pair_slave(item))) then
|
||||
call error_set(FEM_ERR_INPUT, &
|
||||
'contact pair slave analytical surface is not supported', ierr)
|
||||
return
|
||||
end if
|
||||
if (contact_target_is_analytic(contact_pair_master(item))) then
|
||||
if (.not. contact_plane_slave_ok(contact_pair_slave(item))) then
|
||||
call error_set(FEM_ERR_INPUT, &
|
||||
'analytical contact pair slave must be ALL, a node, nset, or node surface', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
else if (contact_target_is_node_surface(contact_pair_slave(item))) then
|
||||
call error_set(FEM_ERR_INPUT, &
|
||||
'contact pair slave node-based surface is not yet supported', ierr)
|
||||
return
|
||||
@@ -1637,7 +1641,11 @@ contains
|
||||
call error_set(FEM_ERR_INPUT, 'node surface data line must not have a face label', ierr)
|
||||
return
|
||||
end if
|
||||
else
|
||||
else if (trim(surface_type(item)) .eq. 'ANALYTICAL') then
|
||||
call validate_analytical_surface(item, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
exit
|
||||
else if (trim(surface_type(item)) .eq. 'ELEMENT') then
|
||||
if (.not. elem_or_elset_exists(surface_target(pos))) then
|
||||
call error_set(FEM_ERR_INPUT, 'surface references unknown element or elset', ierr)
|
||||
return
|
||||
@@ -1646,6 +1654,9 @@ contains
|
||||
call error_set(FEM_ERR_INPUT, 'surface has invalid face label', ierr)
|
||||
return
|
||||
end if
|
||||
else
|
||||
call error_set(FEM_ERR_INPUT, 'surface has unsupported TYPE', ierr)
|
||||
return
|
||||
end if
|
||||
end do
|
||||
end do
|
||||
@@ -1653,6 +1664,36 @@ contains
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine validate_surface_data
|
||||
|
||||
subroutine validate_analytical_surface(surface_id, ierr)
|
||||
integer, intent(in) :: surface_id
|
||||
integer, intent(out) :: ierr
|
||||
integer :: pos
|
||||
real(rk) :: normal_norm
|
||||
|
||||
if (surface_count(surface_id) .ne. 1) then
|
||||
call error_set(FEM_ERR_INPUT, 'analytical surface requires one PLANE line', ierr)
|
||||
return
|
||||
end if
|
||||
normal_norm = sqrt(sum(surface_plane_normal(:,surface_id) * &
|
||||
surface_plane_normal(:,surface_id)))
|
||||
if (normal_norm .le. tiny(ONE)) then
|
||||
call error_set(FEM_ERR_INPUT, 'analytical surface plane normal must be non-zero', ierr)
|
||||
return
|
||||
end if
|
||||
do pos = 1, n_surface_item
|
||||
if (surface_owner(pos) .ne. surface_id) cycle
|
||||
if (trim(surface_target(pos)) .ne. 'PLANE') then
|
||||
call error_set(FEM_ERR_INPUT, 'analytical surface supports only PLANE', ierr)
|
||||
return
|
||||
end if
|
||||
if (len_trim(surface_face(pos)) .ne. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'analytical surface line must not have a face label', ierr)
|
||||
return
|
||||
end if
|
||||
end do
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine validate_analytical_surface
|
||||
|
||||
logical function contact_target_is_node_surface(target)
|
||||
character(len=*), intent(in) :: target
|
||||
integer :: surface_id
|
||||
@@ -1664,6 +1705,17 @@ contains
|
||||
contact_target_is_node_surface = trim(surface_type(surface_id)) .eq. 'NODE'
|
||||
end function contact_target_is_node_surface
|
||||
|
||||
logical function contact_target_is_analytic(target)
|
||||
character(len=*), intent(in) :: target
|
||||
integer :: surface_id
|
||||
|
||||
contact_target_is_analytic = .false.
|
||||
surface_id = database_find_surface(adjustl(target))
|
||||
if (surface_id .le. 0) return
|
||||
if (.not. allocated(surface_type)) return
|
||||
contact_target_is_analytic = trim(surface_type(surface_id)) .eq. 'ANALYTICAL'
|
||||
end function contact_target_is_analytic
|
||||
|
||||
logical function contact_surface_target_exists(target)
|
||||
character(len=*), intent(in) :: target
|
||||
character(len=NAME_LEN) :: local_target
|
||||
@@ -1681,6 +1733,13 @@ contains
|
||||
end if
|
||||
end function contact_surface_target_exists
|
||||
|
||||
logical function contact_plane_slave_ok(target)
|
||||
character(len=*), intent(in) :: target
|
||||
|
||||
contact_plane_slave_ok = &
|
||||
node_or_nset_or_all_exists(target) .or. contact_target_is_node_surface(target)
|
||||
end function contact_plane_slave_ok
|
||||
|
||||
logical function node_or_nset_or_all_exists(target)
|
||||
character(len=*), intent(in) :: target
|
||||
character(len=NAME_LEN) :: local_target
|
||||
@@ -1840,13 +1899,7 @@ contains
|
||||
if (allocated(elset_start)) deallocate(elset_start)
|
||||
if (allocated(elset_count)) deallocate(elset_count)
|
||||
if (allocated(elset_items)) deallocate(elset_items)
|
||||
if (allocated(surface_name)) deallocate(surface_name)
|
||||
if (allocated(surface_start)) deallocate(surface_start)
|
||||
if (allocated(surface_count)) deallocate(surface_count)
|
||||
if (allocated(surface_owner)) deallocate(surface_owner)
|
||||
if (allocated(surface_type)) deallocate(surface_type)
|
||||
if (allocated(surface_target)) deallocate(surface_target)
|
||||
if (allocated(surface_face)) deallocate(surface_face)
|
||||
call db_state_free_surface_arrays()
|
||||
if (allocated(mat_name)) deallocate(mat_name)
|
||||
if (allocated(mat_plastic_model)) deallocate(mat_plastic_model)
|
||||
if (allocated(mat_rate_model)) deallocate(mat_rate_model)
|
||||
@@ -1918,73 +1971,15 @@ contains
|
||||
end subroutine database_finalize
|
||||
|
||||
subroutine db_free_contact_arrays()
|
||||
if (allocated(contact_target)) deallocate(contact_target)
|
||||
if (allocated(contact_normal)) deallocate(contact_normal)
|
||||
if (allocated(contact_offset)) deallocate(contact_offset)
|
||||
if (allocated(contact_penalty)) deallocate(contact_penalty)
|
||||
if (allocated(contact_damping)) deallocate(contact_damping)
|
||||
if (allocated(contact_pair_slave)) deallocate(contact_pair_slave)
|
||||
if (allocated(contact_pair_master)) deallocate(contact_pair_master)
|
||||
if (allocated(contact_pair_property)) deallocate(contact_pair_property)
|
||||
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)
|
||||
if (allocated(contact_pair_penalty_set)) deallocate(contact_pair_penalty_set)
|
||||
if (allocated(contact_pair_damping_set)) deallocate(contact_pair_damping_set)
|
||||
if (allocated(contact_pair_search_set)) deallocate(contact_pair_search_set)
|
||||
if (allocated(contact_pair_friction_set)) deallocate(contact_pair_friction_set)
|
||||
if (allocated(contact_pair_active)) deallocate(contact_pair_active)
|
||||
if (allocated(contact_pair_work)) deallocate(contact_pair_work)
|
||||
if (allocated(contact_pair_max_penetration)) deallocate(contact_pair_max_penetration)
|
||||
if (allocated(contact_pair_force_norm)) deallocate(contact_pair_force_norm)
|
||||
if (allocated(contact_pair_tangent_force)) deallocate(contact_pair_tangent_force)
|
||||
if (allocated(contact_pair_slip)) deallocate(contact_pair_slip)
|
||||
if (allocated(contact_pair_stick_count)) deallocate(contact_pair_stick_count)
|
||||
if (allocated(contact_pair_slip_count)) deallocate(contact_pair_slip_count)
|
||||
call db_free_contact_property_arrays()
|
||||
call db_state_free_contact_arrays()
|
||||
end subroutine db_free_contact_arrays
|
||||
|
||||
subroutine db_free_contact_property_arrays()
|
||||
if (allocated(contact_property_name)) deallocate(contact_property_name)
|
||||
if (allocated(contact_property_penalty)) deallocate(contact_property_penalty)
|
||||
if (allocated(contact_property_damping)) deallocate(contact_property_damping)
|
||||
if (allocated(contact_property_search)) deallocate(contact_property_search)
|
||||
if (allocated(contact_property_friction)) deallocate(contact_property_friction)
|
||||
if (allocated(contact_property_penalty_set)) deallocate(contact_property_penalty_set)
|
||||
if (allocated(contact_property_damping_set)) deallocate(contact_property_damping_set)
|
||||
if (allocated(contact_property_search_set)) deallocate(contact_property_search_set)
|
||||
if (allocated(contact_property_friction_set)) deallocate(contact_property_friction_set)
|
||||
call db_state_free_contact_props()
|
||||
end subroutine db_free_contact_property_arrays
|
||||
|
||||
subroutine db_reset_counts()
|
||||
nnode = 0
|
||||
nelem = 0
|
||||
ndof = 0
|
||||
ngauss_total = 0
|
||||
n_nset = 0
|
||||
n_elset = 0
|
||||
n_surface = 0
|
||||
n_surface_item = 0
|
||||
n_material = 0
|
||||
n_section = 0
|
||||
n_plastic_item = 0
|
||||
n_amp = 0
|
||||
n_amp_item = 0
|
||||
nbc = 0
|
||||
ncload = 0
|
||||
ndload = 0
|
||||
nrobin = 0
|
||||
nmpc = 0
|
||||
nmpc_term = 0
|
||||
ncontact_plane = 0
|
||||
ncontact_pair = 0
|
||||
n_contact_property = 0
|
||||
contact_active_count = 0
|
||||
contact_work_step = ZERO
|
||||
contact_work_total = ZERO
|
||||
contact_max_penetration = ZERO
|
||||
contact_force_norm = ZERO
|
||||
call db_state_reset_counts()
|
||||
end subroutine db_reset_counts
|
||||
|
||||
end module fem_database
|
||||
|
||||
@@ -74,6 +74,8 @@ module fem_database_state
|
||||
character(len=16), allocatable :: surface_type(:)
|
||||
character(len=NAME_LEN_STATE), allocatable :: surface_target(:)
|
||||
character(len=16), allocatable :: surface_face(:)
|
||||
real(rk_state), allocatable :: surface_plane_normal(:,:)
|
||||
real(rk_state), allocatable :: surface_plane_offset(:)
|
||||
|
||||
character(len=NAME_LEN_STATE), allocatable :: mat_name(:)
|
||||
character(len=MAT_MODEL_LEN_STATE), allocatable :: mat_plastic_model(:)
|
||||
@@ -186,4 +188,100 @@ module fem_database_state
|
||||
real(rk_state), allocatable :: contact_pair_slip(:)
|
||||
integer, allocatable :: contact_pair_stick_count(:)
|
||||
integer, allocatable :: contact_pair_slip_count(:)
|
||||
|
||||
contains
|
||||
|
||||
subroutine db_state_free_surface_arrays()
|
||||
if (allocated(surface_name)) deallocate(surface_name)
|
||||
if (allocated(surface_start)) deallocate(surface_start)
|
||||
if (allocated(surface_count)) deallocate(surface_count)
|
||||
if (allocated(surface_owner)) deallocate(surface_owner)
|
||||
if (allocated(surface_type)) deallocate(surface_type)
|
||||
if (allocated(surface_target)) deallocate(surface_target)
|
||||
if (allocated(surface_face)) deallocate(surface_face)
|
||||
if (allocated(surface_plane_normal)) deallocate(surface_plane_normal)
|
||||
if (allocated(surface_plane_offset)) deallocate(surface_plane_offset)
|
||||
end subroutine db_state_free_surface_arrays
|
||||
|
||||
subroutine db_state_init_surface_arrays()
|
||||
if (allocated(surface_name)) surface_name = ' '
|
||||
if (allocated(surface_start)) surface_start = 0
|
||||
if (allocated(surface_count)) surface_count = 0
|
||||
if (allocated(surface_owner)) surface_owner = 0
|
||||
if (allocated(surface_type)) surface_type = 'ELEMENT'
|
||||
if (allocated(surface_target)) surface_target = ' '
|
||||
if (allocated(surface_face)) surface_face = ' '
|
||||
if (allocated(surface_plane_normal)) surface_plane_normal = ZERO_STATE
|
||||
if (allocated(surface_plane_offset)) surface_plane_offset = ZERO_STATE
|
||||
end subroutine db_state_init_surface_arrays
|
||||
|
||||
subroutine db_state_free_contact_props()
|
||||
if (allocated(contact_property_name)) deallocate(contact_property_name)
|
||||
if (allocated(contact_property_penalty)) deallocate(contact_property_penalty)
|
||||
if (allocated(contact_property_damping)) deallocate(contact_property_damping)
|
||||
if (allocated(contact_property_search)) deallocate(contact_property_search)
|
||||
if (allocated(contact_property_friction)) deallocate(contact_property_friction)
|
||||
if (allocated(contact_property_penalty_set)) deallocate(contact_property_penalty_set)
|
||||
if (allocated(contact_property_damping_set)) deallocate(contact_property_damping_set)
|
||||
if (allocated(contact_property_search_set)) deallocate(contact_property_search_set)
|
||||
if (allocated(contact_property_friction_set)) deallocate(contact_property_friction_set)
|
||||
end subroutine db_state_free_contact_props
|
||||
|
||||
subroutine db_state_free_contact_arrays()
|
||||
if (allocated(contact_target)) deallocate(contact_target)
|
||||
if (allocated(contact_normal)) deallocate(contact_normal)
|
||||
if (allocated(contact_offset)) deallocate(contact_offset)
|
||||
if (allocated(contact_penalty)) deallocate(contact_penalty)
|
||||
if (allocated(contact_damping)) deallocate(contact_damping)
|
||||
if (allocated(contact_pair_slave)) deallocate(contact_pair_slave)
|
||||
if (allocated(contact_pair_master)) deallocate(contact_pair_master)
|
||||
if (allocated(contact_pair_property)) deallocate(contact_pair_property)
|
||||
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)
|
||||
if (allocated(contact_pair_penalty_set)) deallocate(contact_pair_penalty_set)
|
||||
if (allocated(contact_pair_damping_set)) deallocate(contact_pair_damping_set)
|
||||
if (allocated(contact_pair_search_set)) deallocate(contact_pair_search_set)
|
||||
if (allocated(contact_pair_friction_set)) deallocate(contact_pair_friction_set)
|
||||
if (allocated(contact_pair_active)) deallocate(contact_pair_active)
|
||||
if (allocated(contact_pair_work)) deallocate(contact_pair_work)
|
||||
if (allocated(contact_pair_max_penetration)) deallocate(contact_pair_max_penetration)
|
||||
if (allocated(contact_pair_force_norm)) deallocate(contact_pair_force_norm)
|
||||
if (allocated(contact_pair_tangent_force)) deallocate(contact_pair_tangent_force)
|
||||
if (allocated(contact_pair_slip)) deallocate(contact_pair_slip)
|
||||
if (allocated(contact_pair_stick_count)) deallocate(contact_pair_stick_count)
|
||||
if (allocated(contact_pair_slip_count)) deallocate(contact_pair_slip_count)
|
||||
call db_state_free_contact_props()
|
||||
end subroutine db_state_free_contact_arrays
|
||||
|
||||
subroutine db_state_reset_counts()
|
||||
nnode = 0
|
||||
nelem = 0
|
||||
ndof = 0
|
||||
ngauss_total = 0
|
||||
n_nset = 0
|
||||
n_elset = 0
|
||||
n_surface = 0
|
||||
n_surface_item = 0
|
||||
n_material = 0
|
||||
n_section = 0
|
||||
n_plastic_item = 0
|
||||
n_amp = 0
|
||||
n_amp_item = 0
|
||||
nbc = 0
|
||||
ncload = 0
|
||||
ndload = 0
|
||||
nrobin = 0
|
||||
nmpc = 0
|
||||
nmpc_term = 0
|
||||
ncontact_plane = 0
|
||||
ncontact_pair = 0
|
||||
n_contact_property = 0
|
||||
contact_active_count = 0
|
||||
contact_work_step = ZERO_STATE
|
||||
contact_work_total = ZERO_STATE
|
||||
contact_max_penetration = ZERO_STATE
|
||||
contact_force_norm = ZERO_STATE
|
||||
end subroutine db_state_reset_counts
|
||||
end module fem_database_state
|
||||
|
||||
Reference in New Issue
Block a user