From 80e6302bc4acc64ec129b1e427ed4ba41d326fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20G=C3=A1rate?= Date: Fri, 19 Dec 2025 18:39:52 +0100 Subject: [PATCH 01/16] initial files --- kratos.gid/images/run16.png | Bin 0 -> 1287 bytes kratos.gid/kratos.spd | 13 +++++-- kratos.gid/kratos.tcl | 2 +- .../scripts/Controllers/RunSimulations.tcl | 33 ++++++++++++++++++ kratos.gid/scripts/spdAuxiliar.tcl | 4 +++ 5 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 kratos.gid/images/run16.png create mode 100644 kratos.gid/scripts/Controllers/RunSimulations.tcl diff --git a/kratos.gid/images/run16.png b/kratos.gid/images/run16.png new file mode 100644 index 0000000000000000000000000000000000000000..ce8b3360dd8d97ef7b7934b6407048061baecdcf GIT binary patch literal 1287 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBufiR<}hF1enLwjaOL`j6Nk5zJhu3lnFep0GlMQ#C5H3Nf< zeMLcHa&~HoLQ-maW}dD3``!E16*5z7)x%AF4SWlnQ!_F>s)|yBtNcQetFn_VQ`GJ4 zc)4sUtbiuurj{fsROII56ON0GHI_ zN%^HEwo0X?nJHFjiD{-uDJiD9Nr}cOx`u`+iMoj?#)i5n#>Oe;riK zGN53Bhi+;fFi6XRVW%@?1~&r(GpDDEV~BL>Ni` zpMnjHH-7*4%-(Zy9$V45Wfl2???2wVcq2oAWtQ#tuOD7KXnykf=AHYex29XYf3K{e%_)#PZi}}?U!#jzyDX;>3W~XkA7$rgq4?; zicUGlv%|#Ir9i1=rD|7lTfA)2lgGkm&V*Y2e8|E5S#(vmw@YA$;myXm*6dwTpWdcU zc_r|^!^LB7!XdTeeESbbACG5h(RVv;VQh8m%Nd#J>gyXgye=;63bZWfT@ku1`m)33 z@W?pttdh6)-S5A4XSk7*Q}pJ8<0Fe_zuxfb#m!Qhe)hp0W4({Jx3HX3QCj6Hliz;Y zCMbUC`wQI-8wy^DOg-sYRbC#Pm;dz3Ov6W47KwCx_u6B8YuABgO>aD%_whULdl##| zw`AJW^83ko$;}%UH=p{WBwzDM^77`;Pdj-Y**0~Q-piWWdF``@Rig2qeWwdv9N2qA zTrJ{HG1K2Wj*mVTy4|as&pr9NhA4N3_z~_7f6hgvbLW4~*6Up5Ytmf)?BG4eXYY*G z+HUsQTh#LAg8}zcS1w&u7aJwMDGx3!nYDUHXzW5Ewaf~;3$rqe7e&o}cIQ&4-Cx6n zZ%>uhX>ZwdB~Gp2TUx_{DN3G)K8LRIWxa6m=H~rtH-En!6t;ckl5?B%FT}6EJoTF7 z{foUPpKxpwYcpglyb%)}yYpjCZe7(OhL+jcpQC1L%8R_~EZt}y85}Sb4q9e09Qmc8~^|S literal 0 HcmV?d00001 diff --git a/kratos.gid/kratos.spd b/kratos.gid/kratos.spd index f88968996..00548cd04 100644 --- a/kratos.gid/kratos.spd +++ b/kratos.gid/kratos.spd @@ -36,6 +36,9 @@ + + + @@ -330,9 +333,6 @@ return [spdAux::ProcGetFilesValues $domNode] ]]> - - - + + + + diff --git a/kratos.gid/kratos.tcl b/kratos.gid/kratos.tcl index f6aec49e6..72b921d07 100644 --- a/kratos.gid/kratos.tcl +++ b/kratos.gid/kratos.tcl @@ -203,7 +203,7 @@ proc Kratos::LoadCommonScripts { } { uplevel #0 [list source [file join $kratos_private(Path) scripts $filename.tcl]] } # Common controllers - foreach filename {ApplicationMarketWindow ExamplesWindow CommonProcs PreferencesWindow TreeInjections MdpaImportMesh Drawer ImportFiles} { + foreach filename {ApplicationMarketWindow ExamplesWindow CommonProcs PreferencesWindow TreeInjections MdpaImportMesh Drawer ImportFiles RunSimulations} { uplevel #0 [list source [file join $kratos_private(Path) scripts Controllers $filename.tcl]] } # Model class diff --git a/kratos.gid/scripts/Controllers/RunSimulations.tcl b/kratos.gid/scripts/Controllers/RunSimulations.tcl new file mode 100644 index 000000000..30710f5a7 --- /dev/null +++ b/kratos.gid/scripts/Controllers/RunSimulations.tcl @@ -0,0 +1,33 @@ +################################################################################## +# This file is common for all Kratos Applications. +# Do not change anything here unless it's strictly necessary. +################################################################################## + +namespace eval ::runsimulations { + Kratos::AddNamespace [namespace current] + + variable folder_name + variable spd_un + variable dir +} + + +proc runsimulations::Init { } { + variable folder_name + variable spd_un + variable dir + + set folder_name "Simulations" + set spd_un "simulation_runs" + set dir [GidUtils::GetDirectoryModel] +} + +proc runsimulations::GetPastSimulationsRunsList { } { + +} + +proc runsimulations::GetNextSimulationRun { } { + + +} + diff --git a/kratos.gid/scripts/spdAuxiliar.tcl b/kratos.gid/scripts/spdAuxiliar.tcl index 779afdecb..045235319 100644 --- a/kratos.gid/scripts/spdAuxiliar.tcl +++ b/kratos.gid/scripts/spdAuxiliar.tcl @@ -516,4 +516,8 @@ proc spdAux::RegisterWindow {window_name} { } +proc spdAux::ProcFillSimulations { domNode args } { + # W "Filling simulations..." +} + spdAux::Init From 4e8615e66790655698c9eba5643f6922aed8be1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20G=C3=A1rate?= Date: Fri, 26 Dec 2025 19:55:53 +0100 Subject: [PATCH 02/16] Open in code --- kratos.gid/apps/Buoyancy/xml/Procs.spd | 2 +- kratos.gid/images/ok16.png | Bin 0 -> 680 bytes kratos.gid/kratos.spd | 6 +- .../scripts/Controllers/RunSimulations.tcl | 34 ++++++++- kratos.gid/scripts/Utils.tcl | 21 +++++- kratos.gid/scripts/spdAuxiliar.tcl | 68 ++++++++++++++++++ 6 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 kratos.gid/images/ok16.png diff --git a/kratos.gid/apps/Buoyancy/xml/Procs.spd b/kratos.gid/apps/Buoyancy/xml/Procs.spd index 19609d17d..62dee8400 100644 --- a/kratos.gid/apps/Buoyancy/xml/Procs.spd +++ b/kratos.gid/apps/Buoyancy/xml/Procs.spd @@ -61,7 +61,7 @@ lappend arguments "SolutionType" $solutionType #W "arguments $arguments" set Sols [::Model::GetSolutionStrategies $arguments ] - set ids [list ] + set ids [list ] foreach ss $Sols { lappend ids [$ss getName] append names [$ss getName] "," diff --git a/kratos.gid/images/ok16.png b/kratos.gid/images/ok16.png new file mode 100644 index 0000000000000000000000000000000000000000..7b4f3494c9d1894961aae4c94a5e83975b728926 GIT binary patch literal 680 zcmV;Z0$2TsP)P)t-sM{rD2 zqHRi$VO+0wR-#dp~?rOq*r^000aY z5F9lm0000dO*8-i03<~(WU_u!l4wneVoHl(3lt6p3I`7x69^9r1qlZc9u*B25E394 z4Hpm$77#LFLJ=Mn1qlW+VM0rcVNsE15FQm{vVK;VYY-n5S*&$ft8-19XIidyPM&C1 zsd81Paa5*nQ>1Q7n`Td-YEYqTQlo6{_VHJ!a#f~qQloAA{rps=Z&|5ykH?~z%c)PF zYO~M0a<_?EpK<^H|4No*Po8O5l53c|q)eG*R;6%Ipli?O*HWTw^7iwm(6vpSXV>Q3 z^!fI4wTZILyNAG?C10BdAN@A`Ss!N=J5CPwa~t| z*}_MUUrUi - - + + + + diff --git a/kratos.gid/scripts/Controllers/RunSimulations.tcl b/kratos.gid/scripts/Controllers/RunSimulations.tcl index 30710f5a7..dc0e6c584 100644 --- a/kratos.gid/scripts/Controllers/RunSimulations.tcl +++ b/kratos.gid/scripts/Controllers/RunSimulations.tcl @@ -24,10 +24,38 @@ proc runsimulations::Init { } { proc runsimulations::GetPastSimulationsRunsList { } { -} + set return_list [list ] + + # Find in the folder + variable dir + variable folder_name + set simulations_dir [file join $dir $folder_name] + if {[file isdirectory $simulations_dir]} { + # find all the folders inside + set dir_list [glob -nocomplain -directory $simulations_dir *] + foreach sim_dir $dir_list { + set sim [dict create] + if {[file isdirectory $sim_dir]} { + set sim_name [file tail $sim_dir] + dict set sim name $sim_name + dict set sim path $sim_dir + lappend return_list $sim + } + } + } + return $return_list -proc runsimulations::GetNextSimulationRun { } { - +} +proc runsimulations::GetNextSimulationRunName { previous_runs_names } { + set run_index [llength $previous_runs_names] + incr run_index + set run_name "Run $run_index" + while {[lsearch -exact $previous_runs_names $run_name] != -1} { + incr run_index + set run_name "Run $run_index" + } + return $run_name } +runsimulations::Init \ No newline at end of file diff --git a/kratos.gid/scripts/Utils.tcl b/kratos.gid/scripts/Utils.tcl index 23ae7c750..b3b3339c5 100644 --- a/kratos.gid/scripts/Utils.tcl +++ b/kratos.gid/scripts/Utils.tcl @@ -361,13 +361,30 @@ proc ? {question true_val false_val} { return [expr $question ? $true_val : $false_val] } -proc Kratos::OpenCaseIn {program} { +proc Kratos::OpenCaseIn {program {ext_path ""}} { switch $program { "VSCode" { if {[GiD_Info Project ModelName] eq "UNNAMED"} {W "Save your model first"} { - catch {exec code -n [GidUtils::GetDirectoryModel]} msg + if {$ext_path ne ""} { + set model_dir $ext_path + } else { + set model_dir [GiD_Info Project ModelName].gid + } + catch { + GidUtils::SetWarnLine "Opening $model_dir in Visual Studio Code..." + # set command {code -n 'C:/Users/garat/Desktop/aaa.gid/Simulations/Run 1'} + # exec $command + # exec [list code -n $model_dir] + # exec code -n "$model_dir" + exec code -n $model_dir + # exec "{*}[auto_execok code] -n $model_dir" + # exec {*}[auto_execok code] -n $model_dir + #W [gid_cross_platform::execute_program_in_path [list "code" "-n" $model_dir]] + } msg if {$msg eq {couldn't execute "code": no such file or directory}} { W "Install Visual Studio Code and add it to your PATH" + } elseif {$msg ne ""} { + W "Error opening Visual Studio Code: $msg" } } } diff --git a/kratos.gid/scripts/spdAuxiliar.tcl b/kratos.gid/scripts/spdAuxiliar.tcl index 045235319..2868306ad 100644 --- a/kratos.gid/scripts/spdAuxiliar.tcl +++ b/kratos.gid/scripts/spdAuxiliar.tcl @@ -518,6 +518,74 @@ proc spdAux::RegisterWindow {window_name} { proc spdAux::ProcFillSimulations { domNode args } { # W "Filling simulations..." + + # detect previous simulation runs + set sim_runs_list [runsimulations::GetPastSimulationsRunsList] + + set simulations_names [list ] + foreach sim_run $sim_runs_list { + dict get $sim_run name + lappend simulations_names [dict get $sim_run name] + } + # set the next simulation name + set next_sim_name [runsimulations::GetNextSimulationRunName $simulations_names] + set next_name_node [$domNode selectNodes ".//value\[@n='current_simulation_run'\]"] + $next_name_node setAttribute v $next_sim_name + + # fill the simulations list + set sim_list_node [$domNode selectNodes ".//container\[@n='simulation_run_list'\]"] + # clear previous entries + foreach child_node [$sim_list_node childNodes] { + $sim_list_node removeChild $child_node + } + foreach sim_run $sim_runs_list { + set sim_name [dict get $sim_run name] + set sim_path [dict get $sim_run path] + + set add_menu_command "{advanced-16 {View in Code} {spdAux::OpenRunInCode $sim_path}}" + append add_menu_command " { advanced-16 {Rename} {spdAux::RenameSimulationRun $sim_path} }" + set del_menu_command "removecontextualmenu='{-} {Edit} {List entities} {Expand} {View this}'" + + set str "" + set current_run_node [ $sim_list_node appendChild [[dom parse $str] documentElement]] + + + # add extra info as status, size, date... + # get the size of the folder + set folder_size 0 + set folder_files [glob -nocomplain -directory $sim_path -types {file} *] + foreach file $folder_files { + set folder_size [expr $folder_size + [file size $file]] + } + set str "" + # append it to the current run node + $current_run_node appendChild [[dom parse $str] documentElement] + + # get the modification date of the projectparameters file + set folder_mtime 0 + set sim_params_file [file join $sim_path "ProjectParameters.json"] + if {[file exists $sim_params_file]} { + set folder_mtime [file mtime $sim_params_file] + } + # timestamp as yyyy-mm-dd hh:mm:ss + set folder_mtime [clock format $folder_mtime -format "%Y-%m-%d %H:%M:%S"] + set str "" + # append it to the current run node + $current_run_node appendChild [[dom parse $str] documentElement] + + # find a file named ProjectParameters.json inside the simulation folder + # set sim_spd_file [file join $sim_path "ProjectParameters.json"] + # if {[file exists $sim_spd_file]} { + # # insert a value disabled saying true + # set str "" + # $sim_list_node appendChild [[dom parse $str] documentElement] + # } + } +} + +proc spdAux::OpenRunInCode { args } { + set path $args + Kratos::OpenCaseIn VSCode $path } spdAux::Init From 2a4b47af5fc4a562fb0d14de5c37f422c6251c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20G=C3=A1rate?= Date: Fri, 26 Dec 2025 20:46:41 +0100 Subject: [PATCH 03/16] create and delete --- kratos.gid/kratos.spd | 2 +- kratos.gid/kratos.tcl | 13 ++++++++-- .../scripts/Controllers/RunSimulations.tcl | 17 ++++++++++++- kratos.gid/scripts/spdAuxiliar.tcl | 25 +++++++++++++------ 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/kratos.gid/kratos.spd b/kratos.gid/kratos.spd index cdc2acb40..8ed2ce468 100644 --- a/kratos.gid/kratos.spd +++ b/kratos.gid/kratos.spd @@ -37,7 +37,7 @@ - + diff --git a/kratos.gid/kratos.tcl b/kratos.gid/kratos.tcl index 72b921d07..e273fb3be 100644 --- a/kratos.gid/kratos.tcl +++ b/kratos.gid/kratos.tcl @@ -453,7 +453,7 @@ proc Kratos::Event_AfterMeshGeneration {fail} { Kratos::Log "Mesh generation failed" return } - + # Change the mesh settings depending on the element requirements. Reset previous settings # catch {Kratos::ResetMeshCriteria $fail} @@ -557,6 +557,15 @@ proc Kratos::WriteCalculationFilesEvent { {filename ""} } { set filename [file join [GiD_Info Project Modelname].gid [Kratos::GetModelName]] } } + + set next_run [runsimulations::GetNextSimulationRunName] + # replace next_run whitespaces by underscores. Do not use regsub + set next_run [string map {" " "_"} $next_run] + + set filename [file join [file dirname $filename] $runsimulations::folder_name $next_run [file tail $filename]] + # create the folder if it does not exist + file mkdir [file dirname $filename] + # The calculation process may need the files of the file selector entries inside the model folder if {$Kratos::kratos_private(UseFiles) eq 1} {FileSelector::CopyFilesIntoModel [file dirname $filename]} @@ -572,7 +581,7 @@ proc Kratos::WriteCalculationFilesEvent { {filename ""} } { } else { ::GidUtils::SetWarnLine "MDPA and JSON written OK" } - if {[::write::GetConfigurationAttribute time_monitor]} { set endtime [clock seconds]; set ttime [expr {$endtime-$inittime}]; + if {[::write::GetConfigurationAttribute time_monitor]} { set endtime [clock seconds]; set ttime [expr {$endtime-$inittime}]; W "Nodal coordinates time: [Kratos::Duration $ttime]" Kratos::Log "Write calculation files in [Duration $ttime]" } diff --git a/kratos.gid/scripts/Controllers/RunSimulations.tcl b/kratos.gid/scripts/Controllers/RunSimulations.tcl index dc0e6c584..a5ea84243 100644 --- a/kratos.gid/scripts/Controllers/RunSimulations.tcl +++ b/kratos.gid/scripts/Controllers/RunSimulations.tcl @@ -47,7 +47,15 @@ proc runsimulations::GetPastSimulationsRunsList { } { } -proc runsimulations::GetNextSimulationRunName { previous_runs_names } { +proc runsimulations::GetNextSimulationRunName { } { + + set sim_runs_list [runsimulations::GetPastSimulationsRunsList] + set previous_runs_names [list ] + foreach sim_run $sim_runs_list { + dict get $sim_run name + lappend previous_runs_names [dict get $sim_run name] + } + set run_index [llength $previous_runs_names] incr run_index set run_name "Run $run_index" @@ -58,4 +66,11 @@ proc runsimulations::GetNextSimulationRunName { previous_runs_names } { return $run_name } +proc runsimulations::DeleteSimulationRun { sim_path } { + # delete the folder and all its contents + if {[file isdirectory $sim_path]} { + file delete -force $sim_path + } +} + runsimulations::Init \ No newline at end of file diff --git a/kratos.gid/scripts/spdAuxiliar.tcl b/kratos.gid/scripts/spdAuxiliar.tcl index 2868306ad..cec31896a 100644 --- a/kratos.gid/scripts/spdAuxiliar.tcl +++ b/kratos.gid/scripts/spdAuxiliar.tcl @@ -522,13 +522,8 @@ proc spdAux::ProcFillSimulations { domNode args } { # detect previous simulation runs set sim_runs_list [runsimulations::GetPastSimulationsRunsList] - set simulations_names [list ] - foreach sim_run $sim_runs_list { - dict get $sim_run name - lappend simulations_names [dict get $sim_run name] - } # set the next simulation name - set next_sim_name [runsimulations::GetNextSimulationRunName $simulations_names] + set next_sim_name [runsimulations::GetNextSimulationRunName] set next_name_node [$domNode selectNodes ".//value\[@n='current_simulation_run'\]"] $next_name_node setAttribute v $next_sim_name @@ -545,11 +540,14 @@ proc spdAux::ProcFillSimulations { domNode args } { set add_menu_command "{advanced-16 {View in Code} {spdAux::OpenRunInCode $sim_path}}" append add_menu_command " { advanced-16 {Rename} {spdAux::RenameSimulationRun $sim_path} }" set del_menu_command "removecontextualmenu='{-} {Edit} {List entities} {Expand} {View this}'" + + # add delete option + append add_menu_command " { advanced-16 {Delete} {spdAux::DeleteSimulationRun $sim_path} }" + + set str "" set current_run_node [ $sim_list_node appendChild [[dom parse $str] documentElement]] - - # add extra info as status, size, date... # get the size of the folder set folder_size 0 @@ -583,6 +581,17 @@ proc spdAux::ProcFillSimulations { domNode args } { } } +proc spdAux::GetNextSimulationRunName { } { + set base_node [customlib::GetBaseRoot] + set sim_node [write::getValueByNode [$base_node selectNodes ".//value\[@n='current_simulation_run'\]"]] + return $sim_node +} + +proc spdAux::DeleteSimulationRun { sim_path } { + runsimulations::DeleteSimulationRun $sim_path + spdAux::RequestRefresh +} + proc spdAux::OpenRunInCode { args } { set path $args Kratos::OpenCaseIn VSCode $path From fa75e1456edb3059963851760c719fa0a8df28c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20G=C3=A1rate?= Date: Fri, 26 Dec 2025 22:11:06 +0100 Subject: [PATCH 04/16] launch scripts pointing to current case --- kratos.gid/exec/compiled.unix.bat | 22 +++++---- kratos.gid/exec/compiled.win.bat | 23 +++++---- kratos.gid/exec/docker.unix.bat | 1 + kratos.gid/exec/docker.win.bat | 16 ++++--- kratos.gid/exec/pip.unix.bat | 15 +++--- kratos.gid/exec/pip.win.bat | 15 +++--- kratos.gid/exec/pip_gids_python.unix.bat | 16 ++++--- kratos.gid/exec/pip_gids_python.win.bat | 16 ++++--- kratos.gid/kratos.spd | 2 +- kratos.gid/kratos.tcl | 2 +- kratos.gid/kratos.unix.bat | 48 ------------------- kratos.gid/kratos.unix.mpi.bat | 36 -------------- kratos.gid/kratos.unix_release.bat | 48 ------------------- kratos.gid/kratos.win.bat | 21 -------- .../scripts/Controllers/RunSimulations.tcl | 40 +++++++++++++--- kratos.gid/scripts/Launch.tcl | 7 +++ kratos.gid/scripts/spdAuxiliar.tcl | 21 +++++++- 17 files changed, 134 insertions(+), 215 deletions(-) delete mode 100755 kratos.gid/kratos.unix.bat delete mode 100755 kratos.gid/kratos.unix.mpi.bat delete mode 100755 kratos.gid/kratos.unix_release.bat delete mode 100644 kratos.gid/kratos.win.bat diff --git a/kratos.gid/exec/compiled.unix.bat b/kratos.gid/exec/compiled.unix.bat index bdc4942a1..a201babf4 100755 --- a/kratos.gid/exec/compiled.unix.bat +++ b/kratos.gid/exec/compiled.unix.bat @@ -1,15 +1,18 @@ #!/bin/bash # OutputFile: "$2/$1.info" # ErrorFile: "$2/$1.err" + +cd "$case_path" + #delete previous result file -rm -f "$2/$1*.post.bin" -rm -f "$2/$1*.post.res" -rm -f "$2/$1*.post.msh" -rm -f "$2/$1.info" -rm -f "$2/$1.err" -rm -f "$2/$1.flavia.dat" -rm -fr "$2/gid_output" -rm -fr "$2/vtk_output" +rm -f "./$1*.post.bin" +rm -f "./$1*.post.res" +rm -f "./$1*.post.msh" +rm -f "./$1.info" +rm -f "./$1.err" +rm -f "./$1.flavia.dat" +rm -fr "./gid_output" +rm -fr "./vtk_output" # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then @@ -36,6 +39,5 @@ export PYTHONHOME=$python_home KERNEL_NAME="linux" - # Run Python using the script MainKratos.py -$python_path MainKratos.py > "$2/$1.info" 2> "$2/$1.err" \ No newline at end of file +$python_path MainKratos.py > "./$1.info" 2> "./$1.err" \ No newline at end of file diff --git a/kratos.gid/exec/compiled.win.bat b/kratos.gid/exec/compiled.win.bat index c903a19c7..934aa23a2 100755 --- a/kratos.gid/exec/compiled.win.bat +++ b/kratos.gid/exec/compiled.win.bat @@ -7,16 +7,18 @@ REM Problem directory = %3 REM OutputFile: "%2\%1.info" REM ErrorFile: "%2\%1.err" -DEL "%2\%1.info" -DEL "%2\%1.err" -DEL "%2\%1*.post.bin" -DEL "%2\%1*.post.res" -DEL "%2\%1*.post.msh" -DEL "%2\%1.info" -DEL "%2\%1.err" -DEL "%2\%1.flavia.dat" -DEL "%2\gid_output" -DEL "%2\vtk_output" +cd %case_path% + +DEL "%case_path%\%1.info" +DEL "%case_path%\%1.err" +DEL "%case_path%\%1*.post.bin" +DEL "%case_path%\%1*.post.res" +DEL "%case_path%\%1*.post.msh" +DEL "%case_path%\%1.info" +DEL "%case_path%\%1.err" +DEL "%case_path%\%1.flavia.dat" +DEL "%case_path%\gid_output" +DEL "%case_path%\vtk_output" @REM echo "Launching on Compiled for windows -> %kratos_bin_path%" > .run @@ -24,5 +26,6 @@ set PATH=%kratos_bin_path%\libs;%PATH% set PYTHONPATH=%kratos_bin_path% set PYTHONHOME=%python_home% + REM Run Python using the script MainKratos.py %python_path% MainKratos.py > "%2\\%1.info" 2> "%2\\%1.err" \ No newline at end of file diff --git a/kratos.gid/exec/docker.unix.bat b/kratos.gid/exec/docker.unix.bat index edd71de45..3e81d5cbf 100755 --- a/kratos.gid/exec/docker.unix.bat +++ b/kratos.gid/exec/docker.unix.bat @@ -2,6 +2,7 @@ # OutputFile: "$2/$1.info" # ErrorFile: "$2/$1.err" #delete previous result file +cd "$case_path" rm -f "$2/$1*.post.bin" rm -f "$2/$1*.post.res" rm -f "$2/$1*.post.msh" diff --git a/kratos.gid/exec/docker.win.bat b/kratos.gid/exec/docker.win.bat index 259341983..68b26a9e4 100755 --- a/kratos.gid/exec/docker.win.bat +++ b/kratos.gid/exec/docker.win.bat @@ -7,12 +7,14 @@ REM Problem directory = %3 REM OutputFile: "%2\%1.info" REM ErrorFile: "%2\%1.err" -REM Remove previous calculation files and results -DEL "%2\%1.info" -DEL "%2\%1.err" -DEL "%2\%1*.post.bin" -DEL "%2\%1*.post.res" -DEL "%2\%1*.post.msh" +@REM if case_path environment variable is defined use it, change directory to it +cd %case_path% +REM Remove previous calculation files and results +DEL "%case_path%\%1.info" +DEL "%case_path%\%1.err" +DEL "%case_path%\%1*.post.bin" +DEL "%case_path%\%1*.post.res" +DEL "%case_path%\%1*.post.msh" @REM Calculate! -docker run -v "%2:/model" --rm --name "%1" %kratos_docker_image% > "%2\\%1.info" 2> "%2\\%1.err" \ No newline at end of file +docker run -v "%case_path%:/model" --rm --name "%1" %kratos_docker_image% > "%case_path%\%1.info" 2> "%case_path%\%1.err" \ No newline at end of file diff --git a/kratos.gid/exec/pip.unix.bat b/kratos.gid/exec/pip.unix.bat index ac5213f78..eadc2ae96 100755 --- a/kratos.gid/exec/pip.unix.bat +++ b/kratos.gid/exec/pip.unix.bat @@ -1,16 +1,17 @@ #!/bin/bash # OutputFile: "$2/$1.info" # ErrorFile: "$2/$1.err" +cd "$case_path" #delete previous result file -rm -f "$2/$1*.post.bin" -rm -f "$2/$1*.post.res" -rm -f "$2/$1*.post.msh" -rm -f "$2/$1.info" -rm -f "$2/$1.err" -rm -f "$2/$1.flavia.dat" +rm -f "./$1*.post.bin" +rm -f "./$1*.post.res" +rm -f "./$1*.post.msh" +rm -f "./$1.info" +rm -f "./$1.err" +rm -f "./$1.flavia.dat" export PYTHONPATH=%python_home% export PYTHONHOME=%python_home% # Run Python using the script MainKratos.py -$python_home/python3 MainKratos.py > "$2/$1.info" 2> "$2/$1.err" \ No newline at end of file +$python_home/python3 MainKratos.py > "./$1.info" 2> "./$1.err" \ No newline at end of file diff --git a/kratos.gid/exec/pip.win.bat b/kratos.gid/exec/pip.win.bat index c24d5b06f..131ea0e9f 100755 --- a/kratos.gid/exec/pip.win.bat +++ b/kratos.gid/exec/pip.win.bat @@ -7,15 +7,18 @@ REM Problem directory = %3 REM OutputFile: "%2\%1.info" REM ErrorFile: "%2\%1.err" +@REM if case_path environment variable is defined use it, change directory to it +cd %case_path% + REM Remove previous calculation files and results -DEL "%2\%1.info" -DEL "%2\%1.err" -DEL "%2\%1*.post.bin" -DEL "%2\%1*.post.res" -DEL "%2\%1*.post.msh" +DEL "%case_path%\%1.info" +DEL "%case_path%\%1.err" +DEL "%case_path%\%1*.post.bin" +DEL "%case_path%\%1*.post.res" +DEL "%case_path%\%1*.post.msh" set PYTHONPATH=%python_home% set PYTHONHOME=%python_home% @REM Calculate! -%python_home%/python.exe MainKratos.py > "%2\\%1.info" 2> "%2\\%1.err" +%python_home%/python.exe MainKratos.py > "%case_path%\%1.info" 2> "%case_path%\%1.err" diff --git a/kratos.gid/exec/pip_gids_python.unix.bat b/kratos.gid/exec/pip_gids_python.unix.bat index b7a0bd6ca..64b9aff77 100644 --- a/kratos.gid/exec/pip_gids_python.unix.bat +++ b/kratos.gid/exec/pip_gids_python.unix.bat @@ -2,15 +2,17 @@ # OutputFile: "$2/$1.info" # ErrorFile: "$2/$1.err" #delete previous result file -rm -f "$2/$1*.post.bin" -rm -f "$2/$1*.post.res" -rm -f "$2/$1*.post.msh" -rm -f "$2/$1.info" -rm -f "$2/$1.err" -rm -f "$2/$1.flavia.dat" +cd "$case_path" +rm -f "./$1*.post.bin" +rm -f "./$1*.post.res" +rm -f "./$1*.post.msh" +rm -f "./$1.info" +rm -f "./$1.err" +rm -f "./$1.flavia.dat" export PYTHONPATH="" export PYTHONHOME="" + # Run Python using the script MainKratos.py -$python_path MainKratos.py > "$2/$1.info" 2> "$2/$1.err" \ No newline at end of file +$python_path MainKratos.py > "./$1.info" 2> "./$1.err" \ No newline at end of file diff --git a/kratos.gid/exec/pip_gids_python.win.bat b/kratos.gid/exec/pip_gids_python.win.bat index c675a3302..25aa0588a 100644 --- a/kratos.gid/exec/pip_gids_python.win.bat +++ b/kratos.gid/exec/pip_gids_python.win.bat @@ -6,15 +6,19 @@ REM Problem directory = %3 REM OutputFile: "%2\%1.info" REM ErrorFile: "%2\%1.err" +@REM if case_path environment variable is defined use it, change directory to it +cd %case_path% REM Remove previous calculation files and results -DEL "%2\%1.info" -DEL "%2\%1.err" -DEL "%2\%1*.post.bin" -DEL "%2\%1*.post.res" -DEL "%2\%1*.post.msh" +DEL "%case_path%\%1.info" +DEL "%case_path%\%1.err" +DEL "%case_path%\%1*.post.bin" +DEL "%case_path%\%1*.post.res" +DEL "%case_path%\%1*.post.msh" @REM Calculate! set PYTHONPATH="" set PYTHONHOME="" -%python_path% MainKratos.py > "%2\\%1.info" 2> "%2\\%1.err" + + +%python_path% MainKratos.py > "%case_path%\%1.info" 2> "%case_path%\%1.err" diff --git a/kratos.gid/kratos.spd b/kratos.gid/kratos.spd index 8ed2ce468..a7a859c42 100644 --- a/kratos.gid/kratos.spd +++ b/kratos.gid/kratos.spd @@ -38,7 +38,7 @@ - + diff --git a/kratos.gid/kratos.tcl b/kratos.gid/kratos.tcl index e273fb3be..2dac6f4df 100644 --- a/kratos.gid/kratos.tcl +++ b/kratos.gid/kratos.tcl @@ -562,7 +562,7 @@ proc Kratos::WriteCalculationFilesEvent { {filename ""} } { # replace next_run whitespaces by underscores. Do not use regsub set next_run [string map {" " "_"} $next_run] - set filename [file join [file dirname $filename] $runsimulations::folder_name $next_run [file tail $filename]] + set filename [file join [runsimulations::GetSimulationRunPath $next_run] [file tail $filename]] # create the folder if it does not exist file mkdir [file dirname $filename] diff --git a/kratos.gid/kratos.unix.bat b/kratos.gid/kratos.unix.bat deleted file mode 100755 index 3ea4ad5d3..000000000 --- a/kratos.gid/kratos.unix.bat +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# OutputFile: "$2/$1.info" -# ErrorFile: "$2/$1.err" -#delete previous result file -rm -f "$2/$1*.post.bin" -rm -f "$2/$1*.post.res" -rm -f "$2/$1*.post.msh" -rm -f "$2/$1.info" -rm -f "$2/$1.err" -rm -f "$2/$1.flavia.dat" - -# include .bashrc if it exists -if [ -f "$HOME/.bashrc" ]; then - . "$HOME/.bashrc" -fi - - - -# gid redefines LD_LIBRARY_PATH to its own libs directory -# and maintains OLD_LD_LIBRARY_PATH with previous settings -# therefore, we use the OLD_LD_LIBRARY_PATH and prepend the path to the kratos libs -if [ "$OLD_LD_LIBRARY_PATH" != "" ]; then - export LD_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs":$OLD_LD_LIBRARY_PATH -else - # do not add the ':' - export LD_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs" -fi - -# Prevents the PYTHONHOME error from happening and isolate possible python repacks present -# in the system and interfeering with runkratos -# export PYTHONHOME="$3/exec/Kratos" -export PYTHONPATH="$3/exec/Kratos/python34.zip":"$3/exec/Kratos":$PYTHONPATH - - -# if mac -KERNEL=`uname -s` -if [ $KERNEL = "Darwin" ]; then - KERNEL_NAME="macosx" - export DYLD_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs":$DYLD_LIBRARY_PATH - export DYLD_FALLBACK_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs":$DYLD_FALLBACK_LIBRARY_PATH - export PYTHONPATH="$3/exec/Kratos/Lib":"$3/exec/Kratos/Lib/lib-dynload/":$PYTHONPATH - export PYTHONHOME="$3/exec/Kratos" -else - KERNEL_NAME="linux" -fi - -# Run Python using the script MainKratos.py -python3 MainKratos.py > "$2/$1.info" 2> "$2/$1.err" diff --git a/kratos.gid/kratos.unix.mpi.bat b/kratos.gid/kratos.unix.mpi.bat deleted file mode 100755 index c15dab760..000000000 --- a/kratos.gid/kratos.unix.mpi.bat +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# OutputFile: "$2/$1.info" -# ErrorFile: "$2/$1.err" -#delete previous result file -rm -f "$2/$1*.post.bin" -rm -f "$2/$1*.post.res" -rm -f "$2/$1*.post.msh" -rm -f "$2/$1.info" -rm -f "$2/$1.err" -rm -f "$2/$1.flavia.dat" - -# include .bashrc if it exists -if [ -f "$HOME/.bashrc" ]; then - . "$HOME/.bashrc" -fi - -# gid redefines LD_LIBRARY_PATH to its own libs directory -# and maintains OLD_LD_LIBRARY_PATH with previous settings -# therefore, we use the OLD_LD_LIBRARY_PATH and prepend the path to the kratos libs -if [ "$OLD_LD_LIBRARY_PATH" != "" ]; then - export LD_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs":"$3/exec/Kratos/OpenMPI/lib":$OLD_LD_LIBRARY_PATH -else - # do not add the ':' - export LD_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs":"$3/exec/Kratos/OpenMPI/lib" -fi - -export PWD=`pwd` -export OPAL_PREFIX="$PWD/exec/Kratos/OpenMPI" - -# Prevents the PYTHONHOME error from happening and isolate possible python repacks present -# in the system and interfeering with runkratos -export PYTHONHOME="$3/exec/Kratos" -export PYTHONPATH="$3/exec/Kratos/python34.zip":"$3/exec/Kratos":$PYTHONPATH - -# Run Python using the script MainKratos.py -"$3/exec/Kratos/OpenMPI/bin/mpirun" --oversubscribe -np 2 "$3/exec/Kratos/runkratos" MainKratos.py > "$2/$1.info" 2> "$2/$1.err" diff --git a/kratos.gid/kratos.unix_release.bat b/kratos.gid/kratos.unix_release.bat deleted file mode 100755 index b81b0283d..000000000 --- a/kratos.gid/kratos.unix_release.bat +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# OutputFile: "$2/$1.info" -# ErrorFile: "$2/$1.err" -#delete previous result file -rm -f "$2/$1*.post.bin" -rm -f "$2/$1*.post.res" -rm -f "$2/$1*.post.msh" -rm -f "$2/$1.info" -rm -f "$2/$1.err" -rm -f "$2/$1.flavia.dat" - -# include .bashrc if it exists -if [ -f "$HOME/.bashrc" ]; then - . "$HOME/.bashrc" -fi - -# gid redefines LD_LIBRARY_PATH to its own libs directory -# and maintains OLD_LD_LIBRARY_PATH with previous settings -# therefore, we use the OLD_LD_LIBRARY_PATH and prepend the path to the kratos libs -if [ "$OLD_LD_LIBRARY_PATH" != "" ]; then - export LD_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs":$OLD_LD_LIBRARY_PATH -else - # do not add the ':' - export LD_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs" -fi - -# Mpi -export PWD=`pwd` -export OPAL_PREFIX="$PWD/exec/Kratos/OpenMPI" - -# Prevents the PYTHONHOME error from happening and isolate possible python repacks present -# in the system and interfeering with runkratos -export PYTHONHOME="$3/exec/Kratos" -export PYTHONPATH="$3/exec/Kratos/python34.zip":"$3/exec/Kratos":$PYTHONPATH - -# if mac -KERNEL=`uname -s` -if [ $KERNEL = "Darwin" ]; then - KERNEL_NAME="macosx" - export DYLD_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs":$DYLD_LIBRARY_PATH - export DYLD_FALLBACK_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs":$DYLD_FALLBACK_LIBRARY_PATH - export PYTHONPATH="$3/exec/Kratos/Lib":"$3/exec/Kratos/Lib/lib-dynload/":$PYTHONPATH -else - KERNEL_NAME="linux" -fi - -# Run Python using the script MainKratos.py -"$3/exec/Kratos/runkratos" MainKratos.py > "$2/$1.info" 2> "$2/$1.err" diff --git a/kratos.gid/kratos.win.bat b/kratos.gid/kratos.win.bat deleted file mode 100644 index d21c8e32d..000000000 --- a/kratos.gid/kratos.win.bat +++ /dev/null @@ -1,21 +0,0 @@ -REM @ECHO OFF -REM Identification for arguments -REM basename = %1 -REM Project directory = %2 -REM Problem directory = %3 - -REM OutputFile: "%2\%1.info" -REM ErrorFile: "%2\%1.err" - -DEL "%2\%1.info" -DEL "%2\%1.err" - -set PATH=%3\\exec\\kratos;%3\\exec\\kratos\\libs;%PATH% -REM set PYTHONPATH=%3\\exec\\kratos -REM Set the number of threads for OpenMP -REM export OMP_NUM_THREADS=%5 -REM set OMP_NUM_THREADS=%5 - -REM Run Python using the script MainKratos.py -"%3\\exec\\kratos\\runkratos" MainKratos.py > "%2\\%1.info" 2> "%2\\%1.err" -REM python MainKratos.py > "%2\\%1.info" 2> "%2\\%1.err" diff --git a/kratos.gid/scripts/Controllers/RunSimulations.tcl b/kratos.gid/scripts/Controllers/RunSimulations.tcl index a5ea84243..8a8b9df01 100644 --- a/kratos.gid/scripts/Controllers/RunSimulations.tcl +++ b/kratos.gid/scripts/Controllers/RunSimulations.tcl @@ -8,18 +8,15 @@ namespace eval ::runsimulations { variable folder_name variable spd_un - variable dir } proc runsimulations::Init { } { variable folder_name variable spd_un - variable dir set folder_name "Simulations" set spd_un "simulation_runs" - set dir [GidUtils::GetDirectoryModel] } proc runsimulations::GetPastSimulationsRunsList { } { @@ -27,7 +24,7 @@ proc runsimulations::GetPastSimulationsRunsList { } { set return_list [list ] # Find in the folder - variable dir + set dir [GidUtils::GetDirectoryModel] variable folder_name set simulations_dir [file join $dir $folder_name] if {[file isdirectory $simulations_dir]} { @@ -58,13 +55,36 @@ proc runsimulations::GetNextSimulationRunName { } { set run_index [llength $previous_runs_names] incr run_index - set run_name "Run $run_index" + set run_name "Run_$run_index" while {[lsearch -exact $previous_runs_names $run_name] != -1} { incr run_index - set run_name "Run $run_index" + set run_name "Run_$run_index" } return $run_name } +proc runsimulations::GetCurrentSimulationRunName { } { + set dir [GidUtils::GetDirectoryModel] + variable folder_name + set simulations_dir [file join $dir $folder_name] + if {[file isdirectory $simulations_dir]} { + # find all the folders inside + set dir_list [glob -nocomplain -directory $simulations_dir *] + set latest_time 0 + set latest_run "" + foreach sim_dir $dir_list { + if {[file isdirectory $sim_dir]} { + set mod_time [file mtime $sim_dir] + if {$mod_time > $latest_time} { + set latest_time $mod_time + set latest_run [file tail $sim_dir] + } + } + } + return $latest_run + } else { + return "" + } +} proc runsimulations::DeleteSimulationRun { sim_path } { # delete the folder and all its contents @@ -73,4 +93,12 @@ proc runsimulations::DeleteSimulationRun { sim_path } { } } +proc runsimulations::GetSimulationRunPath { run_name } { + set dir [GidUtils::GetDirectoryModel] + variable folder_name + set simulations_dir [file join $dir $folder_name] + set run_path [file join $simulations_dir $run_name] + return $run_path +} + runsimulations::Init \ No newline at end of file diff --git a/kratos.gid/scripts/Launch.tcl b/kratos.gid/scripts/Launch.tcl index dba0e5ff1..2cd2837e6 100644 --- a/kratos.gid/scripts/Launch.tcl +++ b/kratos.gid/scripts/Launch.tcl @@ -284,6 +284,13 @@ proc Kratos::ExecuteLaunchByMode {launch_mode} { set bat [dict get $mode script] set bat_file [file join exec $bat.$os.bat] } + set next_run [runsimulations::GetCurrentSimulationRunName] + # replace next_run whitespaces by underscores. Do not use regsub + set next_run [string map {" " "_"} $next_run] + # W "Starting simulation run: $next_run" + + set simulation_case [runsimulations::GetSimulationRunPath $next_run] + set ::env(case_path) $simulation_case switch [dict get $mode name] { Docker { set docker_image [Kratos::ManagePreferences GetValue docker_image] diff --git a/kratos.gid/scripts/spdAuxiliar.tcl b/kratos.gid/scripts/spdAuxiliar.tcl index cec31896a..a87312404 100644 --- a/kratos.gid/scripts/spdAuxiliar.tcl +++ b/kratos.gid/scripts/spdAuxiliar.tcl @@ -543,6 +543,8 @@ proc spdAux::ProcFillSimulations { domNode args } { # add delete option append add_menu_command " { advanced-16 {Delete} {spdAux::DeleteSimulationRun $sim_path} }" + # add rerun case + append add_menu_command " { advanced-16 {Rerun} {runsimulations::RerunSimulation $sim_path} }" @@ -555,7 +557,24 @@ proc spdAux::ProcFillSimulations { domNode args } { foreach file $folder_files { set folder_size [expr $folder_size + [file size $file]] } - set str "" + # express size in units that make sense + set unit "B" + if {$folder_size > 1024} { + set folder_size [expr $folder_size / 1024.0] + set unit "KB" + if {$folder_size > 1024} { + set folder_size [expr $folder_size / 1024.0] + set unit "MB" + if {$folder_size > 1024} { + set folder_size [expr $folder_size / 1024.0] + set unit "GB" + } + } + } + # only two decimals + set folder_size [format "%.2f" $folder_size] + # TODO: Not working well in MB + set str "" # append it to the current run node $current_run_node appendChild [[dom parse $str] documentElement] From 591bc80964a93d88ba61c125ce2f6c85dcdd37f9 Mon Sep 17 00:00:00 2001 From: Javi Garate Date: Mon, 29 Dec 2025 13:21:10 +0100 Subject: [PATCH 05/16] find proper exe for code --- kratos.gid/scripts/Utils.tcl | 47 +++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/kratos.gid/scripts/Utils.tcl b/kratos.gid/scripts/Utils.tcl index b3b3339c5..5aa251b70 100644 --- a/kratos.gid/scripts/Utils.tcl +++ b/kratos.gid/scripts/Utils.tcl @@ -376,7 +376,7 @@ proc Kratos::OpenCaseIn {program {ext_path ""}} { # exec $command # exec [list code -n $model_dir] # exec code -n "$model_dir" - exec code -n $model_dir + Kratos::openInVSCode $model_dir # exec "{*}[auto_execok code] -n $model_dir" # exec {*}[auto_execok code] -n $model_dir #W [gid_cross_platform::execute_program_in_path [list "code" "-n" $model_dir]] @@ -392,6 +392,51 @@ proc Kratos::OpenCaseIn {program {ext_path ""}} { } } +proc Kratos::openInVSCode {path} { + + if {![file exists $path]} { + error "Path does not exist: $path" + } + + set platform $::tcl_platform(platform) + + + switch -glob -- $platform { + + "windows" { + exec [Kratos::get_full_path_code] -n $path + } + + "Darwin" { + # macOS + exec open -a "Visual Studio Code" $path & + } + + default { + # Linux / Unix + exec code -n $path & + } + } +} +proc Kratos::get_full_path_code {} { + + set cmd [auto_execok code] + if {$cmd eq ""} { + error "VS Code not found in PATH" + } + + set full_path_code [lindex $cmd 0] + + if {$::tcl_platform(platform) eq "windows"} { + # auto_execok returns .../bin/code.cmd + # real executable is ../Code.exe + set base [file dirname [file dirname $full_path_code]] + set full_path_code [file join $base Code.exe] + } + + return $full_path_code +} + if { ![GidUtils::IsTkDisabled] } { proc xmlprograms::OpenBrowserForDirectoryDebug { baseframe variable} { set $variable [MessageBoxGetFilename directory write [_ "Select kratos debug compiled folder (kratos / bin / debug)"]] From def40258997b4d23bd2f591e16c608481f2d796d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20G=C3=A1rate?= Date: Mon, 5 Jan 2026 16:19:20 +0100 Subject: [PATCH 06/16] Go to postprocess --- kratos.gid/images/running.png | Bin 0 -> 680 bytes kratos.gid/kratos.spd | 2 +- kratos.gid/kratos.tcl | 18 ++++++++- .../scripts/Controllers/RunSimulations.tcl | 38 ++++++++++++++++++ kratos.gid/scripts/spdAuxiliar.tcl | 7 +++- 5 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 kratos.gid/images/running.png diff --git a/kratos.gid/images/running.png b/kratos.gid/images/running.png new file mode 100644 index 0000000000000000000000000000000000000000..7b4f3494c9d1894961aae4c94a5e83975b728926 GIT binary patch literal 680 zcmV;Z0$2TsP)P)t-sM{rD2 zqHRi$VO+0wR-#dp~?rOq*r^000aY z5F9lm0000dO*8-i03<~(WU_u!l4wneVoHl(3lt6p3I`7x69^9r1qlZc9u*B25E394 z4Hpm$77#LFLJ=Mn1qlW+VM0rcVNsE15FQm{vVK;VYY-n5S*&$ft8-19XIidyPM&C1 zsd81Paa5*nQ>1Q7n`Td-YEYqTQlo6{_VHJ!a#f~qQloAA{rps=Z&|5ykH?~z%c)PF zYO~M0a<_?EpK<^H|4No*Po8O5l53c|q)eG*R;6%Ipli?O*HWTw^7iwm(6vpSXV>Q3 z^!fI4wTZILyNAG?C10BdAN@A`Ss!N=J5CPwa~t| z*}_MUUrUi - + diff --git a/kratos.gid/kratos.tcl b/kratos.gid/kratos.tcl index 2dac6f4df..5c174bc46 100644 --- a/kratos.gid/kratos.tcl +++ b/kratos.gid/kratos.tcl @@ -12,10 +12,12 @@ namespace eval ::Kratos { variable namespaces variable mesh_criteria_forced + + variable pending_postprocess_simulation } proc GiD_Event_InitProblemtype { dir } { - Kratos::Event_InitProblemtype $dir + Kratos::Event_InitProblemtype $dir } proc Kratos::Events { } { @@ -179,6 +181,9 @@ proc Kratos::InitGlobalVariables {dir} { variable mesh_criteria_forced set mesh_criteria_forced [dict create] + + variable pending_postprocess_simulation + set pending_postprocess_simulation "" } proc Kratos::LoadCommonScripts { } { @@ -492,6 +497,17 @@ proc Kratos::BeforeInitGIDPostProcess {} { } } } + + # Check if there is a pending postprocess request + variable pending_postprocess_simulation + if {$pending_postprocess_simulation ne ""} { + # Open the postprocess of the requested simulation + + # TODO: Ask kike if there is a better way to change to post and return the path of a post.lst file + # Instead of writing the post.lst manually + + set pending_postprocess_simulation "" + } } proc Kratos::Event_EndGIDPostProcess {} { diff --git a/kratos.gid/scripts/Controllers/RunSimulations.tcl b/kratos.gid/scripts/Controllers/RunSimulations.tcl index 8a8b9df01..ff4acc53f 100644 --- a/kratos.gid/scripts/Controllers/RunSimulations.tcl +++ b/kratos.gid/scripts/Controllers/RunSimulations.tcl @@ -101,4 +101,42 @@ proc runsimulations::GetSimulationRunPath { run_name } { return $run_path } +proc runsimulations::GoToPostprocess { sim_path } { + set Kratos::pending_postprocess_simulation $sim_path + # W "Changing to Postprocess... $sim_path" + runsimulations::WritePostprocessRequest $sim_path + GiD_Process Postprocess MEscape +} + +# TODO: Ask kike if there is a better way to change to post and return the path of a post.lst file +# Instead of writing the post.lst manually +proc runsimulations::WritePostprocessRequest { sim_path } { + # In the model folder, create a file named "{model_name}.post.lst" + # The content of the file is a copy of the file simp_path/{simulation_name}.post.lst but adding the full path to the simulation folder + set dir [GidUtils::GetDirectoryModel] + set model_name [file tail $dir] + # remove the extension if any + set model_name [file rootname $model_name] + + set postprocess_request_file [file join $dir "${model_name}.post.lst"] + set sim_name [file tail $sim_path] + set sim_postprocess_file [file join $sim_path "${sim_name}.post.lst"] + if {[file exists $sim_postprocess_file]} { + set infile [open $sim_postprocess_file r] + set outfile [open $postprocess_request_file w] + while {[gets $infile line] >= 0} { + # write the line to the output file, if it is not "Multiple" "Single" or "Merge", add the path + if {[string match "Multiple*" $line] || [string match "Single*" $line] || [string match "Merge*" $line]} { + puts $outfile $line + } else { + puts $outfile "[file join $sim_path $line]" + } + } + close $infile + close $outfile + } else { + W "Simulation postprocess file not found: $sim_postprocess_file" + } +} + runsimulations::Init \ No newline at end of file diff --git a/kratos.gid/scripts/spdAuxiliar.tcl b/kratos.gid/scripts/spdAuxiliar.tcl index a87312404..5edd96c3b 100644 --- a/kratos.gid/scripts/spdAuxiliar.tcl +++ b/kratos.gid/scripts/spdAuxiliar.tcl @@ -538,13 +538,15 @@ proc spdAux::ProcFillSimulations { domNode args } { set sim_path [dict get $sim_run path] set add_menu_command "{advanced-16 {View in Code} {spdAux::OpenRunInCode $sim_path}}" - append add_menu_command " { advanced-16 {Rename} {spdAux::RenameSimulationRun $sim_path} }" + # append add_menu_command " { advanced-16 {Rename} {spdAux::RenameSimulationRun $sim_path} }" set del_menu_command "removecontextualmenu='{-} {Edit} {List entities} {Expand} {View this}'" # add delete option append add_menu_command " { advanced-16 {Delete} {spdAux::DeleteSimulationRun $sim_path} }" # add rerun case append add_menu_command " { advanced-16 {Rerun} {runsimulations::RerunSimulation $sim_path} }" + # add view results option + append add_menu_command " { advanced-16 {View Results} {runsimulations::GoToPostprocess $sim_path} }" @@ -574,7 +576,8 @@ proc spdAux::ProcFillSimulations { domNode args } { # only two decimals set folder_size [format "%.2f" $folder_size] # TODO: Not working well in MB - set str "" + set str "" + # set str "" # append it to the current run node $current_run_node appendChild [[dom parse $str] documentElement] From a30217f8e8f3d0db946d27910ee43771d48b5714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20G=C3=A1rate?= Date: Mon, 5 Jan 2026 16:29:13 +0100 Subject: [PATCH 07/16] View error log --- kratos.gid/images/error16.png | Bin 0 -> 1188 bytes kratos.gid/scripts/spdAuxiliar.tcl | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 kratos.gid/images/error16.png diff --git a/kratos.gid/images/error16.png b/kratos.gid/images/error16.png new file mode 100644 index 0000000000000000000000000000000000000000..9f09ecf2e7393ff2c5e7844fb46451ddc12e8027 GIT binary patch literal 1188 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBufiR<}hF1enLwjaOL`j6Nk5zJhu3lnFep0GlMQ#C5H3Nf< zeMLcHa&~HoLQ-maW}dD3``!E16*5z7)x%AF4SWlnQ!_F>s)|yBtNcQetFn_VQ`GJ4 zc)4sUtbiuurj{fsROII56ON0GHI_ zN%^HEwo0X?nJHFjiD{-uDJiD9Nr}cOx`u`+iMoj?#)i5n#>Oe;riK zGN53Bhi+;fFi6XRVW%@?1~&r((=tyN#}EturIX@2LQ*A;)!+Yl?u@0ewY9aeUPM^* zIz?A$me^9kEekthOE+`fs|;-M+@W|&-s6O;QOCavYbUf!2)p1KUZtoQ+mRp<TNMex~OB&wr&07pIkfjoD}OzW;e;<->ZfJN67ae*HRk_9}1h+m~(E9xJ5W zdl`3f`mS`j-%qX_{k``;L(II{+S}zcWWA)P+V-B@*tTM+0t=7GUFn&6zh3<)ir;Tr z{ATvM{S4EeKRdPcO5M(VmfMm&8g-9Pn38YF)g00`OXKo8-g93czj!LBBE`5w{!RX& zzS(c}B25}k9n@KyFfA<5);TWg;=X%JB`fUWLgjnDDK&84-exPoWqd#W?1iukx2h)` zTm3umFVod`fwzBhP0rU%xGZ)0Zs>)h@8-wd`gP_m%eEQ5+~$@6V!NkZ{QpgRmH%0T zkH;L3#m`>;?~&NGeZQqH@9Wf(d2Dv%;E%Tqh7J0EwtQ*46W!7iVOPnuciQI*50x2W z{{Jx!+h@_X!e789Li0d(Z@ExL?jA|0HJfhuB&It3dBSrpa*pANv;GgXO3&O9Sj|(G zv0>MTa>i4Cr}3KPEigQ0{PW!IHMh5RXTR4kNd4#gYP0@^e=pj1SR8!Tm9*mJ^Jm|! zMR$eGnR-swta*NrousX)?DqIwOONT0 z3~*`}I(0llXpR4ez^UC?1>YQ=Pyarrm~Dfy1J{(g6IRc)H?2Aqvb@$KyG7*r>6Exj zh5O1AZ&(-Z`24x4IFGfUK`K 0} { + set icon "error16" + # Add view error option + append add_menu_command " { advanced-16 {View Error Log} {Kratos::OpenCaseIn VSCode [file join $sim_path "[file tail $model_name].err"]} }" + } + } - - set str "" + set str "" set current_run_node [ $sim_list_node appendChild [[dom parse $str] documentElement]] # add extra info as status, size, date... # get the size of the folder From b050f607813fa405ad1d489efff05326f9c8b790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20G=C3=A1rate?= Date: Mon, 5 Jan 2026 16:46:52 +0100 Subject: [PATCH 08/16] after run calculation, refresh tree --- kratos.gid/kratos.tcl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kratos.gid/kratos.tcl b/kratos.gid/kratos.tcl index 5c174bc46..377f6f467 100644 --- a/kratos.gid/kratos.tcl +++ b/kratos.gid/kratos.tcl @@ -54,6 +54,7 @@ proc Kratos::RegisterGiDEvents { } { GiD_RegisterEvent GiD_Event_AfterWriteCalculationFile Kratos::Event_AfterWriteCalculationFile PROBLEMTYPE Kratos GiD_RegisterEvent GiD_Event_BeforeRunCalculation Kratos::Event_BeforeRunCalculation PROBLEMTYPE Kratos GiD_RegisterEvent GiD_Event_SelectGIDBatFile Kratos::Event_SelectGIDBatFile PROBLEMTYPE Kratos + GiD_RegisterEvent GiD_Event_AfterRunCalculation Kratos::Event_AfterRunCalculation PROBLEMTYPE Kratos # Postprocess GiD_RegisterEvent GiD_Event_BeforeInitGIDPostProcess Kratos::BeforeInitGIDPostProcess PROBLEMTYPE Kratos @@ -523,6 +524,11 @@ proc Kratos::Event_EndGIDPostProcess {} { ::Kratos::CreatePreprocessModelTBar } +proc Kratos::Event_AfterRunCalculation { basename dir problemtypedir where error errorfilename } { + # Refresh tree + spdAux::RequestRefresh +} + proc Kratos::Event_BeforeRunCalculation { batfilename basename dir problemtypedir gidexe args } { # Let's launch the Kratos rocket! set run 1 From 286b19145bac1bf7386b936715140107ad79af92 Mon Sep 17 00:00:00 2001 From: Javi Garate Date: Wed, 7 Jan 2026 18:22:48 +0100 Subject: [PATCH 09/16] link to files --- kratos.gid/kratos.tcl | 4 +++ .../scripts/Controllers/RunSimulations.tcl | 4 ++- kratos.gid/scripts/Utils.tcl | 34 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/kratos.gid/kratos.tcl b/kratos.gid/kratos.tcl index 377f6f467..934d15254 100644 --- a/kratos.gid/kratos.tcl +++ b/kratos.gid/kratos.tcl @@ -546,6 +546,10 @@ proc Kratos::Event_BeforeRunCalculation { batfilename basename dir problemtypedi if {[write::isBooleanTrue $app_run_brake]} {return "-cancel-"} if {[Kratos::CheckDependencies] ne 0} {return [list "-cancel-" "Unable to run. Missing dependencies"]} + # after 3 seconds + after 3000 { + Kratos::CreateLinksRunData + } } proc Kratos::Event_SelectGIDBatFile { dir basename } { diff --git a/kratos.gid/scripts/Controllers/RunSimulations.tcl b/kratos.gid/scripts/Controllers/RunSimulations.tcl index ff4acc53f..1b12f8bfd 100644 --- a/kratos.gid/scripts/Controllers/RunSimulations.tcl +++ b/kratos.gid/scripts/Controllers/RunSimulations.tcl @@ -105,7 +105,7 @@ proc runsimulations::GoToPostprocess { sim_path } { set Kratos::pending_postprocess_simulation $sim_path # W "Changing to Postprocess... $sim_path" runsimulations::WritePostprocessRequest $sim_path - GiD_Process Postprocess MEscape + GiD_Process MEscape Postprocess MEscape } # TODO: Ask kike if there is a better way to change to post and return the path of a post.lst file @@ -137,6 +137,8 @@ proc runsimulations::WritePostprocessRequest { sim_path } { } else { W "Simulation postprocess file not found: $sim_postprocess_file" } + } + runsimulations::Init \ No newline at end of file diff --git a/kratos.gid/scripts/Utils.tcl b/kratos.gid/scripts/Utils.tcl index 5aa251b70..e275e7c3d 100644 --- a/kratos.gid/scripts/Utils.tcl +++ b/kratos.gid/scripts/Utils.tcl @@ -471,3 +471,37 @@ if { ![GidUtils::IsTkDisabled] } { } } + +proc Kratos::CreateLinksRunData { } { + + set next_run [runsimulations::GetCurrentSimulationRunName] + # replace next_run whitespaces by underscores. Do not use regsub + set next_run [string map {" " "_"} $next_run] + # W "Starting simulation run: $next_run" + + set simulation_case [runsimulations::GetSimulationRunPath $next_run] + + # Create link for model_name.info and model_name.err + set dir [GidUtils::GetDirectoryModel] + set model_name [Kratos::GetModelName] + set info_file [file join $dir "$model_name.info"] + set err_file [file join $dir "$model_name.err"] + + foreach file_to_link [list $info_file $err_file] { + if {[file exists $file_to_link]} { + file delete -force $file_to_link + } + set link_content [file join $simulation_case [file tail $file_to_link]] + # W "Creating link: $link_content -> $file_to_link" + if {[file exists $link_content]} { + # create the link + file link $file_to_link $link_content + } else { + # W "File to link does not exist: $link_content" + after 5000 { + Kratos::CreateLinksRunData + } + } + + } +} From 97792bcea4d3261a4496d9d3df14fcaf698ef2fd Mon Sep 17 00:00:00 2001 From: Javi Garate Date: Wed, 7 Jan 2026 19:01:56 +0100 Subject: [PATCH 10/16] open last simulation. avoid absolute paths --- kratos.gid/kratos.tcl | 5 +++++ kratos.gid/scripts/Controllers/RunSimulations.tcl | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kratos.gid/kratos.tcl b/kratos.gid/kratos.tcl index 934d15254..52ba4b50e 100644 --- a/kratos.gid/kratos.tcl +++ b/kratos.gid/kratos.tcl @@ -527,6 +527,11 @@ proc Kratos::Event_EndGIDPostProcess {} { proc Kratos::Event_AfterRunCalculation { basename dir problemtypedir where error errorfilename } { # Refresh tree spdAux::RequestRefresh + + set currrent_simulation [runsimulations::GetCurrentSimulationRunName] + set sim_path [file join [GidUtils::GetDirectoryModel] $::runsimulations::folder_name $currrent_simulation] + # W "Writing postprocess request for simulation: $sim_path" + runsimulations::WritePostprocessRequest $sim_path } proc Kratos::Event_BeforeRunCalculation { batfilename basename dir problemtypedir gidexe args } { diff --git a/kratos.gid/scripts/Controllers/RunSimulations.tcl b/kratos.gid/scripts/Controllers/RunSimulations.tcl index 1b12f8bfd..00be8e46f 100644 --- a/kratos.gid/scripts/Controllers/RunSimulations.tcl +++ b/kratos.gid/scripts/Controllers/RunSimulations.tcl @@ -118,9 +118,15 @@ proc runsimulations::WritePostprocessRequest { sim_path } { # remove the extension if any set model_name [file rootname $model_name] + # remove from sim_path the dir (initial part) + if {[string first $dir $sim_path] == 0} { + set sim_path [string range $sim_path [expr [string length $dir] +1] end] + } + set postprocess_request_file [file join $dir "${model_name}.post.lst"] set sim_name [file tail $sim_path] - set sim_postprocess_file [file join $sim_path "${sim_name}.post.lst"] + set sim_postprocess_file [file join $dir $sim_path "${sim_name}.post.lst"] + # W "Writing postprocess request from $sim_postprocess_file to $postprocess_request_file" if {[file exists $sim_postprocess_file]} { set infile [open $sim_postprocess_file r] set outfile [open $postprocess_request_file w] From 6c0a923d01d41aea1f6dee310304c0b4c5fadd3d Mon Sep 17 00:00:00 2001 From: Javi Garate Date: Wed, 7 Jan 2026 19:11:19 +0100 Subject: [PATCH 11/16] delete all --- kratos.gid/kratos.spd | 2 +- .../scripts/Controllers/RunSimulations.tcl | 8 ++++++++ kratos.gid/scripts/spdAuxiliar.tcl | 18 +++++++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/kratos.gid/kratos.spd b/kratos.gid/kratos.spd index b85cfdbe3..58ea66950 100644 --- a/kratos.gid/kratos.spd +++ b/kratos.gid/kratos.spd @@ -36,7 +36,7 @@ - + diff --git a/kratos.gid/scripts/Controllers/RunSimulations.tcl b/kratos.gid/scripts/Controllers/RunSimulations.tcl index 00be8e46f..21132348c 100644 --- a/kratos.gid/scripts/Controllers/RunSimulations.tcl +++ b/kratos.gid/scripts/Controllers/RunSimulations.tcl @@ -86,6 +86,14 @@ proc runsimulations::GetCurrentSimulationRunName { } { } } +proc runsimulations::DeleteAllSimulationRuns { } { + set sim_runs_list [runsimulations::GetPastSimulationsRunsList] + foreach sim_run $sim_runs_list { + set sim_path [dict get $sim_run path] + runsimulations::DeleteSimulationRun $sim_path + } +} + proc runsimulations::DeleteSimulationRun { sim_path } { # delete the folder and all its contents if {[file isdirectory $sim_path]} { diff --git a/kratos.gid/scripts/spdAuxiliar.tcl b/kratos.gid/scripts/spdAuxiliar.tcl index bb4e89cc3..9a2a74bdd 100644 --- a/kratos.gid/scripts/spdAuxiliar.tcl +++ b/kratos.gid/scripts/spdAuxiliar.tcl @@ -525,12 +525,19 @@ proc spdAux::ProcFillSimulations { domNode args } { set sim_runs_list [runsimulations::GetPastSimulationsRunsList] # set the next simulation name - set next_sim_name [runsimulations::GetNextSimulationRunName] - set next_name_node [$domNode selectNodes ".//value\[@n='current_simulation_run'\]"] - $next_name_node setAttribute v $next_sim_name + # set next_sim_name [runsimulations::GetNextSimulationRunName] + # set next_name_node [$domNode selectNodes ".//value\[@n='current_simulation_run'\]"] + # $next_name_node setAttribute v $next_sim_name # fill the simulations list set sim_list_node [$domNode selectNodes ".//container\[@n='simulation_run_list'\]"] + + # add contextual entry to delete all + set glob_add_menu_command "{advanced-16 {Delete All} {spdAux::DeleteAllSimulationRuns}}" + set glob_del_menu_command "{-} {Edit} {List entities} {Expand} {View this}" + $sim_list_node setAttribute addcontextualmenu $glob_add_menu_command + $sim_list_node setAttribute removecontextualmenu $glob_del_menu_command + # clear previous entries foreach child_node [$sim_list_node childNodes] { $sim_list_node removeChild $child_node @@ -625,6 +632,11 @@ proc spdAux::DeleteSimulationRun { sim_path } { spdAux::RequestRefresh } +proc spdAux::DeleteAllSimulationRuns { } { + runsimulations::DeleteAllSimulationRuns + spdAux::RequestRefresh +} + proc spdAux::OpenRunInCode { args } { set path $args Kratos::OpenCaseIn VSCode $path From 540c7df4ec765f781e145e493f8303b428856f7b Mon Sep 17 00:00:00 2001 From: Javi Garate Date: Wed, 7 Jan 2026 19:33:02 +0100 Subject: [PATCH 12/16] rename output to store simulation name --- kratos.gid/kratos.spd | 3 --- kratos.gid/scripts/Writing/WriteProjectParameters.tcl | 3 ++- kratos.gid/scripts/spdAuxiliar.tcl | 7 +------ 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/kratos.gid/kratos.spd b/kratos.gid/kratos.spd index 58ea66950..e4c2ad1c1 100644 --- a/kratos.gid/kratos.spd +++ b/kratos.gid/kratos.spd @@ -37,9 +37,6 @@ - - - diff --git a/kratos.gid/scripts/Writing/WriteProjectParameters.tcl b/kratos.gid/scripts/Writing/WriteProjectParameters.tcl index 2ed2690e5..0bd8c8ebd 100644 --- a/kratos.gid/scripts/Writing/WriteProjectParameters.tcl +++ b/kratos.gid/scripts/Writing/WriteProjectParameters.tcl @@ -486,7 +486,8 @@ proc write::GetDefaultGiDOutput { {appid ""} } { dict set outputProcessParams postprocess_parameters [write::GetDefaultOutputGiDDict $appid] set folder_name [dict get $outputProcessParams postprocess_parameters folder_name] dict unset outputProcessParams postprocess_parameters folder_name - dict set outputProcessParams output_name [file join $folder_name $model_name] + set current_simulation_name [runsimulations::GetCurrentSimulationRunName] + dict set outputProcessParams output_name [file join $folder_name ${model_name}_${current_simulation_name}] set outputConfigDict [dict create] dict set outputConfigDict python_module gid_output_process diff --git a/kratos.gid/scripts/spdAuxiliar.tcl b/kratos.gid/scripts/spdAuxiliar.tcl index 9a2a74bdd..4fd51779b 100644 --- a/kratos.gid/scripts/spdAuxiliar.tcl +++ b/kratos.gid/scripts/spdAuxiliar.tcl @@ -524,13 +524,8 @@ proc spdAux::ProcFillSimulations { domNode args } { # detect previous simulation runs set sim_runs_list [runsimulations::GetPastSimulationsRunsList] - # set the next simulation name - # set next_sim_name [runsimulations::GetNextSimulationRunName] - # set next_name_node [$domNode selectNodes ".//value\[@n='current_simulation_run'\]"] - # $next_name_node setAttribute v $next_sim_name - # fill the simulations list - set sim_list_node [$domNode selectNodes ".//container\[@n='simulation_run_list'\]"] + set sim_list_node $domNode # add contextual entry to delete all set glob_add_menu_command "{advanced-16 {Delete All} {spdAux::DeleteAllSimulationRuns}}" From 687368113e7d6a98d4f6f3c1952c77102d54a032 Mon Sep 17 00:00:00 2001 From: Javi Garate Date: Thu, 8 Jan 2026 12:03:06 +0100 Subject: [PATCH 13/16] find postprocess files by extension --- kratos.gid/scripts/Controllers/RunSimulations.tcl | 10 +++++++++- kratos.gid/scripts/spdAuxiliar.tcl | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kratos.gid/scripts/Controllers/RunSimulations.tcl b/kratos.gid/scripts/Controllers/RunSimulations.tcl index 21132348c..081d2fe81 100644 --- a/kratos.gid/scripts/Controllers/RunSimulations.tcl +++ b/kratos.gid/scripts/Controllers/RunSimulations.tcl @@ -119,6 +119,7 @@ proc runsimulations::GoToPostprocess { sim_path } { # TODO: Ask kike if there is a better way to change to post and return the path of a post.lst file # Instead of writing the post.lst manually proc runsimulations::WritePostprocessRequest { sim_path } { + # W "Writing postprocess request for simulation path: $sim_path" # In the model folder, create a file named "{model_name}.post.lst" # The content of the file is a copy of the file simp_path/{simulation_name}.post.lst but adding the full path to the simulation folder set dir [GidUtils::GetDirectoryModel] @@ -133,7 +134,14 @@ proc runsimulations::WritePostprocessRequest { sim_path } { set postprocess_request_file [file join $dir "${model_name}.post.lst"] set sim_name [file tail $sim_path] - set sim_postprocess_file [file join $dir $sim_path "${sim_name}.post.lst"] + + # instead of looking for a file called ${sim_name}, lets find the first with .post.lst extension + set sim_postprocess_file "" + set files [glob -nocomplain -directory [file join $dir $sim_path] *.post.lst] + set sim_postprocess_file [lindex $files 0] + # W "Using simulation postprocess file: $sim_postprocess_file" + + # set sim_postprocess_file [file join $dir $sim_path "${sim_name}.post.lst"] # W "Writing postprocess request from $sim_postprocess_file to $postprocess_request_file" if {[file exists $sim_postprocess_file]} { set infile [open $sim_postprocess_file r] diff --git a/kratos.gid/scripts/spdAuxiliar.tcl b/kratos.gid/scripts/spdAuxiliar.tcl index 4fd51779b..5e24f5a8c 100644 --- a/kratos.gid/scripts/spdAuxiliar.tcl +++ b/kratos.gid/scripts/spdAuxiliar.tcl @@ -519,7 +519,7 @@ proc spdAux::RegisterWindow {window_name} { proc spdAux::ProcFillSimulations { domNode args } { # W "Filling simulations..." set model_name [GiD_Info Project ModelName] - # remove the extension if any + set model_dir [GidUtils::GetDirectoryModel] # detect previous simulation runs set sim_runs_list [runsimulations::GetPastSimulationsRunsList] @@ -550,7 +550,7 @@ proc spdAux::ProcFillSimulations { domNode args } { # add rerun case append add_menu_command " { advanced-16 {Rerun} {runsimulations::RerunSimulation $sim_path} }" # add view results option - append add_menu_command " { advanced-16 {View Results} {runsimulations::GoToPostprocess $sim_path} }" + append add_menu_command " { advanced-16 {View Results} {runsimulations::GoToPostprocess \"$sim_path\"} }" set icon "ok16" # if there is an error file (modelname.err) inside the simulation folder, change the icon to From 505e59ebb6de7ea2bdf0f12035b6a9415a050023 Mon Sep 17 00:00:00 2001 From: Javi Garate Date: Thu, 8 Jan 2026 14:03:25 +0100 Subject: [PATCH 14/16] relative paths --- .../scripts/Controllers/RunSimulations.tcl | 16 +++++++--- kratos.gid/scripts/spdAuxiliar.tcl | 29 ++++++++++++++----- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/kratos.gid/scripts/Controllers/RunSimulations.tcl b/kratos.gid/scripts/Controllers/RunSimulations.tcl index 081d2fe81..924e143bb 100644 --- a/kratos.gid/scripts/Controllers/RunSimulations.tcl +++ b/kratos.gid/scripts/Controllers/RunSimulations.tcl @@ -87,10 +87,18 @@ proc runsimulations::GetCurrentSimulationRunName { } { } proc runsimulations::DeleteAllSimulationRuns { } { - set sim_runs_list [runsimulations::GetPastSimulationsRunsList] - foreach sim_run $sim_runs_list { - set sim_path [dict get $sim_run path] - runsimulations::DeleteSimulationRun $sim_path + # delete all content of the simulations folder + set dir [GidUtils::GetDirectoryModel] + + variable folder_name + set simulations_dir [file join $dir $folder_name] + + # delete all contents, but not the folder itself + if {[file isdirectory $simulations_dir]} { + set dir_list [glob -nocomplain -directory $simulations_dir *] + foreach sim_dir $dir_list { + file delete -force $sim_dir + } } } diff --git a/kratos.gid/scripts/spdAuxiliar.tcl b/kratos.gid/scripts/spdAuxiliar.tcl index 5e24f5a8c..741029c3d 100644 --- a/kratos.gid/scripts/spdAuxiliar.tcl +++ b/kratos.gid/scripts/spdAuxiliar.tcl @@ -541,22 +541,25 @@ proc spdAux::ProcFillSimulations { domNode args } { set sim_name [dict get $sim_run name] set sim_path [dict get $sim_run path] - set add_menu_command "{advanced-16 {View in Code} {spdAux::OpenRunInCode $sim_path}}" + # make simpath relative to model_dir + set sim_path [string map [list "$model_dir/" ""] $sim_path] + + set add_menu_command "{advanced-16 {View in Code} {spdAux::OpenRunInCode \"$sim_path\"}}" # append add_menu_command " { advanced-16 {Rename} {spdAux::RenameSimulationRun $sim_path} }" set del_menu_command "removecontextualmenu='{-} {Edit} {List entities} {Expand} {View this}'" # add delete option - append add_menu_command " { advanced-16 {Delete} {spdAux::DeleteSimulationRun $sim_path} }" + append add_menu_command " { advanced-16 {Delete} {spdAux::DeleteSimulationRun \"$sim_path\"} }" # add rerun case - append add_menu_command " { advanced-16 {Rerun} {runsimulations::RerunSimulation $sim_path} }" + append add_menu_command " { advanced-16 {Rerun} {runsimulations::RerunSimulation \"$sim_path\"} }" # add view results option append add_menu_command " { advanced-16 {View Results} {runsimulations::GoToPostprocess \"$sim_path\"} }" set icon "ok16" # if there is an error file (modelname.err) inside the simulation folder, change the icon to - if {[file exists [file join $sim_path "[file tail $model_name].err"]]} { + if {[file exists [file join [spdAux::MakeRunAbsolutePath $sim_path] "[file tail $model_name].err"]]} { # if the size is greater than 0 - if {[file size [file join $sim_path "[file tail $model_name].err"] ] > 0} { + if {[file size [file join [spdAux::MakeRunAbsolutePath $sim_path] "[file tail $model_name].err"] ] > 0} { set icon "error16" # Add view error option append add_menu_command " { advanced-16 {View Error Log} {Kratos::OpenCaseIn VSCode [file join $sim_path "[file tail $model_name].err"]} }" @@ -568,7 +571,7 @@ proc spdAux::ProcFillSimulations { domNode args } { # add extra info as status, size, date... # get the size of the folder set folder_size 0 - set folder_files [glob -nocomplain -directory $sim_path -types {file} *] + set folder_files [glob -nocomplain -directory [spdAux::MakeRunAbsolutePath $sim_path] -types {file} *] foreach file $folder_files { set folder_size [expr $folder_size + [file size $file]] } @@ -596,7 +599,7 @@ proc spdAux::ProcFillSimulations { domNode args } { # get the modification date of the projectparameters file set folder_mtime 0 - set sim_params_file [file join $sim_path "ProjectParameters.json"] + set sim_params_file [file join [spdAux::MakeRunAbsolutePath $sim_path] "ProjectParameters.json"] if {[file exists $sim_params_file]} { set folder_mtime [file mtime $sim_params_file] } @@ -623,6 +626,7 @@ proc spdAux::GetNextSimulationRunName { } { } proc spdAux::DeleteSimulationRun { sim_path } { + set path [spdAux::MakeRunAbsolutePath $args] runsimulations::DeleteSimulationRun $sim_path spdAux::RequestRefresh } @@ -632,9 +636,18 @@ proc spdAux::DeleteAllSimulationRuns { } { spdAux::RequestRefresh } +# args is the relative path inside the model folder proc spdAux::OpenRunInCode { args } { - set path $args + set path [spdAux::MakeRunAbsolutePath $args] Kratos::OpenCaseIn VSCode $path } +proc spdAux::MakeRunAbsolutePath { run_path } { + set model_dir [GidUtils::GetDirectoryModel] + if {[file pathtype $run_path] ne "absolute"} { + set run_path [file join $model_dir $run_path] + } + return $run_path +} + spdAux::Init From a4ca6be1bd2896b1a4a4f0e61572ce8217a99aca Mon Sep 17 00:00:00 2001 From: Javi Garate Date: Fri, 9 Jan 2026 15:41:37 +0100 Subject: [PATCH 15/16] falta el run --- kratos.gid/kratos.tcl | 2 +- .../scripts/Controllers/Preferences.xml | 4 + .../scripts/Controllers/PreferencesWindow.tcl | 3 + kratos.gid/scripts/Controllers/RunWindow.tcl | 142 ++++++++++++++++++ kratos.gid/scripts/Menus.tcl | 14 +- 5 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 kratos.gid/scripts/Controllers/RunWindow.tcl diff --git a/kratos.gid/kratos.tcl b/kratos.gid/kratos.tcl index 52ba4b50e..431aa78f5 100644 --- a/kratos.gid/kratos.tcl +++ b/kratos.gid/kratos.tcl @@ -209,7 +209,7 @@ proc Kratos::LoadCommonScripts { } { uplevel #0 [list source [file join $kratos_private(Path) scripts $filename.tcl]] } # Common controllers - foreach filename {ApplicationMarketWindow ExamplesWindow CommonProcs PreferencesWindow TreeInjections MdpaImportMesh Drawer ImportFiles RunSimulations} { + foreach filename {ApplicationMarketWindow ExamplesWindow CommonProcs PreferencesWindow TreeInjections MdpaImportMesh Drawer ImportFiles RunSimulations RunWindow} { uplevel #0 [list source [file join $kratos_private(Path) scripts Controllers $filename.tcl]] } # Model class diff --git a/kratos.gid/scripts/Controllers/Preferences.xml b/kratos.gid/scripts/Controllers/Preferences.xml index ee442869e..5ca77b086 100644 --- a/kratos.gid/scripts/Controllers/Preferences.xml +++ b/kratos.gid/scripts/Controllers/Preferences.xml @@ -18,6 +18,10 @@