Skip to content

Commit 474e3f3

Browse files
Merge pull request #880 from KratosMultiphysics/add/freesurface
FreeSurface Application
2 parents 5a852e0 + 1291ff5 commit 474e3f3

25 files changed

Lines changed: 659 additions & 31 deletions

kratos.gid/apps/Examples/xml/examples.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
<link path="apps/PfemFluid/examples/examples.xml"/>
2323
<link path="apps/PfemThermic/examples/examples.xml"/>
2424
<link path="apps/ShallowWater/examples/examples.xml"/>
25+
<link path="apps/FreeSurface/examples/examples.xml"/>
2526
</examples>

kratos.gid/apps/Fluid/write/writeProjectParameters.tcl

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,31 @@ proc ::Fluid::write::getParametersDict { } {
66
dict set projectParametersDict analysis_stage "KratosMultiphysics.FluidDynamicsApplication.fluid_dynamics_analysis"
77

88
# Problem data
9-
dict set projectParametersDict problem_data [write::GetDefaultProblemDataDict [::Fluid::GetAttribute id]]
9+
dict set projectParametersDict problem_data [::Fluid::write::GetProblemData_Dict]
1010

1111
# output configuration
1212
dict set projectParametersDict output_processes [write::GetDefaultOutputProcessDict [::Fluid::GetAttribute id]]
1313

1414
# Solver settings
15-
set solver_settings_dict [Fluid::write::getSolverSettingsDict]
16-
dict set solver_settings_dict "reform_dofs_at_each_step" false
17-
dict set projectParametersDict solver_settings $solver_settings_dict
15+
dict set projectParametersDict solver_settings [Fluid::write::getSolverSettingsDict]
1816

1917
# Boundary conditions processes
18+
dict set projectParametersDict processes [Fluid::write::GetProcesses_Dict]
19+
20+
return $projectParametersDict
21+
}
22+
23+
proc ::Fluid::write::GetProblemData_Dict { } {
24+
return [write::GetDefaultProblemDataDict [::Fluid::GetAttribute id]]
25+
}
26+
27+
proc ::Fluid::write::GetProcesses_Dict { } {
2028
set processesDict [dict create]
2129
dict set processesDict initial_conditions_process_list [write::getConditionsParametersDict [::Fluid::GetUniqueName nodal_conditions] "Nodal"]
2230
dict set processesDict boundary_conditions_process_list [write::getConditionsParametersDict [::Fluid::GetUniqueName conditions]]
2331
dict set processesDict gravity [list [getGravityProcessDict] ]
2432
dict set processesDict auxiliar_process_list [getAuxiliarProcessList]
25-
26-
dict set projectParametersDict processes $processesDict
27-
28-
return $projectParametersDict
33+
return $processesDict
2934
}
3035

3136
proc ::Fluid::write::writeParametersEvent { } {
@@ -258,7 +263,7 @@ proc ::Fluid::write::getSolverSettingsDict { } {
258263
# Include the formulation settings in the solver settings dict
259264
dict set solverSettingsDict formulation $formulationSettingsDict
260265
}
261-
266+
dict set solverSettingsDict "reform_dofs_at_each_step" false
262267
return $solverSettingsDict
263268
}
264269

kratos.gid/apps/FluidLauncher/start.tcl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
namespace eval ::FluidLauncher {
22
Kratos::AddNamespace [namespace current]
3-
3+
44
variable available_apps
55
}
66

77
proc ::FluidLauncher::Init { app } {
88
variable available_apps
99

1010
# TODO: Get apps from json
11-
set available_apps [list Fluid EmbeddedFluid PotentialFluid Buoyancy ConjugateHeatTransfer FluidDEM]
12-
11+
set available_apps [list Fluid EmbeddedFluid PotentialFluid Buoyancy ConjugateHeatTransfer FluidDEM FreeSurface]
12+
1313
::FluidLauncher::FluidAppSelectorWindow
1414
}
1515

1616
proc ::FluidLauncher::FluidAppSelectorWindow { } {
1717
variable available_apps
18-
18+
1919
set root [customlib::GetBaseRoot]
2020
set nd [ [$root selectNodes "value\[@n='nDim'\]"] getAttribute v]
2121
if { $nd ne "undefined" } {
@@ -69,7 +69,7 @@ proc ::FluidLauncher::FluidAppSelectorWindow { } {
6969

7070
# Information panel
7171
set spdAux::info_main_window_text ""
72-
ttk::labelframe $w.info -text " Information " -relief ridge
72+
ttk::labelframe $w.info -text " Information " -relief ridge
7373
ttk::label $w.info.text -textvariable spdAux::info_main_window_text
7474
grid $w.info.text
7575
grid $w.info -sticky we
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"id": "FreeSurface",
3+
"name": "FreeSurface",
4+
"prefix": "FL",
5+
"themed": false,
6+
"kratos_name": "FreeSurfaceapplication",
7+
"python_packages": [
8+
"KratosFluidDynamicsApplication",
9+
"KratosConvectionDiffusionApplication"
10+
],
11+
"dimensions": [
12+
"2D","3D"
13+
],
14+
"script_files": [
15+
"start.tcl",
16+
"examples/examples.tcl",
17+
"examples/Box.tcl",
18+
"xml/XmlController.tcl",
19+
"write/write.tcl",
20+
"write/writeProjectParameters.tcl"
21+
],
22+
"start_script": "::FreeSurface::Init",
23+
"requeriments": {
24+
"apps": [
25+
"Fluid"
26+
],
27+
"minimum_gid_version": "15.1.3d"
28+
},
29+
"permissions": {
30+
"open_tree": true,
31+
"show_toolbar": true,
32+
"intervals": true,
33+
"wizard": false
34+
},
35+
"write": {
36+
"coordinates": "all",
37+
"properties_location": "json",
38+
"model_part_name": "FluidModelPart",
39+
"output_model_part_name": ""
40+
},
41+
"main_launch_file": "../../exec/MainKratos.py"
42+
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace eval ::FreeSurface::examples {
2+
namespace path ::FreeSurface
3+
Kratos::AddNamespace [namespace current]
4+
}
5+
6+
# Common functions for all examples that uses Fluid App
7+
proc ::FreeSurface::examples::ErasePreviousIntervals { } {
8+
set root [customlib::GetBaseRoot]
9+
set interval_base [spdAux::getRoute "Intervals"]
10+
foreach int [$root selectNodes "$interval_base/blockdata\[@n='Interval'\]"] {
11+
if {[$int @name] ni [list Initial Total Custom1]} {$int delete}
12+
}
13+
}
14+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Group id="Fluid" name="Fluid examples">
3+
<Example id="FreeSurfaceBox2D" app="FreeSurface" logo="box2d.png" name="Free surface 2d" dim="2D" cmd="::FreeSurface::examples::Box::Init">
4+
<Description></Description>
5+
</Example>
6+
</Group>
8.75 KB
Loading
11.8 KB
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace eval ::FreeSurface {
2+
# Variable declaration
3+
variable dir
4+
variable _app
5+
Kratos::AddNamespace [namespace current]
6+
7+
proc GetAttribute {name} {variable _app; return [$_app getProperty $name]}
8+
proc GetUniqueName {name} {variable _app; return [$_app getUniqueName $name]}
9+
proc GetWriteProperty {name} {variable _app; return [$_app getWriteProperty $name]}
10+
}
11+
12+
proc ::FreeSurface::Init { app } {
13+
# Variable initialization
14+
variable dir
15+
variable _app
16+
17+
#W "Sourced FSI"
18+
set dir [apps::getMyDir "FreeSurface"]
19+
set _app $app
20+
21+
::FreeSurface::xml::Init
22+
::FreeSurface::write::Init
23+
24+
}

0 commit comments

Comments
 (0)