|
1 | 1 |
|
2 | 2 | proc ::CDEM::examples::BulkGroup {args} { |
| 3 | + |
| 4 | + |
3 | 5 | if {![Kratos::IsModelEmpty]} { |
4 | | - set txt "Bulk grouping of all the current volumes is about to be executed" |
| 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" |
5 | 11 | set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel] |
6 | 12 | if { $retval == "cancel" } { return } |
7 | 13 | } |
8 | 14 |
|
9 | | - |
10 | | - if {$::Model::SpatialDimension eq "2D"} { |
11 | | - CreateAndAssign2DBondedGroups |
12 | | - } else { |
13 | | - CreateAndAssign3DBondedGroups |
14 | | - } |
15 | | - |
| 15 | + CreateAndAssignBondedGroups |
| 16 | + |
16 | 17 | GiD_Process 'Redraw |
17 | 18 | GidUtils::UpdateWindow GROUPS |
18 | 19 | GidUtils::UpdateWindow LAYER |
19 | 20 | GiD_Process 'Zoom Frame |
20 | 21 | } |
21 | 22 |
|
22 | | -proc ::CDEM::examples::CreateAndAssign3DBondedGroups { } { |
23 | | - |
24 | | - set volume_list [GiD_Geometry -v2 list volume] |
25 | | - |
26 | | - for {set i 0} {$i < [llength $volume_list]} {incr i} { |
27 | | - |
28 | | - set volume_id [lindex $volume_list $i] |
29 | | - GiD_Groups create Bonded_domain_groups//SG$volume_id |
30 | | - GiD_EntitiesGroups assign Bonded_domain_groups//SG$volume_id volumes $volume_id |
31 | | - |
32 | | - set DEMConditions [spdAux::getRoute "DEMConditions"] |
33 | | - set cohesive_cond "$DEMConditions/condition\[@n='DEM-Cohesive'\]" |
34 | | - set cohesive_group [customlib::AddConditionGroupOnXPath $cohesive_cond Bonded_domain_groups//SG$volume_id] |
| 23 | +proc ::CDEM::examples::CreateAndAssignBondedGroups { } { |
| 24 | + # Prepare the variables |
| 25 | + set entity surface |
| 26 | + set condition_id "DEM-Cohesive2D" |
| 27 | + if {$::Model::SpatialDimension eq "3D"} { |
| 28 | + set entity volume |
| 29 | + set condition_id "DEM-Cohesive" |
35 | 30 | } |
36 | | -} |
37 | | - |
38 | | -proc ::CDEM::examples::CreateAndAssign2DBondedGroups { } { |
39 | | - |
40 | | - set surface_list [GiD_Geometry -v2 list surface] |
41 | | - |
42 | | - for {set i 0} {$i < [llength $surface_list]} {incr i} { |
43 | | - |
44 | | - set surface_id [lindex $surface_list $i] |
45 | | - GiD_Groups create Bonded_domain_groups//SG$surface_id |
46 | | - GiD_EntitiesGroups assign Bonded_domain_groups//SG$surface_id surfaces $surface_id |
47 | | - |
48 | | - set DEMConditions [spdAux::getRoute "DEMConditions"] |
49 | | - set cohesive_cond "$DEMConditions/condition\[@n='DEM-Cohesive2D'\]" |
50 | | - set cohesive_group [customlib::AddConditionGroupOnXPath $cohesive_cond Bonded_domain_groups//SG$surface_id] |
| 31 | + # Locate the condition |
| 32 | + set DEMConditions [spdAux::getRoute "DEMConditions"] |
| 33 | + set cohesive_cond "$DEMConditions/condition\[@n='$condition_id'\]" |
| 34 | + |
| 35 | + # Get the list of entities (surfaces/volumes) |
| 36 | + set entity_list [GiD_Geometry -v2 list $entity] |
| 37 | + # Foreach entity, create subgroup and assign it to the condition |
| 38 | + set entity_list_length [objarray length $entity_list] |
| 39 | + for {set i 0} {$i < $entity_list_length} {incr i} { |
| 40 | + # Get the entity id |
| 41 | + set entity_id [objarray get $entity_list $i] |
| 42 | + # Create the subgroup |
| 43 | + set group_id "Bonded_domain_groups//SG$entity_id" |
| 44 | + GiD_Groups create $group_id |
| 45 | + # Assign entity to subgroup |
| 46 | + GiD_EntitiesGroups assign $group_id volumes $entity_id |
| 47 | + # Assign the subgroup to the tree condition |
| 48 | + set cohesive_group [customlib::AddConditionGroupOnXPath $cohesive_cond $group_id] |
51 | 49 | } |
52 | 50 | } |
0 commit comments