Skip to content

Commit fd16bfc

Browse files
Merge branch 'master' into rename-xml-controllers
2 parents d3682d1 + fe123ac commit fd16bfc

4 files changed

Lines changed: 61 additions & 0 deletions

File tree

kratos.gid/apps/CDEM/examples/examples.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ proc CDEM::examples::Init { } {
99
proc CDEM::examples::UpdateMenus { } {
1010
GiDMenu::InsertOption "Kratos" [list "---"] 8 PRE "" "" "" insertafter =
1111
GiDMenu::InsertOption "Kratos" [list "Stone block and sand" ] 8 PRE [list ::CDEM::examples::ContinuumDrop] "" "" insertafter =
12+
GiDMenu::InsertOption "Kratos" [list "Bulk groups" ] 8 PRE [list ::CDEM::xml::BulkGroup] "" "" insertafter =
1213
GiDMenu::UpdateMenus
1314
}
1415

1.48 KB
Loading

kratos.gid/apps/CDEM/start.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ proc ::CDEM::LoadMyFiles { } {
3636
variable dir
3737

3838
uplevel #0 [list source [file join $dir xml XmlController.tcl]]
39+
uplevel #0 [list source [file join $dir xml BulkGroup.tcl]]
3940
uplevel #0 [list source [file join $dir write write.tcl]]
4041
uplevel #0 [list source [file join $dir write writeMDPA_Parts.tcl]]
4142
uplevel #0 [list source [file join $dir write writeMDPA_Walls.tcl]]
@@ -63,6 +64,7 @@ proc ::CDEM::CustomToolbarItems { } {
6364
if {$::Model::SpatialDimension eq "2D"} {
6465
Kratos::ToolbarAddItem "Example" [file join $dir images drop.png] [list -np- ::CDEM::examples::ContinuumDrop] [= "Example\nRocks fall"]
6566
}
67+
Kratos::ToolbarAddItem "Bulk grouping" [file join $dir images stone.png] [list -np- ::CDEM::xml::BulkGroup] [= "Plugin\nBulk grouping"]
6668
}
6769

6870
::CDEM::Init
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
proc ::CDEM::xml::BulkGroup {args} {
3+
4+
5+
if {![Kratos::IsModelEmpty]} {
6+
set entity surfaces
7+
if {$::Model::SpatialDimension eq "3D"} {
8+
set entity volumes
9+
}
10+
set txt "Bulk grouping of all the current $entity is about to be executed"
11+
set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel]
12+
if { $retval == "cancel" } { return }
13+
}
14+
15+
CreateAndAssignBondedGroups
16+
17+
GiD_Process 'Redraw
18+
GidUtils::UpdateWindow GROUPS
19+
GidUtils::UpdateWindow LAYER
20+
GiD_Process 'Zoom Frame
21+
22+
spdAux::RequestRefresh
23+
}
24+
25+
proc ::CDEM::xml::CreateAndAssignBondedGroups { } {
26+
27+
# Prepare the variables
28+
set entity surface
29+
set condition_id "DEM-Cohesive2D"
30+
if {$::Model::SpatialDimension eq "3D"} {
31+
set entity volume
32+
set condition_id "DEM-Cohesive"
33+
}
34+
set group_base Bonded_domain_groups
35+
# Locate the condition
36+
set DEMConditions [spdAux::getRoute "DEMConditions"]
37+
set cohesive_cond "$DEMConditions/condition\[@n='$condition_id'\]"
38+
39+
# Clear previous assignations
40+
if {[GiD_Groups exists $group_base]} {GiD_Groups delete $group_base}
41+
gid_groups_conds::delete "$cohesive_cond/group"
42+
43+
# Get the list of entities (surfaces/volumes)
44+
set entity_list [GiD_Geometry -v2 list $entity]
45+
# Foreach entity, create subgroup and assign it to the condition
46+
set entity_list_length [objarray length $entity_list]
47+
for {set i 0} {$i < $entity_list_length} {incr i} {
48+
# Get the entity id
49+
set entity_id [objarray get $entity_list $i]
50+
# Create the subgroup
51+
set group_id "$group_base//SG$entity_id"
52+
GiD_Groups create $group_id
53+
# Assign entity to subgroup
54+
GiD_EntitiesGroups assign $group_id $entity $entity_id
55+
# Assign the subgroup to the tree condition
56+
set cohesive_group [customlib::AddConditionGroupOnXPath $cohesive_cond $group_id]
57+
}
58+
}

0 commit comments

Comments
 (0)