|
| 1 | +namespace eval ::ShallowWater::examples::Waves { |
| 2 | + namespace path ::ShallowWater::examples |
| 3 | + Kratos::AddNamespace [namespace current] |
| 4 | +} |
| 5 | + |
| 6 | +proc ::ShallowWater::examples::Waves::Init {args} { |
| 7 | + if {![Kratos::IsModelEmpty]} { |
| 8 | + set txt "We are going to draw the example geometry.\nDo you want to lose your previous work?" |
| 9 | + set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel] |
| 10 | + if { $retval == "cancel" } { return } |
| 11 | + } |
| 12 | + DrawGeometry |
| 13 | + AssignGroups |
| 14 | + TreeAssignation |
| 15 | + |
| 16 | + GiD_Process 'Redraw |
| 17 | + GidUtils::UpdateWindow GROUPS |
| 18 | + GidUtils::UpdateWindow LAYER |
| 19 | + GiD_Process 'Zoom Frame |
| 20 | +} |
| 21 | + |
| 22 | +proc ::ShallowWater::examples::Waves::DrawGeometry {args} { |
| 23 | + Kratos::ResetModel |
| 24 | + GiD_Layers create main_layer |
| 25 | + GiD_Layers edit to_use main_layer |
| 26 | + |
| 27 | + # Geometry creation |
| 28 | + ## Points ## |
| 29 | + set coordinates [list 0 0 0 10 0 0 10 10 0 0 10 0] |
| 30 | + set geom_points [list ] |
| 31 | + foreach {x y z} $coordinates { |
| 32 | + lappend geom_points [GiD_Geometry create point append main_layer $x $y $z] |
| 33 | + } |
| 34 | + |
| 35 | + ## Lines ## |
| 36 | + set geom_lines [list ] |
| 37 | + set initial [lindex $geom_points 0] |
| 38 | + foreach point [lrange $geom_points 1 end] { |
| 39 | + lappend geom_lines [GiD_Geometry create line append stline main_layer $initial $point] |
| 40 | + set initial $point |
| 41 | + } |
| 42 | + lappend geom_lines [GiD_Geometry create line append stline main_layer $initial [lindex $geom_points_left 0]] |
| 43 | + |
| 44 | + ## Surface ## |
| 45 | + GiD_Process Mescape Geometry Create NurbsSurface {*}$geom_lines escape escape |
| 46 | +} |
| 47 | + |
| 48 | +proc ::ShallowWater::examples::Waves::AssignGroups {args} { |
| 49 | + # Create and assign the groups |
| 50 | + GiD_Groups create Body |
| 51 | + GiD_Groups edit color Body "#26d1a8ff" |
| 52 | + GiD_EntitiesGroups assign Body surfaces 1 |
| 53 | + |
| 54 | + GiD_Groups create Walls |
| 55 | + GiD_Groups edit color Walls "#3b3b3bff" |
| 56 | + GiD_EntitiesGroups assign Walls lines {1 2 3 4} |
| 57 | +} |
| 58 | + |
| 59 | +proc ::ShallowWater::examples::Waves::TreeAssignation {args} { |
| 60 | + |
| 61 | + # Parts |
| 62 | + set parts [spdAux::getRoute "SWParts"] |
| 63 | + set part_node [customlib::AddConditionGroupOnXPath $parts Body] |
| 64 | + set props [list Element GENERIC_ELEMENT Material Concrete] |
| 65 | + spdAux::SetValuesOnBaseNode $part_node $props |
| 66 | + |
| 67 | + # Initial conditions |
| 68 | + set initial_conditions [spdAux::getRoute "SWInitialConditions"] |
| 69 | + set initial_cond "$initial_conditions/condition\[@n='InitialWaterLevel'\]" |
| 70 | + spdAux::AddIntervalGroup Body "Body//Initial" |
| 71 | + set initial_node [customlib::AddConditionGroupOnXPath $initial_cond "Body//Initial"] |
| 72 | + $initial_node setAttribute ov surface |
| 73 | + set props [list value 1.0 Interval Initial] |
| 74 | + spdAux::SetValuesOnBaseNode $initial_node $props |
| 75 | + |
| 76 | + # Conditions |
| 77 | + set boundary_conditions [spdAux::getRoute "SWConditions"] |
| 78 | + set flow_rate_cond "$boundary_conditions/condition\[@n='ImposedFlowRate'\]" |
| 79 | + spdAux::AddIntervalGroup Walls "Walls//Total" |
| 80 | + set flow_rate_node [customlib::AddConditionGroupOnXPath $flow_rate_cond "Walls//Total"] |
| 81 | + $flow_rate_node setAttribute ov line |
| 82 | + set props [list selector_component_X Not value_component_Y 0.0 Interval Total] |
| 83 | + spdAux::SetValuesOnBaseNode $flow_rate_node $props |
| 84 | + |
| 85 | + # spdAux::AddIntervalGroup Right "Right//Total" |
| 86 | + # set flow_rate_node [customlib::AddConditionGroupOnXPath $flow_rate_cond "Right//Total"] |
| 87 | + # $flow_rate_node setAttribute ov line |
| 88 | + # set props [list value_component_X 0.0 selector_component_Y Not Interval Total] |
| 89 | + # spdAux::SetValuesOnBaseNode $flow_rate_node $props |
| 90 | + |
| 91 | + # spdAux::AddIntervalGroup Left "Left//Total" |
| 92 | + # set flow_rate_node [customlib::AddConditionGroupOnXPath $flow_rate_cond "Left//Total"] |
| 93 | + # $flow_rate_node setAttribute ov line |
| 94 | + # set props [list value_component_X 0.0 selector_component_Y Not Interval Total] |
| 95 | + # spdAux::SetValuesOnBaseNode $flow_rate_node $props |
| 96 | + |
| 97 | + # Refresh |
| 98 | + spdAux::RequestRefresh |
| 99 | +} |
0 commit comments