Skip to content

Commit a3f5ab3

Browse files
import stages files
1 parent b5a72c5 commit a3f5ab3

3 files changed

Lines changed: 51 additions & 35 deletions

File tree

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

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ proc ::GeoMechanics::write::getParametersDict { stage } {
88
if { [GetAttribute multistage_write_mdpa_file_mode] != "single_file" } {
99
dict set project_parameters_dict solver_settings model_import_settings input_filename [$stage @name]
1010
}
11-
12-
1311

1412
# add the phreatic water properties
1513
set list_of_processes [dict get $project_parameters_dict processes constraints_process_list]
@@ -22,34 +20,37 @@ proc ::GeoMechanics::write::getParametersDict { stage } {
2220
return $project_parameters_dict
2321
}
2422

23+
2524
proc ::GeoMechanics::write::GetSingleFileStageProjectParameters { } {
2625
# Get the base dictionary for the project parameters
2726
set project_parameters_dict [dict create]
2827

28+
# Get the stages
29+
set stages_list [::GeoMechanics::xml::GetStages]
30+
set stages_names [list ]
31+
foreach stage $stages_list {
32+
lappend stages_names [$stage @name]
33+
}
34+
2935
# Set the orchestrator
30-
dict set project_parameters_dict orchestrator name "MultistageOrchestrators.KratosMultiphysics.SequentialMultistageOrchestrator"
31-
dict set project_parameters_dict orchestrator settings echo_level 0
32-
dict set project_parameters_dict orchestrator settings execution_list [::GeoMechanics::xml::GetStages "names"]
33-
dict set project_parameters_dict orchestrator settings stage_checkpoints true
34-
dict set project_parameters_dict orchestrator settings stage_checkpoints_folder new_checkpoints
35-
# dict set project_parameters_dict orchestrator settings load_from_checkpoint "new_checkpoints/fluid_stage"
36+
dict set project_parameters_dict orchestrator [::write::GetOrchestratorDict $stages_names]
3637

3738
# Set the stages
3839
set stages [dict create]
3940

4041
set i 0
41-
foreach stage [::GeoMechanics::xml::GetStages] {
42+
foreach stage $stages_list {
4243
set stage_name [$stage @name]
4344
set stage_content [::GeoMechanics::write::getParametersDict $stage]
4445
# In first iteration we add the mdpa importer
4546
if {$i == 0} {
4647
set parameters_modeler [dict create input_filename [Kratos::GetModelName] model_part_name [write::GetConfigurationAttribute model_part_name]]
47-
dict set stages $stage_name stage_preprocess [::GeoMechanics::write::getPreprocessForStage $stage $parameters_modeler]
48+
dict set stages $stage_name stage_preprocess [::write::getPreprocessForStage $stage $parameters_modeler]
4849
} else {
49-
dict set stages $stage_name stage_preprocess [::GeoMechanics::write::getPreprocessForStage $stage]
50+
dict set stages $stage_name stage_preprocess [::write::getPreprocessForStage $stage]
5051
}
5152
dict set stages $stage_name stage_settings $stage_content
52-
dict set stages $stage_name stage_postprocess [::GeoMechanics::write::getPostprocessForStage $stage]
53+
dict set stages $stage_name stage_postprocess [::write::getPostprocessForStage $stage]
5354
incr i
5455
}
5556

@@ -58,28 +59,6 @@ proc ::GeoMechanics::write::GetSingleFileStageProjectParameters { } {
5859
return $project_parameters_dict
5960
}
6061

61-
# Get the dictionary for the preprocess of the stage
62-
proc ::GeoMechanics::write::getPreprocessForStage {stage {mdpaimporter ""}} {
63-
set stage_preprocess [dict create ]
64-
set operation_parameters [dict create ]
65-
dict set stage_preprocess operations [list [dict create name "user_operation.EmptyOperation" Parameters $operation_parameters]]
66-
67-
if { $mdpaimporter ne "" } {
68-
# Get the modeler parameters
69-
set modeler [dict create name "KratosMultiphysics.modelers.import_mdpa_modeler.ImportMDPAModeler" Parameters $mdpaimporter]
70-
dict set stage_preprocess modelers [list $modeler]
71-
}
72-
73-
return $stage_preprocess
74-
}
75-
76-
# Get the dictionary for the postprocess of the stage
77-
proc ::GeoMechanics::write::getPostprocessForStage {stage} {
78-
set stage_postprocess [dict create ]
79-
dict set stage_postprocess operations [list [dict create name "user_operation.EmptyOperation" Parameters [dict create ] ]]
80-
81-
return $stage_postprocess
82-
}
8362

8463
proc ::GeoMechanics::write::writeParametersEvent { } {
8564
if { [GetAttribute multistage_write_json_mode] == "single_file" } {
@@ -91,6 +70,8 @@ proc ::GeoMechanics::write::writeParametersEvent { } {
9170
write::OpenFile "ProjectParameters[$stage @name].json"
9271
write::WriteJSON [::GeoMechanics::write::getParametersDict $stage]
9372
}
73+
74+
# TODO: add the orchestrator in ProjectParameters.json
9475
}
9576
}
9677

kratos.gid/kratos.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ proc Kratos::LoadCommonScripts { } {
209209
# Writing common scripts
210210
foreach filename {Writing WriteHeadings WriteMaterials WriteNodes
211211
WriteElements WriteConditions WriteGeometries WriteConditionsByGiDId WriteConditionsByUniqueId
212-
WriteProjectParameters WriteSubModelPart WriteProcess} {
212+
WriteProjectParameters WriteSubModelPart WriteProcess WriteStages} {
213213
uplevel #0 [list source [file join $kratos_private(Path) scripts Writing $filename.tcl]]
214214
}
215215
# Common scripts
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
# Get the dictionary for the preprocess of the stage
3+
proc ::write::getPreprocessForStage {stage {mdpaimporter ""}} {
4+
set stage_preprocess [dict create ]
5+
set operation_parameters [dict create ]
6+
dict set stage_preprocess operations [list [dict create name "user_operation.EmptyOperation" Parameters $operation_parameters]]
7+
8+
if { $mdpaimporter ne "" } {
9+
# Get the modeler parameters
10+
set modeler [dict create name "KratosMultiphysics.modelers.import_mdpa_modeler.ImportMDPAModeler" Parameters $mdpaimporter]
11+
dict set stage_preprocess modelers [list $modeler]
12+
}
13+
14+
return $stage_preprocess
15+
}
16+
17+
# Get the dictionary for the postprocess of the stage
18+
proc ::write::getPostprocessForStage {stage} {
19+
set stage_postprocess [dict create ]
20+
dict set stage_postprocess operations [list [dict create name "user_operation.EmptyOperation" Parameters [dict create ] ]]
21+
22+
return $stage_postprocess
23+
}
24+
25+
proc ::write::GetOrchestratorDict { stages_names } {
26+
27+
set orchestrator_dict [dict create]
28+
dict set orchestrator_dict name "MultistageOrchestrators.KratosMultiphysics.SequentialMultistageOrchestrator"
29+
dict set orchestrator_dict settings echo_level 0
30+
dict set orchestrator_dict settings execution_list $stages_names
31+
dict set orchestrator_dict settings stage_checkpoints true
32+
dict set orchestrator_dict settings stage_checkpoints_folder new_checkpoints
33+
# dict set orchestrator_dict settings load_from_checkpoint "new_checkpoints/fluid_stage"
34+
return $orchestrator_dict
35+
}

0 commit comments

Comments
 (0)