File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ https://www.youtube.com/watch?v=zZq7ypDdudo
2727In Kratos preferences, select the execution mode:
2828* Pip packages: Kratos will be installed via ` pip install `
2929* local compiled: If you are a developer and build your applications, use this one
30+ * docker: If you do not want to install any dependency, just run via docker!
31+ * The default image is [ fjgarate/kratos-run] ( https://hub.docker.com/repository/docker/fjgarate/kratos-run )
3032
3133## Usage
3234* Run GiD
Original file line number Diff line number Diff line change 1+ FROM python:3.9
2+
3+ RUN pip install KratosMultiphysics-all
4+ WORKDIR "/model"
5+ ENTRYPOINT [ "python3", "MainKratos.py" ]
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # OutputFile: "$2/$1.info"
3+ # ErrorFile: "$2/$1.err"
4+ # delete previous result file
5+ rm -f " $2 /$1 *.post.bin"
6+ rm -f " $2 /$1 *.post.res"
7+ rm -f " $2 /$1 *.post.msh"
8+ rm -f " $2 /$1 .info"
9+ rm -f " $2 /$1 .err"
10+ rm -f " $2 /$1 .flavia.dat"
11+
12+ # Run Python using the script MainKratos.py
13+ docker run -v " $2 :/model" --rm fjgarate/kratos-run > " $2 \\ $1 .info" 2> " $2 \\ $1 .err"
Original file line number Diff line number Diff line change 1+ REM @ECHO OFF
2+ REM Identification for arguments
3+ REM basename = %1
4+ REM Project directory = %2
5+ REM Problem directory = %3
6+
7+ REM OutputFile: "%2\%1.info"
8+ REM ErrorFile: "%2\%1.err"
9+
10+ REM Remove previous calculation files and results
11+ DEL " %2 \%1 .info"
12+ DEL " %2 \%1 .err"
13+ DEL " %2 \%1 *.post.bin"
14+ DEL " %2 \%1 *.post.res"
15+ DEL " %2 \%1 *.post.msh"
16+
17+ @ REM Calculate!
18+ docker run -v " %2 :/model" --rm --name " %1 " %kratos_docker_image% > " %2 \\%1 .info" 2 > " %2 \\%1 .err"
Original file line number Diff line number Diff line change 1919 },
2020 {
2121 "name" : " Docker" ,
22- "script" : " " ,
22+ "script" : " docker " ,
2323 "dependency_check" : " Kratos::CheckDependenciesDockerMode"
2424 }
2525 ]
Original file line number Diff line number Diff line change 1919 <option value =' 2' label =' 2' />
2020 </combobox >
2121 <entrywithbutton name =" debug_folder" label =" Debug path" variable =" debug_folder" buttonimage =" folder.png" variablemanager =' Kratos::ManagePreferences' buttonfunction =" OpenBrowserForDirectory" help =' Path to the kratos debug folder. This is placed in the launch.json file for debugging' />
22- <combobox name =" launch_configuration" label =" Launch configuration" variable =" launch_configuration" variablemanager =' Kratos::ManagePreferences' help =' ' >
22+ <comboboxframe name =" launch_configuration" label =" Launch configuration" variable =" launch_configuration" variablemanager =' Kratos::ManagePreferences' help =' ' >
2323 <option value =' Launch via pip' label =' Launch via pip' />
24- <!-- <option value='Launch via pip with local packages' label='Launch via pip with local packages'/> -->
2524 <option value =' Launch local compiled version' label =' Launch local compiled version' />
26- <!-- < option value='Docker' label='Docker'/> -- >
25+ <option value =' Docker' label =' Docker' setactivate = " docker_image " / >
2726 <!-- <option value='Custom...' label='Custom...'/> -->
28- </combobox >
27+
28+ <entry name =" docker_image" variable =" docker_image" label =" Docker image" variablemanager =' Kratos::ManagePreferences' help =' Name of the Kratos Docker image' />
29+ </comboboxframe >
2930 </labelframe >
3031</group >
3132
Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ proc Kratos::ManagePreferences { cmd name {value ""}} {
3535 " launch_configuration" {
3636 set ret " local"
3737 }
38+ " docker_image" {
39+ set ret " fjgarate/kratos-run"
40+ }
41+ default {
42+ set ret 0
43+ }
3844 }
3945 }
4046 }
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ proc Kratos::CheckDependenciesLocalPipMode {} {
134134
135135}
136136proc Kratos::CheckDependenciesLocalMode {} {
137-
137+
138138}
139139proc Kratos::CheckDependenciesDockerMode {} {
140140
@@ -189,7 +189,10 @@ proc Kratos::ExecuteLaunchByMode {launch_mode} {
189189 set bat [dict get $mode script]
190190 set bat_file [file join exec $bat .$os .bat]
191191 }
192-
192+ if {[dict get $mode name] eq " Docker" } {
193+ set docker_image [Kratos::ManagePreferences GetValue docker_image]
194+ set ::env(kratos_docker_image) $docker_image
195+ }
193196 return $bat_file
194197}
195198
@@ -203,4 +206,11 @@ proc Kratos::GetLaunchMode { {launch_mode "current"} } {
203206 }
204207 }
205208 return $curr_mode
209+ }
210+
211+ proc Kratos::StopCalculation { } {
212+ if {[dict get [Kratos::GetLaunchMode] name] eq " Docker" } {
213+ exec docker stop [Kratos::GetModelName]
214+ }
215+ GiD_Process Mescape Utilities CancelProcess escape escape
206216}
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ proc Kratos::CreatePreprocessModelTBar { {type "DEFAULT INSIDELEFT"} } {
4040 Kratos::ToolbarAddItem " Spacer" " " " " " "
4141 Kratos::ToolbarAddItem " Run" " run.png" {Utilities Calculate} [= " Run the simulation" ]
4242 Kratos::ToolbarAddItem " Output" " output.png" [list -np- PWViewOutput] [= " View process info" ]
43- Kratos::ToolbarAddItem " Stop" " stop.png" {Utilities CancelProcess} [= " Cancel process" ]
43+ Kratos::ToolbarAddItem " Stop" " stop.png" [ list -np- Kratos::StopCalculation] [= " Cancel process" ]
4444 Kratos::ToolbarAddItem " SpacerApp1" " " " " " "
4545 if {[info exists kratos_private(UseFiles)] && $kratos_private(UseFiles) == 1} {
4646 Kratos::ToolbarAddItem " Files" " files.png" [list -np- spdAux::LaunchFileWindow] [= " File handler window" ]
You can’t perform that action at this time.
0 commit comments