@@ -100,4 +100,127 @@ proc Pfem::write::writeCustomFilesEvent { } {
100
100
# write::RenameFileInModel "ProjectParameters.json" "ProjectParameters.py"
101
101
}
102
102
103
+
104
+ proc Pfem::write::getConditionsParametersDict {un {condition_type " Condition" }} {
105
+
106
+ set root [customlib::GetBaseRoot]
107
+
108
+ set bcCondsDict [list ]
109
+
110
+ set xp1 " [ spdAux::getRoute $un ] /condition/group"
111
+ set groups [$root selectNodes $xp1 ]
112
+ if {$groups eq " " } {
113
+ set xp1 " [ spdAux::getRoute $un ] /group"
114
+ set groups [$root selectNodes $xp1 ]
115
+ }
116
+ foreach group $groups {
117
+ set groupName [$group @n]
118
+ set cid [[$group parent] @n]
119
+ set groupName [write::GetWriteGroupName $groupName ]
120
+ set groupId [::write::getMeshId $cid $groupName ]
121
+ set condId [[$group parent] @n]
122
+ if {$condition_type eq " Condition" } {
123
+ set condition [::Model::getCondition $condId ]
124
+ } {
125
+ set condition [::Model::getNodalConditionbyId $condId ]
126
+ }
127
+ set processName [$condition getProcessName]
128
+ set process [::Model::GetProcess $processName ]
129
+ set processDict [dict create]
130
+ set paramDict [dict create]
131
+ dict set paramDict model_part_name $groupId
132
+
133
+ set process_attributes [$process getAttributes]
134
+ set process_parameters [$process getInputs]
135
+
136
+ dict set process_attributes process_name [dict get $process_attributes n]
137
+ dict unset process_attributes n
138
+ dict unset process_attributes pn
139
+
140
+ set processDict [dict merge $processDict $process_attributes ]
141
+ if {[$condition hasAttribute VariableName]} {
142
+ set variable_name [$condition getAttribute VariableName]
143
+ # "lindex" is a rough solution. Look for a better one.
144
+ if {$variable_name ne " " } {dict set paramDict variable_name [lindex $variable_name 0]}
145
+ }
146
+ foreach {inputName in_obj} $process_parameters {
147
+ set in_type [$in_obj getType]
148
+ if {$in_type eq " vector" } {
149
+ set vector_type [$in_obj getAttribute " vectorType" ]
150
+ if {$vector_type eq " bool" } {
151
+ set ValX [expr [get_domnode_attribute [$group find n ${inputName} X] v] ? True : False]
152
+ set ValY [expr [get_domnode_attribute [$group find n ${inputName} Y] v] ? True : False]
153
+ set ValZ [expr False]
154
+ if {[$group find n ${inputName} Z] ne " " } {set ValZ [expr [get_domnode_attribute [$group find n ${inputName} Z] v] ? True : False]}
155
+ dict set paramDict $inputName [list $ValX $ValY $ValZ ]
156
+ } {
157
+ if {[$in_obj getAttribute " enabled" ] in [list " 1" " 0" ]} {
158
+ foreach i [list " X" " Y" " Z" ] {
159
+ if {[expr [get_domnode_attribute [$group find n Enabled_$i ] v] ] ne " Yes" } {
160
+ set Val$i null
161
+ } else {
162
+ set printed 0
163
+ if {[$in_obj getAttribute " function" ] eq " 1" } {
164
+ if {[get_domnode_attribute [$group find n " ByFunction$i " ] v] eq " Yes" } {
165
+ set funcinputName " ${i} function_$inputName "
166
+ set value [get_domnode_attribute [$group find n $funcinputName ] v]
167
+ set Val$i $value
168
+ set printed 1
169
+ }
170
+ }
171
+ if {!$printed } {
172
+ set value [expr [gid_groups_conds::convert_value_to_default [$group find n ${inputName}$i ] ] ]
173
+ set Val$i $value
174
+ }
175
+ }
176
+ }
177
+ } elseif {$vector_type eq " tablefile" || $vector_type eq " file" } {
178
+ set ValX " [ get_domnode_attribute [$group find n ${inputName} X] v]"
179
+ set ValY " [ get_domnode_attribute [$group find n ${inputName} Y] v]"
180
+ set ValZ " 0"
181
+ if {[$group find n ${inputName} Z] ne " " } {set ValZ " [ get_domnode_attribute [$group find n ${inputName} Z] v]" }
182
+ } else {
183
+ set ValX [expr [gid_groups_conds::convert_value_to_default [$group find n ${inputName} X] ] ]
184
+ set ValY [expr [gid_groups_conds::convert_value_to_default [$group find n ${inputName} Y] ] ]
185
+ set ValZ [expr 0.0]
186
+ if {[$group find n ${inputName} Z] ne " " } {set ValZ [expr [gid_groups_conds::convert_value_to_default [$group find n ${inputName} Z] ]]}
187
+ }
188
+ dict set paramDict $inputName [list $ValX $ValY $ValZ ]
189
+ }
190
+ } elseif {$in_type eq " double" || $in_type eq " integer" } {
191
+ set printed 0
192
+ if {[$in_obj getAttribute " function" ] eq " 1" } {
193
+ if {[get_domnode_attribute [$group find n " ByFunction" ] v] eq " Yes" } {
194
+ set funcinputName " function_$inputName "
195
+ set value [get_domnode_attribute [$group find n $funcinputName ] v]
196
+ dict set paramDict $inputName $value
197
+ set printed 1
198
+ }
199
+ }
200
+ if {!$printed } {
201
+ set value [gid_groups_conds::convert_value_to_default [$group find n $inputName ]]
202
+ # set value [get_domnode_attribute [$group find n $inputName] v]
203
+ dict set paramDict $inputName [expr $value ]
204
+ }
205
+ } elseif {$in_type eq " bool" } {
206
+ set value [get_domnode_attribute [$group find n $inputName ] v]
207
+ set value [expr $value ? True : False]
208
+ dict set paramDict $inputName [expr $value ]
209
+ } elseif {$in_type eq " tablefile" } {
210
+ set value [get_domnode_attribute [$group find n $inputName ] v]
211
+ dict set paramDict $inputName $value
212
+ } else {
213
+ if {[get_domnode_attribute [$group find n $inputName ] state] ne " hidden" } {
214
+ set value [get_domnode_attribute [$group find n $inputName ] v]
215
+ dict set paramDict $inputName $value
216
+ }
217
+ }
218
+ }
219
+ if {[$group find n Interval] ne " " } {dict set paramDict interval [write::getInterval [get_domnode_attribute [$group find n Interval] v]] }
220
+ dict set processDict Parameters $paramDict
221
+ lappend bcCondsDict $processDict
222
+ }
223
+ return $bcCondsDict
224
+ }
225
+
103
226
Pfem::write::Init
0 commit comments