Skip to content

Commit 0e61ea0

Browse files
add problemtype version and mesh data
1 parent b5cc708 commit 0e61ea0

3 files changed

Lines changed: 41 additions & 6 deletions

File tree

kratos.gid/kratos.tcl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ proc Kratos::InitGlobalVariables {dir} {
142142
set kratos_private(echo_level) 0
143143
# indent in mdpa files | 0 ASCII unindented | 1 ASCII indented pretty
144144
set kratos_private(mdpa_format) 1
145+
# Version of the kratos executable
146+
set kratos_private(exec_version) "dev"
147+
# Allow logs -> 0 No | 1 Only local | 2 Share with dev team
148+
set Kratos::kratos_private(allow_logs) 1
149+
# git hash of the problemtype
150+
set Kratos::kratos_private(problemtype_git_hash) 0
145151

146152
# Variable to store the Kratos menu items
147153
set kratos_private(MenuItems) [dict create]
@@ -157,10 +163,6 @@ proc Kratos::InitGlobalVariables {dir} {
157163
set kratos_private(ProjectIsNew) 1
158164
# Variables from the problemtype definition (kratos.xml)
159165
array set kratos_private [ReadProblemtypeXml [file join $kratos_private(Path) kratos.xml] Infoproblemtype {Name Version CheckMinimumGiDVersion}]
160-
# Version of the kratos executable
161-
set kratos_private(exec_version) "dev"
162-
# Allow logs -> 0 No | 1 Only local | 2 Share with dev team
163-
set Kratos::kratos_private(allow_logs) 1
164166
}
165167

166168
proc Kratos::LoadCommonScripts { } {
@@ -400,6 +402,8 @@ proc Kratos::Event_AfterMeshGeneration {fail} {
400402
set endtime [clock seconds]
401403
set ttime [expr {$endtime-$tmp_init_mesh_time}]
402404
Kratos::Log "Mesh end process in [Duration $ttime]"
405+
set mesh_data [Kratos::GetMeshBasicData]
406+
Kratos::Log "Mesh data -> [write::tcl2json $mesh_data]"
403407
}
404408

405409
proc Kratos::Event_AfterRenameGroup { oldname newname } {

kratos.gid/scripts/Utils.tcl

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,22 @@ proc Kratos::LogInitialData { } {
193193

194194
# Get the exec version
195195
Kratos::GetExecVersion
196+
Kratos::GetProblemtypeGitTag
196197

197198
set initial_data [dict create]
198199
dict set initial_data GiD_version [GiD_Info gidversion]
199-
dict set initial_data problemtype_git_hash "68418871cff2b897f7fb9176827871b339fe5f91"
200+
dict set initial_data problemtype_git_hash $Kratos::kratos_private(problemtype_git_hash)
201+
dict set initial_data problemtype_version $Kratos::kratos_private(Version)
200202
dict set initial_data executable_version $Kratos::kratos_private(exec_version)
201203
dict set initial_data current_platform $::tcl_platform(platform)
204+
dict set initial_data gid_version [GiD_Info gidversion]
202205

203206
Kratos::Log [write::tcl2json $initial_data]
204207
}
205208

206209

207210
proc Kratos::Duration { int_time } {
211+
if {$int_time == 0} {return "0 sec"}
208212
set timeList [list]
209213
foreach div {86400 3600 60 1} mod {0 24 60 60} name {day hr min sec} {
210214
set n [expr {$int_time / $div}]
@@ -237,4 +241,31 @@ proc Kratos::GetExecVersion {} {
237241
}
238242
}
239243
}
244+
}
245+
proc Kratos::GetProblemtypeGitTag {} {
246+
catch {
247+
variable kratos_private
248+
set tmp_filename [GidUtils::GetTmpFilename]
249+
set result [exec git -C $kratos_private(Path) log --format="%H" -n 1 >> $tmp_filename]
250+
set fp [open $tmp_filename r]
251+
set file_data [read $fp]
252+
close $fp
253+
file delete $tmp_filename
254+
set data [split $file_data "\n"]
255+
set kratos_private(problemtype_git_hash) [string trim [string trim [lindex $data 0]] "\""]
256+
}
257+
}
258+
259+
proc Kratos::GetMeshBasicData { } {
260+
set result [dict create]
261+
foreach element_type [GidUtils::GetElementTypes all] {
262+
set ne [GiD_Info Mesh NumElements $element_type]
263+
if { $ne } {
264+
dict set result $element_type $ne
265+
}
266+
}
267+
268+
dict set result nodes [GiD_Info Mesh NumNodes]
269+
dict set result is_quadratic [expr [GiD_Info Project Quadratic] && ![GiD_Cartesian get iscartesian] ]
270+
return $result
240271
}

kratos.gid/scripts/Writing/Writing.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ proc write::writeEvent { filename } {
115115

116116
#### MDPA Write ####
117117
if {$errcode eq 0} {
118-
Kratos::Log "Write app MDPA $appid"
118+
Kratos::Log "Write MDPA $appid"
119119
set errcode [writeAppMDPA $appid]
120120
}
121121
#### Project Parameters Write ####

0 commit comments

Comments
 (0)