Advance V5 core capabilities and planning
This commit is contained in:
@@ -19,6 +19,7 @@ module fem_coupling
|
||||
public :: cpl_get_facets
|
||||
public :: cpl_apply_facet_pressure
|
||||
public :: cpl_apply_facet_tractions
|
||||
public :: cpl_apply_facet_nodal_loads
|
||||
|
||||
contains
|
||||
|
||||
@@ -307,6 +308,75 @@ contains
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine cpl_apply_facet_tractions
|
||||
|
||||
subroutine cpl_apply_facet_nodal_loads(nfacet_in, max_face_nodes_in, &
|
||||
facet_id, facet_nnode_in, &
|
||||
node_forces, ierr)
|
||||
integer, intent(in) :: nfacet_in
|
||||
integer, intent(in) :: max_face_nodes_in
|
||||
integer, intent(in) :: facet_id(nfacet_in)
|
||||
integer, intent(in) :: facet_nnode_in(nfacet_in)
|
||||
real(rk), intent(in) :: node_forces(NDIM,max_face_nodes_in,nfacet_in)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer :: item
|
||||
integer :: idx
|
||||
integer :: local_node
|
||||
integer :: node
|
||||
integer :: idir
|
||||
integer :: dof
|
||||
|
||||
if (.not. allocated(fsph)) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'SPH force vector is not allocated', ierr)
|
||||
return
|
||||
end if
|
||||
if (nfacet_in .lt. 0) then
|
||||
call error_set(FEM_ERR_COUPLING, 'number of SPH nodal facets is negative', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
if (max_face_nodes_in .lt. 1) then
|
||||
call error_set(FEM_ERR_COUPLING, 'SPH nodal facet dimension is invalid', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
do item = 1, nfacet_in
|
||||
idx = find_facet(facet_id(item))
|
||||
if (idx .eq. 0) then
|
||||
call error_set(FEM_ERR_COUPLING, &
|
||||
'SPH nodal facet load references unknown facet', ierr)
|
||||
return
|
||||
end if
|
||||
if (facet_nnode_in(item) .ne. facet_nnode(idx)) then
|
||||
call error_set(FEM_ERR_COUPLING, &
|
||||
'SPH nodal facet load has inconsistent node count', ierr)
|
||||
return
|
||||
end if
|
||||
if (facet_nnode_in(item) .gt. max_face_nodes_in) then
|
||||
call error_set(FEM_ERR_COUPLING, &
|
||||
'SPH nodal facet load exceeds node dimension', ierr)
|
||||
return
|
||||
end if
|
||||
end do
|
||||
|
||||
do item = 1, nfacet_in
|
||||
idx = find_facet(facet_id(item))
|
||||
if (elem_status(facet_elem(idx)) .ne. 0) cycle
|
||||
|
||||
do local_node = 1, facet_nnode(idx)
|
||||
node = facet_conn(local_node,idx)
|
||||
do idir = 1, NDIM
|
||||
dof = dof_id(idir,node)
|
||||
if (dof .gt. 0) then
|
||||
fsph(dof) = fsph(dof) + node_forces(idir,local_node,item)
|
||||
end if
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine cpl_apply_facet_nodal_loads
|
||||
|
||||
subroutine count_candidate_faces(max_faces, ierr)
|
||||
integer, intent(out) :: max_faces
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
@@ -0,0 +1,569 @@
|
||||
module fem_particle_coupling
|
||||
use fem_precision
|
||||
use fem_error
|
||||
use fem_coupling
|
||||
use fem_particle_state
|
||||
use fem_particle_contact
|
||||
use fem_particle_facet_step
|
||||
implicit none
|
||||
|
||||
private
|
||||
|
||||
public :: particle_fem_facet_count
|
||||
public :: particle_fem_get_facets
|
||||
public :: particle_fem_get_active_slots
|
||||
public :: particle_fem_collect_loads
|
||||
public :: particle_fem_collect_all_loads
|
||||
public :: particle_fem_apply_loads
|
||||
public :: particle_fem_apply_facets
|
||||
public :: particle_fem_apply_all
|
||||
public :: particle_fem_scan_facets
|
||||
public :: particle_fem_scan_all
|
||||
public :: particle_fem_stats_summary
|
||||
public :: particle_fem_stats_force_norms
|
||||
|
||||
contains
|
||||
|
||||
subroutine particle_fem_facet_count(nfacet, max_nodes, ierr)
|
||||
integer, intent(out) :: nfacet
|
||||
integer, intent(out) :: max_nodes
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
call cpl_get_facet_count(nfacet, max_nodes, ierr)
|
||||
end subroutine particle_fem_facet_count
|
||||
|
||||
subroutine particle_fem_get_active_slots(max_slots, slots, count, ierr)
|
||||
integer, intent(in) :: max_slots
|
||||
integer, intent(out) :: slots(max_slots)
|
||||
integer, intent(out) :: count
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer :: item
|
||||
|
||||
count = 0
|
||||
if (max_slots .lt. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'particle FEM slot capacity is invalid', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
count = particle_count()
|
||||
if (count .gt. max_slots) then
|
||||
call error_set(FEM_ERR_INPUT, 'particle FEM slot buffer is too small', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
if (max_slots .gt. 0) slots = 0
|
||||
do item = 1, count
|
||||
slots(item) = item
|
||||
end do
|
||||
call error_clear(ierr)
|
||||
end subroutine particle_fem_get_active_slots
|
||||
|
||||
subroutine particle_fem_get_facets(nfacet, max_nodes, coords, velocities, &
|
||||
normals, area, facet_nnode, facet_id, &
|
||||
ierr)
|
||||
integer, intent(in) :: nfacet
|
||||
integer, intent(in) :: max_nodes
|
||||
real(rk), intent(out) :: coords(NDIM,max_nodes,nfacet)
|
||||
real(rk), intent(out) :: velocities(NDIM,max_nodes,nfacet)
|
||||
real(rk), intent(out) :: normals(NDIM,nfacet)
|
||||
real(rk), intent(out) :: area(nfacet)
|
||||
integer, intent(out) :: facet_nnode(nfacet)
|
||||
integer, intent(out) :: facet_id(nfacet)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer, allocatable :: elem_id(:)
|
||||
integer, allocatable :: face_id(:)
|
||||
integer, allocatable :: facet_conn(:,:)
|
||||
integer :: stat
|
||||
|
||||
call validate_facet_buffers(nfacet, max_nodes, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
allocate(elem_id(nfacet), face_id(nfacet), &
|
||||
facet_conn(max_nodes,nfacet), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'failed to allocate FEM facet ids', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call cpl_get_facets(nfacet, max_nodes, facet_id, elem_id, face_id, &
|
||||
facet_nnode, facet_conn, coords, velocities, normals, &
|
||||
area, ierr)
|
||||
deallocate(elem_id, face_id, facet_conn)
|
||||
end subroutine particle_fem_get_facets
|
||||
|
||||
subroutine particle_fem_collect_loads(nparticle, slots, params, &
|
||||
clear_particle_forces, nfacet_in, &
|
||||
max_nodes_in, facet_id, facet_nnode, &
|
||||
node_loads, stats, ierr)
|
||||
integer, intent(in) :: nparticle
|
||||
integer, intent(in) :: slots(nparticle)
|
||||
type(particle_contact_params), intent(in) :: params
|
||||
logical, intent(in) :: clear_particle_forces
|
||||
integer, intent(in) :: nfacet_in
|
||||
integer, intent(in) :: max_nodes_in
|
||||
integer, intent(out) :: facet_id(nfacet_in)
|
||||
integer, intent(out) :: facet_nnode(nfacet_in)
|
||||
real(rk), intent(out) :: node_loads(NDIM,max_nodes_in,nfacet_in)
|
||||
type(pfacet_step_stats), intent(out) :: stats
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer, allocatable :: tmp_facet_id(:)
|
||||
integer, allocatable :: elem_id(:)
|
||||
integer, allocatable :: face_id(:)
|
||||
integer, allocatable :: tmp_facet_nnode(:)
|
||||
integer, allocatable :: facet_conn(:,:)
|
||||
real(rk), allocatable :: coords(:,:,:)
|
||||
real(rk), allocatable :: velocities(:,:,:)
|
||||
real(rk), allocatable :: normals(:,:)
|
||||
real(rk), allocatable :: area(:)
|
||||
real(rk), allocatable :: tmp_node_loads(:,:,:)
|
||||
integer :: active_nfacet
|
||||
integer :: active_max_nodes
|
||||
integer :: stat
|
||||
|
||||
call pfacet_step_reset(stats)
|
||||
call validate_particle_count(nparticle, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
call particle_contact_validate(params, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
call validate_facet_buffers(nfacet_in, max_nodes_in, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
facet_id = 0
|
||||
facet_nnode = 0
|
||||
node_loads = ZERO
|
||||
if (clear_particle_forces) call particle_clear_forces()
|
||||
|
||||
call cpl_get_facet_count(active_nfacet, active_max_nodes, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
if (active_nfacet .eq. 0) then
|
||||
call error_clear(ierr)
|
||||
return
|
||||
end if
|
||||
if (nfacet_in .lt. active_nfacet .or. &
|
||||
max_nodes_in .lt. active_max_nodes) then
|
||||
call error_set(FEM_ERR_COUPLING, &
|
||||
'particle FEM load buffers are too small', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
allocate(tmp_facet_id(active_nfacet), elem_id(active_nfacet), &
|
||||
face_id(active_nfacet), tmp_facet_nnode(active_nfacet), &
|
||||
facet_conn(active_max_nodes,active_nfacet), &
|
||||
coords(NDIM,active_max_nodes,active_nfacet), &
|
||||
velocities(NDIM,active_max_nodes,active_nfacet), &
|
||||
normals(NDIM,active_nfacet), area(active_nfacet), &
|
||||
tmp_node_loads(NDIM,active_max_nodes,active_nfacet), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'failed to allocate particle FEM facet buffers', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
tmp_node_loads = ZERO
|
||||
call cpl_get_facets(active_nfacet, active_max_nodes, tmp_facet_id, &
|
||||
elem_id, face_id, tmp_facet_nnode, facet_conn, &
|
||||
coords, velocities, normals, area, ierr)
|
||||
if (ierr .eq. FEM_SUCCESS) then
|
||||
call pfacet_step_cloud(nparticle, slots, active_nfacet, &
|
||||
active_max_nodes, tmp_facet_nnode, coords, &
|
||||
velocities, params, tmp_node_loads, stats, ierr)
|
||||
end if
|
||||
if (ierr .eq. FEM_SUCCESS) then
|
||||
facet_id(1:active_nfacet) = tmp_facet_id
|
||||
facet_nnode(1:active_nfacet) = tmp_facet_nnode
|
||||
node_loads(:,1:active_max_nodes,1:active_nfacet) = tmp_node_loads
|
||||
end if
|
||||
|
||||
deallocate(tmp_facet_id, elem_id, face_id, tmp_facet_nnode, facet_conn)
|
||||
deallocate(coords, velocities, normals, area, tmp_node_loads)
|
||||
end subroutine particle_fem_collect_loads
|
||||
|
||||
subroutine particle_fem_collect_all_loads(params, clear_particle_forces, &
|
||||
nfacet_in, max_nodes_in, &
|
||||
facet_id, facet_nnode, &
|
||||
node_loads, stats, ierr)
|
||||
type(particle_contact_params), intent(in) :: params
|
||||
logical, intent(in) :: clear_particle_forces
|
||||
integer, intent(in) :: nfacet_in
|
||||
integer, intent(in) :: max_nodes_in
|
||||
integer, intent(out) :: facet_id(nfacet_in)
|
||||
integer, intent(out) :: facet_nnode(nfacet_in)
|
||||
real(rk), intent(out) :: node_loads(NDIM,max_nodes_in,nfacet_in)
|
||||
type(pfacet_step_stats), intent(out) :: stats
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer, allocatable :: slots(:)
|
||||
integer :: count
|
||||
integer :: stat
|
||||
integer :: item
|
||||
|
||||
count = particle_count()
|
||||
call pfacet_step_reset(stats)
|
||||
if (count .eq. 0) then
|
||||
facet_id = 0
|
||||
facet_nnode = 0
|
||||
node_loads = ZERO
|
||||
if (clear_particle_forces) call particle_clear_forces()
|
||||
call error_clear(ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
allocate(slots(count), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'failed to allocate particle slots', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
do item = 1, count
|
||||
slots(item) = item
|
||||
end do
|
||||
|
||||
call particle_fem_collect_loads(count, slots, params, &
|
||||
clear_particle_forces, nfacet_in, &
|
||||
max_nodes_in, facet_id, facet_nnode, &
|
||||
node_loads, stats, ierr)
|
||||
deallocate(slots)
|
||||
end subroutine particle_fem_collect_all_loads
|
||||
|
||||
subroutine particle_fem_apply_loads(nfacet_in, max_nodes_in, facet_id, &
|
||||
facet_nnode, node_loads, ierr)
|
||||
integer, intent(in) :: nfacet_in
|
||||
integer, intent(in) :: max_nodes_in
|
||||
integer, intent(in) :: facet_id(nfacet_in)
|
||||
integer, intent(in) :: facet_nnode(nfacet_in)
|
||||
real(rk), intent(in) :: node_loads(NDIM,max_nodes_in,nfacet_in)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer, allocatable :: active_id(:)
|
||||
integer, allocatable :: active_nnode(:)
|
||||
real(rk), allocatable :: active_loads(:,:,:)
|
||||
integer :: item
|
||||
integer :: active_count
|
||||
integer :: stat
|
||||
|
||||
call validate_facet_buffers(nfacet_in, max_nodes_in, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
active_count = 0
|
||||
do item = 1, nfacet_in
|
||||
if (facet_id(item) .gt. 0 .and. facet_nnode(item) .gt. 0) then
|
||||
active_count = active_count + 1
|
||||
else if (facet_id(item) .ne. 0 .or. facet_nnode(item) .ne. 0) then
|
||||
call error_set(FEM_ERR_COUPLING, &
|
||||
'particle FEM collected facet slot is incomplete', ierr)
|
||||
return
|
||||
end if
|
||||
end do
|
||||
if (active_count .eq. 0) then
|
||||
call error_clear(ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
allocate(active_id(active_count), active_nnode(active_count), &
|
||||
active_loads(NDIM,max_nodes_in,active_count), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'failed to allocate compact particle FEM loads', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
active_count = 0
|
||||
do item = 1, nfacet_in
|
||||
if (facet_id(item) .gt. 0) then
|
||||
active_count = active_count + 1
|
||||
active_id(active_count) = facet_id(item)
|
||||
active_nnode(active_count) = facet_nnode(item)
|
||||
active_loads(:,:,active_count) = node_loads(:,:,item)
|
||||
end if
|
||||
end do
|
||||
|
||||
call cpl_apply_facet_nodal_loads(active_count, max_nodes_in, active_id, &
|
||||
active_nnode, active_loads, ierr)
|
||||
deallocate(active_id, active_nnode, active_loads)
|
||||
end subroutine particle_fem_apply_loads
|
||||
|
||||
subroutine particle_fem_apply_facets(nparticle, slots, params, &
|
||||
clear_particle_forces, stats, ierr)
|
||||
integer, intent(in) :: nparticle
|
||||
integer, intent(in) :: slots(nparticle)
|
||||
type(particle_contact_params), intent(in) :: params
|
||||
logical, intent(in) :: clear_particle_forces
|
||||
type(pfacet_step_stats), intent(out) :: stats
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer, allocatable :: facet_id(:)
|
||||
integer, allocatable :: facet_nnode(:)
|
||||
real(rk), allocatable :: node_loads(:,:,:)
|
||||
integer :: nfacet
|
||||
integer :: max_nodes
|
||||
integer :: stat
|
||||
|
||||
call pfacet_step_reset(stats)
|
||||
call cpl_get_facet_count(nfacet, max_nodes, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
if (nfacet .eq. 0) then
|
||||
if (clear_particle_forces) call particle_clear_forces()
|
||||
call error_clear(ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
allocate(facet_id(nfacet), facet_nnode(nfacet), &
|
||||
node_loads(NDIM,max_nodes,nfacet), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'failed to allocate particle FEM nodal loads', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call particle_fem_collect_loads(nparticle, slots, params, &
|
||||
clear_particle_forces, nfacet, max_nodes, &
|
||||
facet_id, facet_nnode, node_loads, stats, &
|
||||
ierr)
|
||||
if (ierr .eq. FEM_SUCCESS .and. stats%contact_count .gt. 0) then
|
||||
call particle_fem_apply_loads(nfacet, max_nodes, facet_id, facet_nnode, &
|
||||
node_loads, ierr)
|
||||
end if
|
||||
|
||||
deallocate(facet_id, facet_nnode, node_loads)
|
||||
end subroutine particle_fem_apply_facets
|
||||
|
||||
subroutine particle_fem_apply_all(params, clear_particle_forces, stats, ierr)
|
||||
type(particle_contact_params), intent(in) :: params
|
||||
logical, intent(in) :: clear_particle_forces
|
||||
type(pfacet_step_stats), intent(out) :: stats
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer, allocatable :: slots(:)
|
||||
integer :: count
|
||||
integer :: item
|
||||
integer :: stat
|
||||
|
||||
call pfacet_step_reset(stats)
|
||||
count = particle_count()
|
||||
if (count .eq. 0) then
|
||||
if (clear_particle_forces) call particle_clear_forces()
|
||||
call error_clear(ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
allocate(slots(count), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'failed to allocate particle FEM slots', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
do item = 1, count
|
||||
slots(item) = item
|
||||
end do
|
||||
|
||||
call particle_fem_apply_facets(count, slots, params, &
|
||||
clear_particle_forces, stats, ierr)
|
||||
deallocate(slots)
|
||||
end subroutine particle_fem_apply_all
|
||||
|
||||
subroutine particle_fem_scan_facets(nparticle, slots, params, stats, ierr)
|
||||
integer, intent(in) :: nparticle
|
||||
integer, intent(in) :: slots(nparticle)
|
||||
type(particle_contact_params), intent(in) :: params
|
||||
type(pfacet_step_stats), intent(out) :: stats
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer, allocatable :: facet_id(:)
|
||||
integer, allocatable :: facet_nnode(:)
|
||||
real(rk), allocatable :: node_loads(:,:,:)
|
||||
real(rk), allocatable :: saved_force(:,:)
|
||||
integer :: nfacet
|
||||
integer :: max_nodes
|
||||
integer :: stat
|
||||
integer :: restore_ierr
|
||||
|
||||
call pfacet_step_reset(stats)
|
||||
call validate_particle_count(nparticle, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
if (nparticle .eq. 0) then
|
||||
call error_clear(ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
allocate(saved_force(NDIM,nparticle), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'failed to save particle forces', ierr)
|
||||
return
|
||||
end if
|
||||
call save_particle_forces(nparticle, slots, saved_force, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) then
|
||||
deallocate(saved_force)
|
||||
return
|
||||
end if
|
||||
|
||||
call cpl_get_facet_count(nfacet, max_nodes, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) then
|
||||
call restore_particle_forces(nparticle, slots, saved_force, restore_ierr)
|
||||
deallocate(saved_force)
|
||||
return
|
||||
end if
|
||||
if (nfacet .eq. 0) then
|
||||
call restore_particle_forces(nparticle, slots, saved_force, ierr)
|
||||
deallocate(saved_force)
|
||||
return
|
||||
end if
|
||||
|
||||
allocate(facet_id(nfacet), facet_nnode(nfacet), &
|
||||
node_loads(NDIM,max_nodes,nfacet), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call restore_particle_forces(nparticle, slots, saved_force, restore_ierr)
|
||||
deallocate(saved_force)
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'failed to allocate particle FEM scan buffers', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call particle_fem_collect_loads(nparticle, slots, params, .false., nfacet, &
|
||||
max_nodes, facet_id, facet_nnode, &
|
||||
node_loads, stats, ierr)
|
||||
call restore_particle_forces(nparticle, slots, saved_force, restore_ierr)
|
||||
if (ierr .eq. FEM_SUCCESS .and. restore_ierr .ne. FEM_SUCCESS) then
|
||||
ierr = restore_ierr
|
||||
end if
|
||||
|
||||
deallocate(facet_id, facet_nnode, node_loads)
|
||||
deallocate(saved_force)
|
||||
end subroutine particle_fem_scan_facets
|
||||
|
||||
subroutine particle_fem_scan_all(params, stats, ierr)
|
||||
type(particle_contact_params), intent(in) :: params
|
||||
type(pfacet_step_stats), intent(out) :: stats
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer, allocatable :: slots(:)
|
||||
integer :: count
|
||||
integer :: item
|
||||
integer :: stat
|
||||
|
||||
call pfacet_step_reset(stats)
|
||||
count = particle_count()
|
||||
if (count .eq. 0) then
|
||||
call error_clear(ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
allocate(slots(count), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'failed to allocate particle scan slots', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
do item = 1, count
|
||||
slots(item) = item
|
||||
end do
|
||||
|
||||
call particle_fem_scan_facets(count, slots, params, stats, ierr)
|
||||
deallocate(slots)
|
||||
end subroutine particle_fem_scan_all
|
||||
|
||||
subroutine particle_fem_stats_summary(stats, particle_count_out, &
|
||||
contact_count, max_overlap, &
|
||||
elastic_energy, dissipated_power, &
|
||||
force_norm, ierr)
|
||||
type(pfacet_step_stats), intent(in) :: stats
|
||||
integer, intent(out) :: particle_count_out
|
||||
integer, intent(out) :: contact_count
|
||||
real(rk), intent(out) :: max_overlap
|
||||
real(rk), intent(out) :: elastic_energy
|
||||
real(rk), intent(out) :: dissipated_power
|
||||
real(rk), intent(out) :: force_norm
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
call pfacet_step_summary(stats, particle_count_out, contact_count, &
|
||||
max_overlap, elastic_energy, dissipated_power, &
|
||||
force_norm, ierr)
|
||||
end subroutine particle_fem_stats_summary
|
||||
|
||||
subroutine particle_fem_stats_force_norms(stats, particle_force_norm, &
|
||||
node_force_norm, ierr)
|
||||
type(pfacet_step_stats), intent(in) :: stats
|
||||
real(rk), intent(out) :: particle_force_norm
|
||||
real(rk), intent(out) :: node_force_norm
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
call pfacet_step_force_norms(stats, particle_force_norm, node_force_norm, &
|
||||
ierr)
|
||||
end subroutine particle_fem_stats_force_norms
|
||||
|
||||
subroutine save_particle_forces(nparticle, slots, saved_force, ierr)
|
||||
integer, intent(in) :: nparticle
|
||||
integer, intent(in) :: slots(nparticle)
|
||||
real(rk), intent(out) :: saved_force(NDIM,nparticle)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer :: item
|
||||
integer :: ext_id
|
||||
logical :: active
|
||||
real(rk) :: position(NDIM)
|
||||
real(rk) :: velocity(NDIM)
|
||||
real(rk) :: radius
|
||||
real(rk) :: mass
|
||||
|
||||
call validate_particle_count(nparticle, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
saved_force = ZERO
|
||||
do item = 1, nparticle
|
||||
call particle_get(slots(item), ext_id, active, position, velocity, &
|
||||
radius, mass, saved_force(:,item), ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end do
|
||||
call error_clear(ierr)
|
||||
end subroutine save_particle_forces
|
||||
|
||||
subroutine restore_particle_forces(nparticle, slots, saved_force, ierr)
|
||||
integer, intent(in) :: nparticle
|
||||
integer, intent(in) :: slots(nparticle)
|
||||
real(rk), intent(in) :: saved_force(NDIM,nparticle)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
integer :: item
|
||||
|
||||
do item = 1, nparticle
|
||||
call particle_set_force(slots(item), saved_force(:,item), ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end do
|
||||
call error_clear(ierr)
|
||||
end subroutine restore_particle_forces
|
||||
|
||||
subroutine validate_particle_count(nparticle, ierr)
|
||||
integer, intent(in) :: nparticle
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
if (nparticle .lt. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'particle FEM count is invalid', ierr)
|
||||
return
|
||||
end if
|
||||
call error_clear(ierr)
|
||||
end subroutine validate_particle_count
|
||||
|
||||
subroutine validate_facet_buffers(nfacet, max_nodes, ierr)
|
||||
integer, intent(in) :: nfacet
|
||||
integer, intent(in) :: max_nodes
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
if (nfacet .lt. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'particle FEM facet count is invalid', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
if (max_nodes .lt. 1) then
|
||||
call error_set(FEM_ERR_INPUT, 'particle FEM node capacity is invalid', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
call error_clear(ierr)
|
||||
end subroutine validate_facet_buffers
|
||||
|
||||
end module fem_particle_coupling
|
||||
Reference in New Issue
Block a user