Skip to content

Commit da7950f

Browse files
Merge pull request #844 from KratosMultiphysics/shallow/add-strategies
[Shallow water] Add strategies
2 parents b9228a8 + bc8334e commit da7950f

10 files changed

Lines changed: 104 additions & 45 deletions

File tree

kratos.gid/apps/ShallowWater/app.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
"materials": "SWMaterials",
3030
"topography_data": "SWTopographicData",
3131
"initial_conditions": "SWInitialConditions",
32-
"conditions": "SWConditions",
33-
"gravity": "SWGravity",
34-
"time_parameters": "SWTimeParameters"
32+
"conditions": "SWConditions"
3533
},
3634
"write": {
3735
"coordinates": "all",

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ proc ::ShallowWater::write::GetProblemDataDict { } {
5151
proc ::ShallowWater::write::GetSolverSettingsDict { } {
5252
# General data
5353
set solverSettingsDict [dict create]
54-
dict set solverSettingsDict solver_type "stabilized_shallow_water_solver"
54+
dict set solverSettingsDict solver_type [write::getValue SWSolStrat]
5555
dict set solverSettingsDict model_part_name [GetAttribute model_part_name]
5656
dict set solverSettingsDict domain_size 2
57+
dict set solverSettingsDict gravity [write::getValue SWGravity]
5758

5859
# Model import settings
5960
set modelImportDict [dict create]
@@ -66,8 +67,9 @@ proc ::ShallowWater::write::GetSolverSettingsDict { } {
6667
dict set materialsDict materials_filename [GetAttribute materials_file]
6768
dict set solverSettingsDict material_import_settings $materialsDict
6869

69-
# set solverSettingsDict [dict merge $solverSettingsDict [write::getSolutionStrategyParametersDict SWSolutionStrat SWScheme SWStratParams]]
70-
# set solverSettingsDict [dict merge $solverSettingsDict [write::getSolversParametersDict ShallowWater]]
70+
# Strategy, scheme and linear solver settings
71+
set solverSettingsDict [dict merge $solverSettingsDict [write::getSolutionStrategyParametersDict SWSolStrat SWScheme SWStrategyParams] ]
72+
set solverSettingsDict [dict merge $solverSettingsDict [write::getSolversParametersDict ShallowWater] ]
7173

7274
# Time stepping settings
7375
set timeSteppingDict [dict create]

kratos.gid/apps/ShallowWater/xml/AnalysisType.spd

Lines changed: 0 additions & 7 deletions
This file was deleted.

kratos.gid/apps/ShallowWater/xml/Conditions.xml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<ConditionItem
44
n="ImposedFlowRate"
55
pn="Imposed flow rate"
6+
state="[checkStateByUniqueName SWSolStrat stabilized_shallow_water_solver]"
67
Interval="Total"
7-
ImplementedInApplication="ShallowWaterApplication"
88
App="ShallowWater"
99
Type="BoundaryCondition"
1010
ElementType="Line"
@@ -16,17 +16,30 @@
1616
<TopologyFeatures>
1717
<item GeometryType="Line" nodes="2" KratosName="LineCondition2D2N"/>
1818
</TopologyFeatures>
19-
<DegreesOfFreedom></DegreesOfFreedom>
20-
<inputs></inputs>
21-
<outputs>
22-
</outputs>
19+
</ConditionItem>
20+
21+
<ConditionItem
22+
n="ImposedVelocity"
23+
pn="Imposed velocity"
24+
state="[checkStateByUniqueName SWSolStrat wave_solver]"
25+
Interval="Total"
26+
App="ShallowWater"
27+
Type="BoundaryCondition"
28+
ElementType="Line"
29+
VariableName="VELOCITY"
30+
ProcessName="AssignVectorVariableProcess"
31+
help=""
32+
units="m/s"
33+
unit_magnitude="L/T">
34+
<TopologyFeatures>
35+
<item GeometryType="Line" nodes="2" KratosName="LineCondition2D2N"/>
36+
</TopologyFeatures>
2337
</ConditionItem>
2438

2539
<ConditionItem
2640
n="ImposedFreeSurface"
2741
pn="Imposed free surface"
2842
Interval="Total"
29-
ImplementedInApplication="ShallowWaterApplication"
3043
App="ShallowWater"
3144
Type="BoundaryCondition"
3245
ElementType="Line"
@@ -38,9 +51,5 @@
3851
<TopologyFeatures>
3952
<item GeometryType="Line" nodes="2" KratosName="LineCondition2D2N"/>
4053
</TopologyFeatures>
41-
<DegreesOfFreedom></DegreesOfFreedom>
42-
<inputs></inputs>
43-
<outputs>
44-
</outputs>
4554
</ConditionItem>
4655
</ConditionList>

kratos.gid/apps/ShallowWater/xml/Main.spd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<container n="ShallowWater" pn="Shallow Water" icon="app" prefix="SW" tree_state="open" open_window="0">
3+
<include n="AnalysisType" active="1" path="apps/ShallowWater/xml/Strategy.spd"/>
34
<include n="Parts" active="1" path="apps/ShallowWater/xml/Parts.spd"/>
45
<include n="TopographicData" active="1" path="apps/ShallowWater/xml/TopographicData.spd"/>
56
<include n="InitialConditions" active="1" path="apps/ShallowWater/xml/InitialConditions.spd"/>
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<container n="SolutionStrat" pn="Solution" un="SWSolutionStrat" icon="solver" help="Solution Strategy" open_window="0">
2+
<container n="SolutionStrat" pn="Solution" un="SWStrategyParams" icon="solver" help="Solution Strategy" open_window="0">
3+
4+
<!-- Parallelism -->
35
<include n="Parallelism" active="1" path="apps/Common/xml/Parallelism.spd"/>
6+
7+
<!-- Linear solvers -->
48
<dynamicnode command="spdAux::injectSolvers" args=""/>
9+
10+
<!-- Strategy parameters -->
511
<container n="StratParams" pn="Strategy parameters" un="SWStratParams" icon="prdata16.gif" state="normal" open_window="0">
612
<dynamicnode command="spdAux::injectSolStratParams" args=""/>
713
</container>
8-
<container n="Gravity" pn="Gravity" un="SWGravity" help="It is always in the vertical direction, positive down." open_window="0" icon="gravity_vector">
9-
<value n="GravityValue" pn="Gravity value" v="9.81" help="Gravity value" unit_magnitude="Acceleration" units="m/s^2" />
14+
15+
<!-- Gravity -->
16+
<container n="Gravity" pn="Gravity" help="It is always in the vertical direction, positive down." open_window="0" icon="gravity_vector">
17+
<value n="GravityValue" pn="Gravity value" un="SWGravity" v="9.81" help="Gravity value" unit_magnitude="Acceleration" units="m/s^2" />
1018
</container>
19+
20+
<!-- Time paremeters -->
1121
<container n="TimeParameters" pn="Time parameters" un="SWTimeParameters" help="Time parameters" open_window="0" icon="time4">
1222
<value n="StartTime" pn="Start time" v="0.0" help=""/>
1323
<value n="EndTime" pn="End time" v="1.0" help=""/>
@@ -17,4 +27,5 @@
1727
<value n="MinimumDeltaTime" pn="Minimum delta time" v="0.0001" help="" state="[checkStateByUniqueName SWAutomaticDeltaTime Yes]"/>
1828
<value n="MaximumDeltaTime" pn="Maximum delta time" v="1.0" help="" state="[checkStateByUniqueName SWAutomaticDeltaTime Yes]"/>
1929
</container>
30+
2031
</container>

kratos.gid/apps/ShallowWater/xml/Strategies.xml

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<StrategyList>
33
<StrategyItem n="stabilized_shallow_water_solver"
4-
pn="Stabilized shallow water solver"
5-
ImplementedInFile="stabilized_shallow_water_solver.py"
6-
ImplementedInApplication="ShallowWaterApplication"
7-
ImplementedInPythonFile="stabilized_shallow_water_solver"
8-
MinimumKratosVersion="9000"
4+
pn="Shallow water flow"
95
App="ShallowWater"
6+
NeedElements="false"
107
help="">
118

129
<!-- list of options to be filled -->
1310
<parameter_list>
1411
<parameter n="maximum_iterations" pn="Maximum iterations" type="integer" v="10" values="" help=""/>
1512
<parameter n="echo_level" pn="Echo level" type="int" v="0" help=""/>
13+
<parameter n="stabilization_factor" pn="Stabilization factor" type="double" v="0.01" help=""/>
14+
<parameter n="shock_capturing_type" pn="Shock capturing type" type="combo" values="residual_viscosity,gradient_jump,flux_correction" v="residual_viscosity" help=""/>
15+
<parameter n="shock_capturing_factor" pn="Shock capturing factor" type="double" v="0.5" help=""/>
1616
</parameter_list>
1717

18+
<!-- linear solver settings -->
1819
<linearSolvers>
19-
<linearSolverItem n="linear_solver_settings" pn="Linear Solver" >
20+
<linearSolverItem n="linear_solver_settings" pn="Linear Solver">
2021
<filterFeatures>
2122
<filter field="SolverType" value="Standard"/>
2223
</filterFeatures>
@@ -25,10 +26,54 @@
2526
</linearSolverItem>
2627
</linearSolvers>
2728

29+
<!-- scheme settings -->
2830
<schemes>
29-
<scheme n="bdf" pn="Backward differenctiation formula" help="">
31+
<scheme n="bdf" pn="Backward differenctiation formula" help="" NeedElements="false">
32+
<parameter_list>
33+
<parameter n="time_integration_order" pn="BDF order" type="int" v="2" help=""/>
34+
</parameter_list>
35+
<element_filters>
36+
</element_filters>
37+
</scheme>
38+
</schemes>
39+
40+
</StrategyItem>
41+
42+
<StrategyItem n="wave_solver"
43+
pn="Waves propagation"
44+
App="ShallowWater"
45+
NeedElements="false"
46+
help="">
47+
48+
<!-- list of options to be filled -->
49+
<parameter_list>
50+
<parameter n="maximum_iterations" pn="Maximum iterations" type="integer" v="10" values="" help=""/>
51+
<parameter n="echo_level" pn="Echo level" type="int" v="0" help=""/>
52+
<parameter n="stabilization_factor" pn="Stabilization factor" type="double" v="0.01" help=""/>
53+
</parameter_list>
54+
55+
<!-- linear solver settings -->
56+
<linearSolvers>
57+
<linearSolverItem n="linear_solver_settings" pn="Linear Solver">
58+
<filterFeatures>
59+
<filter field="SolverType" value="Standard"/>
60+
</filterFeatures>
61+
<defaults>
62+
</defaults>
63+
</linearSolverItem>
64+
</linearSolvers>
65+
66+
<!-- scheme settings -->
67+
<schemes>
68+
<scheme n="bdf" pn="Backward differenctiation formula" help="" NeedElements="false">
69+
<parameter_list>
70+
<parameter n="time_integration_order" pn="BDF order" type="int" v="2" help=""/>
71+
</parameter_list>
72+
<element_filters>
73+
</element_filters>
74+
</scheme>
75+
<scheme n="cn" pn="Crank Nicolson" help="" NeedElements="false">
3076
<parameter_list>
31-
<parameter n="order" pn="Order" type="int" v="2" help=""/>
3277
</parameter_list>
3378
<element_filters>
3479
</element_filters>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<container n="Physics" pn="Physics" help="Physics and analysis information" icon="analysis" state="normal" open_window="0">
3+
<value n="SolStrat" pn="Solution type" un="SWSolStrat" v="" values="" dict="[GetSolutionStrategies App ShallowWater]" actualize_tree="1"/>
4+
<value n="Scheme" pn="Scheme" un="SWScheme" v="" values="" dict="[GetSchemes]" actualize_tree="1"/>
5+
</container>

kratos.gid/apps/ShallowWater/xml/XmlController.tcl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace eval ::ShallowWater::xml {
66
proc ::ShallowWater::xml::Init {} {
77
Model::InitVariables dir $::ShallowWater::dir
88

9+
Model::getSolutionStrategies Strategies.xml
910
Model::getElements "../../Common/xml/Elements.xml"
1011
Model::getConditions Conditions.xml
1112
Model::getMaterials Materials.xml
@@ -21,8 +22,8 @@ proc ::ShallowWater::xml::getUniqueName {name} {
2122

2223
proc ::ShallowWater::xml::CustomTree {args} {
2324
# Set the nodal conditions active
24-
gid_groups_conds::setAttributes "[spdAux::getRoute [GetUniqueName topography_data]]/condition" [list state normal]
25-
gid_groups_conds::setAttributes "[spdAux::getRoute [GetUniqueName initial_conditions]]/condition" [list state normal]
25+
gid_groups_conds::setAttributes "[spdAux::getRoute SWTopographicData]/condition" [list state normal]
26+
gid_groups_conds::setAttributes "[spdAux::getRoute SWInitialConditions]/condition" [list state normal]
2627

2728
# Register the primary outputs from topography data
2829
gid_groups_conds::setAttributes "[spdAux::getRoute NodalResults]/value\[@n = 'MOMENTUM'\]" [list state normal]
@@ -31,5 +32,5 @@ proc ::ShallowWater::xml::CustomTree {args} {
3132
gid_groups_conds::setAttributes "[spdAux::getRoute NodalResults]/value\[@n = 'FREE_SURFACE_ELEVATION'\]" [list state normal]
3233

3334
# Set the default value for the Z component in the boundary conditions
34-
gid_groups_conds::setAttributes "[spdAux::getRoute [GetUniqueName conditions]]/condition\[@n = 'ImposedFlowRate'\]/value\[@n = 'selector_component_Z'\]" [list v Not]
35+
gid_groups_conds::setAttributes "[spdAux::getRoute SWConditions]/condition\[@n = 'ImposedFlowRate'\]/value\[@n = 'selector_component_Z'\]" [list v Not]
3536
}

kratos.gid/scripts/Controllers/CommonProcs.tcl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ proc spdAux::ProcGetSolutionStrategies {domNode args} {
8181
set pnames [list ]
8282
# W $args
8383
set sols [::Model::GetSolutionStrategies {*}$args]
84-
# W $Sols
84+
# W $sols
8585
foreach ss $sols {
8686
lappend names [$ss getName]
8787
lappend pnames [$ss getName]
@@ -101,14 +101,8 @@ proc spdAux::ProcGetSchemes {domNode args} {
101101
set nodeApp [GetAppIdFromNode $domNode]
102102
# W $nodeApp
103103
set sol_stratUN [apps::getAppUniqueName $nodeApp SolStrat]
104-
set sol_stat_path [spdAux::getRoute $sol_stratUN]
105104

106-
#if {[get_domnode_attribute [$domNode selectNodes $sol_stat_path] v] eq ""} {
107-
#W "entra"
108-
get_domnode_attribute [$domNode selectNodes $sol_stat_path] dict
109-
get_domnode_attribute [$domNode selectNodes $sol_stat_path] values
110-
#}
111-
set solStratName [::write::getValue $sol_stratUN]
105+
set solStratName [::write::getValue $sol_stratUN "" force]
112106
if {$solStratName eq "" } {error "No solution strategy"}
113107
#W "Unique name: $sol_stratUN - Nombre $solStratName"
114108
set schemes [::Model::GetAvailableSchemes $solStratName {*}$args]

0 commit comments

Comments
 (0)