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 numpy
4+ WORKDIR "/model"
5+ ENTRYPOINT [ "python3", "MainKratos.py" ]
6+
7+ # docker build --tag="kratos-run:latest" -t kratos-run .
8+ # docker tag kratos-run:latest fjgarate/kratos-run:latest
9+ # docker push fjgarate/kratos-run:0.0.1
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 --name " $1 " $kratos_docker_image > " $2 /$1 .info" 2> " $2 /$1 .err"
14+ # 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 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 @@ -10,4 +10,4 @@ rm -f "$2/$1.err"
1010rm -f " $2 /$1 .flavia.dat"
1111
1212# Run Python using the script MainKratos.py
13- python3 MainKratos.py > " $2 /$1 .info" 2> " $2 /$1 .err"
13+ $kratos_python_exe MainKratos.py > " $2 /$1 .info" 2> " $2 /$1 .err"
Original file line number Diff line number Diff line change @@ -15,4 +15,4 @@ DEL "%2\%1*.post.res"
1515DEL " %2 \%1 *.post.msh"
1616
1717@ REM Calculate!
18- python MainKratos.py > " %2 \\%1 .info" 2 > " %2 \\%1 .err"
18+ %kratos_python_exe% MainKratos.py > " %2 \\%1 .info" 2 > " %2 \\%1 .err"
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ proc Kratos::RegisterGiDEvents { } {
6969 GiD_RegisterEvent GiD_Event_SelectGIDBatFile Kratos::Event_SelectGIDBatFile PROBLEMTYPE Kratos
7070
7171 # Postprocess
72+ GiD_RegisterEvent GiD_Event_BeforeInitGIDPostProcess Kratos::BeforeInitGIDPostProcess PROBLEMTYPE Kratos
7273 GiD_RegisterEvent GiD_Event_InitGIDPostProcess Kratos::Event_InitGIDPostProcess PROBLEMTYPE Kratos
7374 GiD_RegisterEvent GiD_Event_EndGIDPostProcess Kratos::Event_EndGIDPostProcess PROBLEMTYPE Kratos
7475
@@ -475,6 +476,19 @@ proc Kratos::Event_InitGIDPostProcess {} {
475476 gid_groups_conds::open_post check_default
476477}
477478
479+ proc Kratos::BeforeInitGIDPostProcess {} {
480+ # In docker run, rename lst file
481+ if {[info exists Kratos::kratos_private(launch_configuration)]} {
482+ set launch_mode $Kratos::kratos_private(launch_configuration)
483+ if {$launch_mode eq " Docker" } {
484+ set list_file [file join [GidUtils::GetDirectoryModel] model.post.lst]
485+ if {[file exists $list_file ]} {
486+ file copy -force $list_file [GidUtils::GetFilenameInsideProject [file rootname [GidUtils::GetDirectoryModel]] .post.lst]
487+ }
488+ }
489+ }
490+ }
491+
478492proc Kratos::Event_EndGIDPostProcess {} {
479493 # Close all postprocess windows
480494 gid_groups_conds::close_all_windows
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 =' ' >
23- <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'/> -->
25- <option value =' Launch local compiled version' label =' Launch local compiled version' />
26- <!-- <option value='Docker' label='Docker'/> -->
27- <!-- <option value='Custom...' label='Custom...'/> -->
28- </combobox >
22+ <comboboxframe name =" launch_configuration" label =" Launch configuration" variable =" launch_configuration" variablemanager =' Kratos::ManagePreferences' help =' ' >
23+ <option value =' Launch via pip' label =' Launch via pip' setactivate =" python_path" />
24+ <option value =' Launch local compiled version' label =' Launch local compiled version (kratos.gid/exec/Kratos/runkratos)' />
25+ <option value =' Docker' label =' Docker' setactivate =" docker_image" />
26+
27+ <entrywithbutton name =" python_path" variable =" python_path" label =" Python path (exe)" variablemanager =' Kratos::ManagePreferences' help =' Path to python.exe' buttonimage =" folder.png" buttonfunction =" GetPythonPath" />
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,15 @@ 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+ " python_path" {
42+ set ret [file join [Kratos::GetDefaultPythonPath] [Kratos::GetPythonExeName] ]
43+ }
44+ default {
45+ set ret 0
46+ }
3847 }
3948 }
4049 }
You can’t perform that action at this time.
0 commit comments