• R/O
  • SSH

treelm: 提交

Repository of the treelm library. Now found at https://github.com/apes-suite/treelm


Commit MetaInfo

修訂9c1305e3aafeb33d62912eefe0fd0001d61ee366 (tree)
時間2023-05-26 04:31:36
作者Harald Klimach <harald.klimach@dlr....>
CommiterHarald Klimach

Log Message

Moved shape-specific functionality to the tem_shape_module.

Change Summary

差異

diff -r be94602ad3a9 -r 9c1305e3aafe source/tem_shape_module.f90
--- a/source/tem_shape_module.f90 Thu May 25 18:08:50 2023 +0200
+++ b/source/tem_shape_module.f90 Thu May 25 21:31:36 2023 +0200
@@ -46,12 +46,16 @@
4646 use env_module, only: rk, long_k, labelLen, pathLen, &
4747 & globalMaxLevels
4848 use tem_aux_module, only: tem_abort
49+ use tem_bc_prop_module, only: tem_bc_prop_type
4950 use treelmesh_module, only: treelmesh_type
50- use tem_topology_module, only: tem_levelOf, tem_IDofCoord
51+ use tem_topology_module, only: tem_levelOf, tem_firstIdAtLevel, &
52+ & tem_lastIdAtLevel
5153 use tem_pointData_module, only: tem_grwPoints_type, init, append
5254 use tem_geometry_module, only: tem_CoordOfReal, tem_PosOfId
5355 use tem_dyn_array_module, only: dyn_intArray_type, append
5456 use tem_property_module, only: prp_hasBnd, prp_fluidify
57+ use tem_param_module, only: qQQQ, qDir
58+ use tem_stencil_module, only: tem_stencilHeader_type
5559 use tem_canonicalND_module, only: tem_canonicalND_type, tem_canonicalND_out, &
5660 & tem_load_canonicalND, &
5761 & tem_cano_initSubTree, &
@@ -91,7 +95,7 @@
9195 public :: tem_boundary_shape
9296 public :: tem_level_shape
9397 public :: tem_shape_out
94- public :: tem_shape_subTreeFromGeomInters
98+ public :: tem_shape2subTree
9599
96100 !> Parameters for different tracking shapes
97101 !> Global mesh
@@ -884,6 +888,316 @@
884888 ! ************************************************************************** !
885889
886890
891+ ! ************************************************************************** !
892+ !> This routine identifies elements that belong to certain bounaries.
893+ !! Labels of required boundaries are given by bcLabels.
894+ !! bc_prop contains boudnary_ID of all local elements.
895+ !! Firstly, bcLabels are converted into bcIDs.
896+ !! Then all elements in bc_prop are looped over to check if it matches one of
897+ !! the required bcID. If match, its position is save in map2global.
898+ !! Number of elements found on each level is saved in countElems.
899+ subroutine tem_shape_findElemByBCLabels( bcLabels, bc_prop, &
900+ & foundAny, map2global, bcIDs, stencil)
901+ ! ---------------------------------------------------------------------------
902+ !> bcLabels
903+ character(len=labelLen), intent(in) :: bcLabels(:)
904+ !> bc property
905+ type(tem_bc_prop_type), intent(in) :: bc_prop
906+ !> if any element be identified
907+ logical, intent(out) :: foundAny
908+ !> dynamic array. Elements positions in bc_prop%property%elemID
909+ type(dyn_intArray_type), intent(inout) :: map2global
910+ !> id of boundary condition to be tracked
911+ integer, allocatable, intent(out) :: bcIDs(:)
912+ !> stencil required to get useful links
913+ type( tem_stencilHeader_type ), optional, intent(in) :: stencil
914+ ! ---------------------------------------------------------------------------
915+ integer :: dPos, iElem, iBC, nBCs, iBCtype, posInTree, QQN
916+ logical :: wasAdded, found
917+ integer, allocatable :: map(:)
918+ ! ---------------------------------------------------------------------------
919+
920+ if( present( stencil ) ) then
921+ allocate( map( size(stencil%map) ) )
922+ map = stencil%map
923+ qqn = stencil%QQN
924+ else
925+ allocate( map(qQQQ) )
926+ map = qDir
927+ qqn = qQQQ
928+ end if
929+
930+
931+ foundAny = .false.
932+ ! convert bcLabels to bcIDs
933+ nBCs = size(bcLabels)
934+ allocate( bcIDs( nBCs ) )
935+
936+ ! loop over all required bcLabels
937+ do iBC = 1, nBCs
938+
939+ found = .false.
940+
941+ ! loop over all BCs in the mesh
942+ do iBCtype = 1, bc_prop%nBCtypes
943+ if ( trim(bcLabels(iBC)) == bc_prop%bc_label( iBCtype ) ) then
944+ bcIDs( iBC ) = iBCtype
945+ found = .true.
946+ exit
947+ end if
948+ end do
949+
950+ if ( .not. found ) then
951+ write(logUnit(1),*) 'Required BC label: '//trim(bcLabels(iBC))
952+ write(logUnit(1),*) 'can not be found in given mesh!'
953+ stop
954+ end if
955+ end do ! iBC
956+
957+ ! Loop over all element with boundary property
958+ do iElem = 1, bc_prop%property%nElems
959+
960+ do iBC = 1, nBCs
961+ if ( any(int(bc_prop%boundary_ID( map(:qqn), iElem )) == bcIDs(iBC) ) ) then
962+
963+ posInTree = bc_prop%property%elemID(iElem)
964+ ! Append to treeID list (note that already existing ones are
965+ ! omitted)
966+ call append( me = map2global, &
967+ & pos = dPos, &
968+ & val = posInTree, &
969+ & wasAdded = wasAdded )
970+
971+ ! Count up if it was added
972+ if( wasAdded ) then
973+ ! tLevel = tem_levelOf( inTree%treeID(posInTree) )
974+ ! countElems( tLevel ) = countElems( tLevel ) + 1
975+ foundAny = .true.
976+
977+ exit ! continue with next element
978+ end if ! wasAdded
979+
980+ end if ! boundary_ID == bcIDs
981+ end do
982+
983+ end do ! iElem
984+
985+ end subroutine tem_shape_findElemByBCLabels
986+ ! ************************************************************************** !
987+
988+
989+ ! ************************************************************************** !
990+ subroutine tem_shape_initByLevels( inTree, minLevel, maxLevel, countElems, &
991+ & map2global )
992+ ! ---------------------------------------------------------------------------
993+ !> Global mesh from which the elements are identified and then stored to
994+ type( treelmesh_type ), intent(in) :: inTree
995+ !> level range of target elements
996+ integer, intent(in) :: minLevel, maxLevel
997+ !> How many elements there will be for each level in the track
998+ integer, intent(out) :: countElems( globalMaxLevels )
999+ !> growing array. Elements positions in inTree%treeID
1000+ type(dyn_intArray_type), intent(inout) :: map2global
1001+ ! ---------------------------------------------------------------------------
1002+ integer(kind=long_k) :: myID, minID, maxID
1003+ integer :: tLevel, dPos, iElem, loc_min, loc_max
1004+ logical :: wasAdded
1005+ ! ---------------------------------------------------------------------------
1006+
1007+ loc_min = minLevel
1008+ loc_max = maxLevel
1009+ if ( minLevel > maxLevel ) then
1010+ ! take inverse
1011+ loc_min = maxLevel
1012+ loc_max = minLevel
1013+ end if
1014+
1015+ if ( minLevel < 1 ) loc_min = 1
1016+ if ( maxLevel > globalMaxLevels ) loc_max = globalMaxLevels
1017+
1018+ call tem_log(3, 'Initializing shapes by elements between level '&
1019+ & //trim(tem_toStr(loc_min))//' and '//trim(tem_toStr(loc_max)) )
1020+
1021+ ! the treeID range is the first ID on min level and the last ID on max level
1022+ minID = tem_firstIdAtLevel( loc_min )
1023+ maxID = tem_lastIdAtLevel( loc_max )
1024+
1025+ ! Loop over all elements in inTree
1026+ do iElem = 1, inTree%nElems
1027+
1028+ myID = inTree%treeID(iElem)
1029+
1030+ if( (myID >= minID) .and. (myID <= maxID) ) then
1031+ ! Append to treeID list (note that already existing ones are
1032+ ! omitted)
1033+ call append( me = map2global, &
1034+ & pos = dPos, &
1035+ & val = iElem, &
1036+ & wasAdded = wasAdded )
1037+
1038+ ! Count up if it was added
1039+ if( wasAdded ) then
1040+ tLevel = tem_levelOf( inTree%treeID(iElem) )
1041+ countElems( tLevel ) = countElems( tLevel ) + 1
1042+ end if ! wasAdded
1043+
1044+ end if
1045+
1046+ end do ! iElem
1047+
1048+ end subroutine tem_shape_initByLevels
1049+ ! ************************************************************************** !
1050+
1051+
1052+ ! ************************************************************************** !
1053+ !> This routine identify all the elements in inTree that has a certain property
1054+ !! bit, save their positions in inTree into array: map2global,
1055+ !! save the number of these elements into level wise array: countElems
1056+ !! (e.g. for shape kind='property').
1057+ !!
1058+ subroutine tem_shape_initPropElements( propBits, inTree, countElems, map2global )
1059+ ! ---------------------------------------------------------------------------
1060+ !> shape objects on which to work
1061+ integer( kind=long_k ), intent(in) :: propBits
1062+ !> Global mesh from which the elements are identified and then stored to
1063+ type( treelmesh_type ), intent(in) :: inTree
1064+ !> How many elements there will be for each level in the track
1065+ integer, intent( out ) :: countElems( globalMaxLevels )
1066+ !> growing array. Elements positions in inTree%treeID
1067+ type(dyn_intArray_type), intent(inout) :: map2global
1068+ ! ---------------------------------------------------------------------------
1069+ integer(kind=long_k) :: elemProp, match
1070+ integer :: tLevel, dPos, iElem
1071+ logical :: wasAdded
1072+ ! ---------------------------------------------------------------------------
1073+
1074+ write(logUnit(1),*) 'Initializing shapes of elements that have a ' &
1075+ & // 'certain property'
1076+
1077+ ! Loop over all elements in inTree
1078+ do iElem = 1, inTree%nElems
1079+
1080+ ! get its property bits
1081+ elemProp = inTree%elemPropertyBits( iElem )
1082+
1083+ ! check whether its property
1084+ match = iand( propBits, elemProp )
1085+
1086+ if( match > 0_long_k ) then
1087+
1088+ ! Append to treeID list (note that already existing ones are
1089+ ! omitted)
1090+ call append( me = map2global, &
1091+ & pos = dPos, &
1092+ & val = iElem, &
1093+ & wasAdded = wasAdded )
1094+
1095+ ! Count up if it was added
1096+ if( wasAdded ) then
1097+ tLevel = tem_levelOf( inTree%treeID(iElem) )
1098+ countElems( tLevel ) = countElems( tLevel ) + 1
1099+ end if ! wasAdded
1100+
1101+ end if ! match > 0
1102+
1103+ end do ! iElem
1104+
1105+ end subroutine tem_shape_initPropElements
1106+ ! ************************************************************************** !
1107+
1108+
1109+ ! ************************************************************************** !
1110+ !> Identify elements matching a given shape to build a subTree.
1111+ subroutine tem_shape2subTree( me, iShape, inTree, storePnts, map2global, &
1112+ & grwPnts, countElems, countPnts, bcIDs, &
1113+ & bc_prop, stencil )
1114+ ! ---------------------------------------------------------------------- !
1115+ !> The shape to identify elements for
1116+ type(tem_shape_type), intent(in) :: me
1117+
1118+ !> Numbering of the shape (only for logging)
1119+ integer, intent(in) :: iShape
1120+
1121+ !> The tree to look in for elements that match the shape definition
1122+ type(treelmesh_type), intent(in) :: inTree
1123+
1124+ !> Whether to store point values
1125+ logical, intent(in) :: storePnts
1126+
1127+ !> Mapping to global elements in the tree
1128+ type(dyn_intArray_type), intent(inout) :: map2global
1129+
1130+ !> Growing list of Points to be observed
1131+ type(tem_grwPoints_type), intent(inout) :: grwPnts
1132+
1133+ !> Number of elements on each level matching the shape
1134+ integer, intent(out) :: countElems(globalMaxLevels)
1135+
1136+ !> Number of points to be observed
1137+ integer, intent(out) :: countPnts
1138+
1139+ !> Field of boundary ids that are to be tracked
1140+ integer, allocatable, intent(out) :: bcIDs(:)
1141+
1142+ !> Boundary condition property to identify boundary elements
1143+ type(tem_bc_prop_type), optional, intent(in) :: bc_prop
1144+
1145+ !> Stencil associated with the boundary to find respective neighbors
1146+ type(tem_stencilHeader_type), optional, intent(in) :: stencil
1147+ ! ---------------------------------------------------------------------- !
1148+ logical :: foundAny
1149+ integer :: nShapeElems(globalMaxLevels)
1150+ ! ---------------------------------------------------------------------- !
1151+
1152+ nShapeElems = 0
1153+
1154+ select case( me%shapeID )
1155+ case( tem_geometrical_shape )
1156+ ! Use elements intersecting a geometrical object
1157+ write(logUnit(5),*) 'iShape ', iShape, ' is a geometrical shape.'
1158+ call tem_shape_subTreeFromGeomInters( me = me, &
1159+ & inTree = inTree, &
1160+ & countElems = nShapeElems, &
1161+ & countPoints = countPnts, &
1162+ & grwPnts = grwPnts, &
1163+ & storePnts = storePnts, &
1164+ & map2global = map2global )
1165+
1166+ !TODO: treat points that lie outside the domain but may be sufficiently
1167+ ! close for extrapolation.
1168+
1169+ case( tem_property_shape )
1170+ ! Only use elements with a certain property
1171+ write(logUnit(5),*) 'iShape ', iShape, ' is a property shape.'
1172+ call tem_shape_initPropElements( me%propBits, inTree, &
1173+ & nShapeElems, map2global )
1174+
1175+ case( tem_boundary_shape )
1176+ ! Only use elements belong to certain boundaries
1177+ write(logUnit(5),*) 'iShape ', iShape, ' is a boundary shape.'
1178+ if (present(bc_prop) .and. present(stencil)) then
1179+ call tem_shape_findElemByBCLabels( bcLabels = me%bcLabels, &
1180+ & bc_prop = bc_prop, &
1181+ & foundAny = foundAny, &
1182+ & map2global = map2Global, &
1183+ & bcIDs = bcIDs, &
1184+ & stencil = stencil )
1185+ if (foundAny) nShapeElems = 1
1186+ else
1187+ call tem_abort('In tem_shape2subTree: Stencil or bc_prop not passed!')
1188+ end if
1189+
1190+ case( tem_level_shape )
1191+ write(logUnit(5),*) 'iShape ', iShape, ' is a level shape.'
1192+ call tem_shape_initByLevels( inTree, me%minLevel, &
1193+ & me%maxLevel, &
1194+ & nShapeElems, map2global )
1195+ end select ! shapeID
1196+
1197+ countElems = countElems + nShapeElems
1198+
1199+ end subroutine tem_shape2subTree
1200+ ! ************************************************************************** !
8871201
8881202 end module tem_shape_module
8891203 ! ****************************************************************************** !
diff -r be94602ad3a9 -r 9c1305e3aafe source/tem_subTree_module.f90
--- a/source/tem_subTree_module.f90 Thu May 25 18:08:50 2023 +0200
+++ b/source/tem_subTree_module.f90 Thu May 25 21:31:36 2023 +0200
@@ -56,15 +56,11 @@
5656 use tem_grow_array_module, only: grw_intArray_type, init, append, destroy
5757 use tem_property_module, only: gather_property, prp_hasQVal
5858 use tem_prophead_module, only: tem_prop_countelems
59- use tem_shape_module, only: tem_shape_type, tem_global_shape, &
60- & tem_geometrical_shape, tem_property_shape,&
61- & tem_local_shape, tem_boundary_shape, &
62- & tem_level_shape, &
63- & tem_shape_subTreeFromGeomInters
59+ use tem_shape_module, only: tem_shape_type, &
60+ & tem_global_shape, &
61+ & tem_local_shape, &
62+ & tem_shape2subTree
6463 use tem_geometry_module, only: tem_setEffBoundingBox, tem_baryOfId
65- use tem_topology_module, only: tem_levelOf, tem_firstIdAtLevel, &
66- & tem_lastIdAtLevel
67- use tem_param_module, only: qQQQ, qDir
6864 use tem_construction_module, only: tem_levelDesc_type
6965 use tem_subTree_type_module, only: tem_subTree_type, &
7066 & tem_dump_subTree
@@ -310,7 +306,7 @@
310306 !> new mesh
311307 type(tem_subTree_type), intent(out) :: subTree
312308 !> shape objects on which to work
313- type(tem_shape_type ),intent(in) :: inShape(:)
309+ type(tem_shape_type),intent(in) :: inShape(:)
314310 !> optional level descriptor needed for local shape
315311 type(tem_levelDesc_type ), optional, intent(in) :: levelDesc(:)
316312 !> bc property which is used to identify elements belong to certain BCs
@@ -333,7 +329,6 @@
333329 ! if the local rank has part of the tracking object
334330 logical :: participateInMesh, globalParticipateInMesh
335331 ! if any element be found for this iShape
336- logical :: foundAny
337332 integer :: local_countElems( globalMaxLevels )
338333 integer :: local_countPnts
339334 logical :: local_storePnts
@@ -377,59 +372,28 @@
377372
378373 do iShape = 1, size( inShape )
379374
380- select case( inShape(iShape)%shapeID )
381- case( tem_geometrical_shape )
382- ! Use elements intersecting a geometrical object
383- call tem_log(5, 'iShape '//trim(tem_toStr(iShape)) &
384- & //' is geometrical shape')
385- call tem_shape_subTreeFromGeomInters( me = inShape(iShape), &
386- & inTree = inTree, &
387- & countElems = local_countElems, &
388- & countPoints = local_countPnts, &
389- & grwPnts = local_grwPnts, &
390- & storePnts = local_storePnts, &
391- & map2global = local_map2global )
392-
393- case( tem_property_shape )
394- ! Only use elements with a certain property
395- call tem_log(5, 'iShape '//trim(tem_toStr(iShape))//' is a property shape')
396- call tem_shape_initPropElements( inShape(iShape)%propBits, inTree, &
397- & local_countElems, local_map2global )
375+ call tem_shape2subTree(me = inShape(iShape), &
376+ & iShape = iShape, &
377+ & inTree = inTree, &
378+ & storePnts = local_storePnts, &
379+ & map2global = local_map2global, &
380+ & grwPnts = local_grwPnts, &
381+ & countElems = local_countElems, &
382+ & countPnts = local_countPnts, &
383+ & bcIDs = subTree%bc_ID, &
384+ & bc_prop = bc_prop, &
385+ & stencil = stencil )
398386
399- case( tem_boundary_shape )
400- ! Only use elements belong to certain boundaries
401- call tem_log(5, 'iShape '//trim(tem_toStr(iShape))//' is a boundary shape')
402- if (present(bc_prop) .and. present(stencil)) then
403- call tem_shape_findElemByBCLabels( bcLabels = inShape(iShape) &
404- & %bcLabels, &
405- & bc_prop = bc_prop, &
406- & foundAny = foundAny, &
407- & map2global = local_map2Global, &
408- & bcIDs = subTree%bc_ID, &
409- & stencil = stencil )
410- if ( foundAny ) local_countElems = 1
411- else
412- call tem_abort('In tem_create_subTree_of: Stencil or bc_prop not' &
413- & //'passed')
414- end if
415-
416- case( tem_level_shape )
417- call tem_log(5, 'iShape '//trim(tem_toStr(iShape))//' is a level shape')
418- call tem_shape_initByLevels( inTree, inShape(iShape)%minLevel, &
419- & inShape(iShape)%maxLevel, &
420- & local_countElems, local_map2global )
421- end select ! shapeID
422387 end do ! iShape
423388
424389 participateInMesh = ( sum(local_countElems) > 0 .or. local_countPnts > 0 )
390+
425391 ! abort if no elements are found for the given shape
426392 call MPI_ALLREDUCE( participateInMesh, globalParticipateInMesh, 1, &
427393 & MPI_LOGICAL, MPI_LOR, inTree%global%comm, iError )
428394 if (.not. globalParticipateInMesh) then
429- !TODO: treat points that lie outside the domain but may be sufficiently
430- ! close.
431- write(logUnit(1),*) 'Error: No elements found for '// &
432- & 'defined shape '//trim(prefix)//' in the mesh'
395+ write(logUnit(1),*) 'Error: No elements found for ' &
396+ & // trim(subTree%global%dirname) // ' in the mesh'
433397 call tem_abort()
434398 end if
435399
@@ -641,63 +605,6 @@
641605
642606
643607 ! ****************************************************************************** !
644- !> This routine identify all the elements in inTree that has a certain property
645- !! bit, save their positions in inTree into array: map2global,
646- !! save the number of these elements into level wise array: countElems
647- !! (e.g. for shape kind='property').
648- !!
649- subroutine tem_shape_initPropElements( propBits, inTree, countElems, map2global )
650- ! ---------------------------------------------------------------------------
651- !> shape objects on which to work
652- integer( kind=long_k ), intent(in) :: propBits
653- !> Global mesh from which the elements are identified and then stored to
654- type( treelmesh_type ), intent(in) :: inTree
655- !> How many elements there will be for each level in the track
656- integer, intent( out ) :: countElems( globalMaxLevels )
657- !> growing array. Elements positions in inTree%treeID
658- type(dyn_intArray_type), intent(inout) :: map2global
659- ! ---------------------------------------------------------------------------
660- integer(kind=long_k) :: elemProp, match
661- integer :: tLevel, dPos, iElem
662- logical :: wasAdded
663- ! ---------------------------------------------------------------------------
664-
665- write(logUnit(1),*) 'Initializing shapes of elements that have a '// &
666- & 'certain property'
667-
668- ! Loop over all elements in inTree
669- do iElem = 1, inTree%nElems
670-
671- ! get its property bits
672- elemProp = inTree%elemPropertyBits( iElem )
673-
674- ! check whether its property
675- match = iand( propBits, elemProp )
676-
677- if( match > 0_long_k ) then
678-
679- ! Append to treeID list (note that already existing ones are
680- ! omitted)
681- call append( me = map2global, &
682- & pos = dPos, &
683- & val = iElem, &
684- & wasAdded = wasAdded )
685-
686- ! Count up if it was added
687- if( wasAdded ) then
688- tLevel = tem_levelOf( inTree%treeID(iElem) )
689- countElems( tLevel ) = countElems( tLevel ) + 1
690- end if ! wasAdded
691-
692- end if ! match > 0
693-
694- end do ! iElem
695-
696- end subroutine tem_shape_initPropElements
697-! ****************************************************************************** !
698-
699-
700-! ****************************************************************************** !
701608 !> This subroutine collects the treeIDs of all elements in the level
702609 !! descriptor on the local partition (e.g. used in debug mesh, no general
703610 !! option for now).
@@ -794,172 +701,5 @@
794701 end subroutine tem_write_debugMesh
795702 ! ****************************************************************************** !
796703
797-! ****************************************************************************** !
798- !> This routine identify elements that belong to certain bounaries.
799- !! Labels of required boundaries are given by bcLabels.
800- !! bc_prop contains boudnary_ID of all local elements.
801- !! Firstly, bcLabels are converted into bcIDs.
802- !! Then all elements in bc_prop are looped over to check if it matches one of
803- !! the required bcID. If match, its position is save in map2global.
804- !! Number of elements found on each level is saved in countElems.
805- subroutine tem_shape_findElemByBCLabels( bcLabels, bc_prop, &
806- & foundAny, map2global, bcIDs, stencil)
807- ! ---------------------------------------------------------------------------
808- !> bcLabels
809- character(len=labelLen), intent(in) :: bcLabels(:)
810- !> bc property
811- type( tem_bc_prop_type ), intent(in) :: bc_prop
812- !> if any element be identified
813- logical, intent(out) :: foundAny
814- !> dynamic array. Elements positions in bc_prop%property%elemID
815- type(dyn_intArray_type), intent(inout) :: map2global
816- !> id of boundary condition to be tracked
817- integer, allocatable, intent(out) :: bcIDs(:)
818- !> stencil required to get useful links
819- type( tem_stencilHeader_type ), optional, intent(in) :: stencil
820- ! ---------------------------------------------------------------------------
821- integer :: dPos, iElem, iBC, nBCs, iBCtype, posInTree, QQN
822- logical :: wasAdded, found
823- integer, allocatable :: map(:)
824- ! ---------------------------------------------------------------------------
825-
826- if( present( stencil ) ) then
827- allocate( map( size(stencil%map) ) )
828- map = stencil%map
829- qqn = stencil%QQN
830- else
831- allocate( map(qQQQ) )
832- map = qDir
833- qqn = qQQQ
834- end if
835-
836-! write(*,*) 'inside tem_shape_findElemByBCLabels routine'
837-
838- foundAny = .false.
839- ! convert bcLabels to bcIDs
840- nBCs = size(bcLabels)
841- allocate( bcIDs( nBCs ) )
842-
843-! write(*,*) 'size of bcLabels: ', nBCs
844-
845- ! loop over all required bcLabels
846- do iBC = 1, nBCs
847-
848- found = .false.
849-
850- ! loop over all BCs in the mesh
851- do iBCtype = 1, bc_prop%nBCtypes
852- if ( trim(bcLabels(iBC)) == bc_prop%bc_label( iBCtype ) ) then
853- bcIDs( iBC ) = iBCtype
854- found = .true.
855-! write(*,*) 'required bc label: '//trim(bcLabels(iBC))
856-! write(*,*) 'its bcID: ', bcIDs(iBC)
857- exit
858- end if
859- end do
860-
861- if ( .not. found ) then
862- write(logUnit(1),*) 'Required BC label: '//trim(bcLabels(iBC))
863- write(logUnit(1),*) 'can not be found in given mesh!'
864- stop
865- end if
866- end do ! iBC
867-! write(*,*) 'finished find bcIDs'
868-! write(*,*) 'nElems of bc_prop%property:', bc_prop%property%nElems
869-
870- ! Loop over all element with boundary property
871- do iElem = 1, bc_prop%property%nElems
872-
873- do iBC = 1, nBCs
874- if ( any(int(bc_prop%boundary_ID( map(:qqn), iElem )) == bcIDs(iBC) ) ) then
875-
876- posInTree = bc_prop%property%elemID(iElem)
877- ! Append to treeID list (note that already existing ones are
878- ! omitted)
879- call append( me = map2global, &
880- & pos = dPos, &
881- & val = posInTree, &
882- & wasAdded = wasAdded )
883-
884- ! Count up if it was added
885- if( wasAdded ) then
886- ! tLevel = tem_levelOf( inTree%treeID(posInTree) )
887- ! countElems( tLevel ) = countElems( tLevel ) + 1
888- foundAny = .true.
889-
890-! write(*,*) 'Found a element on level: ', tLevel
891- exit ! continue with next element
892- end if ! wasAdded
893-
894- end if ! boundary_ID == bcIDs
895- end do
896-
897- end do ! iElem
898-
899- end subroutine tem_shape_findElemByBCLabels
900-! ****************************************************************************** !
901-
902-! ****************************************************************************** !
903- subroutine tem_shape_initByLevels( inTree, minLevel, maxLevel, countElems, &
904- & map2global )
905- ! ---------------------------------------------------------------------------
906- !> Global mesh from which the elements are identified and then stored to
907- type( treelmesh_type ), intent(in) :: inTree
908- !> level range of target elements
909- integer, intent(in) :: minLevel, maxLevel
910- !> How many elements there will be for each level in the track
911- integer, intent(out) :: countElems( globalMaxLevels )
912- !> growing array. Elements positions in inTree%treeID
913- type(dyn_intArray_type), intent(inout) :: map2global
914- ! ---------------------------------------------------------------------------
915- integer(kind=long_k) :: myID, minID, maxID
916- integer :: tLevel, dPos, iElem, loc_min, loc_max
917- logical :: wasAdded
918- ! ---------------------------------------------------------------------------
919-
920- loc_min = minLevel
921- loc_max = maxLevel
922- if ( minLevel > maxLevel ) then
923- ! take inverse
924- loc_min = maxLevel
925- loc_max = minLevel
926- end if
927-
928- if ( minLevel < 1 ) loc_min = 1
929- if ( maxLevel > globalMaxLevels ) loc_max = globalMaxLevels
930-
931- call tem_log(3, 'Initializing shapes by elements between level '&
932- & //trim(tem_toStr(loc_min))//' and '//trim(tem_toStr(loc_max)) )
933-
934- ! the treeID range is the first ID on min level and the last ID on max level
935- minID = tem_firstIdAtLevel( loc_min )
936- maxID = tem_lastIdAtLevel( loc_max )
937-
938- ! Loop over all elements in inTree
939- do iElem = 1, inTree%nElems
940-
941- myID = inTree%treeID(iElem)
942-
943- if( (myID >= minID) .and. (myID <= maxID) ) then
944- ! Append to treeID list (note that already existing ones are
945- ! omitted)
946- call append( me = map2global, &
947- & pos = dPos, &
948- & val = iElem, &
949- & wasAdded = wasAdded )
950-
951- ! Count up if it was added
952- if( wasAdded ) then
953- tLevel = tem_levelOf( inTree%treeID(iElem) )
954- countElems( tLevel ) = countElems( tLevel ) + 1
955- end if ! wasAdded
956-
957- end if
958-
959- end do ! iElem
960-
961- end subroutine tem_shape_initByLevels
962-! ****************************************************************************** !
963-
964704 end module tem_subTree_module
965705 ! ****************************************************************************** !
Show on old repository browser