generalized _FEasCP (string what,int ID) to use targeted arrays

available what options are 'elem' and 'node'
This commit is contained in:
Philip Eisenlohr 2007-03-27 12:53:31 +00:00
parent 9fca4824e4
commit 9671dc7de5
1 changed files with 32 additions and 15 deletions

View File

@ -8,7 +8,7 @@
! --------------------------- ! ---------------------------
! _Nelems : total number of elements in mesh ! _Nelems : total number of elements in mesh
! _NcpElems : total number of elements in mesh ! _NcpElems : total number of CP elements in mesh
! _Nnodes : total number of nodes in mesh ! _Nnodes : total number of nodes in mesh
! _maxNnodes : max number of nodes in any element ! _maxNnodes : max number of nodes in any element
! _maxNips : max number of IPs in any element ! _maxNips : max number of IPs in any element
@ -18,7 +18,8 @@
! _node : x,y,z coordinates (initially!) ! _node : x,y,z coordinates (initially!)
! _sharedElem : entryCount and list of elements containing node ! _sharedElem : entryCount and list of elements containing node
! !
! _mapFEtoCPelement : [sorted FEid, corresponding CPid] ! _mapFEtoCPelem : [sorted FEid, corresponding CPid]
! _mapFEtoCPnode : [sorted FEid, corresponding CPid]
! !
! MISSING: these definitions should actually reside in the ! MISSING: these definitions should actually reside in the
! FE-solver specific part (different for MARC/ABAQUS)..! ! FE-solver specific part (different for MARC/ABAQUS)..!
@ -39,7 +40,7 @@
! order is +x,-x,+y,-y,+z,-z but meaning strongly depends on Elemtype ! order is +x,-x,+y,-y,+z,-z but meaning strongly depends on Elemtype
! --------------------------- ! ---------------------------
integer(pInt) mesh_Nelems,mesh_NcpElems,mesh_Nnodes,mesh_maxNnodes,mesh_maxNips,mesh_maxNsharedElems integer(pInt) mesh_Nelems,mesh_NcpElems,mesh_Nnodes,mesh_maxNnodes,mesh_maxNips,mesh_maxNsharedElems
integer(pInt), dimension(:,:), allocatable :: mesh_mapFEtoCPelement integer(pInt), dimension(:,:), allocatable, target :: mesh_mapFEtoCPelem,mesh_mapFEtoCPnode
integer(pInt), dimension(:,:), allocatable :: mesh_element, mesh_sharedElem integer(pInt), dimension(:,:), allocatable :: mesh_element, mesh_sharedElem
integer(pInt), dimension(:,:,:,:), allocatable :: mesh_ipNeighborhood integer(pInt), dimension(:,:,:,:), allocatable :: mesh_ipNeighborhood
real(pReal), allocatable :: mesh_node (:,:) real(pReal), allocatable :: mesh_node (:,:)
@ -200,35 +201,51 @@ matchFace: do j = 1,FE_NfaceNodes(-neighbor,t) ! count over nodes on matching f
!*********************************************************** !***********************************************************
! FE to CP id mapping by binary search thru lookup array ! FE to CP id mapping by binary search thru lookup array
!
! valid questions are 'elem', 'node'
!*********************************************************** !***********************************************************
FUNCTION mesh_FEtoCPelement(FEid) FUNCTION mesh_FEasCP(what,id)
use prec, only: pInt use prec, only: pInt
use IO, only: IO_lc
implicit none implicit none
integer(pInt), intent(in) :: FEid character(len=*), intent(in) :: what
integer(pInt) mesh_FEtoCPelement, lower,upper,center integer(pInt), intent(in) :: id
integer(pInt), dimension(:,:), pointer :: lookupMap
integer(pInt) mesh_FEasCP, lower,upper,center
mesh_FEasCP = 0_pInt
select case(IO_lc(what(1:4)))
case('elem')
lookupMap => mesh_mapFEtoCPelem
case('node')
lookupMap => mesh_mapFEtoCPnode
case default
return
end select
mesh_FEtoCPelement = 0_pInt
lower = 1_pInt lower = 1_pInt
upper = size(mesh_mapFEtoCPelement,2) upper = size(lookupMap,2)
if (mesh_mapFEtoCPelement(1,lower) == FEid) then ! check at bounds
mesh_FEtoCPelement = mesh_mapFEtoCPelement(2,lower) if (lookupMap(1,lower) == id) then
mesh_FEasCP = lookupMap(2,lower)
return return
elseif (mesh_mapFEtoCPelement(1,upper) == FEid) then elseif (lookupMap(1,upper) == id) then
mesh_FEtoCPelement = mesh_mapFEtoCPelement(2,upper) mesh_FEasCP = lookupMap(2,upper)
return return
endif endif
! binary search in between bounds
do while (upper-lower > 0) do while (upper-lower > 0)
center = (lower+upper)/2 center = (lower+upper)/2
if (mesh_mapFEtoCPelement(1,center) < FEid) then if (lookupMap(1,center) < id) then
lower = center lower = center
elseif (mesh_mapFEtoCPelement(1,center) > FEid) then elseif (lookupMap(1,center) > id) then
upper = center upper = center
else else
mesh_FEtoCPelement = mesh_mapFEtoCPelement(2,center) mesh_FEasCP = lookupMap(2,center)
exit exit
end if end if
end do end do