added function mesh_FEtoCPelement(FEid)

This commit is contained in:
Philip Eisenlohr 2007-03-21 16:18:33 +00:00
parent 2b05803684
commit b91ab5ae61
1 changed files with 217 additions and 175 deletions

View File

@ -3,7 +3,7 @@
MODULE mesh
!##############################################################
use prec, only: pRe,pIn
use prec, only: pReal,pInt
implicit none
! ---------------------------
@ -11,52 +11,94 @@
! _Nnodes : total number of nodes in mesh
! _maxNnodes : max number of nodes in any element
! _maxNips : max number of IPs in any element
! _element : type, material, node indices
! _mapFEtoCPelement : [sorted FEid, corresponding CPid]
! _element : FEid, type, material, texture, node indices
! _node : x,y,z coordinates (initially!)
! _nodeIndex : count of elements containing node,
! [element_num, node_index], ...
! _envIP : 6 neighboring IPs as [element_num, IP_index]
! order is +x, +y,+z, -x, -y, -z in local coord
! ---------------------------
integer(pIn) mesh_Nelems, mesh_Nnodes, mesh_maxNnodes,mesh_maxNips
integer(pIn), allocatable :: mesh_element (:,:)
integer(pIn), allocatable :: mesh_nodeIndex (:,:)
integer(pIn), allocatable :: mesh_envIP (:,:)
real(pRe), allocatable :: mesh_node (:,:)
integer(pInt) mesh_Nelems, mesh_Nnodes, mesh_maxNnodes,mesh_maxNips
integer(pInt), dimension(2,:), allocatable :: mesh_mapFEtoCPelement
integer(pInt), dimension(:,:), allocatable :: mesh_element, mesh_nodeIndex, mesh_envIP
real(pReal), allocatable :: mesh_node (:,:)
CONTAINS
! ---------------------------
! subroutine mesh_init()
! function mesh_FEtoCPelement(FEid)
! function mesh_build_IPenvironment()
! subroutine mesh_parse_inputFile()
! ---------------------------
! ***********************************************************
! FE to CP id mapping by binary search thru lookup array
! ***********************************************************
FUNCTION mesh_FEtoCPelement(FEid)
use prec, only: pInt
implicit none
integer(pInt), intent(in) :: FEid
integer(pInt) mesh_FEtoCPelement, lower,upper,center
mesh_FEtoCPelement = 0_pInt
lower = 1_pInt
upper = size(mesh_mapFEtoCPelement,2)
if (mesh_mapFEtoCPelement(lower,1) == FEid) then
mesh_FEtoCPelement = mesh_mapFEtoCPelement(lower,2)
return
elseif (mesh_mapFEtoCPelement(upper,1) == FEid) then
mesh_FEtoCPelement = mesh_mapFEtoCPelement(upper,2)
return
endif
do while (upper-lower > 0)
center = (lower+upper)/2
if (mesh_mapFEtoCPelement(center,1) < FEid) then
lower = center
elseif (mesh_mapFEtoCPelement(center,1) > FEid) then
upper = center
else
mesh_FEtoCPelement = mesh_mapFEtoCPelement(center,2)
exit
end if
end do
return
END FUNCTION
! ***********************************************************
! initialization
! ***********************************************************
SUBROUTINE mesh_init ()
mesh_Nelems = 0_pIn
mesh_Nnodes = 0_pIn
mesh_maxNips = 0_pIn
mesh_maxNnodes = 0_pIn
mesh_Nelems = 0_pInt
mesh_Nnodes = 0_pInt
mesh_maxNips = 0_pInt
mesh_maxNnodes = 0_pInt
call mesh_parse_inputFile ()
END SUBROUTINE
! ***********************************************************
! parsing of input file
! ***********************************************************
FUNCTION mesh_parse_inputFile ()
use prec, only: pRe,pIn
use prec, only: pReal,pInt
use IO
implicit none
logical mesh_parse_inputFile
integer(pIn) i,j,positions(10*2+1)
integer(pIn) elem_num,elem_type,Nnodes,node_num,num_ip,mat,tp(70,2)
integer(pInt) i,j,positions(10*2+1)
integer(pInt) elem_num,elem_type,Nnodes,node_num,num_ip,mat,tp(70,2)
! Set a format to read the entire line (max. len is 80 characters)
610 FORMAT(A80)
@ -99,9 +141,9 @@
allocate (mesh_element(mesh_Nelems,2+mesh_maxNips))
allocate (mesh_nodeIndex (mesh_Nnodes,1+mesh_maxNnodes*2)
allocate (mesh_envIP(mesh_Nelems,mesh_maxNips,6,2))
mesh_element = 0_pIn
mesh_nodeIndex = 0_pIn
mesh_envIP = 0_pIn
mesh_element = 0_pInt
mesh_nodeIndex = 0_pInt
mesh_envIP = 0_pInt
! MISSING: setting up of envIP