1+
2+ proc ::PotentialFluid::examples::NACA0012 {args} {
3+ if {![Kratos::IsModelEmpty]} {
4+ set txt " We are going to draw the example geometry.\n Do you want to lose your previous work?"
5+ set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel]
6+ if { $retval == " cancel" } { return }
7+ }
8+ DrawNACA0012Geometry$::Model::SpatialDimension
9+ AssignGroupsNACA0012$::Model::SpatialDimension
10+ AssignNACA0012MeshSizes$::Model::SpatialDimension
11+ TreeAssignationNACA0012$::Model::SpatialDimension
12+
13+ GiD_Process 'Redraw
14+ GidUtils::UpdateWindow GROUPS
15+ GidUtils::UpdateWindow LAYER
16+ GiD_Process 'Zoom Frame
17+
18+ }
19+
20+ proc PotentialFluid::examples::DrawNACA0012Geometry2D {args} {
21+ Kratos::ResetModel
22+ GiD_Layers create Fluid
23+ GiD_Layers edit to_use Fluid
24+
25+ # Geometry creation
26+ # # Airfoil
27+ GiD_Process Mescape Geometry Create NurbsLine 1.000000 0.000000 0 0.998459 0.000224 0 0.993844 0.000891 0 0.986185 0.001990 0 0.975528 0.003501 0 0.961940 0.005399 0 0.945503 0.007651 0 0.926320 0.010221 0 0.904508 0.013071 0 0.880203 0.016158 0 0.853553 0.019438 0 0.824724 0.022869 0 0.793893 0.026405 0 0.761249 0.030000 0 0.726995 0.033610 0 0.691342 0.037188 0 0.654508 0.040686 0 0.616723 0.044055 0 0.578217 0.047242 0 0.539230 0.050196 0 0.500000 0.052862 0 0.460770 0.055184 0 0.421783 0.057108 0 0.383277 0.058582 0 0.345492 0.059557 0 0.308658 0.059988 0 0.273005 0.059841 0 0.238751 0.059088 0 0.206107 0.057712 0 0.175276 0.055708 0 0.146447 0.053083 0 0.119797 0.049854 0 0.095492 0.046049 0 0.073680 0.041705 0 0.054497 0.036867 0 0.038060 0.031580 0 0.024472 0.025893 0 0.013815 0.019854 0 0.006156 0.013503 0 0.001541 0.006877 0 0.000000 0.000000 0 0.001541 -0.006877 0 0.006156 -0.013503 0 0.013815 -0.019854 0 0.024472 -0.025893 0 0.038060 -0.031580 0 0.054497 -0.036867 0 0.073680 -0.041705 0 0.095492 -0.046049 0 0.119797 -0.049854 0 0.146447 -0.053083 0 0.175276 -0.055708 0 0.206107 -0.057712 0 0.238751 -0.059088 0 0.273005 -0.059841 0 0.308658 -0.059988 0 0.345492 -0.059557 0 0.383277 -0.058582 0 0.421783 -0.057108 0 0.460770 -0.055184 0 0.500000 -0.052862 0 0.539230 -0.050196 0 0.578217 -0.047242 0 0.616723 -0.044055 0 0.654508 -0.040686 0 0.691342 -0.037188 0 0.726995 -0.033610 0 0.761249 -0.030000 0 0.793893 -0.026405 0 0.824724 -0.022869 0 0.853553 -0.019438 0 0.880203 -0.016158 0 0.904508 -0.013071 0 0.926320 -0.010221 0 0.945503 -0.007651 0 0.961940 -0.005399 0 0.975528 -0.003501 0 0.986185 -0.001990 0 0.993844 -0.000891 0 0.998459 -0.000224 0 Join 1 escape escape escape escape escape escape escape escape Escape
28+ GiD_Process Mescape Geometry Edit DivideLine Multiple NumDivisions 2 1 escape escape escape
29+
30+ # # Points ##
31+ set coordinates [list 50 25 0 -50 25 0 -50 -25 0 50 -25 0]
32+ set fluidPoints [list ]
33+ foreach {x y z} $coordinates {
34+ lappend fluidPoints [GiD_Geometry create point append Fluid $x $y $z ]
35+ }
36+
37+ # # Lines ##
38+ set fluidLines [list ]
39+ set initial [lindex $fluidPoints 0]
40+ foreach point [lrange $fluidPoints 1 end] {
41+ lappend fluidLines [GiD_Geometry create line append stline Fluid $initial $point ]
42+ set initial $point
43+ }
44+ lappend fluidLines [GiD_Geometry create line append stline Fluid $initial [lindex $fluidPoints 0]]
45+
46+ # # Surface
47+ # Lines 2,3 (airfoil) and 4,5,6,7 (far field)
48+ GiD_Process Mescape Geometry Create NurbsSurface 2 3 4 5 6 7 escape escape
49+ }
50+
51+ # Group assign
52+ proc PotentialFluid::examples::AssignGroupsNACA00122D {args} {
53+ # Create the groups
54+ GiD_Groups create Fluid
55+ GiD_Groups edit color Fluid " #26d1a8ff"
56+ GiD_EntitiesGroups assign Fluid surfaces 1
57+
58+ GiD_Groups create FarField
59+ GiD_Groups edit color FarField " #e0210fff"
60+ GiD_EntitiesGroups assign FarField lines 4
61+ GiD_EntitiesGroups assign FarField lines 5
62+ GiD_EntitiesGroups assign FarField lines 6
63+ GiD_EntitiesGroups assign FarField lines 7
64+
65+ # GiD_Groups create UpperSurface
66+ # GiD_Groups edit color UpperSurface "#42eb71ff"
67+ # GiD_EntitiesGroups assign UpperSurface lines 2
68+
69+ # GiD_Groups create LowerSurface
70+ # GiD_Groups edit color LowerSurface "#42eb71ff"
71+ # GiD_EntitiesGroups assign LowerSurface lines 3
72+
73+ GiD_Groups create Body
74+ GiD_Groups edit color Body " #42eb71ff"
75+ GiD_EntitiesGroups assign Body lines {2 3}
76+ }
77+
78+ proc PotentialFluid::examples::AssignNACA0012MeshSizes2D {args} {
79+ set fluid_mesh_size 2.0
80+ set airfoil_mesh_size 0.01
81+ GiD_Process Mescape Utilities Variables SizeTransitionsFactor 0.3 escape escape
82+ # GiD_Process Mescape Meshing AssignSizes Lines $airfoil_mesh_size {*}[GiD_EntitiesGroups get UpperSurface lines] escape escape
83+ # GiD_Process Mescape Meshing AssignSizes Lines $airfoil_mesh_size {*}[GiD_EntitiesGroups get LowerSurface lines] escape escape
84+ GiD_Process Mescape Meshing AssignSizes Lines $airfoil_mesh_size {*}[GiD_EntitiesGroups get Body lines] escape escape
85+ GiD_Process Mescape Meshing AssignSizes Surfaces $fluid_mesh_size [GiD_EntitiesGroups get Fluid surfaces] escape escape
86+
87+ }
88+
89+ proc PotentialFluid::examples::TreeAssignationNACA00122D {args} {
90+ set nd $::Model::SpatialDimension
91+ set root [customlib::GetBaseRoot]
92+
93+ set condtype line
94+ set elemtype surface
95+ if {$nd eq " 3D" } {
96+ set condtype surface
97+ set elemtype volume
98+ }
99+
100+ # Fluid Parts
101+ set fluidParts [spdAux::getRoute " FLParts" ]
102+ set fluidNode [customlib::AddConditionGroupOnXPath $fluidParts Fluid]
103+ $fluidNode setAttribute ov $elemtype
104+ set props [list Element PotentialFlowElement$nd ConstitutiveLaw Inviscid DENSITY 1.225]
105+ spdAux::SetValuesOnBaseNode $fluidNode $props
106+
107+ set fluidConditions [spdAux::getRoute " FLBC" ]
108+ ErasePreviousIntervals
109+
110+ # Far field
111+ set fluidFarField " $fluidConditions /condition\[ @n='PotentialWallCondition$nd '\] "
112+ set farFieldNode [customlib::AddConditionGroupOnXPath $fluidFarField FarField]
113+ $farFieldNode setAttribute ov $condtype
114+ set props [list angle_of_attack 0.0 mach_infinity 0.03 speed_of_sound 340.0]
115+ spdAux::SetValuesOnBaseNode $farFieldNode $props
116+
117+ # Fluid Conditions
118+ [customlib::AddConditionGroupOnXPath " $fluidConditions /condition\[ @n='Body$nd '\] " Body] setAttribute ov $condtype
119+
120+ # Parallelism
121+ set parameters [list ParallelSolutionType OpenMP OpenMPNumberOfThreads 4]
122+ set xpath [spdAux::getRoute " Parallelization" ]
123+ spdAux::SetValuesOnBasePath $xpath $parameters
124+
125+ spdAux::RequestRefresh
126+ }
127+
128+ proc PotentialFluid::examples::ErasePreviousIntervals { } {
129+ set root [customlib::GetBaseRoot]
130+ set interval_base [spdAux::getRoute " Intervals" ]
131+ foreach int [$root selectNodes " $interval_base /blockdata\[ @n='Interval'\] " ] {
132+ if {[$int @name] ni [list Initial Total Custom1]} {$int delete}
133+ }
134+ }
135+
136+ proc PotentialFluid::examples::AddCuts { } {
137+ # Cuts
138+ set results " [ spdAux::getRoute FLResults] /container\[ @n='GiDOutput'\] "
139+
140+ set cp [[customlib::GetBaseRoot] selectNodes " $results /container\[ @n = 'CutPlanes'\] /blockdata\[ @name = 'CutPlane'\] " ]
141+ [$cp selectNodes " ./value\[ @n = 'point'\] " ] setAttribute v " 0.0,0.5,0.0"
142+ }
143+
144+ # Draw Geometry
145+ proc PotentialFluid::examples::DrawNACA0012Geometry3D {args} {
146+ Kratos::ResetModel
147+ GiD_Layers create Fluid
148+ GiD_Layers edit to_use Fluid
149+
150+ # Geometry creation
151+ # # Airfoil
152+ GiD_Process 'Rotate Angle 270 0
153+ GiD_Process Mescape Geometry Create NurbsLine 1.000000 0 0.000000 0.998459 0 0.000224 0.993844 0 0.000891 0.986185 0 0.001990 0.975528 0 0.003501 0.961940 0 0.005399 0.945503 0 0.007651 0.926320 0 0.010221 0.904508 0 0.013071 0.880203 0 0.016158 0.853553 0 0.019438 0.824724 0 0.022869 0.793893 0 0.026405 0.761249 0 0.030000 0.726995 0 0.033610 0.691342 0 0.037188 0.654508 0 0.040686 0.616723 0 0.044055 0.578217 0 0.047242 0.539230 0 0.050196 0.500000 0 0.052862 0.460770 0 0.055184 0.421783 0 0.057108 0.383277 0 0.058582 0.345492 0 0.059557 0.308658 0 0.059988 0.273005 0 0.059841 0.238751 0 0.059088 0.206107 0 0.057712 0.175276 0 0.055708 0.146447 0 0.053083 0.119797 0 0.049854 0.095492 0 0.046049 0.073680 0 0.041705 0.054497 0 0.036867 0.038060 0 0.031580 0.024472 0 0.025893 0.013815 0 0.019854 0.006156 0 0.013503 0.001541 0 0.006877 0.000000 0 0.000000 0.001541 0 -0.006877 0.006156 0 -0.013503 0.013815 0 -0.019854 0.024472 0 -0.025893 0.038060 0 -0.031580 0.054497 0 -0.036867 0.073680 0 -0.041705 0.095492 0 -0.046049 0.119797 0 -0.049854 0.146447 0 -0.053083 0.175276 0 -0.055708 0.206107 0 -0.057712 0.238751 0 -0.059088 0.273005 0 -0.059841 0.308658 0 -0.059988 0.345492 0 -0.059557 0.383277 0 -0.058582 0.421783 0 -0.057108 0.460770 0 -0.055184 0.500000 0 -0.052862 0.539230 0 -0.050196 0.578217 0 -0.047242 0.616723 0 -0.044055 0.654508 0 -0.040686 0.691342 0 -0.037188 0.726995 0 -0.033610 0.761249 0 -0.030000 0.793893 0 -0.026405 0.824724 0 -0.022869 0.853553 0 -0.019438 0.880203 0 -0.016158 0.904508 0 -0.013071 0.926320 0 -0.010221 0.945503 0 -0.007651 0.961940 0 -0.005399 0.975528 0 -0.003501 0.986185 0 -0.001990 0.993844 0 -0.000891 0.998459 0 -0.000224 Join 1 escape escape escape escape escape escape escape escape Escape
154+ # GiD_Process Mescape Geometry Create NurbsLine 1.000000 0 0.000000 1.5 0 0 1 0 0.1 0.5 0 0.1 Join 1 escape escape escape escape escape escape escape escape Escape
155+ GiD_Process Mescape Geometry Edit DivideLine Multiple NumDivisions 2 1 escape escape escape
156+ set AOA 5
157+
158+ GiD_Process Mescape Utilities Move AllTypes Duplicate MaintainLayers Rotation FNoJoin 0.0,0.0,0.0 FNoJoin 0.0,1.0,0.0 $AOA points 1 2 lines 2 3 surfaces volumes dimensions escape Mescape
159+
160+ # # Points ##
161+ set coordinates [list 50 0 25 -50 0 25 -50 0 -25 50 0 -25]
162+ set fluidPoints [list ]
163+ foreach {x y z} $coordinates {
164+ lappend fluidPoints [GiD_Geometry create point append Fluid $x $y $z ]
165+ }
166+
167+ # # Lines ##
168+ set fluidLines [list ]
169+ set initial [lindex $fluidPoints 0]
170+ foreach point [lrange $fluidPoints 1 end] {
171+ lappend fluidLines [GiD_Geometry create line append stline Fluid $initial $point ]
172+ set initial $point
173+ }
174+ lappend fluidLines [GiD_Geometry create line append stline Fluid $initial [lindex $fluidPoints 0]]
175+
176+ # # Surface
177+ # Lines 2,3 (airfoil) and 4,5,6,7 (far field)
178+ GiD_Process Mescape Geometry Create NurbsSurface 2 3 4 5 6 7 escape escape
179+ GiD_Process Mescape Utilities Copy Surfaces Duplicate DoExtrude Volumes MaintainLayers Translation FNoJoin 0.0,0.0,0.0 FNoJoin 0.0,10.0,0.0 1 escape Mescape
180+ GiD_Process 'Zoom Frame
181+
182+
183+ }
184+
185+ # Group assign
186+ proc PotentialFluid::examples::AssignGroupsNACA00123D {args} {
187+ GiD_Groups create Fluid
188+ GiD_Groups edit color Fluid " #26d1a8ff"
189+ GiD_EntitiesGroups assign Fluid volumes 1
190+
191+ GiD_Groups create FarField
192+ GiD_Groups edit color FarField " #e0210fff"
193+ GiD_EntitiesGroups assign FarField surfaces {1 4 5 6 7 8}
194+
195+ GiD_Groups create Body
196+ GiD_Groups edit color Body " #42eb71ff"
197+ GiD_EntitiesGroups assign Body surfaces {2 3}
198+
199+ GiD_Groups create BodyLines
200+ GiD_Groups edit color BodyLines " #42eb71ff"
201+ GiD_EntitiesGroups assign BodyLines lines {2 3 8 9 14 15}
202+
203+ GiD_Groups create BodyPoints
204+ GiD_Groups edit color BodyPoints " #42eb71ff"
205+ GiD_EntitiesGroups assign BodyPoints points {1 2 7 8}
206+
207+ GiD_Groups create Wake
208+ GiD_Groups edit color Wake " #e0210fff"
209+ GiD_EntitiesGroups assign Wake lines {14}
210+
211+ GiD_Groups create WingTips
212+ GiD_Groups edit color WingTips " #e0210fff"
213+ GiD_EntitiesGroups assign WingTips points {1 7}
214+ }
215+
216+ proc PotentialFluid::examples::AssignNACA0012MeshSizes3D {args} {
217+ # set fluid_mesh_size 2.0
218+ set wing_lines_mesh_size 0.1
219+ # set wing_points_mesh_size 0.1
220+ GiD_Process Mescape Utilities Variables SizeTransitionsFactor 0.3 escape escape
221+ # GiD_Process Mescape Meshing AssignSizes Lines $airfoil_mesh_size {*}[GiD_EntitiesGroups get UpperSurface lines] escape escape
222+ # GiD_Process Mescape Meshing AssignSizes Lines $airfoil_mesh_size {*}[GiD_EntitiesGroups get LowerSurface lines] escape escape
223+ GiD_Process Mescape Meshing AssignSizes Lines $wing_lines_mesh_size {*}[GiD_EntitiesGroups get BodyLines lines] escape escape
224+ # GiD_Process Mescape Meshing AssignSizes Points $wing_points_mesh_size {*}[GiD_EntitiesGroups get Body points] escape escape
225+ # GiD_Process Mescape Meshing AssignSizes Surfaces $fluid_mesh_size [GiD_EntitiesGroups get Fluid surfaces] escape escape
226+ # Kratos::Event_BeforeMeshGeneration $fluid_mesh_size
227+ }
228+
229+ proc PotentialFluid::examples::TreeAssignationNACA00123D {args} {
230+ set nd $::Model::SpatialDimension
231+ set root [customlib::GetBaseRoot]
232+
233+ set condtype line
234+ if {$nd eq " 3D" } { set condtype surface }
235+
236+ # Fluid Parts
237+ set fluidParts [spdAux::getRoute " FLParts" ]
238+ set fluidNode [customlib::AddConditionGroupOnXPath $fluidParts Fluid]
239+ set props [list Element PotentialFlowElement$nd ConstitutiveLaw Inviscid DENSITY 1.225]
240+ spdAux::SetValuesOnBaseNode $fluidNode $props
241+
242+ set fluidConditions [spdAux::getRoute " FLBC" ]
243+ ErasePreviousIntervals
244+
245+ # Far field
246+ set fluidFarField " $fluidConditions /condition\[ @n='PotentialWallCondition$nd '\] "
247+ set farFieldNode [customlib::AddConditionGroupOnXPath $fluidFarField FarField]
248+ $farFieldNode setAttribute ov $condtype
249+ set props [list angle_of_attack 0.0 mach_infinity 0.03 speed_of_sound 340.0]
250+ spdAux::SetValuesOnBaseNode $farFieldNode $props
251+
252+ # Fluid Conditions
253+ [customlib::AddConditionGroupOnXPath " $fluidConditions /condition\[ @n='Body$nd '\] " Body] setAttribute ov $condtype
254+ [customlib::AddConditionGroupOnXPath " $fluidConditions /condition\[ @n='Wake$nd '\] " Wake] setAttribute ov $condtype
255+ [customlib::AddConditionGroupOnXPath " $fluidConditions /condition\[ @n='Tip$nd '\] " WingTips] setAttribute ov $condtype
256+
257+ # Parallelism
258+ set time_parameters [list ParallelSolutionType OpenMP OpenMPNumberOfThreads 4]
259+ set time_params_path [spdAux::getRoute " Parallelization" ]
260+ foreach {n v} $time_parameters {
261+ [$root selectNodes " $time_params_path /value\[ @n = '$n '\] " ] setAttribute v $v
262+ }
263+
264+ spdAux::RequestRefresh
265+ }
0 commit comments