Skip to content

Commit

Permalink
[Dam] Add initial joint width to joints and fix problem with tables (#…
Browse files Browse the repository at this point in the history
…984)

* Add INITAL_JOINT_WIDTH

* Set INITIAL_JOINT_WIDTH to 1

* Translate comments

* Fix problem with TableDict

* Change name of Bofang's Law variable (Day maximum temperature)

* Set initial joint width to 0
  • Loading branch information
joaquinirazabal authored Jul 10, 2024
1 parent c1daa19 commit 33036bd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
2 changes: 1 addition & 1 deletion kratos.gid/apps/Dam/examples/ThermoMechaDam2D.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ proc ::Dam::examples::ThermoMechaDam2D::TreeAssignation {args} {
# Bofang Temperature
set bofang_temperature "$damDirichletConditions/condition\[@n='BOFANGTEMPERATURE'\]"
set bofang_temperature_node [customlib::AddConditionGroupOnXPath $bofang_temperature Water]
set props_bofang_temperature [list is_fixed 1 Gravity_Direction Y Reservoir_Bottom_Coordinate_in_Gravity_Direction 0.0 Surface_Temp 15.19 Bottom_Temp 9.35 Height_Dam 30.0 Temperature_Amplitude 6.51 Day_Ambient_Temp 201 Water_level 20.0 Month 7 ]
set props_bofang_temperature [list is_fixed 1 Gravity_Direction Y Reservoir_Bottom_Coordinate_in_Gravity_Direction 0.0 Surface_Temp 15.19 Bottom_Temp 9.35 Height_Dam 30.0 Temperature_Amplitude 6.51 Day_Max_Temp 201 Water_level 20.0 Month 7 ]
spdAux::SetValuesOnBaseNode $bofang_temperature_node $props_bofang_temperature

# Uniform Temperature
Expand Down
48 changes: 28 additions & 20 deletions kratos.gid/apps/Dam/write/write.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ namespace eval ::Dam::write {

variable ThermalSubModelPartDict

# Variable global definida al principio y utilizada para transferir entre procesos el número de tablas existentes
# Global variable defined at the beginning and used to transfer between processes the number of existing tables
variable number_tables
}

proc ::Dam::write::Init { } {
# Namespace variables inicialization
# Namespace variables initialization
variable ConditionsDictGroupIterators
variable NodalConditionsGroup
set ConditionsDictGroupIterators [dict create]
Expand Down Expand Up @@ -67,21 +67,28 @@ proc ::Dam::write::UpdateMaterials { } {
set matdict [write::getMatDict]
foreach {mat props} $matdict {
set constlaw [dict get $props ConstitutiveLaw]
# Modificar la ley constitutiva
# Modify constitutive law
set newconstlaw $constlaw
if {$constlaw eq "ElasticCohesive3DLaw"} {
dict set matdict $mat INITIAL_JOINT_WIDTH 0.0
}
if {$constlaw eq "ElasticCohesive2DPlaneStrain"} {
dict set matdict $mat INITIAL_JOINT_WIDTH 0.0
dict set matdict $mat THICKNESS 1.0
set newconstlaw "ElasticCohesive2DLaw"
}
if {$constlaw eq "ElasticCohesive2DPlaneStress"} {
dict set matdict $mat INITIAL_JOINT_WIDTH 0.0
dict set matdict $mat THICKNESS 1.0
set newconstlaw "ElasticCohesive2DLaw"
}
if {$constlaw eq "IsotropicDamageCohesive2DPlaneStress"} {
dict set matdict $mat INITIAL_JOINT_WIDTH 0.0
dict set matdict $mat THICKNESS 1.0
set newconstlaw "IsotropicDamageCohesive2DLaw"
}
if {$constlaw eq "IsotropicDamageCohesive2DPlaneStrain"} {
dict set matdict $mat INITIAL_JOINT_WIDTH 0.0
dict set matdict $mat THICKNESS 1.0
set newconstlaw "IsotropicDamageCohesive2DLaw"
}
Expand Down Expand Up @@ -116,10 +123,10 @@ proc ::Dam::write::writeMeshes { } {
Dam::write::ThermalSubModelPart
}

# Solo Malla , no en conditions
# Only mesh, not in the condition
writeNodalConditions [GetAttribute nodal_conditions_un]

# A Condition y a meshes-> salvo lo que no tenga topologia
# To conditions and to meshes-> unless it does not have a topology
writeLoads [GetAttribute conditions_un]
writeLoads [GetAttribute thermal_conditions_un]
writeLoads [GetAttribute nodal_conditions_un]
Expand Down Expand Up @@ -214,6 +221,7 @@ proc ::Dam::write::writeTables { } {
set printed_tables [list ]
foreach table [GetPrinTables] {
lassign $table tableid fileid condid groupid valueid
set groupid [write::GetWriteGroupName $groupid]
dict set TableDict $condid $groupid $valueid tableid $tableid
dict set TableDict $condid $groupid $valueid fileid $fileid
if {$tableid ni $printed_tables} {
Expand Down Expand Up @@ -258,8 +266,8 @@ proc ::Dam::write::GetPrinTables {} {

set root [customlib::GetBaseRoot]
if {$Kratos::kratos_private(UseFiles) eq 1} {FileSelector::CopyFilesIntoModel [file join [GiD_Info project ModelName] ".gid"]}
set listaTablas [list ]
set listaFiles [list ]
set tableid_list [list ]
set files_list [list ]
set num 0
set origins [list [GetAttribute conditions_un] [GetAttribute thermal_conditions_un] [GetAttribute nodal_conditions_un] "DamSelfweight"]
foreach unique_name $origins {
Expand All @@ -271,31 +279,31 @@ proc ::Dam::write::GetPrinTables {} {
set condid [get_domnode_attribute [[$node parent] parent] n]
# W $fileid
if {$fileid ni [list "" "- No file" $::spdAux::no_file_string]} {
if {$fileid ni $listaFiles} {
lappend listaFiles $fileid
if {$fileid ni $files_list} {
lappend files_list $fileid
incr num
set tableid $num
} else {
set tableid 0
foreach table $listaTablas {
foreach table $tableid_list {
lassign $table tableid2 fileid2 condid2 groupid2 valueid2
if {$fileid2 eq $fileid} {set tableid $tableid2; break}
}
}
#W "$tableid $fileid $condid $groupid $valueid"
lappend listaTablas [list $tableid $fileid $condid $groupid $valueid]
lappend tableid_list [list $tableid $fileid $condid $groupid $valueid]
}
}
}
return $listaTablas
return $tableid_list
}

proc ::Dam::write::GetPrinTables_dev { } {

set root [customlib::GetBaseRoot]
if {$Kratos::kratos_private(UseFiles) eq 1} {FileSelector::CopyFilesIntoModel [file join [GiD_Info project ModelName] ".gid"]}
set listaTablas2 [list ]
set listaFiles2 [list ]
set tableid_list2 [list ]
set files_list2 [list ]
set num [llength [GetPrinTables]]

set path_devices "[spdAux::getRoute DamTempDevice]/blockdata\[@n='device'\]"
Expand All @@ -308,22 +316,22 @@ proc ::Dam::write::GetPrinTables_dev { } {
set fileid [write::getValueByNode $node_table_device]

if {$fileid ni [list "" "- No file" $::spdAux::no_file_string]} {
if {$fileid ni $listaFiles2} {
lappend listaFiles2 $fileid
if {$fileid ni $files_list2} {
lappend files_list2 $fileid
incr num
set tableid $num
} else {
set tableid 0
foreach table $listaTablas2 {
foreach table $tableid_list2 {
lassign $table tableid2 fileid2
if {$fileid2 eq $fileid} {set tableid $tableid2; break}
}
}
#W "$tableid $fileid $condid $groupid $valueid"
lappend listaTablas2 [list $tableid $fileid]
lappend tableid_list2 [list $tableid $fileid]
}
}
return $listaTablas2
return $tableid_list2
}

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -359,7 +367,7 @@ proc ::Dam::write::writeThermalElements {} {
Dam::write::writeThermalConnectivities [lindex $ThermalGroups $i] hexahedra EulerianConvDiff3D8N "Dam::write::Hexahedron3D8Connectivities" ElementId ElementList

dict set ThermalSubModelPartDict [lindex $ThermalGroups $i] Elements $ElementList
# Añado guiones bajos donde hay espacios en los nombres de los submodelparts.
# Replace spaces with underscoresn the submodelpart names
set old_name_SubModelPart "Thermal_[lindex $ThermalGroups $i]"
set new_name_SubModelPart [string map {" " "_"} $old_name_SubModelPart]
dict set ThermalSubModelPartDict [lindex $ThermalGroups $i] SubModelPartName $new_name_SubModelPart
Expand Down
14 changes: 7 additions & 7 deletions kratos.gid/apps/Dam/write/writeProjectParameters.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ proc ::Dam::write::DefinitionDomains { } {
# This process assign a number for the different tables instead of names (this is for matching with .mdpa)
proc ::Dam::write::ChangeFileNameforTableid { processList } {

# Variable global definida al principio y utilizada para transferir entre procesos el número de tablas existentes
# Global variable defined at the beginning and used to transfer between processes the number of existing tables
variable number_tables

set returnList [list ]
Expand Down Expand Up @@ -862,12 +862,12 @@ proc ::Dam::write::DevicesOutput { } {

proc ::Dam::write::TemperaturebyDevices { } {

# Variable global definida al principio y utilizada para transferir entre procesos el número de tablas existentes
# Global variable defined at the beginning and used to transfer between processes the number of existing tables
variable number_tables

set device_temp_state [write::getValue DamTemperatureState]
set lista [list ]
set listaFiles [list ]
set files_list [list ]

if { $device_temp_state == True} {

Expand Down Expand Up @@ -919,13 +919,13 @@ proc ::Dam::write::TemperaturebyDevices { } {
dict set parameterDict value $value

if {$fileid ni [list "" "- No file" $::spdAux::no_file_string]} {
if {$fileid ni $listaFiles} {
lappend listaFiles $fileid
if {$fileid ni $files_list} {
lappend files_list $fileid
incr number_devices
dict set parameterDict table [expr $number_tables + $number_devices]
} else {
for {set i 0} {$i < [llength $listaFiles]} {incr i} {
if {$fileid eq [lindex $listaFiles $i]} {
for {set i 0} {$i < [llength $files_list]} {incr i} {
if {$fileid eq [lindex $files_list $i]} {
dict set parameterDict table [expr $number_tables + $i + 1]
break
}
Expand Down
2 changes: 1 addition & 1 deletion kratos.gid/apps/Dam/xml/Processes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<parameter n="Bottom_Temp" pn="Bottom Temperature" type="double" v="0.0"/>
<parameter n="Height_Dam" pn="Height Dam" type="double" v="0.0"/>
<parameter n="Temperature_Amplitude" pn="Temperature Amplitude" type="double" v="0.0"/>
<parameter n="Day_Ambient_Temp" pn="Day" type="integer" v="0.0"/>
<parameter n="Day_Max_Temp" pn="Day Maximum Temperature" type="integer" v="0.0"/>
<parameter n="Water_level" pn="Water Level" type="double" v="0.0"/>
<parameter n="Water_level_Table" pn="Water Level table filename" type="tablefile" v=""/>
<parameter n="Month" pn="Month" type="double" v="0.0"/>
Expand Down

0 comments on commit 33036bd

Please sign in to comment.