|
| 1 | +namespace eval ::ShallowWater::examples::HydraulicJump { |
| 2 | + namespace path ::ShallowWater::examples |
| 3 | + Kratos::AddNamespace [namespace current] |
| 4 | +} |
| 5 | + |
| 6 | +proc ::ShallowWater::examples::HydraulicJump::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::HydraulicJump::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 100 0 0 100 4 0 0 4 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 0]] |
| 43 | + |
| 44 | + ## Surface ## |
| 45 | + GiD_Process Mescape Geometry Create NurbsSurface {*}$geom_lines escape escape |
| 46 | +} |
| 47 | + |
| 48 | +proc ::ShallowWater::examples::HydraulicJump::AssignGroups {args} { |
| 49 | + # Create and assign the groups |
| 50 | + GiD_Groups create Channel |
| 51 | + GiD_Groups edit color Channel "#26d1a8ff" |
| 52 | + GiD_EntitiesGroups assign Channel surfaces 1 |
| 53 | + |
| 54 | + GiD_Groups create Walls |
| 55 | + GiD_Groups edit color Walls "#3b3b3bff" |
| 56 | + GiD_EntitiesGroups assign Walls lines {1 3} |
| 57 | + |
| 58 | + GiD_Groups create Upstream |
| 59 | + GiD_Groups edit color Upstream "#3b3b3bff" |
| 60 | + GiD_EntitiesGroups assign Upstream lines 4 |
| 61 | + |
| 62 | + GiD_Groups create Downstream |
| 63 | + GiD_Groups edit color Downstream "#3b3b3bff" |
| 64 | + GiD_EntitiesGroups assign Downstream lines 2 |
| 65 | +} |
| 66 | + |
| 67 | +proc ::ShallowWater::examples::HydraulicJump::TreeAssignation {args} { |
| 68 | + |
| 69 | + # Parts |
| 70 | + set parts [spdAux::getRoute "SWParts"] |
| 71 | + set part_node [customlib::AddConditionGroupOnXPath $parts Channel] |
| 72 | + set props [list Element GENERIC_ELEMENT Material Concrete] |
| 73 | + spdAux::SetValuesOnBaseNode $part_node $props |
| 74 | + |
| 75 | + # Topography data |
| 76 | + set topography_conditions [spdAux::getRoute "SWTopographicData"] |
| 77 | + set topography_cond "$topography_conditions/condition\[@n='Topography'\]" |
| 78 | + set topography_node [customlib::AddConditionGroupOnXPath $topography_cond Channel] |
| 79 | + $topography_node setAttribute ov surface |
| 80 | + set props [list ByFunction 1 function_value "3*x"] |
| 81 | + spdAux::SetValuesOnBaseNode $topography_node $props |
| 82 | + |
| 83 | + # Initial conditions |
| 84 | + set initial_conditions [spdAux::getRoute "SWInitialConditions"] |
| 85 | + set initial_cond "$initial_conditions/condition\[@n='InitialWaterLevel'\]" |
| 86 | + spdAux::AddIntervalGroup Channel "Channel//Initial" |
| 87 | + set initial_node [customlib::AddConditionGroupOnXPath $initial_cond "Channel//Initial"] |
| 88 | + $initial_node setAttribute ov surface |
| 89 | + set props [list variable_name FREE_SURFACE_ELEVATION value 2.0 Interval Initial set_minimum_height 1 minimum_height_value 1] |
| 90 | + spdAux::SetValuesOnBaseNode $initial_node $props |
| 91 | + |
| 92 | + # Conditions |
| 93 | + set boundary_conditions [spdAux::getRoute "SWConditions"] |
| 94 | + set flow_rate_cond "$boundary_conditions/condition\[@n='ImposedFlowRate'\]" |
| 95 | + set water_height_cond "$boundary_conditions/condition\[@n='ImposedFreeSurface'\]" |
| 96 | + |
| 97 | + spdAux::AddIntervalGroup Walls "Walls//Total" |
| 98 | + set flow_rate_node [customlib::AddConditionGroupOnXPath $flow_rate_cond "Walls//Total"] |
| 99 | + $flow_rate_node setAttribute ov line |
| 100 | + set props [list selector_component_X Not value_component_Y 0.0 Interval Total] |
| 101 | + spdAux::SetValuesOnBaseNode $flow_rate_node $props |
| 102 | + |
| 103 | + spdAux::AddIntervalGroup Upstream "Upstream//Total" |
| 104 | + set flow_rate_node [customlib::AddConditionGroupOnXPath $flow_rate_cond "Upstream//Total"] |
| 105 | + $flow_rate_node setAttribute ov line |
| 106 | + set props [list value_component_X 2.0 selector_component_Y 0.0 Interval Total] |
| 107 | + spdAux::SetValuesOnBaseNode $flow_rate_node $props |
| 108 | + |
| 109 | + spdAux::AddIntervalGroup Downstream "Downstream//Total" |
| 110 | + set free_surface_node [customlib::AddConditionGroupOnXPath $water_height_cond "Downstream//Total"] |
| 111 | + $free_surface_node setAttribute ov line |
| 112 | + set props [list value 2.0 Interval Total] |
| 113 | + spdAux::SetValuesOnBaseNode $free_surface_node $props |
| 114 | + |
| 115 | + # Refresh |
| 116 | + spdAux::RequestRefresh |
| 117 | +} |
0 commit comments