-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathwrite.tcl
More file actions
147 lines (118 loc) · 4.51 KB
/
Copy pathwrite.tcl
File metadata and controls
147 lines (118 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
namespace eval MPM::write {
namespace path ::MPM
Kratos::AddNamespace [namespace current]
variable writeAttributes
variable ConditionsDictGroupIterators [dict create]
variable grid_elems [list GRID2D GRID3D]
}
proc MPM::write::Init { } {
SetAttribute parts_un [::MPM::GetUniqueName parts]
SetAttribute nodal_conditions_un [::MPM:::GetUniqueName nodal_conditions]
SetAttribute conditions_un [::MPM::GetUniqueName conditions]
SetAttribute initial_conditions_un [::MPM::GetUniqueName initial_conditions]
SetAttribute writeCoordinatesByGroups [::MPM::GetWriteProperty coordinates]
SetAttribute main_launch_file [::MPM::GetAttribute main_launch_file]
SetAttribute materials_file [::MPM::GetWriteProperty materials_file]
SetAttribute properties_location [::MPM::GetWriteProperty properties_location]
SetAttribute model_part_name [::MPM::GetWriteProperty model_part_name]
SetAttribute write_mdpa_mode [::MPM::GetWriteProperty write_mdpa_mode]
}
# Events
proc MPM::write::writeModelPartEvent { } {
write::initWriteConfiguration [Structural::write::GetAttributes]
write::initWriteConfiguration [GetAttributes]
MPM::write::UpdateMaterials
set filename [Kratos::GetModelName]
## Grid MPDA ##
MPM::write::WriteGridMDPA
write::CloseFile
write::RenameFileInModel "$filename.mdpa" "${filename}_Grid.mdpa"
## Body MDPA ##
write::OpenFile "${filename}_Body.mdpa"
# Headers
MPM::write::WriteBodyMDPA
write::CloseFile
}
proc MPM::write::GetPartsGroupsNames { part_type } {
set groups [MPM::write::GetPartsGroups $part_type]
set result [list ]
foreach group $groups {
lappend result [$group @n]
}
return $result
}
proc MPM::write::GetPartsGroups { part_type } {
variable grid_elems
set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/condition/group"
set body_groups [list ]
foreach gNode [[customlib::GetBaseRoot] selectNodes $xp1] {
set elem [write::getValueByNode [$gNode selectNodes ".//value\[@n='Element'\]"] ]
if {($part_type eq "grid" && $elem in $grid_elems) || ($part_type ne "grid" && $elem ni $grid_elems)} {
lappend body_groups $gNode
}
}
return $body_groups
}
proc ::MPM::write::GetUsedElements { {get "Objects"} } {
set lista [list ]
foreach gNode [MPM::write::GetPartsGroups Body] {
set elem_name [write::getValueByNode [$gNode selectNodes ".//value\[@n='Element']"] ]
set e [Model::getElement $elem_name]
if {$get eq "Name"} { set e [$e getName] }
lappend lista $e
}
return $lista
}
proc MPM::write::writeSubmodelparts { type } {
foreach group [MPM::write::GetPartsGroupsNames $type] {
write::writeGroupSubModelPartAsGeometry $group
}
}
proc MPM::write::GetConditionsGroups { } {
set groups [::write::GetGroupsNamesAssignedIn [GetAttribute conditions_un]]
return $groups
}
proc MPM::write::writeCustomFilesEvent { } {
# Materials file
set mats_json [dict get [write::getPropertiesList [GetAttribute parts_un] True Initial_MPM_Material] properties ]
set new_mats [list ]
foreach mat $mats_json {
set type [dict exists $mat Material constitutive_law]
# if {$type eq 0} {
# set submodelpart [lindex [split [dict get $mat model_part_name] "."] end]
# dict set mat model_part_name Background_Grid.$submodelpart
# }
if {$type eq 1} {
lappend new_mats $mat
}
}
write::OpenFile [GetAttribute materials_file]
write::WriteJSON [dict create properties $new_mats]
write::CloseFile
write::SetConfigurationAttribute main_launch_file [GetAttribute main_launch_file]
}
proc MPM::write::UpdateMaterials { } {
set matdict [write::getMatDict]
foreach {mat props} $matdict {
# Modificar la ley constitutiva
dict set matdict $mat THICKNESS 1.0000E+00
set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/condition/group\[@n='$mat'\]/value\[@n='THICKNESS'\]"
set vNode [[customlib::GetBaseRoot] selectNodes $xp1]
if {$vNode ne ""} {
dict set matdict $mat THICKNESS [write::getValueByNode $vNode]
}
}
write::setMatDict $matdict
}
proc MPM::write::GetAttribute {att} {
variable writeAttributes
return [dict get $writeAttributes $att]
}
proc MPM::write::GetAttributes {} {
variable writeAttributes
return $writeAttributes
}
proc MPM::write::SetAttribute {att val} {
variable writeAttributes
dict set writeAttributes $att $val
}