Skip to content

Commit 2bc36cd

Browse files
Delete repeated code
1 parent 67494aa commit 2bc36cd

7 files changed

Lines changed: 16 additions & 108 deletions

File tree

Lines changed: 7 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
proc CDEM::write::WriteMDPAParts { } {
2-
variable last_property_id
3-
4-
# Prepare properties
5-
write::processMaterials "" $last_property_id;
6-
set last_property_id [expr $last_property_id + [dict size $::write::mat_dict]]
7-
82
# Headers
93
write::writeModelPartData
104

5+
# Process properties
6+
DEM::write::processPartMaterials
7+
118
# Materials
12-
CDEM::write::writeMaterialsParts
9+
DEM::write::writeMaterialsParts
1310

1411
# Nodal coordinates (only for DEM Parts <inefficient> )
1512
write::writeNodalCoordinatesOnParts
@@ -22,7 +19,7 @@ proc CDEM::write::WriteMDPAParts { } {
2219
write::writeElementConnectivities
2320

2421
# Begin NodalData RADIUS
25-
CDEM::write::writeSphereRadius
22+
DEM::write::writeSphereRadius
2623

2724
# Begin NodalData COHESIVE_GROUP
2825
CDEM::write::writeCohesiveGroups
@@ -38,54 +35,6 @@ proc CDEM::write::WriteMDPAParts { } {
3835
CDEM::write::WriteCustomDEMSmp
3936
}
4037

41-
## TODO: proc under revision. This works but the proc is different from the DEM::write version.
42-
proc CDEM::write::WriteCustomDEMSmp { } {
43-
set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-CustomSmp'\]/group"
44-
foreach group [[customlib::GetBaseRoot] selectNodes $xp1] {
45-
set group_id [$group @n]
46-
set group_raw [write::GetWriteGroupName $group_id]
47-
set good_name [write::transformGroupName $group_raw]
48-
set destination_mdpa [write::getValueByNode [$group selectNodes "./value\[@n='WhatMdpa'\]"]]
49-
if {$destination_mdpa == "DEM"} {
50-
write::WriteString "Begin SubModelPart $good_name \/\/ Custom SubModelPart. Group name: $group_id"
51-
write::WriteString "Begin SubModelPartData"
52-
write::WriteString "End SubModelPartData"
53-
write::WriteString "Begin SubModelPartNodes"
54-
GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $group_id] [subst "%10i\n"]]
55-
write::WriteString "End SubModelPartNodes"
56-
write::WriteString "End SubModelPart"
57-
write::WriteString ""
58-
}
59-
}
60-
}
61-
62-
proc CDEM::write::GetDEMGroupsCustomSubmodelpart { } {
63-
set groups [list ]
64-
set xp2 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-CustomSmp'\]/group"
65-
foreach group [[customlib::GetBaseRoot] selectNodes $xp2] {
66-
set destination_mdpa [write::getValueByNode [$group selectNodes "./value\[@n='WhatMdpa'\]"]]
67-
if {$destination_mdpa == "DEM"} {
68-
set groupid [$group @n]
69-
lappend groups [write::GetWriteGroupName $groupid]
70-
}
71-
}
72-
return $groups
73-
}
74-
75-
proc CDEM::write::writeSphereRadius { } {
76-
set root [customlib::GetBaseRoot]
77-
set xp1 "[spdAux::getRoute [GetAttribute partscont_un]]/group"
78-
foreach group [$root selectNodes $xp1] {
79-
set groupid [$group @n]
80-
set grouppid [write::GetWriteGroupName $groupid]
81-
write::WriteString "Begin NodalData RADIUS // GUI group identifier: $grouppid"
82-
GiD_WriteCalculationFile connectivities [dict create $groupid "%.0s %10d 0 %10g\n"]
83-
write::WriteString "End NodalData"
84-
write::WriteString ""
85-
}
86-
}
87-
88-
8938
proc CDEM::write::writeCohesiveGroups { } {
9039
set root [customlib::GetBaseRoot]
9140
if {$::Model::SpatialDimension eq "3D"} {
@@ -97,8 +46,8 @@ proc CDEM::write::writeCohesiveGroups { } {
9746
foreach group [$root selectNodes $xp1] {
9847
incr cohesive_group
9948
set groupid [$group @n]
100-
set grouppid [write::GetWriteGroupName $groupid]
101-
write::WriteString "Begin NodalData COHESIVE_GROUP // GUI group identifier: $grouppid"
49+
set group_id [write::GetWriteGroupName $groupid]
50+
write::WriteString "Begin NodalData COHESIVE_GROUP // GUI group identifier: $group_id"
10251
GiD_WriteCalculationFile connectivities [dict create $groupid "%.0s %10d 0 $cohesive_group\n"]
10352
write::WriteString "End NodalData"
10453
write::WriteString ""
@@ -125,49 +74,3 @@ proc CDEM::write::writeSkinSphereNodes { } {
12574
write::WriteString "End NodalData"
12675
write::WriteString ""
12776
}
128-
129-
130-
proc CDEM::write::writeMaterialsParts { } {
131-
variable partsProperties
132-
set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'PartsCont'\]/group"
133-
set partsProperties $::write::mat_dict
134-
set printable [list PARTICLE_DENSITY \
135-
YOUNG_MODULUS \
136-
POISSON_RATIO \
137-
FRICTION \
138-
COEFFICIENT_OF_RESTITUTION \
139-
ROLLING_FRICTION \
140-
ROLLING_FRICTION_WITH_WALLS \
141-
CONTACT_SIGMA_MIN \
142-
CONTACT_TAU_ZERO \
143-
CONTACT_INTERNAL_FRICC \
144-
ConstitutiveLaw \
145-
SHEAR_ENERGY_COEF \
146-
LOOSE_MATERIAL_YOUNG_MODULUS \
147-
FRACTURE_ENERGY \
148-
INTERNAL_FRICTION_ANGLE \
149-
ROTATIONAL_MOMENT_COEFFICIENT \
150-
PARTICLE_COHESION]
151-
152-
foreach group [dict keys $partsProperties] {
153-
write::WriteString "Begin Properties [dict get $partsProperties $group MID]"
154-
foreach {prop val} [dict get $partsProperties $group] {
155-
if {$prop in $printable} {
156-
if {$prop eq "ConstitutiveLaw"} {
157-
write::WriteString " DEM_CONTINUUM_CONSTITUTIVE_LAW_NAME $val"
158-
} elseif {$prop eq "FRICTION"} {
159-
set propvalue [expr {tan($val)}]
160-
write::WriteString " FRICTION $propvalue"
161-
} else {
162-
write::WriteString " $prop $val"
163-
}
164-
}
165-
}
166-
if {$::Model::SpatialDimension eq "2D"} {
167-
write::WriteString " DEM_DISCONTINUUM_CONSTITUTIVE_LAW_NAME DEM_D_Linear_viscous_Coulomb2D"
168-
} else {
169-
write::WriteString " DEM_DISCONTINUUM_CONSTITUTIVE_LAW_NAME DEM_D_Linear_viscous_Coulomb"}
170-
171-
write::WriteString "End Properties\n"
172-
}
173-
}

kratos.gid/apps/CDEM/write/writeMDPA_Walls.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
3+
# Overwritten to ad TOP BOTTOM params
44
proc DEM::write::DefineFEMExtraConditions {props} {
55
set material_analysis [write::getValue DEMTestMaterial Active]
66
if {$material_analysis == "true"} {

kratos.gid/apps/CDEM/write/writeProjectParameters.tcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
# Project Parameters
33

44
proc CDEM::write::getParametersDict { } {
5+
# Get the DEM original json and
56
set project_parameters_dict [DEM::write::getParametersDict]
67

8+
# Add advanced options
79
dict set project_parameters_dict "DeltaOption" [write::getValue AdvOptions DeltaOption]
810
dict set project_parameters_dict "SearchTolerance" [write::getValue AdvOptions TangencyAbsoluteTolerance]
911
dict set project_parameters_dict "CoordinationNumber" [write::getValue AdvOptions TangencyCoordinationNumber]
@@ -13,6 +15,7 @@ proc CDEM::write::getParametersDict { } {
1315
dict set project_parameters_dict "ComputeStressTensorOption" [write::getValue AdvOptions ComputeStressTensorOption]
1416
dict set project_parameters_dict "MaxAmplificationRatioOfSearchRadius" 1000
1517

18+
# Add material testing
1619
set material_test_parameters_dict [dict create]
1720
set material_analysis [write::getValue DEMTestMaterial Active]
1821
if {$material_analysis == "true"} {

kratos.gid/apps/CDEM/xml/XmlController.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ proc CDEM::xml::getUniqueName {name} {
2121
}
2222

2323
proc CDEM::xml::CustomTree { args } {
24-
DEM::xml::CustomTree args
24+
DEM::xml::CustomTree {*}$args
2525

2626
set root [customlib::GetBaseRoot]
2727
if {[$root selectNodes "[spdAux::getRoute DEMStratSection]/container\[@n='AdvOptions'\]"] eq ""} {

kratos.gid/apps/DEM/write/writeMDPA_Parts.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ proc DEM::write::WriteMDPAParts { } {
1515
write::writeNodalCoordinatesOnGroups [GetDEMGroupsBoundaryC]
1616
write::writeNodalCoordinatesOnGroups [GetNodesForGraphs]
1717

18-
# Element connectivities (Groups on STParts)
18+
# Element connectivities (Groups on Parts)
1919
PrepareCustomMeshedParts
2020
write::writeElementConnectivities
2121
RestoreCustomMeshedParts

kratos.gid/apps/DEM/write/writeMDPA_Walls.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ proc DEM::write::writeWallConditionMesh { condition group props } {
509509
}
510510
write::WriteString " IDENTIFIER [write::transformGroupName $group]"
511511

512-
DefineFEMExtraConditions $props
512+
DEM::write::DefineFEMExtraConditions $props
513513

514514
}
515515
write::WriteString " End SubModelPartData"

kratos.gid/apps/DEM/write/write_utils.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ proc DEM::write::AssignGeometricalEntitiesToSkinSphere2D {} {
551551
set list_of_lines [GiD_Geometry list line 1:end]
552552
if {![GiD_Groups exists SKIN_SPHERE_DO_NOT_DELETE]} {
553553
GiD_Groups create SKIN_SPHERE_DO_NOT_DELETE
554+
GiD_Groups edit state SKIN_SPHERE_DO_NOT_DELETE hidden
554555
}
555556

556557
set points_to_add_to_skin_circles [list]
@@ -570,6 +571,7 @@ proc DEM::write::AssignGeometricalEntitiesToSkinSphere3D {} {
570571
set list_of_surfaces [GiD_Geometry list surface 1:end]
571572
if {![GiD_Groups exists SKIN_SPHERE_DO_NOT_DELETE]} {
572573
GiD_Groups create SKIN_SPHERE_DO_NOT_DELETE
574+
GiD_Groups edit state SKIN_SPHERE_DO_NOT_DELETE hidden
573575
}
574576

575577
set points_to_add_to_skin_spheres [list]

0 commit comments

Comments
 (0)