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/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/images/error16.png b/kratos.gid/images/error16.png
new file mode 100644
index 000000000..9f09ecf2e
Binary files /dev/null and b/kratos.gid/images/error16.png differ
diff --git a/kratos.gid/images/ok16.png b/kratos.gid/images/ok16.png
new file mode 100644
index 000000000..7b4f3494c
Binary files /dev/null and b/kratos.gid/images/ok16.png differ
diff --git a/kratos.gid/images/run16.png b/kratos.gid/images/run16.png
new file mode 100644
index 000000000..ce8b3360d
Binary files /dev/null and b/kratos.gid/images/run16.png differ
diff --git a/kratos.gid/images/running.png b/kratos.gid/images/running.png
new file mode 100644
index 000000000..7b4f3494c
Binary files /dev/null and b/kratos.gid/images/running.png differ
diff --git a/kratos.gid/kratos.spd b/kratos.gid/kratos.spd
index f88968996..e4c2ad1c1 100644
--- a/kratos.gid/kratos.spd
+++ b/kratos.gid/kratos.spd
@@ -36,6 +36,8 @@
+
+
@@ -330,9 +332,6 @@
return [spdAux::ProcGetFilesValues $domNode]
]]>
-
-
-
+
+
+
+
diff --git a/kratos.gid/kratos.tcl b/kratos.gid/kratos.tcl
index f6aec49e6..431aa78f5 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 { } {
@@ -52,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
@@ -179,6 +182,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 { } {
@@ -203,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} {
+ 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
@@ -453,7 +459,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}
@@ -492,6 +498,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 {} {
@@ -507,6 +524,16 @@ proc Kratos::Event_EndGIDPostProcess {} {
::Kratos::CreatePreprocessModelTBar
}
+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 } {
# Let's launch the Kratos rocket!
set run 1
@@ -524,6 +551,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 } {
@@ -557,6 +588,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 [runsimulations::GetSimulationRunPath $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 +612,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/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/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 @@
+
+
+
+
diff --git a/kratos.gid/scripts/Controllers/PreferencesWindow.tcl b/kratos.gid/scripts/Controllers/PreferencesWindow.tcl
index 041450851..dd4984e92 100644
--- a/kratos.gid/scripts/Controllers/PreferencesWindow.tcl
+++ b/kratos.gid/scripts/Controllers/PreferencesWindow.tcl
@@ -44,6 +44,9 @@ proc Kratos::ManagePreferences { cmd name {value ""}} {
"kratos_bin_path" {
set ret [file join $::Kratos::kratos_private(Path) exec kratos runkratos.exe]
}
+ "run_window" {
+ set ret 1
+ }
default {
set ret 0
}
diff --git a/kratos.gid/scripts/Controllers/RunSimulations.tcl b/kratos.gid/scripts/Controllers/RunSimulations.tcl
new file mode 100644
index 000000000..924e143bb
--- /dev/null
+++ b/kratos.gid/scripts/Controllers/RunSimulations.tcl
@@ -0,0 +1,174 @@
+##################################################################################
+# 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
+}
+
+
+proc runsimulations::Init { } {
+ variable folder_name
+ variable spd_un
+
+ set folder_name "Simulations"
+ set spd_un "simulation_runs"
+}
+
+proc runsimulations::GetPastSimulationsRunsList { } {
+
+ set return_list [list ]
+
+ # Find in the folder
+ 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 *]
+ 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::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"
+ while {[lsearch -exact $previous_runs_names $run_name] != -1} {
+ incr 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::DeleteAllSimulationRuns { } {
+ # 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
+ }
+ }
+}
+
+proc runsimulations::DeleteSimulationRun { sim_path } {
+ # delete the folder and all its contents
+ if {[file isdirectory $sim_path]} {
+ file delete -force $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
+}
+
+proc runsimulations::GoToPostprocess { sim_path } {
+ set Kratos::pending_postprocess_simulation $sim_path
+ # W "Changing to Postprocess... $sim_path"
+ runsimulations::WritePostprocessRequest $sim_path
+ 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
+# 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]
+ set model_name [file tail $dir]
+ # 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]
+
+ # 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]
+ 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/Controllers/RunWindow.tcl b/kratos.gid/scripts/Controllers/RunWindow.tcl
new file mode 100644
index 000000000..d248bc8a6
--- /dev/null
+++ b/kratos.gid/scripts/Controllers/RunWindow.tcl
@@ -0,0 +1,142 @@
+namespace eval ::RunWindow {
+ Kratos::AddNamespace [namespace current]
+
+ variable run_window
+ variable run_window_name
+
+
+ variable gid_output
+ variable vtk_output
+ variable show_dialog_again
+}
+
+proc RunWindow::Init { } {
+
+ variable run_window_name
+ set run_window_name ".gid.kratosrunwindow"
+
+ variable gid_output
+ variable vtk_output
+
+ # initialize show-again flag from global Kratos private setting
+ variable show_dialog_again
+ set show_dialog_again $::Kratos::kratos_private(run_window)
+}
+
+proc RunWindow::ShowRunWindow { } {
+ variable run_window
+ variable run_window_name
+
+ # if ::Kratos::kratos_private(run_window) is 1, show the window
+ if {$::Kratos::kratos_private(run_window) == 1} {
+ # check if the window is already created
+
+ if {[winfo exists $run_window_name]} {
+ # destry
+ destroy $run_window_name
+ }
+ RunWindow::InitRunWindow
+ }
+}
+
+proc RunWindow::InitRunWindow { } {
+ variable run_window_name
+ set w $run_window_name
+
+ InitWindow $w [_ "Kratos Multiphysics - Run Simulations"] Kratos "" "" 1
+
+ # run window content must be a in entry for the run name, 2 checkboxes for options (gid output, vtk output) and
+ # a check button to toggle between show again or not, and a run button
+
+ set frame_main $w.frame_main
+ ttk::frame $frame_main
+ pack $frame_main -side top -fill both -expand 1 -padx 20 -pady 15
+
+ # Row 0: Run name section
+ ttk::labelframe $frame_main.name_frame -text [_ "Simulation Run"] -padding {10 5}
+ grid $frame_main.name_frame -row 0 -column 0 -columnspan 3 -sticky ew -pady {0 15}
+
+ ttk::entry $frame_main.name_frame.run_name_entry -width 50
+ pack $frame_main.name_frame.run_name_entry -fill x
+ set default_run_name [runsimulations::GetNextSimulationRunName]
+ $frame_main.name_frame.run_name_entry insert 0 $default_run_name
+
+ # Create checkbuttons with command callbacks
+ ttk::checkbutton $frame_main.name_frame.gid_output_check -text [_ "Enable GiD Output"] -variable ::RunWindow::gid_output -command "RunWindow::ToggleOutput ::RunWindow::gid_output EnableGiDOutput"
+ ttk::checkbutton $frame_main.name_frame.vtk_output_check -text [_ "Enable VTK Output"] -variable ::RunWindow::vtk_output -command "RunWindow::ToggleOutput ::RunWindow::vtk_output EnableVtkOutput"
+
+ # Set initial state from tree
+ set gid_enabled [write::getValue EnableGiDOutput]
+ if {$gid_enabled eq "Yes"} {
+ $frame_main.name_frame.gid_output_check state selected
+ } else {
+ $frame_main.name_frame.gid_output_check state !selected
+ }
+
+ set vtk_enabled [write::getValue EnableVtkOutput]
+ if {$vtk_enabled eq "Yes"} {
+ $frame_main.name_frame.vtk_output_check state selected
+ } else {
+ $frame_main.name_frame.vtk_output_check state !selected
+ }
+
+ pack $frame_main.name_frame.gid_output_check -side left -padx {0 20}
+ pack $frame_main.name_frame.vtk_output_check -side left
+
+ # Row 2: Bottom row with checkbox and button
+ ttk::checkbutton $frame_main.show_again_check -text [_ "Show this dialog again"] -variable ::RunWindow::show_dialog_again -onvalue 1 -offvalue 0 -command RunWindow::ToggleShowAgain
+ ttk::button $frame_main.run_button -text [_ "Run Simulation"] -command RunWindow::OnRunSimulationButtonPressed -width 15
+ grid $frame_main.show_again_check -row 2 -column 0 -sticky w
+
+
+ grid $frame_main.run_button -row 2 -column 2 -sticky e
+
+ grid columnconfigure $frame_main 1 -weight 1
+
+}
+
+proc RunWindow::ToggleOutput { variable_name un } {
+ # get current value from the window
+ set current [set $variable_name]
+ if {$current eq 1} {
+ set current "Yes"
+ } else {
+ set current "No"
+ }
+ spdAux::SetValueOnTreeItem v $current $un
+
+}
+
+# keep global run window flag in sync with the checkbox
+proc RunWindow::ToggleShowAgain { } {
+ variable show_dialog_again
+ if {![info exists show_dialog_again]} {
+ set show_dialog_again 1
+ }
+ set ::Kratos::kratos_private(run_window) $show_dialog_again
+}
+
+proc RunWindow::OnRunSimulationButtonPressed { } {
+ variable run_window_name
+ set w $run_window_name
+ variable gid_output
+ variable vtk_output
+
+ # get the run name
+ set run_name [$w.frame_main.name_frame.run_name_entry get]
+
+ # check that the name is not empty
+ if {[string length $run_name] == 0} {
+ Kratos::ShowErrorMessage [_ "Error"] [_ "The simulation run name cannot be empty."]
+ return
+ }
+
+ # TODO: Store the next name, run and close the window
+ # proceed to run the simulation
+ runsimulations::RunSimulation $run_name
+
+ # close the window
+ destroy $w
+}
+
+::RunWindow::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/Menus.tcl b/kratos.gid/scripts/Menus.tcl
index a3ae1203f..709378d18 100644
--- a/kratos.gid/scripts/Menus.tcl
+++ b/kratos.gid/scripts/Menus.tcl
@@ -39,7 +39,7 @@ proc Kratos::CreatePreprocessModelTBar { {type "DEFAULT INSIDELEFT"} } {
Kratos::EndCreatePreprocessTBar
Kratos::ToolbarAddItem "Model" "propstree.png" [list -np- gid_groups_conds::open_conditions menu] [= "Define the model properties"]
Kratos::ToolbarAddItem "Spacer" "" "" ""
- Kratos::ToolbarAddItem "Run" "run.png" {Utilities Calculate} [= "Run the simulation"]
+ Kratos::ToolbarAddItem "Run" "run.png" [list -np- RunWindow::ShowRunWindow] [= "Run the simulation"]
Kratos::ToolbarAddItem "Output" "output.png" [list -np- PWViewOutput] [= "View process info"]
Kratos::ToolbarAddItem "Stop" "stop.png" [list -np- Kratos::StopCalculation] [= "Cancel process"]
Kratos::ToolbarAddItem "SpacerApp1" "" "" ""
@@ -103,6 +103,18 @@ proc Kratos::CreatePreprocessModelTBar { {type "DEFAULT INSIDELEFT"} } {
}
}
+proc Kratos::RocketButton { } {
+ variable kratos_private
+
+ # if run_window is disabled, do nothing
+ if {[write::isBooleanFalse $kratos_private(run_window)]} {
+ GiD_Process Mescape Utilities Calculate Mescape
+ } else {
+ RunWindow::ShowRunWindow
+ }
+
+}
+
proc Kratos::ToolbarDependenciesRefresh { } {
Kratos::CheckDependencies
Kratos::ToolbarRefresh
diff --git a/kratos.gid/scripts/Utils.tcl b/kratos.gid/scripts/Utils.tcl
index 23ae7c750..e275e7c3d 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"
+ 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]]
+ } 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"
}
}
}
@@ -375,6 +392,51 @@ proc Kratos::OpenCaseIn {program} {
}
}
+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)"]]
@@ -409,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
+ }
+ }
+
+ }
+}
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 779afdecb..741029c3d 100644
--- a/kratos.gid/scripts/spdAuxiliar.tcl
+++ b/kratos.gid/scripts/spdAuxiliar.tcl
@@ -516,4 +516,138 @@ proc spdAux::RegisterWindow {window_name} {
}
+proc spdAux::ProcFillSimulations { domNode args } {
+ # W "Filling simulations..."
+ set model_name [GiD_Info Project ModelName]
+ set model_dir [GidUtils::GetDirectoryModel]
+
+ # detect previous simulation runs
+ set sim_runs_list [runsimulations::GetPastSimulationsRunsList]
+
+ # fill the simulations list
+ set sim_list_node $domNode
+
+ # 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
+ }
+ foreach sim_run $sim_runs_list {
+ set sim_name [dict get $sim_run name]
+ set sim_path [dict get $sim_run 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\"} }"
+ # 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\"} }"
+
+ set icon "ok16"
+ # if there is an error file (modelname.err) inside the simulation folder, change the icon to
+ 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 [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"]} }"
+ }
+ }
+
+ 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 [spdAux::MakeRunAbsolutePath $sim_path] -types {file} *]
+ foreach file $folder_files {
+ set folder_size [expr $folder_size + [file size $file]]
+ }
+ # 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 ""
+ # 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 [spdAux::MakeRunAbsolutePath $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::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 } {
+ set path [spdAux::MakeRunAbsolutePath $args]
+ runsimulations::DeleteSimulationRun $sim_path
+ spdAux::RequestRefresh
+}
+
+proc spdAux::DeleteAllSimulationRuns { } {
+ runsimulations::DeleteAllSimulationRuns
+ spdAux::RequestRefresh
+}
+
+# args is the relative path inside the model folder
+proc spdAux::OpenRunInCode { 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