Simulations history#1023
Open
jginternational wants to merge 18 commits into
Open
Conversation
Member
Author
|
Added the launch window:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces “simulation history” by running each calculation in a dedicated per-run subfolder under the model (e.g., Simulations/Run_*), surfacing those runs in the GiD tree with contextual actions (open/delete/rerun/view results/view error), and adding a small run dialog + preference to control whether the dialog is shown.
Changes:
- Route write/run artifacts into per-simulation subfolders and propagate the per-run working directory via
case_pathfor launch scripts. - Add UI components for simulation history (tree container + fill proc + contextual actions) and a “Run Window” dialog/preference.
- Adjust output naming and postprocess request generation to support per-run result loading.
Reviewed changes
Copilot reviewed 23 out of 28 changed files in this pull request and generated 18 comments.
Show a summary per file
| File | Description |
|---|---|
| kratos.gid/scripts/Writing/WriteProjectParameters.tcl | Appends current simulation name into GiD output naming. |
| kratos.gid/scripts/Utils.tcl | Adds VS Code open helpers and .info/.err linking to the model folder. |
| kratos.gid/scripts/spdAuxiliar.tcl | Adds simulations-history tree fill proc and contextual actions. |
| kratos.gid/scripts/Menus.tcl | Wires toolbar “Run” to the new run window logic. |
| kratos.gid/scripts/Launch.tcl | Sets case_path env var for exec scripts based on simulation run folder. |
| kratos.gid/scripts/Controllers/RunWindow.tcl | New run dialog for naming runs + toggling GiD/VTK output flags. |
| kratos.gid/scripts/Controllers/RunSimulations.tcl | New helper module for listing/deleting runs and postprocess request writing. |
| kratos.gid/scripts/Controllers/PreferencesWindow.tcl | Adds default value handling for run_window. |
| kratos.gid/scripts/Controllers/Preferences.xml | Adds the “Run Window” preference UI control. |
| kratos.gid/kratos.tcl | Loads new controllers, registers AfterRun event, and writes into per-run folders. |
| kratos.gid/kratos.spd | Adds a “Simulations” container and registers the FillSimulations proc. |
| kratos.gid/exec/pip.win.bat | Switches cleaning/log output paths to use %case_path%. |
| kratos.gid/exec/pip.unix.bat | Switches cleaning/log output paths to use $case_path + relative outputs. |
| kratos.gid/exec/pip_gids_python.win.bat | Switches cleaning/log output paths to use %case_path%. |
| kratos.gid/exec/pip_gids_python.unix.bat | Switches cleaning/log output paths to use $case_path + relative outputs. |
| kratos.gid/exec/docker.win.bat | Switches cleaning/log output paths and docker mount to use %case_path%. |
| kratos.gid/exec/docker.unix.bat | Starts switching to $case_path but still uses $2 for deletes/mount/logs. |
| kratos.gid/exec/compiled.win.bat | Switches cleaning to %case_path% but still writes logs to %2. |
| kratos.gid/exec/compiled.unix.bat | Switches cleaning/log output paths to $case_path + relative outputs. |
| kratos.gid/kratos.win.bat | Deleted legacy launcher script. |
| kratos.gid/kratos.unix.mpi.bat | Deleted legacy launcher script. |
| kratos.gid/kratos.unix.bat | Deleted legacy launcher script. |
| kratos.gid/kratos.unix_release.bat | Deleted legacy launcher script. |
| kratos.gid/apps/Buoyancy/xml/Procs.spd | Minor whitespace/indentation change. |
Comments suppressed due to low confidence (1)
kratos.gid/exec/docker.unix.bat:14
docker.unix.batnowcds into$case_path, but it still deletes and writes logs under$2(project directory) and mounts$2:/modelinto the container. That means results/logs won’t go into the per-run folder and the script can delete the wrong files relative to the new working directory.
#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"
rm -f "$2/$1.info"
rm -f "$2/$1.err"
rm -f "$2/$1.flavia.dat"
# Run Python using the script MainKratos.py
docker run -v "$2:/model" --rm --name "$1" $kratos_docker_image > "$2/$1.info" 2> "$2/$1.err"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+134
to
+140
| return | ||
| } | ||
|
|
||
| # TODO: Store the next name, run and close the window | ||
| # proceed to run the simulation | ||
| runsimulations::RunSimulation $run_name | ||
|
|
Comment on lines
+551
to
+556
| # 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\"} }" |
Comment on lines
+628
to
+632
| proc spdAux::DeleteSimulationRun { sim_path } { | ||
| set path [spdAux::MakeRunAbsolutePath $args] | ||
| runsimulations::DeleteSimulationRun $sim_path | ||
| spdAux::RequestRefresh | ||
| } |
Comment on lines
40
to
43
| 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"] |
Comment on lines
366
to
+369
| "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 |
| set bat [dict get $mode script] | ||
| set bat_file [file join exec $bat.$os.bat] | ||
| } | ||
| set next_run [runsimulations::GetCurrentSimulationRunName] |
| # OutputFile: "$2/$1.info" | ||
| # ErrorFile: "$2/$1.err" | ||
|
|
||
| cd "$case_path" |
Comment on lines
+368
to
+372
| if {$ext_path ne ""} { | ||
| set model_dir $ext_path | ||
| } else { | ||
| set model_dir [GiD_Info Project ModelName].gid | ||
| } |
Comment on lines
+593
to
+599
| 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] |
Comment on lines
+477
to
+483
| 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] | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The idea is to keep a history of the simulations calculated of a case, and, in a mid term future, when GiD adapts, be able to compare results from 2 different simulations.
Every time you click on run, the problemtype creates a subfolder for the simulation, and the input files and python script are copied there.

In the tree, user can see the history like this:
With the red icon if the calculation failed, and green if everything is OK
For every simulation, the user can:
Pending tasks
This PR is open to new features and comments!