Searches database for references of a given node or element ID number.
Useful for debugging error messages from the solver to determine what a
given node or element is involved in (contact sets, loads, etc)
#######################################################################################
proc SearchComps {} {
global query_type query_id complist compidlist
# query_type = 0 element, query_type=1 node
if { $query_type == 0 } {
# element data
set compidlist [hm_getentityvalue elements $query_id collector.id 0]
set complist [hm_getcollectorname components $compidlist]
} else {
# node data
hm_blockmessages 1
*clearmark components 2
*clearmark nodes 1
*createmark nodes 1 $query_id
catch {*findmark nodes 1 1 1 components 0 2}
hm_blockmessages 0
set compidlist [hm_getmark components 2]
foreach compid [set compidlist] {
set compname [hm_getcollectorname components $compid]
lappend complist "$compname"
}
#end of if query type
}
*createmark sets 1 "all"
set allsets [hm_getmark sets 1]
foreach setid [set allsets] {
set settype [hm_getentityvalue sets $setid type 0]
set listmax [hm_getentityvalue sets $setid idsmax 0]
set currentsetname [hm_getentityvalue sets $setid name 1]
if { $query_type == 0 && $settype == 2 } {
# check if this element is in the set
set currentsetids [ hm_getentityarray sets $setid elements ]
for {set x 0} {$x<$listmax} {incr x} {
set setelement [lindex $currentsetids $x]
#tk_messageBox -message "set contains elements $setelement"
if { $query_id == $setelement } {
tk_messageBox -title Query -icon info -message "Set $currentsetname contains element $query_id"
lappend setidlist $setid
lappend setlist "$currentsetname"
}
}
#end of if query 0 settype 2
}
if { $query_type == 0 && $settype == 3 } {
# check if this element is in the components of the set
set currentsetids [ hm_getentityarray sets $setid components ]
for {set x 0} {$x<$listmax} {incr x} {
set setcomponent [lindex $currentsetids $x]
if { $compidlist == $setcomponent } {
set setcompname [hm_getcollectorname components $setcomponent]
tk_messageBox -title Query -icon info -message "Set $currentsetname contains component $setcompname with element $query_id"
lappend setidlist $setid
lappend setlist "$currentsetname"
}
}
#end of if query 0 settype 3
}
if { $query_type == 1 && $settype == 1 } {
# check if this node is in the set
set currentsetids [ hm_getentityarray sets $setid nodes ]
for {set x 0} {$x<$listmax} {incr x} {
set setnode [lindex $currentsetids $x]
if { $query_id == $setnode } {
tk_messageBox -title Query -icon info -message "Set $currentsetname contains node $query_id"
lappend setidlist $setid
lappend setlist "$currentsetname"
}
}
#end of if query 1 settype 1
}
if { $query_type == 1 && $settype == 3 } {
# check if this node is in the components of the set
set currentsetids [ hm_getentityarray sets $setid components ]
for {set x 0} {$x<$listmax} {incr x} {
set setcomponent [lindex $currentsetids $x]
foreach xx [set compidlist] {
if { $xx == $setcomponent } {
set setcompname [hm_getcollectorname components $setcomponent]
tk_messageBox -title Query -icon info -message "Set $currentsetname contains component $setcompname with node $query_id"
lappend setidlist $setid
lappend setlist "$currentsetname"
}
}
}
#end of if query 0 settype 3
}
# query_type = 0 element, query_type=1 node
if { $query_type == 0 } {
# find groups attached to search element
hm_blockmessages 1
*clearmark elements 1
*clearmark groups 1
*createmark elements 1 $query_id
*findmark elements 1 1 1 groups 0 1
hm_blockmessages 0
set directsets [hm_getmark groups 1]
lappend groupidlist $directsets
} else {
# find groups attached to search node
hm_blockmessages 1
*clearmark nodes 1
*clearmark groups 1
*clearmark groups 2
*createmark nodes 1 $query_id
*findmark nodes 1 1 1 groups 0 2
hm_blockmessages 0
set directsets [hm_getmark groups 2]
lappend groupidlist $directsets
# end of query type
}
foreach yy [set groupidlist] {
if { [string length $yy] != 0 } {
set groupname [hm_getcollectorname groups $yy]
lappend grouplist "$groupname"
if { $query_type == 0 } {
tk_messageBox -title Query -icon info -message "Group $groupname contains element $query_id"
} else {
tk_messageBox -title Query -icon info -message "Group $groupname contains node $query_id"
}
}
#end of foreach yy
}
if { $query_type == 0 } {
# find contact surfs attached to search element
hm_blockmessages 1
*clearmark elements 1
*clearmark contactsurfs 1
*createmark elements 1 $query_id
*findmark elements 1 1 1 contactsurfs 0 1
hm_blockmessages 0
set csidlist [hm_getmark contactsurfs 1]
# end of query type
}
*clearmark groups 1
*createmark groups 1 "all"
set allgroups [hm_getmark groups 1]
foreach groupid [set allgroups] {
set mastertype [hm_getentityvalue groups $groupid masterdefinition 0]
set slavetype [hm_getentityvalue groups $groupid slavedefinition 0]
set currentgroupname [hm_getentityvalue groups $groupid name 1]
if { $query_type == 0 && $mastertype == 1 } {
# check if this element is in a component of the group
set masterlistmax [hm_getentityvalue groups $groupid mastercomponentlistmax 0]
set currentmasterids [ hm_getentityarray groups $groupid mastercomponentlist ]
for {set x 0} {$x<$masterlistmax} {incr x} {
set groupcomp [lindex $currentmasterids $x]
if { $compidlist == $groupcomp } {
set groupcompname [hm_getcollectorname components $groupcomp]
tk_messageBox -title Query -icon info -message "Group $currentgroupname contains component $groupcompname with element $query_id"
lappend groupidlist $groupid
lappend grouplist "$currentgroupname"
}
}
#end of if query 0 mastertype 1
}
if { $query_type == 0 && $slavetype == 1 } {
# check if this element is in a component of the group
set slavelistmax [hm_getentityvalue groups $groupid slavecomponentlistmax 0]
set currentslaveids [ hm_getentityarray groups $groupid slavecomponentlist ]
for {set x 0} {$x<$slavelistmax} {incr x} {
set groupcomp [lindex $currentslaveids $x]
if { $compidlist == $groupcomp } {
set groupcompname [hm_getcollectorname components $groupcomp]
tk_messageBox -title Query -icon info -message "Group $currentgroupname contains component $groupcompname with element $query_id"
lappend groupidlist $groupid
lappend grouplist "$currentgroupname"
}
}
#end of if query 0 slavetype 1
}
if { $query_type == 0 && $mastertype == 4 } {
# check if this element is in the sets of the group
set masterlistmax [hm_getentityvalue groups $groupid mastersetlistmax 0]
set currentmasterids [ hm_getentityarray groups $groupid mastersetlist ]
for {set x 0} {$x<$masterlistmax} {incr x} {
set groupset [lindex $currentmasterids $x]
foreach xx [set setidlist] {
if { $xx == $groupset } {
set groupsetname [hm_getcollectorname sets $groupset]
tk_messageBox -title Query -icon info -message "Group $currentgroupname contains set $groupsetname with element $query_id"
lappend groupidlist $groupid
lappend grouplist "$currentgroupname"
}
#end of foreach xx
}
}
#end of if query 0 mastertype 4
}
if { $query_type == 0 && $slavetype == 4 } {
# check if this element is in the sets of the group
set slavelistmax [hm_getentityvalue groups $groupid slavesetlistmax 0]
set currentslaveids [ hm_getentityarray groups $groupid slavesetlist ]
for {set x 0} {$x<$slavelistmax} {incr x} {
set groupset [lindex $currentslaveids $x]
foreach xx [set setidlist] {
if { $xx == $groupset } {
set groupsetname [hm_getcollectorname sets $groupset]
tk_messageBox -title Query -icon info -message "Group $currentgroupname contains set $groupsetname with element $query_id"
lappend groupidlist $groupid
lappend grouplist "$currentgroupname"
}
#end of foreach xx
}
}
#end of if query 0 slavetype 4
}
if { $query_type == 0 && $mastertype == 5 } {
# check if this element is in the contactsurfs of the group
set masterlistmax [hm_getentityvalue groups $groupid mastercontactsurflistmax 0]
set currentmasterids [ hm_getentityarray groups $groupid mastercontactsurflist ]
for {set x 0} {$x<$masterlistmax} {incr x} {
set groupcs [lindex $currentmasterids $x]
foreach xx [set csidlist] {
if { $xx == $groupcs } {
set groupcsname [hm_getcollectorname contactsurfs $groupcs]
tk_messageBox -title Query -icon info -message "Group $currentgroupname contains surface $groupcsname with element $query_id"
lappend groupidlist $groupid
lappend grouplist "$currentgroupname"
}
#end of foreach xx
}
}
#end of if query 0 mastertype 5
}
if { $query_type == 0 && $slavetype == 5 } {
# check if this element is in the contactsurfs of the group
set slavelistmax [hm_getentityvalue groups $groupid slavecontactsurflistmax 0]
set currentslaveids [ hm_getentityarray groups $groupid slavecontactsurflist ]
for {set x 0} {$x<$slavelistmax} {incr x} {
set groupcs [lindex $currentslaveids $x]
foreach xx [set csidlist] {
if { $xx == $groupcs } {
set groupcsname [hm_getcollectorname contactsurfs $groupcs]
tk_messageBox -title Query -icon info -message "Group $currentgroupname contains surface $groupcsname with element $query_id"
lappend groupidlist $groupid
lappend grouplist "$currentgroupname"
}
#end of foreach xx
}
}
#end of if query 0 slavetype 5
}
if { $query_type == 1 && $mastertype == 1 } {
# check if this node is in a component of the group
set masterlistmax [hm_getentityvalue groups $groupid mastercomponentlistmax 0]
set currentmasterids [ hm_getentityarray groups $groupid mastercomponentlist ]
for {set x 0} {$x<$masterlistmax} {incr x} {
set groupcomp [lindex $currentmasterids $x]
if { $compidlist == $groupcomp } {
set groupcompname [hm_getcollectorname components $groupcomp]
tk_messageBox -title Query -icon info -message "Group $currentgroupname contains component $groupcompname with node $query_id"
lappend groupidlist $groupid
lappend grouplist "$currentgroupname"
}
}
#end of if query 1 mastertype 1
}
if { $query_type == 1 && $slavetype == 1 } {
# check if this node is in a component of the group
set slavelistmax [hm_getentityvalue groups $groupid slavecomponentlistmax 0]
set currentslaveids [ hm_getentityarray groups $groupid slavecomponentlist ]
for {set x 0} {$x<$slavelistmax} {incr x} {
set groupcomp [lindex $currentslaveids $x]
if { $compidlist == $groupcomp } {
set groupcompname [hm_getcollectorname components $groupcomp]
tk_messageBox -title Query -icon info -message "Group $currentgroupname contains component $groupcompname with node $query_id"
lappend groupidlist $groupid
lappend grouplist "$currentgroupname"
}
}
#end of if query 1 slavetype 1
}
if { $query_type == 1 && $mastertype == 4 } {
# check if this node is in the sets of the group
set masterlistmax [hm_getentityvalue groups $groupid mastersetlistmax 0]
set currentmasterids [ hm_getentityarray groups $groupid mastersetlist ]
for {set x 0} {$x<$masterlistmax} {incr x} {
set groupset [lindex $currentmasterids $x]
foreach xx [set setidlist] {
if { $xx == $groupset } {
set groupsetname [hm_getcollectorname sets $groupset]
tk_messageBox -title Query -icon info -message "Group $currentgroupname contains set $groupsetname with node $query_id"
lappend groupidlist $groupid
lappend grouplist "$currentgroupname"
}
#end of foreach xx
}
}
#end of if query 1 mastertype 4
}
if { $query_type == 1 && $slavetype == 4 } {
# check if this node is in the sets of the group
set slavelistmax [hm_getentityvalue groups $groupid slavesetlistmax 0]
set currentslaveids [ hm_getentityarray groups $groupid slavesetlist ]
for {set x 0} {$x<$slavelistmax} {incr x} {
set groupset [lindex $currentslaveids $x]
foreach xx [set setidlist] {
if { $xx == $groupset } {
set groupsetname [hm_getcollectorname sets $groupset]
tk_messageBox -title Query -icon info -message "Group $currentgroupname contains set $groupsetname with node $query_id"
lappend groupidlist $groupid
lappend grouplist "$currentgroupname"
}
#end of foreach xx
}
}
#end of if query 1 slavetype 4
}
# end of foreach setid
}
# end of SearchGroups
}
#######################################################################################
proc SearchLoads {} {
global query_type query_id compidlist setidlist setlist
global codetype sumfile
# query_type = 0 element, query_type=1 node
if { $query_type == 0 } {
# element data - check for attached load
hm_blockmessages 1
*clearmark loads 2
*clearmark elements 1
*createmark elements 1 $query_id
*findmark elements 1 1 1 loads 0 2
hm_blockmessages 0
set loadidlist [hm_getmark loads 2]
foreach loadid [set loadidlist] {
set loadcol [hm_getentityvalue loads $loadid collector.id 0]
if { $loadcol == 0 } {
set loadcol [hm_getentityvalue loads $loadid collectorid.id 0]
}
set loadcolname [hm_getcollectorname loadcols $loadcol]
set loadtype [hm_getentityvalue loads $loadid config 0]
switch $loadtype {
1 { set loadtypename "force"}
2 { set loadtypename "moment"}
8 { set loadtypename "velocity"}
9 { set loadtypename "acceleration"}
3 { set loadtypename "constraint"}
4 { set loadtypename "pressure"}
5 { set loadtypename "temperature"}
6 { set loadtypename "flux"}
default { set loadtypename "unknown"}
}
tk_messageBox -title Query -icon info -message "Element $query_id has $loadtypename load $loadid attached from load collector $loadcolname"
puts $sumfile [format "Element %9i has %s load %9i attached from load collector %s." "$query_id" "$loadtypename" "$loadid" "$loadcolname"]
}
flush $sumfile
} else {
# node data - check for attached load
hm_blockmessages 1
*clearmark loads 2
*clearmark nodes 1
*createmark nodes 1 $query_id
*findmark nodes 1 1 1 loads 0 2
hm_blockmessages 0
set loadidlist [hm_getmark loads 2]
foreach loadid [set loadidlist] {
set loadcol [hm_getentityvalue loads $loadid collector.id 0]
if { $loadcol == 0 } {
set loadcol [hm_getentityvalue loads $loadid collectorid.id 0]
}
set loadcolname [hm_getcollectorname loadcols $loadcol]
set loadtype [hm_getentityvalue loads $loadid config 0]
switch $loadtype {
1 { set loadtypename "force"}
2 { set loadtypename "moment"}
8 { set loadtypename "velocity"}
9 { set loadtypename "acceleration"}
3 { set loadtypename "constraint"}
4 { set loadtypename "pressure"}
5 { set loadtypename "temperature"}
6 { set loadtypename "flux"}
default { set loadtypename "unknown"}
}
tk_messageBox -title Query -icon info -message "Node $query_id has $loadtypename load $loadid attached from load collector $loadcolname"
puts $sumfile [format "Node %9i has %s load %9i attached from load collector %s." "$query_id" "$loadtypename" "$loadid" "$loadcolname"]
}
flush $sumfile
#end of if query type
}
if { $query_type == 0 && $codetype == 2} {
# element search, ABAQUS model Look for DLOAD load collector
foreach loadcolid [set allloadcols] {
set loadcoltype [hm_getentityvalue loadcols $loadcolid \$Dload_Parameters 0]
set currentlcname [hm_getentityvalue loadcol $loadcolid name 1]
if { $loadcoltype == 1} {
# this is a DLOAD, search for elset
#tk_messageBox -message "Loadcol $currentlcname has DLOAD"
set withelset [hm_getentityvalue loadcols $loadcolid "\$Dload_Elset" 0]
if { $withelset == 1} {
set loadsetname [hm_getentityvalue loadcols $loadcolid "\$Dload_Elset_Name.name" 1]
#set loadsetid [hm_getentityvalue set "$loadsetname" id 0]
#tk_messageBox -message "Load uses set $loadsetname "
foreach xx [set setlist] {
if { [string compare -nocase $xx $loadsetname] } {
tk_messageBox -title Query -icon info -message "Loadcollector $currentlcname contains DLOAD with Entity Set $loadsetname with element $query_id"
puts $sumfile [format "Loadcollector %s contains DLOAD with Entity Set %s containing element %9i" "$currentlcname" "$loadsetname" "$query_id"]
}
#end of foreach xx
}
}
}
# end of foreach loadcolid
}
#end of if codetype2
}
if { $query_type == 1 && $codetype == 2} {
# node search, ABAQUS model Look for CLOAD load collector with NSET
foreach loadcolid [set allloadcols] {
set loadcoltype [hm_getentityvalue loadcols $loadcolid \$Cload_Parameters 0]
set currentlcname [hm_getentityvalue loadcol $loadcolid name 1]
if { $loadcoltype == 1} {
# this is a CLOAD, search for nset
set withelset [hm_getentityvalue loadcols $loadcolid "\$Cload_Nset" 0]
if { $withelset == 1} {
set loadsetname [hm_getentityvalue loadcols $loadcolid "\$Cload_Nset_Name.name" 1]
#set loadsetid [hm_getentityvalue set "$loadsetname" id 0]
foreach xx [set setidlist] {
if { [string compare -nocase $xx $loadsetname] } {
tk_messageBox -title Query -icon info -message "Loadcollector $currentlcname contains CLOAD with Entity Set $loadsetname with node $query_id"
puts $sumfile [format "Loadcollector %s contains CLOAD with Entity Set %s containing node %9i" "$currentlcname" "$loadsetname" "$query_id"]
}
#end of foreach xx
}
}
}
# end of foreach loadcolid
}
#end of if codetype2
}
if { $query_type == 1 && $codetype == 1} {
# node search, Dyna model Look for INITIAL VELOCITY (InitialVel) or BOUNDARY PRESCRIBED MOTION RIGID or
# BOUNDARY SPC SET (BoundSpcSet) with NSET
foreach loadcolid [set allloadcols] {
set currentlcname [hm_getentityvalue loadcol $loadcolid name 1]
set loadsetid [hm_getentityvalue loadcols $loadcolid "\$LSD_NSID" 0]
if { $loadsetid != 0} {
set loadsetname [hm_getentityvalue set $loadsetid name 1]
foreach xx [set setidlist] {
if { [string compare -nocase $xx $loadsetname] } {
tk_messageBox -title Query -icon info -message "Loadcollector $currentlcname references Entity Set $loadsetname with node $query_id"
puts $sumfile [format "Loadcollector %s references Entity Set %s containing node %9i" "$currentlcname" "$loadsetname" "$query_id"]
}
#end of foreach xx
}
}
# end of foreach loadcolid
}
#end of if codetype1
}
if { $query_type == 0 && $codetype == 1} {
# element search, Dyna model Look for BOUNDARY PRESCRIBED MOTION (PrcrbRgd) or LOAD RIGID BODY (LoadRBody) with PID
proc GetTemplate {} {
global codename templatefile codetype
set codename [hm_info templatecodename]
set templatefile [hm_info templatefilename]
#tk_messageBox -message "Code $codename"
switch $codename {
"LS-Dyna" { set codetype 1
}
"LS-DYNA3D" { set codetype 1
}
"abaqus" { set codetype 2
}
"nastran" { set codetype 3
}
"optistruct" { set codetype 4
}
default { tk_messageBox -title Query -icon error -message "WRONG template is loaded in HM. \n Please load a template and try again.";
}
}
# end of GetTemplate
}
#######################################################################################
#
# Main procedure
proc QueryDB {} {
global lastpath summary_file query_id query_type
global codetype
global complist compidlist setlist setidlist grouplist groupidlist
global check_groups check_loads sumfile
# find working directory
FindDirectory
# get template type
GetTemplate
set query_id [expr $query_id * 1 ]
set summary_file "$lastpath"
append summary_file "\\$query_id"
append summary_file "_query.txt"
set sumfile [open "$summary_file" w+]
#tk_messageBox -message "opened $summary_file"
puts $sumfile "Query ID Macro - search database for usage of an element or node"
set complist ""
set compidlist {}
set setlist ""
set setidlist {}
set grouplist ""
set groupidlist {}
# search for id number in components
SearchComps
if {$query_type == 0 } {
puts $sumfile [format "Element %9i is in the following component: \n\ %s" "$query_id" "$complist"]
tk_messageBox -title Query -icon info -message "Element $query_id is in component: $complist"
} else {
puts $sumfile [format "Node %9i is in the following components:" "$query_id"]
puts $sumfile [format "%s" "$complist"]
tk_messageBox -title Query -icon info -message "Node $query_id is in components: $complist"
}
flush $sumfile
# search for id number in sets
set exist_sets [hm_count sets "all" 0 0 ]
if { $exist_sets != 0 } {
SearchSets
}
if {$query_type == 0 } {
puts $sumfile [format "Element %9i is in the following sets:" "$query_id"]
puts $sumfile [format "%s" "$setlist"]
} else {
puts $sumfile [format "Node %9i is in the following sets:" "$query_id"]
puts $sumfile [format "%s" "$setlist"]
}
flush $sumfile
# search for id number in groups
if { $check_groups == 1 } {
set exist_groups [hm_count groups "all" 0 0 ]
if { $exist_groups != 0 } {
SearchGroups
}
#end of if check groups
}
if {$query_type == 0 } {
puts $sumfile [format "Element %9i is in the following groups:" "$query_id"]
puts $sumfile [format "%s" "$grouplist"]
} else {
puts $sumfile [format "Node %9i is in the following groups:" "$query_id"]
puts $sumfile [format "%s" "$grouplist"]
}
flush $sumfile
# search for id number in loads
if { $check_loads == 1 } {
set exist_loads [hm_count loads "all" 0 0 ]
if { $exist_loads != 0 } {
SearchLoads
}
#end of if check loads
}
flush $sumfile
close $sumfile;
tk_messageBox -title Query -icon info -message " See summary file $summary_file \n\ for text file of references.";