Skip to content

Commit fcbf507

Browse files
new p2p1 example
1 parent aeabfdb commit fcbf507

3 files changed

Lines changed: 213 additions & 0 deletions

File tree

kratos.gid/apps/Fluid/app.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"start.tcl",
1616
"examples/examples.tcl",
1717
"examples/CylinderInFlow.tcl",
18+
"examples/CylinderInFlowP2P1.tcl",
1819
"examples/HighRiseBuilding.tcl",
1920
"xml/XmlController.tcl",
2021
"write/write.tcl",
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
2+
namespace eval ::Fluid::examples::CylinderInFlowP2P1 {
3+
namespace path ::Fluid::examples
4+
Kratos::AddNamespace [namespace current]
5+
}
6+
7+
proc ::Fluid::examples::CylinderInFlowP2P1::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+
AssignMeshSizes$::Model::SpatialDimension
16+
TreeAssignation$::Model::SpatialDimension
17+
18+
GiD_Process 'Redraw
19+
GidUtils::UpdateWindow GROUPS
20+
GidUtils::UpdateWindow LAYER
21+
GiD_Process 'Zoom Frame
22+
}
23+
24+
25+
# Draw Geometry
26+
proc ::Fluid::examples::CylinderInFlowP2P1::DrawGeometry3D {args} {
27+
DrawGeometry2D
28+
GiD_Process Mescape Utilities Copy Surfaces Duplicate DoExtrude Volumes MaintainLayers Translation FNoJoin 0.0,0.0,0.0 FNoJoin 0.0,0.0,1.0 1 escape escape escape
29+
GiD_Layers edit opaque Fluid 0
30+
31+
GiD_Process escape escape 'Render Flat escape 'Rotate Angle 270 90 escape escape escape escape 'Rotate objaxes x -150 y -30 escape escape
32+
}
33+
proc ::Fluid::examples::CylinderInFlowP2P1::DrawGeometry2D {args} {
34+
Kratos::ResetModel
35+
GiD_Layers create Fluid
36+
GiD_Layers edit to_use Fluid
37+
38+
# Geometry creation
39+
## Points ##
40+
set coordinates [list 0 1 0 5 1 0 5 0 0 0 0 0]
41+
set fluidPoints [list ]
42+
foreach {x y z} $coordinates {
43+
lappend fluidPoints [GiD_Geometry create point append Fluid $x $y $z]
44+
}
45+
46+
## Lines ##
47+
set fluidLines [list ]
48+
set initial [lindex $fluidPoints 0]
49+
foreach point [lrange $fluidPoints 1 end] {
50+
lappend fluidLines [GiD_Geometry create line append stline Fluid $initial $point]
51+
set initial $point
52+
}
53+
lappend fluidLines [GiD_Geometry create line append stline Fluid $initial [lindex $fluidPoints 0]]
54+
55+
## Surface ##
56+
GiD_Process Mescape Geometry Create NurbsSurface {*}$fluidLines escape escape
57+
58+
# Body #
59+
GiD_Layers create Body
60+
GiD_Layers edit to_use Body
61+
set circle_center_x 1.25
62+
set circle_center_y 0.5
63+
set circle_center_z 0.0
64+
set center_radius 0.1
65+
GiD_Process Mescape Geometry Create Object CirclePNR $circle_center_x $circle_center_y $circle_center_z 0.0 0.0 1.0 $center_radius escape
66+
GiD_Geometry delete surface 2
67+
68+
# Create the hole
69+
GiD_Layers edit to_use Fluid
70+
GiD_Process MEscape Geometry Edit HoleNurb 1 5 escape escape
71+
72+
}
73+
74+
75+
# Group assign
76+
proc ::Fluid::examples::CylinderInFlowP2P1::AssignGroups2D {args} {
77+
# Create the groups
78+
GiD_Groups create Fluid
79+
GiD_Groups edit color Fluid "#26d1a8ff"
80+
GiD_EntitiesGroups assign Fluid surfaces 1
81+
82+
GiD_Groups create Inlet
83+
GiD_Groups edit color Inlet "#e0210fff"
84+
GiD_EntitiesGroups assign Inlet lines 4
85+
86+
GiD_Groups create Outlet
87+
GiD_Groups edit color Outlet "#42eb71ff"
88+
GiD_EntitiesGroups assign Outlet lines 2
89+
90+
GiD_Groups create No_Slip_Walls
91+
GiD_Groups edit color No_Slip_Walls "#3b3b3bff"
92+
GiD_EntitiesGroups assign No_Slip_Walls lines {1 3}
93+
94+
GiD_Groups create No_Slip_Cylinder
95+
GiD_Groups edit color No_Slip_Cylinder "#3b3b3bff"
96+
GiD_EntitiesGroups assign No_Slip_Cylinder lines 5
97+
}
98+
proc ::Fluid::examples::CylinderInFlowP2P1::AssignGroups3D {args} {
99+
# Create the groups
100+
GiD_Groups create Fluid
101+
GiD_Groups edit color Fluid "#26d1a8ff"
102+
GiD_EntitiesGroups assign Fluid volumes 1
103+
104+
GiD_Groups create Inlet
105+
GiD_Groups edit color Inlet "#e0210fff"
106+
GiD_EntitiesGroups assign Inlet surfaces 5
107+
108+
GiD_Groups create Outlet
109+
GiD_Groups edit color Outlet "#42eb71ff"
110+
GiD_EntitiesGroups assign Outlet surfaces 3
111+
112+
GiD_Groups create No_Slip_Walls
113+
GiD_Groups edit color No_Slip_Walls "#3b3b3bff"
114+
GiD_EntitiesGroups assign No_Slip_Walls surfaces {1 2 4 7}
115+
116+
GiD_Groups create No_Slip_Cylinder
117+
GiD_Groups edit color No_Slip_Cylinder "#3b3b3bff"
118+
GiD_EntitiesGroups assign No_Slip_Cylinder surfaces 6
119+
}
120+
121+
122+
# Mesh sizes
123+
proc ::Fluid::examples::CylinderInFlowP2P1::AssignMeshSizes3D {args} {
124+
set cylinder_mesh_size 0.005
125+
set walls_mesh_size 0.05
126+
set fluid_mesh_size 0.05
127+
GiD_Process Mescape Utilities Variables SizeTransitionsFactor 0.4 escape escape
128+
GiD_Process Mescape Meshing AssignSizes Surfaces $cylinder_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Cylinder surfaces] escape escape
129+
GiD_Process Mescape Meshing AssignSizes Surfaces $walls_mesh_size {*}[GiD_EntitiesGroups get Inlet surfaces] escape escape
130+
GiD_Process Mescape Meshing AssignSizes Surfaces $walls_mesh_size {*}[GiD_EntitiesGroups get Outlet surfaces] escape escape
131+
GiD_Process Mescape Meshing AssignSizes Surfaces $walls_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Walls surfaces] escape escape
132+
GiD_Process Mescape Meshing AssignSizes Volumes $fluid_mesh_size [GiD_EntitiesGroups get Fluid volumes] escape escape
133+
Kratos::Event_BeforeMeshGeneration $fluid_mesh_size
134+
}
135+
proc ::Fluid::examples::CylinderInFlowP2P1::AssignMeshSizes2D {args} {
136+
set cylinder_mesh_size 0.005
137+
set fluid_mesh_size 0.05
138+
GiD_Process Mescape Utilities Variables SizeTransitionsFactor 0.4 escape escape
139+
GiD_Process Mescape Meshing AssignSizes Lines $cylinder_mesh_size {*}[GiD_EntitiesGroups get No_Slip_Cylinder lines] escape escape
140+
GiD_Process Mescape Meshing AssignSizes Surfaces $fluid_mesh_size [GiD_EntitiesGroups get Fluid surfaces] escape escape
141+
Kratos::Event_BeforeMeshGeneration $fluid_mesh_size
142+
}
143+
144+
145+
# Tree assign
146+
proc ::Fluid::examples::CylinderInFlowP2P1::TreeAssignation3D {args} {
147+
TreeAssignation2D
148+
::Fluid::examples::AddCuts
149+
}
150+
proc ::Fluid::examples::CylinderInFlowP2P1::TreeAssignation2D {args} {
151+
set nd $::Model::SpatialDimension
152+
set root [customlib::GetBaseRoot]
153+
154+
set condtype line
155+
if {$nd eq "3D"} { set condtype surface }
156+
157+
# Monolithic solution strategy set
158+
spdAux::SetValueOnTreeItem v "Monolithic" FLSolStrat
159+
spdAux::SetValueOnTreeItem v "bdf2" FLScheme
160+
161+
# Fluid Parts
162+
set fluidParts [spdAux::getRoute "FLParts"]
163+
set fluidNode [customlib::AddConditionGroupOnXPath $fluidParts Fluid]
164+
# set props [list Element Monolithic$nd ConstitutiveLaw Newtonian2DLaw DENSITY 1.0 DYNAMIC_VISCOSITY 0.002 YIELD_STRESS 0 POWER_LAW_K 1 POWER_LAW_N 1]
165+
set props [list Element P2P1$nd ConstitutiveLaw Newtonian2DLaw DENSITY 1.0 DYNAMIC_VISCOSITY 0.002]
166+
spdAux::SetValuesOnBaseNode $fluidNode $props
167+
168+
set fluidConditions [spdAux::getRoute "FLBC"]
169+
::Fluid::examples::ErasePreviousIntervals
170+
171+
# Fluid Inlet
172+
Fluid::xml::CreateNewInlet Inlet {new true name inlet1 ini 0 end 1} true "6*y*(1-y)*sin(pi*t*0.5)"
173+
Fluid::xml::CreateNewInlet Inlet {new true name inlet2 ini 1 end End} true "6*y*(1-y)"
174+
175+
# Fluid Outlet
176+
set fluidOutlet "$fluidConditions/condition\[@n='Outlet$nd'\]"
177+
set outletNode [customlib::AddConditionGroupOnXPath $fluidOutlet Outlet]
178+
$outletNode setAttribute ov $condtype
179+
set props [list value 0.0]
180+
spdAux::SetValuesOnBaseNode $outletNode $props
181+
182+
# Fluid Conditions
183+
[customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NoSlip$nd'\]" No_Slip_Walls] setAttribute ov $condtype
184+
[customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='NoSlip$nd'\]" No_Slip_Cylinder] setAttribute ov $condtype
185+
186+
# Time parameters
187+
set parameters [list EndTime 45 DeltaTime 0.1]
188+
set xpath [spdAux::getRoute "FLTimeParameters"]
189+
spdAux::SetValuesOnBasePath $xpath $parameters
190+
191+
# Output
192+
set parameters [list OutputControlType step OutputDeltaStep 1]
193+
set xpath "[spdAux::getRoute FLResults]/container\[@n='GiDOutput'\]/container\[@n='GiDOptions'\]"
194+
spdAux::SetValuesOnBasePath $xpath $parameters
195+
196+
# Parallelism
197+
set parameters [list ParallelSolutionType OpenMP OpenMPNumberOfThreads 4]
198+
set xpath [spdAux::getRoute "Parallelization"]
199+
spdAux::SetValuesOnBasePath $xpath $parameters
200+
201+
# Set the linear solver as bicgstab
202+
spdAux::SetValueOnTreeItem v "bicgstab" FLMonolithiclinear_solver_settings Solver
203+
204+
spdAux::RequestRefresh
205+
}

kratos.gid/apps/Fluid/examples/examples.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@
1414
<Example id="CylinderInFlow3D" app="Fluid" logo="CylinderInFlow3D.png" name="Cylinder in flow 3D" dim="3D" cmd="::Fluid::examples::CylinderInFlow::Init">
1515
<Description></Description>
1616
</Example>
17+
18+
<Example id="CylinderInFlowP2P12D" app="Fluid" logo="CylinderInFlow2D.png" name="Cylinder in flow 2D with P2 P1 element" dim="2D" cmd="::Fluid::examples::CylinderInFlowP2P1::Init">
19+
<Description></Description>
20+
</Example>
21+
<!-- <Example id="CylinderInFlow3D" app="Fluid" logo="CylinderInFlow3D.png" name="Cylinder in flow 3D" dim="3D" cmd="::Fluid::examples::CylinderInFlow::Init">
22+
<Description></Description>
23+
</Example> -->
1724
</Group>

0 commit comments

Comments
 (0)