-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathwriteProjectParameters.tcl
More file actions
319 lines (264 loc) · 13.6 KB
/
writeProjectParameters.tcl
File metadata and controls
319 lines (264 loc) · 13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# Project Parameters
proc ::Fluid::write::getParametersDict { } {
set projectParametersDict [dict create]
# Problem data
dict set projectParametersDict problem_data [write::GetDefaultProblemDataDict $Fluid::app_id]
# output configuration
dict set projectParametersDict output_processes [write::GetDefaultOutputProcessDict $Fluid::app_id]
# Solver settings
set solver_settings_dict [Fluid::write::getSolverSettingsDict]
dict set solver_settings_dict "reform_dofs_at_each_step" false
dict set projectParametersDict solver_settings $solver_settings_dict
# Boundary conditions processes
set processesDict [dict create]
dict set processesDict initial_conditions_process_list [write::getConditionsParametersDict [GetAttribute nodal_conditions_un] "Nodal"]
dict set processesDict boundary_conditions_process_list [write::getConditionsParametersDict [GetAttribute conditions_un]]
dict set processesDict gravity [list [getGravityProcessDict] ]
dict set processesDict auxiliar_process_list [getAuxiliarProcessList]
dict set projectParametersDict processes $processesDict
return $projectParametersDict
}
proc Fluid::write::writeParametersEvent { } {
set projectParametersDict [getParametersDict]
write::SetParallelismConfiguration
write::WriteJSON $projectParametersDict
}
proc Fluid::write::getAuxiliarProcessList {} {
set process_list [list ]
foreach process [getDragProcessList] {lappend process_list $process}
foreach process [getWssProcessList] {lappend process_list $process}
return $process_list
}
# proc Fluid::write::getWssProcessList {} {
# set root [customlib::GetBaseRoot]
# set process_list [list ]
# set xp1 "[spdAux::getRoute [GetAttribute wss_un]]"
# set write_output [write::getStringBinaryFromValue [write::getValueByNode [$root selectNodes "$xp1/value\[@n='write_wss_output_file'\]"]]]
# set print_screen [write::getStringBinaryFromValue [write::getValueByNode [$root selectNodes "$xp1/value\[@n='print_wss_to_screen'\]"]]]
# set pdict [dict create]
# dict set pdict "python_module" "compute_wss_statistics_process"
# dict set pdict "kratos_module" "KratosMultiphysics.FluidDynamicsBiomedicalApplication"
# dict set pdict "process_name" "ComputeWssStatisticsProcess"
# set params [dict create]
# dict set params "model_part_name" GENERIC__HIDDEN__SKIN_
# dict set params "calculate_wss" $print_screen
# dict set params "calculate_osi" true
# dict set pdict "Parameters" $params
# lappend process_list $pdict
# return $process_list
# }
proc Fluid::write::getWssProcessList {} {
set root [customlib::GetBaseRoot]
set process_list [list ]
set xp1 "[spdAux::getRoute [GetAttribute wss_un]]/group"
set groups [$root selectNodes $xp1]
foreach group $groups {
set groupName [$group @n]
set groupName [write::GetWriteGroupName $groupName]
set cid [[$group parent] @n]
set submodelpart [::write::getSubModelPartId $cid $groupName]
set write_output [write::getStringBinaryFromValue [write::getValueByNode [$group selectNodes "./value\[@n='write_wss_output_file'\]"]]]
set print_screen [write::getStringBinaryFromValue [write::getValueByNode [$group selectNodes "./value\[@n='print_wss_to_screen'\]"]]]
set pdict [dict create]
dict set pdict "python_module" "compute_wss_statistics_process"
dict set pdict "kratos_module" "KratosMultiphysics.FluidDynamicsBiomedicalApplication"
dict set pdict "process_name" "ComputeWssStatisticsProcess"
set params [dict create]
dict set params "model_part_name" [write::GetModelPartNameWithParent $submodelpart]
dict set params "write_wss_output_file" $write_output
dict set params "print_wss_to_screen" $print_screen
dict set pdict "Parameters" $params
lappend process_list $pdict
}
}
proc Fluid::write::getDragProcessList {} {
set root [customlib::GetBaseRoot]
set process_list [list ]
set xp1 "[spdAux::getRoute [GetAttribute drag_un]]/group"
set groups [$root selectNodes $xp1]
foreach group $groups {
set groupName [$group @n]
set groupName [write::GetWriteGroupName $groupName]
set cid [[$group parent] @n]
set submodelpart [::write::getSubModelPartId $cid $groupName]
set write_output [write::getStringBinaryFromValue [write::getValueByNode [$group selectNodes "./value\[@n='write_drag_output_file'\]"]]]
set print_screen [write::getStringBinaryFromValue [write::getValueByNode [$group selectNodes "./value\[@n='print_drag_to_screen'\]"]]]
set interval_name [write::getValueByNode [$group selectNodes "./value\[@n='Interval'\]"]]
set pdict [dict create]
dict set pdict "python_module" "compute_body_fitted_drag_process"
dict set pdict "kratos_module" "KratosMultiphysics.FluidDynamicsApplication"
dict set pdict "process_name" "ComputeBodyFittedDragProcess"
set params [dict create]
dict set params "model_part_name" [write::GetModelPartNameWithParent $submodelpart]
dict set params "write_drag_output_file" $write_output
dict set params "print_drag_to_screen" $print_screen
dict set params "interval" [write::getInterval $interval_name]
dict set pdict "Parameters" $params
lappend process_list $pdict
}
return $process_list
}
# Gravity SubModelParts and Process collection
proc Fluid::write::getGravityProcessDict {} {
set root [customlib::GetBaseRoot]
set value [write::getValue FLGravity GravityValue]
set cx [write::getValue FLGravity Cx]
set cy [write::getValue FLGravity Cy]
set cz [write::getValue FLGravity Cz]
#W "Gravity $value on \[$cx , $cy , $cz\]"
set pdict [dict create]
dict set pdict "python_module" "assign_vector_by_direction_process"
dict set pdict "kratos_module" "KratosMultiphysics"
dict set pdict "process_name" "AssignVectorByDirectionProcess"
set params [dict create]
set partgroup [write::getPartsSubModelPartId]
dict set params "model_part_name" [write::GetModelPartNameWithParent [concat [lindex $partgroup 0]]]
dict set params "variable_name" "BODY_FORCE"
dict set params "modulus" $value
dict set params "constrained" false
dict set params "direction" [list $cx $cy $cz]
dict set pdict "Parameters" $params
return $pdict
}
# Skin SubModelParts ids
proc Fluid::write::getBoundaryConditionMeshId {} {
set root [customlib::GetBaseRoot]
set listOfBCGroups [list ]
set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition/group"
set groups [$root selectNodes $xp1]
foreach group $groups {
set groupName [$group @n]
set groupName [write::GetWriteGroupName $groupName]
set cid [[$group parent] @n]
set cond [Model::getCondition $cid]
if {[$cond getAttribute "SkinConditions"] eq "True"} {
if {[[::Model::getCondition $cid] getGroupBy] eq "Condition"} {
# Grouped conditions have its own submodelpart
if {$cid ni $listOfBCGroups} {
lappend listOfBCGroups $cid
}
} else {
set gname [::write::getSubModelPartId $cid $groupName]
if {$gname ni $listOfBCGroups} {lappend listOfBCGroups $gname}
}
}
}
return $listOfBCGroups
}
# No-skin SubModelParts ids
proc Fluid::write::getNoSkinConditionMeshId {} {
set root [customlib::GetBaseRoot]
set listOfNoSkinGroups [list ]
# Append drag processes model parts names
set xp1 "[spdAux::getRoute [GetAttribute drag_un]]/group"
set dragGroups [$root selectNodes $xp1]
foreach dragGroup $dragGroups {
set groupName [$dragGroup @n]
set groupName [write::GetWriteGroupName $groupName]
set cid [[$dragGroup parent] @n]
set submodelpart [::write::getSubModelPartId $cid $groupName]
if {$submodelpart ni $listOfNoSkinGroups} {lappend listOfNoSkinGroups $submodelpart}
}
# Append no skin conditions model parts names
set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition/group"
set groups [$root selectNodes $xp1]
foreach group $groups {
set groupName [$group @n]
set groupName [write::GetWriteGroupName $groupName]
set cid [[$group parent] @n]
set cond [Model::getCondition $cid]
if {[$cond getAttribute "SkinConditions"] eq "False"} {
set gname [::write::getSubModelPartId $cid $groupName]
if {$gname ni $listOfNoSkinGroups} {lappend listOfNoSkinGroups $gname}
}
}
return $listOfNoSkinGroups
}
proc Fluid::write::GetUsedElements {} {
set root [customlib::GetBaseRoot]
# Get the fluid part
set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/group"
set lista [list ]
foreach gNode [[customlib::GetBaseRoot] selectNodes $xp1] {
set g $gNode
set name [write::getValueByNode [$gNode selectNodes ".//value\[@n='Element']"] ]
if {$name ni $lista} {lappend lista $name}
}
return $lista
}
proc Fluid::write::getSolverSettingsDict { } {
set solverSettingsDict [dict create]
dict set solverSettingsDict model_part_name [GetAttribute model_part_name]
set nDim [expr [string range [write::getValue nDim] 0 0]]
dict set solverSettingsDict domain_size $nDim
set currentStrategyId [write::getValue FLSolStrat]
set strategy_write_name [[::Model::GetSolutionStrategy $currentStrategyId] getAttribute "ImplementedInPythonFile"]
dict set solverSettingsDict solver_type $strategy_write_name
# model import settings
set modelDict [dict create]
dict set modelDict input_type "mdpa"
set model_name [Fluid::write::getFluidModelPartFilename]
dict set modelDict input_filename $model_name
dict set solverSettingsDict model_import_settings $modelDict
# material import settings
set materialsDict [dict create]
dict set materialsDict materials_filename [GetAttribute materials_file]
dict set solverSettingsDict material_import_settings $materialsDict
set solverSettingsDict [dict merge $solverSettingsDict [write::getSolutionStrategyParametersDict FLSolStrat FLScheme FLStratParams] ]
set solverSettingsDict [dict merge $solverSettingsDict [write::getSolversParametersDict Fluid] ]
# Parts
dict set solverSettingsDict volume_model_part_name {*}[write::getPartsSubModelPartId]
# Skin parts
dict set solverSettingsDict skin_parts [getBoundaryConditionMeshId]
# No skin parts
dict set solverSettingsDict no_skin_parts [getNoSkinConditionMeshId]
# Time scheme settings
if {$currentStrategyId eq "Monolithic"} {
dict set solverSettingsDict time_scheme [write::getValue FLScheme]
}
# Time stepping settings
set timeSteppingDict [dict create]
set automaticDeltaTime [write::getValue FLTimeParameters AutomaticDeltaTime]
dict set timeSteppingDict automatic_time_step $automaticDeltaTime
if {$automaticDeltaTime eq "Yes"} {
dict set timeSteppingDict "CFL_number" [write::getValue FLTimeParameters CFLNumber]
dict set timeSteppingDict "minimum_delta_time" [write::getValue FLTimeParameters MinimumDeltaTime]
dict set timeSteppingDict "maximum_delta_time" [write::getValue FLTimeParameters MaximumDeltaTime]
} else {
dict set timeSteppingDict "time_step" [write::getValue FLTimeParameters DeltaTime]
}
dict set solverSettingsDict time_stepping $timeSteppingDict
# For monolithic schemes, set the formulation settings
if {$currentStrategyId eq "Monolithic"} {
# Create formulation dictionary
set formulationSettingsDict [dict create]
# Set formulation dictionary element type
set elements [Fluid::write::GetUsedElements]
if {[llength $elements] ne 1} {error "You must select 1 element"} {set element_name [lindex $elements 0]}
if {$element_name eq "QSVMS2D" || $element_name eq "QSVMS3D"} {
set element_type "qsvms"
} elseif {$element_name eq "DVMS2D" || $element_name eq "DVMS3D"} {
set element_type "dvms"
} elseif {$element_name eq "FIC2D" || $element_name eq "FIC3D"} {
set element_type "fic"
} else {
set err [concat "Wrong monolithic element type: " $element_name]
error $err
}
dict set formulationSettingsDict element_type $element_type
# Set OSS and remove oss_switch from the original dictionary
# It is important to check that there is oss_switch, otherwise the derived apps (e.g. embedded) might crash
if {[dict exists $solverSettingsDict oss_switch]} {
dict set formulationSettingsDict use_orthogonal_subscales [write::getStringBinaryFromValue [dict get $solverSettingsDict oss_switch]]
dict unset solverSettingsDict oss_switch
}
# Set dynamic tau and remove dynamic_tau from the original dictionary
if {$element_name eq "QSVMS2D" || $element_name eq "QSVMS3D"} {
dict set formulationSettingsDict dynamic_tau [dict get $solverSettingsDict dynamic_tau]
dict unset solverSettingsDict dynamic_tau
# Include the formulation settings in the solver settings dict
dict set solverSettingsDict formulation $formulationSettingsDict
}
}
return $solverSettingsDict
}