Skip to content

Simulations history#1023

Open
jginternational wants to merge 18 commits into
masterfrom
add-simulations
Open

Simulations history#1023
jginternational wants to merge 18 commits into
masterfrom
add-simulations

Conversation

@jginternational

Copy link
Copy Markdown
Member

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:
image
With the red icon if the calculation failed, and green if everything is OK

For every simulation, the user can:

  • Open the case in VSCode
  • Delete (will delete the results)
  • Rerun
  • View result (Goes to postprocess and load the results)
  • View error log (only if error)
image

Pending tasks

  • At this point, we need to work on the log view in real time. GiD expects the .info file to be in the model folder.
  • Add an spd viewer, in 'disabled' mode, so the user can see the state of the tree that generates the run. now the only way is to Open with VSCode and view the mdpa and Project parameters (maybe it's enough)
  • In future GiD versions, add "Compare results". the user will be able to compare 2 or more simulations, step by step.

This PR is open to new features and comments!

@jginternational

jginternational commented Jan 10, 2026

Copy link
Copy Markdown
Member Author

Added the launch window:
Features:

  • Set launch name
  • Enable/disable gid/vtk outputs
  • Skip this window
  • Launch location: local, cloud, hpc custom
  • Launch mode if local

@jginternational jginternational marked this pull request as ready for review July 7, 2026 11:04
Copilot AI review requested due to automatic review settings July 7, 2026 11:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_path for 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.bat now cds into $case_path, but it still deletes and writes logs under $2 (project directory) and mounts $2:/model into 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 thread kratos.gid/kratos.tcl
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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants