|
| 1 | + |
| 2 | +namespace eval ::FreeSurface::examples::Box { |
| 3 | + namespace path ::FreeSurface::examples |
| 4 | + Kratos::AddNamespace [namespace current] |
| 5 | +} |
| 6 | + |
| 7 | +proc ::FreeSurface::examples::Box::Init {args} { |
| 8 | + if {![Kratos::IsModelEmpty]} { |
| 9 | + set txt "We are going to draw the example geometry.\nDo you want to lose your previous work?" |
| 10 | + set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel] |
| 11 | + if { $retval == "cancel" } { return } |
| 12 | + } |
| 13 | + DrawGeometry$::Model::SpatialDimension |
| 14 | + AssignGroups$::Model::SpatialDimension |
| 15 | + TreeAssignation$::Model::SpatialDimension |
| 16 | + |
| 17 | + GiD_Process 'Redraw |
| 18 | + GidUtils::UpdateWindow GROUPS |
| 19 | + GidUtils::UpdateWindow LAYER |
| 20 | + GiD_Process 'Zoom Frame |
| 21 | + spdAux::RequestRefresh |
| 22 | +} |
| 23 | + |
| 24 | + |
| 25 | +# Draw Geometry |
| 26 | +proc ::FreeSurface::examples::Box::DrawGeometry2D {args} { |
| 27 | + Kratos::ResetModel |
| 28 | + GiD_Layers create Fluid |
| 29 | + GiD_Layers edit to_use Fluid |
| 30 | + |
| 31 | + # Geometry creation |
| 32 | + ## Points ## |
| 33 | + set coordinates [list -3.91362 -3.3393 0 -2.91362 -3.3393 0 -2.91362 -3.1393 0 -2.91362 -2.7393 0 -2.71362 -2.7393 0] |
| 34 | + lappend coordinates {*}[list -2.71362 -2.5393 0 -3.91362 -2.5393 0 -3.91362 -3.1393 0 -4.11362 -3.1393 0 -4.11362 -3.3393 0 ] |
| 35 | + set fluidPoints [list ] |
| 36 | + foreach {x y z} $coordinates { |
| 37 | + lappend fluidPoints [GiD_Geometry create point append Fluid $x $y $z] |
| 38 | + } |
| 39 | + |
| 40 | + ## Lines ## |
| 41 | + set fluidLines [list ] |
| 42 | + set initial [lindex $fluidPoints 0] |
| 43 | + foreach point [lrange $fluidPoints 1 end] { |
| 44 | + lappend fluidLines [GiD_Geometry create line append stline Fluid $initial $point] |
| 45 | + set initial $point |
| 46 | + } |
| 47 | + lappend fluidLines [GiD_Geometry create line append stline Fluid $initial [lindex $fluidPoints 0]] |
| 48 | + |
| 49 | + ## Surface ## |
| 50 | + GiD_Process Mescape Geometry Create NurbsSurface {*}$fluidLines escape escape |
| 51 | + |
| 52 | + ## Points ## |
| 53 | + set coordinates [list -3.91362 -3.5393 0 -2.91362 -3.5393 0 ] |
| 54 | + set fluidPoints [list ] |
| 55 | + foreach {x y z} $coordinates { |
| 56 | + lappend fluidPoints [GiD_Geometry create point append Fluid $x $y $z] |
| 57 | + } |
| 58 | + |
| 59 | + ## Lines ## |
| 60 | + set fluidLines [list ] |
| 61 | + set initial 1 |
| 62 | + foreach point [list {*}$fluidPoints 2] { |
| 63 | + lappend fluidLines [GiD_Geometry create line append stline Fluid $initial $point] |
| 64 | + set initial $point |
| 65 | + } |
| 66 | + |
| 67 | + ## Surface ## |
| 68 | + GiD_Process Mescape Geometry Create NurbsSurface 1 {*}$fluidLines escape escape |
| 69 | + |
| 70 | + |
| 71 | +} |
| 72 | + |
| 73 | +# Group assign |
| 74 | +proc ::FreeSurface::examples::Box::AssignGroups2D {args} { |
| 75 | + # Create the groups |
| 76 | + GiD_Groups create Fluid |
| 77 | + GiD_Groups edit color Fluid "#26d1a8ff" |
| 78 | + GiD_EntitiesGroups assign Fluid surfaces {1 2} |
| 79 | + |
| 80 | + GiD_Groups create Inlet |
| 81 | + GiD_Groups edit color Inlet "#e0210fff" |
| 82 | + GiD_EntitiesGroups assign Inlet lines 9 |
| 83 | + |
| 84 | + GiD_Groups create Outlet |
| 85 | + GiD_Groups edit color Outlet "#42eb71ff" |
| 86 | + GiD_EntitiesGroups assign Outlet lines {5 12} |
| 87 | + |
| 88 | + GiD_Groups create Slip_Walls |
| 89 | + GiD_Groups edit color Slip_Walls "#3b3b3bff" |
| 90 | + GiD_EntitiesGroups assign Slip_Walls lines {2 3 4 6 7 8 10 11 13} |
| 91 | + |
| 92 | + GiD_Groups create Surface_Bottom |
| 93 | + GiD_Groups edit color Surface_Bottom "#3b3b3bff" |
| 94 | + GiD_EntitiesGroups assign Surface_Bottom surfaces 2 |
| 95 | +} |
| 96 | + |
| 97 | +# Tree assign |
| 98 | +proc ::FreeSurface::examples::Box::TreeAssignation2D {args} { |
| 99 | + set nd $::Model::SpatialDimension |
| 100 | + set root [customlib::GetBaseRoot] |
| 101 | + |
| 102 | + set condtype line |
| 103 | + |
| 104 | + # Fluid Parts |
| 105 | + set fluidParts [spdAux::getRoute "FLParts"] |
| 106 | + set fluidNode [customlib::AddConditionGroupOnXPath $fluidParts Fluid] |
| 107 | + |
| 108 | + set fluidConditions [spdAux::getRoute "FLNodalConditions"] |
| 109 | + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='DISTANCE'\]" Inlet] setAttribute ov line |
| 110 | + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='DISTANCE'\]" Surface_Bottom] setAttribute ov surface |
| 111 | + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='LIN_DARCY_COEF'\]" Surface_Bottom] setAttribute ov surface |
| 112 | + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NONLIN_DARCY_COEF'\]" Surface_Bottom] setAttribute ov surface |
| 113 | + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='POROSITY'\]" Surface_Bottom] setAttribute ov surface |
| 114 | + |
| 115 | + set fluidConditions [spdAux::getRoute "FLBC"] |
| 116 | + ::Fluid::examples::ErasePreviousIntervals |
| 117 | + |
| 118 | + # Fluid Inlet |
| 119 | + Fluid::xml::CreateNewInlet Inlet {new true name inlet1 ini 0 end End} true "1" |
| 120 | + |
| 121 | + # Fluid Outlet |
| 122 | + set fluidOutlet "$fluidConditions/condition\[@n='Outlet$nd'\]" |
| 123 | + set outletNode [customlib::AddConditionGroupOnXPath $fluidOutlet Outlet] |
| 124 | + $outletNode setAttribute ov $condtype |
| 125 | + set props [list value 0.0] |
| 126 | + spdAux::SetValuesOnBaseNode $outletNode $props |
| 127 | + |
| 128 | + # Fluid Conditions |
| 129 | + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='Slip$nd'\]" Slip_Walls] setAttribute ov $condtype |
| 130 | + |
| 131 | + # [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='Lin_Darcy_Coef_$nd'\]" Surface_Bottom] setAttribute ov $condtype |
| 132 | + # [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='Non_Lin_Darcy_Coef_$nd'\]" Surface_Bottom] setAttribute ov $condtype |
| 133 | + # [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='Porosity$nd'\]" Surface_Bottom] setAttribute ov $condtype |
| 134 | + |
| 135 | + # Time parameters |
| 136 | + set parameters [list EndTime 5 DeltaTime 0.1] |
| 137 | + set xpath [spdAux::getRoute "FLTimeParameters"] |
| 138 | + spdAux::SetValuesOnBasePath $xpath $parameters |
| 139 | + |
| 140 | + # Output |
| 141 | + set parameters [list OutputControlType time OutputDeltaTime 0.1] |
| 142 | + set xpath "[spdAux::getRoute FLResults]/container\[@n='GiDOutput'\]/container\[@n='GiDOptions'\]" |
| 143 | + spdAux::SetValuesOnBasePath $xpath $parameters |
| 144 | + |
| 145 | + # Parallelism |
| 146 | + set parameters [list ParallelSolutionType OpenMP OpenMPNumberOfThreads 4] |
| 147 | + set xpath [spdAux::getRoute "Parallelization"] |
| 148 | + spdAux::SetValuesOnBasePath $xpath $parameters |
| 149 | + |
| 150 | + |
| 151 | +} |
0 commit comments