Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kratos.gid/apps/Buoyancy/xml/Procs.spd
Original file line number Diff line number Diff line change
Expand Up @@ -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] ","
Expand Down
22 changes: 12 additions & 10 deletions kratos.gid/exec/compiled.unix.bat
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
$python_path MainKratos.py > "./$1.info" 2> "./$1.err"
23 changes: 13 additions & 10 deletions kratos.gid/exec/compiled.win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@ 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

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"
1 change: 1 addition & 0 deletions kratos.gid/exec/docker.unix.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 9 additions & 7 deletions kratos.gid/exec/docker.win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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"
docker run -v "%case_path%:/model" --rm --name "%1" %kratos_docker_image% > "%case_path%\%1.info" 2> "%case_path%\%1.err"
15 changes: 8 additions & 7 deletions kratos.gid/exec/pip.unix.bat
Original file line number Diff line number Diff line change
@@ -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"
$python_home/python3 MainKratos.py > "./$1.info" 2> "./$1.err"
15 changes: 9 additions & 6 deletions kratos.gid/exec/pip.win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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"
16 changes: 9 additions & 7 deletions kratos.gid/exec/pip_gids_python.unix.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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"
$python_path MainKratos.py > "./$1.info" 2> "./$1.err"
16 changes: 10 additions & 6 deletions kratos.gid/exec/pip_gids_python.win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Binary file added kratos.gid/images/error16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kratos.gid/images/ok16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kratos.gid/images/run16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added kratos.gid/images/running.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions kratos.gid/kratos.spd
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<appLink n="MdpaGenerator" public="1" pn="Mdpa Generator" active="0" appid="MdpaGenerator" prefix="MDPAGen_" is_tool="1" production="1"/>
<appLink n="Examples" public="1" pn="Examples" active="0" appid="Examples" prefix="EXA_" is_tool="1" production="1"/>
<appLink n="GeoMechanics" public="1" pn="GeoMechanics" active="0" appid="GeoMechanics" prefix="GEOM_" />
<container n="Simulations" pn="Simulations" un="simulation_runs" open_window="1" icon="run16" state="[FillSimulations]" removecontextualmenu='{Edit} {Expand} {View this}'>
</container>
<blockdata n="units" pn="Units" icon="units" open_window="0">
<value n='units_mesh' pn='Mesh units' unit_mesh_definition="1"/>
<value n='units_system' pn='Units system' units_system_definition="1">
Expand Down Expand Up @@ -330,9 +332,6 @@
return [spdAux::ProcGetFilesValues $domNode]
]]>
</proc>



<proc n='GetMaterialsList' args='args'>
<![CDATA[
spdAux::ProcGetMaterialsList $domNode {*}$args
Expand All @@ -349,6 +348,13 @@
spdAux::ProcEditDatabaseList $domNode $dict $dict_units $boundary_conds $args
]]>
</proc>

<proc n='FillSimulations' args='args'>
<![CDATA[
spdAux::ProcFillSimulations $domNode {*}$args
return "normal"
]]>
</proc>
<dynamicnode command="spdAux::injectProcs" args=""/>
</procs>
<container n="files" state="hidden"></container>
Expand Down
48 changes: 44 additions & 4 deletions kratos.gid/kratos.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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 { } {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 { } {
Expand All @@ -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
Expand Down Expand Up @@ -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}

Expand Down Expand Up @@ -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 {} {
Expand All @@ -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
Expand All @@ -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 } {
Expand Down Expand Up @@ -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]}

Expand All @@ -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]"
}
Expand Down
Loading