1- proc DEM ::write::WriteMDPAParts { } {
1+ proc CDEM ::write::WriteMDPAParts { } {
22 variable last_property_id
33
44 # Prepare properties
@@ -31,14 +31,14 @@ proc DEM::write::WriteMDPAParts { } {
3131
3232 # SubmodelParts
3333 write::writePartSubModelPart
34- if {$::Model::SpatialDimension eq " 2D" } { writeVelocityMeshes2D
35- } else {writeVelocityMeshes }
34+ if {$::Model::SpatialDimension eq " 2D" } {DEM::write::writeDEMConditionMeshes2D
35+ } else {DEM::write::writeDEMConditionMeshes }
3636
3737 # CustomSubmodelParts
3838 # WriteWallCustomDEMSmp not required for dem.
3939}
4040
41- proc DEM ::write::WriteWallCustomDEMSmp { } {
41+ proc CDEM ::write::WriteWallCustomDEMSmp { } {
4242 set xp1 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = 'DEM-CustomSmp'\] /group"
4343 foreach group [[customlib::GetBaseRoot] selectNodes $xp1 ] {
4444 set groupid [$group @n]
@@ -57,7 +57,7 @@ proc DEM::write::WriteWallCustomDEMSmp { } {
5757 }
5858}
5959
60- proc DEM ::write::GetDEMGroupsCustomSubmodelpart { } {
60+ proc CDEM ::write::GetDEMGroupsCustomSubmodelpart { } {
6161 set groups [list ]
6262 set xp2 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = 'DEM-CustomSmp'\] /group"
6363 foreach group [[customlib::GetBaseRoot] selectNodes $xp2 ] {
@@ -70,7 +70,7 @@ proc DEM::write::GetDEMGroupsCustomSubmodelpart { } {
7070 return $groups
7171}
7272
73- proc DEM ::write::GetDEMGroupsInitialC { } {
73+ proc CDEM ::write::GetDEMGroupsInitialC { } {
7474 set groups [list ]
7575 set xp3 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = 'DEM-VelocityIC'\] /group"
7676 foreach group [[customlib::GetBaseRoot] selectNodes $xp3 ] {
@@ -80,7 +80,7 @@ proc DEM::write::GetDEMGroupsInitialC { } {
8080 return $groups
8181}
8282
83- proc DEM ::write::GetDEMGroupsBoundayC { } {
83+ proc CDEM ::write::GetDEMGroupsBoundayC { } {
8484 set groups [list ]
8585 set xp4 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = 'DEM-VelocityBC'\] /group"
8686 foreach group [[customlib::GetBaseRoot] selectNodes $xp4 ] {
@@ -91,7 +91,7 @@ proc DEM::write::GetDEMGroupsBoundayC { } {
9191}
9292
9393
94- proc DEM ::write::writeSphereRadius { } {
94+ proc CDEM ::write::writeSphereRadius { } {
9595 set root [customlib::GetBaseRoot]
9696 set xp1 " [ spdAux::getRoute [GetAttribute partscont_un] ]/group"
9797 foreach group [$root selectNodes $xp1 ] {
@@ -105,7 +105,7 @@ proc DEM::write::writeSphereRadius { } {
105105}
106106
107107
108- proc DEM ::write::writeCohesiveGroups { } {
108+ proc CDEM ::write::writeCohesiveGroups { } {
109109 set root [customlib::GetBaseRoot]
110110 if {$::Model::SpatialDimension eq " 3D" } {
111111 set xp1 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = 'DEM-Cohesive'\] /group"
@@ -125,7 +125,7 @@ proc DEM::write::writeCohesiveGroups { } {
125125 }
126126}
127127
128- proc DEM ::write::writeSkinSphereNodes { } {
128+ proc CDEM ::write::writeSkinSphereNodes { } {
129129 # Write Skin Sphere
130130 set number 1
131131 set list_of_active_dem_elements " "
@@ -147,7 +147,7 @@ proc DEM::write::writeSkinSphereNodes { } {
147147
148148
149149
150- proc DEM ::write::GetNodalConditionsGroups { {include_cond 0} } {
150+ proc CDEM ::write::GetNodalConditionsGroups { {include_cond 0} } {
151151 set groups [list ]
152152 set xp1 " [ spdAux::getRoute [GetAttribute nodal_conditions_un] ]/condition/group"
153153 foreach group [[customlib::GetBaseRoot] selectNodes $xp1 ] {
@@ -164,280 +164,33 @@ proc DEM::write::GetNodalConditionsGroups { {include_cond 0} } {
164164# }
165165# }
166166
167- proc DEM::write::writeVelocityMeshes { } {
168- set i 0
169- foreach {cond group_list} [GetSpheresGroupsListInConditions] {
170- if {$cond eq " DEM-VelocityBC" } {
171- set cnd [Model::getCondition $cond ]
172- foreach group $group_list {
173- incr i
174- write::WriteString " Begin SubModelPart $i // GUI DEM-VelocityBC - $cond - group identifier: $group "
175- write::WriteString " Begin SubModelPartData // DEM-VelocityBC. Group name: $group "
176- set xp1 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = '$cond '\] /group\[ @n = '$group '\] "
177- set group_node [[customlib::GetBaseRoot] selectNodes $xp1 ]
178-
179- set prescribeMotion_flag [write::getValueByNode [$group_node selectNodes " ./value\[ @n='PrescribeMotion_flag'\] " ]]
180- if {[write::isBooleanTrue $prescribeMotion_flag ]} {
181-
182- # Linear velocity
183- set velocity [write::getValueByNode [$group_node selectNodes " ./value\[ @n='VelocityModulus'\] " ]]
184- lassign [write::getValueByNode [$group_node selectNodes " ./value\[ @n='DirectionVector'\] " ]] velocity_X velocity_Y velocity_Z
185- lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y $velocity_Z ]] velocity_X velocity_Y velocity_Z
186- lassign [MathUtils::ScalarByVectorProd $velocity [list $velocity_X $velocity_Y $velocity_Z ] ] vx vy vz
187- write::WriteString " LINEAR_VELOCITY \[ 3\] ($vx , $vy , $vz )"
188-
189- # Period
190- set periodic [write::getValueByNode [$group_node selectNodes " ./value\[ @n='LinearPeriodic'\] " ]]
191- if {[write::isBooleanTrue $periodic ]} {
192- set period [write::getValueByNode [$group_node selectNodes " ./value\[ @n='LinearPeriod'\] " ]]
193- } else {
194- set period 0.0
195- }
196- write::WriteString " VELOCITY_PERIOD $period "
197-
198- # Angular velocity
199- set velocity [write::getValueByNode [$group_node selectNodes " ./value\[ @n='AngularVelocityModulus'\] " ]]
200- lassign [write::getValueByNode [$group_node selectNodes " ./value\[ @n='AngularDirectionVector'\] " ]] velocity_X velocity_Y velocity_Z
201- lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y $velocity_Z ]] velocity_X velocity_Y velocity_Z
202- lassign [MathUtils::ScalarByVectorProd $velocity [list $velocity_X $velocity_Y $velocity_Z ] ] wX wY wZ
203- write::WriteString " ANGULAR_VELOCITY \[ 3\] ($wX ,$wY ,$wZ )"
204-
205-
206- # Angular center of rotation
207- lassign [write::getValueByNode [$group_node selectNodes " ./value\[ @n='CenterOfRotation'\] " ]] oX oY oZ
208- write::WriteString " ROTATION_CENTER \[ 3\] ($oX ,$oY ,$oZ )"
209-
210-
211- # Angular Period
212- set angular_periodic [write::getValueByNode [$group_node selectNodes " ./value\[ @n='AngularPeriodic'\] " ]]
213- if {[write::isBooleanTrue $angular_periodic ]} {
214- set angular_period [write::getValueByNode [$group_node selectNodes " ./value\[ @n='AngularPeriod'\] " ]]
215- } else {
216- set angular_period 0.0
217- }
218- write::WriteString " ANGULAR_VELOCITY_PERIOD $angular_period "
219-
220- # set intervals
221- set LinearStartTime [write::getValueByNode [$group_node selectNodes " ./value\[ @n='LinearStartTime'\] " ]]
222- set LinearEndTime [write::getValueByNode [$group_node selectNodes " ./value\[ @n='LinearEndTime'\] " ]]
223- set AngularStartTime [write::getValueByNode [$group_node selectNodes " ./value\[ @n='AngularStartTime'\] " ]]
224- set AngularEndTime [write::getValueByNode [$group_node selectNodes " ./value\[ @n='AngularEndTime'\] " ]]
225- write::WriteString " VELOCITY_START_TIME $LinearStartTime "
226- write::WriteString " VELOCITY_STOP_TIME $LinearEndTime "
227- write::WriteString " ANGULAR_VELOCITY_START_TIME $AngularStartTime "
228- write::WriteString " ANGULAR_VELOCITY_STOP_TIME $AngularEndTime "
229-
230- # Interval. # TODO, able to assign intervals as start and end time. Both linear and angular could be different
231- # set interval [write::getValueByNode [$group_node selectNodes "./value\[@n='Interval'\]"]]
232- # lassign [write::getInterval $interval] ini end
233- # if {![string is double $ini]} {
234- # set ini [write::getValue DEMTimeParameters StartTime]
235- # }
236- # write::WriteString " ${cond}_START_TIME $ini"
237- # if {![string is double $end]} {
238- # set end [write::getValue DEMTimeParameters EndTime]
239- # }
240- # write::WriteString " ${cond}_STOP_TIME $end"
241- }
242-
243- write::WriteString " End SubModelPartData"
244- write::WriteString " Begin SubModelPartNodes"
245- GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $group ] [subst " %10i\n " ]]
246- write::WriteString " End SubModelPartNodes"
247- write::WriteString " End SubModelPart"
248- write::WriteString " "
249- }
250- } elseif {$cond eq " DEM-VelocityIC" } {
251- set cnd [Model::getCondition $cond ]
252- foreach group $group_list {
253- incr i
254- write::WriteString " Begin SubModelPart $i // GUI DEM-VelocityIC - $cond - group identifier: $group "
255- write::WriteString " Begin SubModelPartData // DEM-VelocityIC. Group name: $group "
256- set xp1 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = '$cond '\] /group\[ @n = '$group '\] "
257- set group_node [[customlib::GetBaseRoot] selectNodes $xp1 ]
258-
259- set prescribeMotion_flag [write::getValueByNode [$group_node selectNodes " ./value\[ @n='PrescribeMotion_flag'\] " ]]
260- if {[write::isBooleanTrue $prescribeMotion_flag ]} {
261-
262- # Linear velocity
263- set velocity [write::getValueByNode [$group_node selectNodes " ./value\[ @n='InitialVelocityModulus'\] " ]]
264- lassign [write::getValueByNode [$group_node selectNodes " ./value\[ @n='iDirectionVector'\] " ]] velocity_X velocity_Y velocity_Z
265- lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y $velocity_Z ]] velocity_X velocity_Y velocity_Z
266- lassign [MathUtils::ScalarByVectorProd $velocity [list $velocity_X $velocity_Y $velocity_Z ] ] vx vy vz
267- # write::WriteString " INITIAL_VELOCITY \[3\] ($vx, $vy, $vz)" # why arent we using vectorial def for this
268- write::WriteString " INITIAL_VELOCITY_X_VALUE $vx "
269- write::WriteString " INITIAL_VELOCITY_Y_VALUE $vy "
270- write::WriteString " INITIAL_VELOCITY_Z_VALUE $vz "
271-
272- # Angular velocity
273- set avelocity [write::getValueByNode [$group_node selectNodes " ./value\[ @n='InitialAngularVelocityModulus'\] " ]]
274- lassign [write::getValueByNode [$group_node selectNodes " ./value\[ @n='iAngularDirectionVector'\] " ]] velocity_X velocity_Y velocity_Z
275- lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y $velocity_Z ]] velocity_X velocity_Y velocity_Z
276- lassign [MathUtils::ScalarByVectorProd $avelocity [list $velocity_X $velocity_Y $velocity_Z ] ] wX wY wZ
277- # write::WriteString " INITIAL_ANGULAR_VELOCITY \[3\] ($wX,$wY,$wZ)"
278-
279- write::WriteString " INITIAL_ANGULAR_VELOCITY_X_VALUE $wX "
280- write::WriteString " INITIAL_ANGULAR_VELOCITY_Y_VALUE $wY "
281- write::WriteString " INITIAL_ANGULAR_VELOCITY_Z_VALUE $wZ "
282- }
283-
284- write::WriteString " End SubModelPartData"
285- write::WriteString " Begin SubModelPartNodes"
286- GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $group ] [subst " %10i\n " ]]
287- write::WriteString " End SubModelPartNodes"
288- write::WriteString " End SubModelPart"
289- write::WriteString " "
290- }
291- }
292- }
293- }
294-
295-
296- proc DEM::write::writeVelocityMeshes2D { } {
297- set i 0
298- foreach {cond group_list} [GetSpheresGroupsListInConditions] {
299- if {$cond eq " DEM-VelocityBC2D" } {
300- set cnd [Model::getCondition $cond ]
301- foreach group $group_list {
302- incr i
303- write::WriteString " Begin SubModelPart $i // GUI DEM-VelocityBC - $cond - group identifier: $group "
304- write::WriteString " Begin SubModelPartData // DEM-VelocityBC. Group name: $group "
305- set xp1 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = '$cond '\] /group\[ @n = '$group '\] "
306- set group_node [[customlib::GetBaseRoot] selectNodes $xp1 ]
307-
308- set prescribeMotion_flag [write::getValueByNode [$group_node selectNodes " ./value\[ @n='PrescribeMotion_flag'\] " ]]
309- if {[write::isBooleanTrue $prescribeMotion_flag ]} {
310-
311- # Linear velocity
312- set velocity [write::getValueByNode [$group_node selectNodes " ./value\[ @n='VelocityModulus'\] " ]]
313- lassign [write::getValueByNode [$group_node selectNodes " ./value\[ @n='DirectionVector'\] " ]] velocity_X velocity_Y
314- lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y ]] velocity_X velocity_Y
315- lassign [MathUtils::ScalarByVectorProd $velocity [list $velocity_X $velocity_Y ] ] vx vy
316- write::WriteString " LINEAR_VELOCITY \[ 3\] ($vx , $vy , 0.0)"
317-
318- # Period
319- set periodic [write::getValueByNode [$group_node selectNodes " ./value\[ @n='LinearPeriodic'\] " ]]
320- if {[write::isBooleanTrue $periodic ]} {
321- set period [write::getValueByNode [$group_node selectNodes " ./value\[ @n='LinearPeriod'\] " ]]
322- } else {
323- set period 0.0
324- }
325- write::WriteString " VELOCITY_PERIOD $period "
326-
327- # Angular velocity
328- set avelocity [write::getValueByNode [$group_node selectNodes " ./value\[ @n='AngularVelocityModulus'\] " ]]
329- write::WriteString " ANGULAR_VELOCITY \[ 3\] (0.0,0.0,$avelocity )"
330-
331- # Angular center of rotation
332- lassign [write::getValueByNode [$group_node selectNodes " ./value\[ @n='CenterOfRotation'\] " ]] oX oY
333- write::WriteString " ROTATION_CENTER \[ 3\] ($oX ,$oY ,0.0)"
334-
335- # Angular Period
336- set angular_periodic [write::getValueByNode [$group_node selectNodes " ./value\[ @n='AngularPeriodic'\] " ]]
337- if {[write::isBooleanTrue $angular_periodic ]} {
338- set angular_period [write::getValueByNode [$group_node selectNodes " ./value\[ @n='AngularPeriod'\] " ]]
339- } else {
340- set angular_period 0.0
341- }
342- write::WriteString " ANGULAR_VELOCITY_PERIOD $angular_period "
343-
344- # set intervals
345- set LinearStartTime [write::getValueByNode [$group_node selectNodes " ./value\[ @n='LinearStartTime'\] " ]]
346- set LinearEndTime [write::getValueByNode [$group_node selectNodes " ./value\[ @n='LinearEndTime'\] " ]]
347- set AngularStartTime [write::getValueByNode [$group_node selectNodes " ./value\[ @n='AngularStartTime'\] " ]]
348- set AngularEndTime [write::getValueByNode [$group_node selectNodes " ./value\[ @n='AngularEndTime'\] " ]]
349- write::WriteString " VELOCITY_START_TIME $LinearStartTime "
350- write::WriteString " VELOCITY_STOP_TIME $LinearEndTime "
351- write::WriteString " ANGULAR_VELOCITY_START_TIME $AngularStartTime "
352- write::WriteString " ANGULAR_VELOCITY_STOP_TIME $AngularEndTime "
353-
354- # Interval. # TODO, able to assign intervals as start and end time. Both linear and angular could be different
355- # set interval [write::getValueByNode [$group_node selectNodes "./value\[@n='Interval'\]"]]
356- # lassign [write::getInterval $interval] ini end
357- # if {![string is double $ini]} {
358- # set ini [write::getValue DEMTimeParameters StartTime]
359- # }
360- # write::WriteString " ${cond}_START_TIME $ini"
361- # if {![string is double $end]} {
362- # set end [write::getValue DEMTimeParameters EndTime]
363- # }
364- # write::WriteString " ${cond}_STOP_TIME $end"
365- }
366-
367- write::WriteString " End SubModelPartData"
368- write::WriteString " Begin SubModelPartNodes"
369- GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $group ] [subst " %10i\n " ]]
370- write::WriteString " End SubModelPartNodes"
371- write::WriteString " End SubModelPart"
372- write::WriteString " "
373- }
374- } elseif {$cond eq " DEM-VelocityIC2D" } {
375- set cnd [Model::getCondition $cond ]
376- foreach group $group_list {
377- incr i
378- write::WriteString " Begin SubModelPart $i // GUI DEM-VelocityIC - $cond - group identifier: $group "
379- write::WriteString " Begin SubModelPartData // DEM-VelocityIC. Group name: $group "
380- set xp1 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = '$cond '\] /group\[ @n = '$group '\] "
381- set group_node [[customlib::GetBaseRoot] selectNodes $xp1 ]
382-
383- set prescribeMotion_flag [write::getValueByNode [$group_node selectNodes " ./value\[ @n='PrescribeMotion_flag'\] " ]]
384- if {[write::isBooleanTrue $prescribeMotion_flag ]} {
385-
386- # Linear velocity
387- set velocity [write::getValueByNode [$group_node selectNodes " ./value\[ @n='InitialVelocityModulus'\] " ]]
388- lassign [write::getValueByNode [$group_node selectNodes " ./value\[ @n='iDirectionVector'\] " ]] velocity_X velocity_Y
389- lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y ]] velocity_X velocity_Y
390- lassign [MathUtils::ScalarByVectorProd $velocity [list $velocity_X $velocity_Y ] ] vx vy
391- write::WriteString " INITIAL_VELOCITY_X_VALUE $vx "
392- write::WriteString " INITIAL_VELOCITY_Y_VALUE $vy "
393- write::WriteString " INITIAL_VELOCITY_Z_VALUE 0.0"
394-
395- # Angular velocity
396- set avelocity [write::getValueByNode [$group_node selectNodes " ./value\[ @n='InitialAngularVelocityModulus'\] " ]]
397- write::WriteString " INITIAL_ANGULAR_VELOCITY_X_VALUE 0.0"
398- write::WriteString " INITIAL_ANGULAR_VELOCITY_Y_VALUE 0.0"
399- write::WriteString " INITIAL_ANGULAR_VELOCITY_Z_VALUE $avelocity "
400- }
401-
402- write::WriteString " End SubModelPartData"
403- write::WriteString " Begin SubModelPartNodes"
404- GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $group ] [subst " %10i\n " ]]
405- write::WriteString " End SubModelPartNodes"
406- write::WriteString " End SubModelPart"
407- write::WriteString " "
408- }
409- }
410- }
411- }
412-
413-
414- proc DEM::write::GetSpheresGroupsListInConditions { } {
167+ proc CDEM::write::GetSpheresGroupsListInConditions { } {
415168 set conds_groups_dict [dict create ]
416169 set groups [list ]
170+
417171 # Get all the groups with spheres
418172 foreach group [GetSpheresGroups] {
419173 foreach surface [GiD_EntitiesGroups get $group elements] {
420174 foreach involved_group [GiD_EntitiesGroups entity_groups elements $surface ] {
421- set involved_group_id [write::GetWriteGroupName $involved_group ]
422- if {$involved_group_id ni $groups } {lappend groups $involved_group_id }
175+ set involved_group_id [write::GetWriteGroupName $involved_group ]
176+ if {$involved_group_id ni $groups } {lappend groups $involved_group_id }
423177 }
424178 }
425179 }
426180
427181 # Find the relations condition -> group
428182 set xp1 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition"
429183 foreach cond [[customlib::GetBaseRoot] selectNodes $xp1 ] {
430-
431- set condid [$cond @n]
432- foreach cond_group [$cond selectNodes " group" ] {
433- set group [write::GetWriteGroupName [$cond_group @n]]
434- if {$group in $groups } {dict lappend conds_groups_dict $condid [$cond_group @n]}
435- }
184+ set condid [$cond @n]
185+ foreach cond_group [$cond selectNodes " group" ] {
186+ set group [write::GetWriteGroupName [$cond_group @n]]
187+ if {$group in $groups } {dict lappend conds_groups_dict $condid [$cond_group @n]}
188+ }
436189 }
437190 return $conds_groups_dict
438191}
439192
440- proc DEM ::write::GetSpheresGroups { } {
193+ proc CDEM ::write::GetSpheresGroups { } {
441194 set groups [list ]
442195 if {$::Model::SpatialDimension eq " 2D" } { set xp1 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = 'DEM-VelocityBC2D'\] /group"
443196 } else {set xp1 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = 'DEM-VelocityBC'\] /group" }
@@ -455,7 +208,7 @@ proc DEM::write::GetSpheresGroups { } {
455208 return $groups
456209}
457210
458- proc DEM ::write::writeMaterialsParts { } {
211+ proc CDEM ::write::writeMaterialsParts { } {
459212 variable partsProperties
460213 set xp1 " [ spdAux::getRoute [GetAttribute conditions_un] ]/condition\[ @n = 'PartsCont'\] /group"
461214 set partsProperties $::write::mat_dict
0 commit comments