diff --git a/kratos.gid/apps/DEM/app.json b/kratos.gid/apps/DEM/app.json index 3dc664a50..43447bb9a 100644 --- a/kratos.gid/apps/DEM/app.json +++ b/kratos.gid/apps/DEM/app.json @@ -26,6 +26,7 @@ "write/write_utils.tcl", "examples/examples.tcl", "examples/SpheresDrop.tcl", + "examples/SpheresDropForTest.tcl", "examples/CirclesDrop.tcl" ], "start_script": "::DEM::Init", @@ -42,8 +43,10 @@ }, "unique_names": { "parts": "DEMParts", - "nodal_conditions": "DEMNodalConditions", + "init_conditions": "DEMInitialConditions", "conditions": "DEMConditions", + "loads": "DEMFEMLoads", + "injectors": "DEMInlet", "materials": "DEMMaterials" }, "write": { diff --git a/kratos.gid/apps/DEM/examples/CirclesDrop.tcl b/kratos.gid/apps/DEM/examples/CirclesDrop.tcl index 4d32ff0ae..91e576041 100644 --- a/kratos.gid/apps/DEM/examples/CirclesDrop.tcl +++ b/kratos.gid/apps/DEM/examples/CirclesDrop.tcl @@ -4,6 +4,8 @@ namespace eval ::DEM::examples::CirclesDrop { } proc ::DEM::examples::CirclesDrop::Init {args} { + W "This example requires to be updated to the new version of the interface." + if {![Kratos::IsModelEmpty]} { set txt "We are going to draw the example geometry.\nDo you want to discard your previous work?" set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel] diff --git a/kratos.gid/apps/DEM/examples/SpheresDrop.tcl b/kratos.gid/apps/DEM/examples/SpheresDrop.tcl index 40244bdea..fa675900d 100644 --- a/kratos.gid/apps/DEM/examples/SpheresDrop.tcl +++ b/kratos.gid/apps/DEM/examples/SpheresDrop.tcl @@ -5,6 +5,7 @@ namespace eval ::DEM::examples::SpheresDrop { } proc ::DEM::examples::SpheresDrop::Init {args} { + W "This example requires to be updated to the new version of the interface." if {![Kratos::IsModelEmpty]} { set txt "We are going to draw the example geometry.\nDo you want to discard your previous work?" set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel] @@ -64,7 +65,7 @@ proc ::DEM::examples::SpheresDrop::AssignToTree { } { set walls "$DEMConditions/condition\[@n='DEM-FEM-Wall'\]" set wallsNode [customlib::AddConditionGroupOnXPath $walls Floor] $wallsNode setAttribute ov surface - + # Inlet set DEMInlet "$DEMConditions/condition\[@n='Inlet'\]" set inletNode [customlib::AddConditionGroupOnXPath $DEMInlet "Inlet"] diff --git a/kratos.gid/apps/DEM/examples/SpheresDropForTest.tcl b/kratos.gid/apps/DEM/examples/SpheresDropForTest.tcl new file mode 100644 index 000000000..434f17c92 --- /dev/null +++ b/kratos.gid/apps/DEM/examples/SpheresDropForTest.tcl @@ -0,0 +1,249 @@ +namespace eval ::DEM::examples::SpheresDropForTest { + namespace path ::DEM::examples + Kratos::AddNamespace [namespace current] + +} + +proc ::DEM::examples::SpheresDropForTest::Init {args} { + if {![Kratos::IsModelEmpty]} { + set txt "We are going to draw the example geometry.\nDo you want to discard your previous work?" + set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel] + if { $retval == "cancel" } { return } + } + + DrawGeometry + AssignToTree + AssignMeshSize + + GiD_Process 'Redraw + GidUtils::UpdateWindow GROUPS + GidUtils::UpdateWindow LAYER +} + +proc ::DEM::examples::SpheresDropForTest::DrawGeometry { } { + Kratos::ResetModel + + # Draw floor surface + GiD_Process Mescape Geometry Create Object Rectangle -2 -2 5 2 2 5 escape + GiD_Process Mescape Geometry Create Object Rectangle -2 -2 6 2 2 6 escape + GiD_Process Mescape Geometry Create Object Rectangle -12 -2 5 -8 2 5 escape + GiD_Process Mescape Geometry Create Object Rectangle -12 -2 6 -8 2 6 escape + + GiD_Process Mescape Geometry Create Object Rectangle -7 10 6 -2 4 6 escape + + + # Draw the volumes meshed with spheres + GiD_Process Mescape Geometry Create Object Sphere 0 0 2 1 escape escape + GiD_Process Mescape Geometry Create Object Sphere -3 2 2 1 escape escape + GiD_Process Mescape Geometry Create Object Sphere -7 -2 2 1 escape escape + GiD_Process Mescape Geometry Create Object Sphere -11 -2 2 1 escape escape + + + # Group creation + GiD_Groups create "f1" + GiD_Groups create "f2" + GiD_Groups create "f3" + GiD_Groups create "f4" + + GiD_Groups create "d1" + GiD_Groups create "d2" + GiD_Groups create "d3" + GiD_Groups create "d4" + GiD_Groups create "f2d" + + # Group assignation + GiD_EntitiesGroups assign "f1" surfaces 1 + GiD_EntitiesGroups assign "f2" surfaces 2 + GiD_EntitiesGroups assign "f3" surfaces 3 + GiD_EntitiesGroups assign "f4" surfaces 4 + GiD_EntitiesGroups assign "f2d" surfaces 5 + + #GiD_EntitiesGroups assign "ClusterInlet" surfaces 3 + GiD_EntitiesGroups assign "d1" volumes 1 + GiD_EntitiesGroups assign "d2" volumes 2 + GiD_EntitiesGroups assign "d3" volumes 3 + GiD_EntitiesGroups assign "d4" volumes 4 +} + +proc ::DEM::examples::SpheresDropForTest::AssignToTree { } { + # Material + set DEMmaterials [spdAux::getRoute "DEMMaterials"] + set props [list PARTICLE_DENSITY 2500.0 YOUNG_MODULUS 1.0e6] + set material_node [[customlib::GetBaseRoot] selectNodes "$DEMmaterials/blockdata\[@name = 'DEM-DefaultMaterial' \]"] + spdAux::SetValuesOnBaseNode $material_node $props + + ####### DEM-Parts + set DEMParts [spdAux::getRoute "DEMParts"]/condition\[@n='Parts_DEM'\] + set DEMPartsNode [customlib::AddConditionGroupOnXPath $DEMParts d1] + $DEMPartsNode setAttribute ov volume + set props [list Material "DEM-DefaultMaterial"] + spdAux::SetValuesOnBaseNode $DEMPartsNode $props + + set DEMParts [spdAux::getRoute "DEMParts"]/condition\[@n='Parts_DEM'\] + set DEMPartsNode [customlib::AddConditionGroupOnXPath $DEMParts d2] + $DEMPartsNode setAttribute ov volume + set props [list Material "DEM-DefaultMaterial"] + spdAux::SetValuesOnBaseNode $DEMPartsNode $props + + set DEMParts [spdAux::getRoute "DEMParts"]/condition\[@n='Parts_DEM'\] + set DEMPartsNode [customlib::AddConditionGroupOnXPath $DEMParts d3] + $DEMPartsNode setAttribute ov volume + set props [list Material "DEM-DefaultMaterial"] + spdAux::SetValuesOnBaseNode $DEMPartsNode $props + + set DEMParts [spdAux::getRoute "DEMParts"]/condition\[@n='Parts_DEM'\] + set DEMPartsNode [customlib::AddConditionGroupOnXPath $DEMParts d4] + $DEMPartsNode setAttribute ov volume + set props [list Material "DEM-DefaultMaterial"] + spdAux::SetValuesOnBaseNode $DEMPartsNode $props + + + set DEMParts [spdAux::getRoute "DEMParts"]/condition\[@n='Parts_DEM'\] + set DEMPartsNode [customlib::AddConditionGroupOnXPath $DEMParts f2d] + $DEMPartsNode setAttribute ov volume + set props [list Material "DEM-DefaultMaterial"] + spdAux::SetValuesOnBaseNode $DEMPartsNode $props + set props_extra [list AdvancedMeshingFeatures Yes AdvancedMeshingFeaturesAlgorithmType FEMtoDEM FEMtoDEM AttheNodes Diameter 0.5 ProbabilityDistribution NormalDistribution StandardDeviation 0.1] + spdAux::SetValuesOnBaseNode $DEMPartsNode $props_extra + + + + ###### FEM-Parts + set FEMParts [spdAux::getRoute "DEMParts"]/condition\[@n='Parts_FEM'\] + set FEMPartsNode [customlib::AddConditionGroupOnXPath $FEMParts f1] + $FEMPartsNode setAttribute ov surface + set props [list Material "DEM-DefaultMaterial"] + spdAux::SetValuesOnBaseNode $FEMPartsNode $props + + set FEMParts [spdAux::getRoute "DEMParts"]/condition\[@n='Parts_FEM'\] + set FEMPartsNode [customlib::AddConditionGroupOnXPath $FEMParts f2] + $FEMPartsNode setAttribute ov surface + set props [list Material "DEM-DefaultMaterial"] + spdAux::SetValuesOnBaseNode $FEMPartsNode $props + + set FEMParts [spdAux::getRoute "DEMParts"]/condition\[@n='Parts_FEM'\] + set FEMPartsNode [customlib::AddConditionGroupOnXPath $FEMParts f3] + $FEMPartsNode setAttribute ov surface + set props [list Material "DEM-DefaultMaterial"] + spdAux::SetValuesOnBaseNode $FEMPartsNode $props + + set FEMParts [spdAux::getRoute "DEMParts"]/condition\[@n='Parts_FEM'\] + set FEMPartsNode [customlib::AddConditionGroupOnXPath $FEMParts f4] + $FEMPartsNode setAttribute ov surface + set props [list Material "DEM-DefaultMaterial"] + spdAux::SetValuesOnBaseNode $FEMPartsNode $props + + + + + + # Velocity over particles + set object_BC {container[@n='DEM']/container[@n='BoundaryConditions']/condition[@n='DEMVelocity']} + set object_BCNode [customlib::AddConditionGroupOnXPath $object_BC d1] + $object_BCNode setAttribute ov volume + set props [list Constraints true,true,true selector_component_X ByValue value_component_X 1.0 selector_component_Y ByValue value_component_Y 0.0 selector_component_Z ByValue value_component_Z 0.0 Interval Total] + spdAux::SetValuesOnBaseNode $object_BCNode $props + + # angular Velocity over particles + set object_BC {container[@n='DEM']/container[@n='BoundaryConditions']/condition[@n='DEMAngular']} + set object_BCNode [customlib::AddConditionGroupOnXPath $object_BC d2] + $object_BCNode setAttribute ov volume + set props [list Constraints true,true,true selector_component_X ByValue value_component_X 1.0 selector_component_Y ByValue value_component_Y 1.0 selector_component_Z ByValue value_component_Z 0.0 Interval Total] + spdAux::SetValuesOnBaseNode $object_BCNode $props + + + # Velocity over fem + set femBC {container[@n='DEM']/container[@n='BoundaryConditions']/condition[@n='FEMVelocity']} + set femBCNode [customlib::AddConditionGroupOnXPath $femBC f1] + $femBCNode setAttribute ov surface + set props [list selector_component_X ByValue value_component_X 1.0 selector_component_Y ByValue value_component_Y 1.0 selector_component_Z ByValue value_component_Z 0.0 Interval Total] + spdAux::SetValuesOnBaseNode $femBCNode $props + + + # Angular Velocity over fem + set femBC {container[@n='DEM']/container[@n='BoundaryConditions']/condition[@n='FEMAngular']} + set femBCNode [customlib::AddConditionGroupOnXPath $femBC f2] + $femBCNode setAttribute ov surface + set props [list selector_component_X ByValue value_component_X 1.0 selector_component_Y ByValue value_component_Y 0.0 selector_component_Z ByValue value_component_Z 1.0 Interval Total] + spdAux::SetValuesOnBaseNode $femBCNode $props + + + + # force over particles + set object_BC {container[@n='DEM']/container[@n='Loads']/condition[@n='DEMForce']} + set object_BCNode [customlib::AddConditionGroupOnXPath $object_BC d3] + $object_BCNode setAttribute ov volume + set props [list Constraints true,true,true selector_component_X ByValue value_component_X 1.0 selector_component_Y ByValue value_component_Y 2.0 selector_component_Z ByValue value_component_Z 0.0 Interval Total] + spdAux::SetValuesOnBaseNode $object_BCNode $props + + # torque over particles + set object_BC {container[@n='DEM']/container[@n='Loads']/condition[@n='DEMTorque']} + set object_BCNode [customlib::AddConditionGroupOnXPath $object_BC d4] + $object_BCNode setAttribute ov volume + set props [list Constraints true,true,true selector_component_X ByValue value_component_X 1.0 selector_component_Y ByValue value_component_Y 0.0 selector_component_Z ByValue value_component_Z 2.0 Interval Total] + spdAux::SetValuesOnBaseNode $object_BCNode $props + + + # force over particles + set object_BC {container[@n='DEM']/container[@n='Loads']/condition[@n='FEMForce']} + set object_BCNode [customlib::AddConditionGroupOnXPath $object_BC f3] + $object_BCNode setAttribute ov volume + set props [list Constraints true,true,true selector_component_X ByValue value_component_X 1.0 selector_component_Y ByValue value_component_Y 2.0 selector_component_Z ByValue value_component_Z 0.0 Interval Total] + spdAux::SetValuesOnBaseNode $object_BCNode $props + + # torque over particles + set object_BC {container[@n='DEM']/container[@n='Loads']/condition[@n='FEMTorque']} + set object_BCNode [customlib::AddConditionGroupOnXPath $object_BC f4] + $object_BCNode setAttribute ov volume + set props [list Constraints true,true,true selector_component_X ByValue value_component_X 1.0 selector_component_Y ByValue value_component_Y 0.0 selector_component_Z ByValue value_component_Z 2.0 Interval Total] + spdAux::SetValuesOnBaseNode $object_BCNode $props + + + + # # InletPart - No inlets de moment + # set FEMParts_inlet [spdAux::getRoute "DEMParts"]/condition\[@n='Parts_Inlet-FEM'\] + # set FEMParts_inletNode [customlib::AddConditionGroupOnXPath $FEMParts_inlet Inlet] + # $FEMParts_inletNode setAttribute ov surface + # set props [list Material "DEM-DefaultMaterial"] + # spdAux::SetValuesOnBaseNode $FEMParts_inletNode $props + + # BC over Inlet + # set InletBC {container[@n='DEM']/container[@n='BoundaryConditions']/condition[@n='FEMVelocity']} + # #Velocity over walls is the name on the tree (pn) + # set InletBCNode [customlib::AddConditionGroupOnXPath $InletBC Inlet] + # $InletBCNode setAttribute ov surface + # set props [list selector_component_X ByValue value_component_X 2.0 selector_component_Y ByValue value_component_Y 0.0 selector_component_Z ByValue value_component_Z 0.0 Interval Total] + # spdAux::SetValuesOnBaseNode $InletBCNode $props + + # # Inlet + # set InletVars {container[@n='DEM']/container[@n='Injectors']/condition[@n='DEMInlet']} + # set InletVarsNode [customlib::AddConditionGroupOnXPath $InletVars Inlet] + # $InletVarsNode setAttribute ov surface + # set props [list Material "DEM-DefaultMaterial" ParticleDiameter 0.13 InVelocityModulus 2.3 InDirectionVector "0.0,0.0,-1.0"] + # spdAux::SetValuesOnBaseNode $InletVarsNode $props + + + + + # spdAux::SetValuesOnBaseNode $inletNode $props + + # # DEM custom submodelpart + # set custom_dem "$DEMConditions/condition\[@n='DEM-CustomSmp'\]" + # set customNode [customlib::AddConditionGroupOnXPath $custom_dem Object_1] + # $customNode setAttribute ov volume + + # # General data + # # Time parameters + # set change_list [list EndTime 5 DeltaTime 1e-5 NeighbourSearchFrequency 50] + # set xpath [spdAux::getRoute DEMTimeParameters] + # spdAux::SetValuesOnBasePath $xpath $change_list + + spdAux::RequestRefresh +} + +proc ::DEM::examples::SpheresDropForTest::AssignMeshSize { } { + GiD_Process Mescape Meshing ElemType Sphere Volumes 1 escape + GiD_Process Mescape Meshing AssignSizes Volumes 1 1:end escape escape escape + GiD_Process Mescape Meshing AssignSizes Surfaces 1 1:end escape escape escape + GiD_Process Mescape Meshing AssignSizes Lines 1 1:end escape escape escape +} \ No newline at end of file diff --git a/kratos.gid/apps/DEM/examples/examples.xml b/kratos.gid/apps/DEM/examples/examples.xml index 46c1e3be8..f2c92b600 100644 --- a/kratos.gid/apps/DEM/examples/examples.xml +++ b/kratos.gid/apps/DEM/examples/examples.xml @@ -6,4 +6,7 @@ + + + \ No newline at end of file diff --git a/kratos.gid/apps/DEM/start.tcl b/kratos.gid/apps/DEM/start.tcl index 223af9429..5059fedd0 100644 --- a/kratos.gid/apps/DEM/start.tcl +++ b/kratos.gid/apps/DEM/start.tcl @@ -1,6 +1,6 @@ namespace eval ::DEM { Kratos::AddNamespace [namespace current] - + # Variable declaration variable dir variable _app @@ -26,17 +26,18 @@ proc ::DEM::Init { app } { proc ::DEM::CustomToolbarItems { } { variable dir - + Kratos::ToolbarAddItem "MaterialRelations" "material-relation.png" [list -np- DEM::xml::ShowMaterialRelationWindow] [= "Material relations"] } proc ::DEM::BeforeMeshGeneration {elementsize} { set root [customlib::GetBaseRoot] - set xp1 "[spdAux::getRoute DEMParts]/group" + set xp1 "[spdAux::getRoute DEMParts]/condition\[@n = 'Parts_DEM'\]/group" foreach group [concat [$root selectNodes $xp1] [DEM::write::GetDEMGroupsCustomSubmodelpart]] { set groupid [$group @n] set advanced_meshing_features [write::getValueByNode [$group selectNodes "./value\[@n='AdvancedMeshingFeatures'\]"]] if {![write::isBooleanTrue $advanced_meshing_features]} { + # Usually, the DEMParts will be marked as not AdvancedMeshingFeatures, composed as volumes and meshed as spheres. if {$::Model::SpatialDimension eq "3D"} { foreach volume [GiD_EntitiesGroups get $groupid volumes] { GiD_Process Mescape Meshing ElemType Sphere Volumes $volume escape escape @@ -47,6 +48,8 @@ proc ::DEM::BeforeMeshGeneration {elementsize} { } } } else { + # If a DEMPart is created as FEM and AdvancedMeshingFeatures=true, initially meshed as fem + # it will later access Elements_Substitution to transform those elements into spheres (in AfterMeshGeneration) if {$::Model::SpatialDimension eq "3D"} { foreach volume [GiD_EntitiesGroups get $groupid volumes] { GiD_Process Mescape Meshing ElemType Default Volumes $volume escape escape @@ -67,59 +70,136 @@ proc ::DEM::BeforeMeshGeneration {elementsize} { proc ::DEM::AfterMeshGeneration { fail } { set root [customlib::GetBaseRoot] - # Separar 2d de 3d - set xp1 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='DEM-FEM-Wall'\]/group" - foreach group [$root selectNodes $xp1] { + + #LINEAR VELOCITY + # should be: unassign all spheres from all the groups in FEM conditions . + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'FEMVelocity'\]/group" + foreach group [$root selectNodes $xp] { set groupid [$group @n] GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type sphere] } - set xp2 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='DEM-FEM-Wall2D'\]/group" - foreach group [$root selectNodes $xp2] { + + ## unassign all circles from all the groups in FEM conditions 2D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'FEMVelocity2D'\]/group" + foreach group [$root selectNodes $xp] { set groupid [$group @n] GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type circle] } - set xp0 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='DEM-VelocityIC'\]/group" - foreach group [$root selectNodes $xp0] { + ## unassign all triangles from all the groups in DEM conditions 3D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'DEMVelocity'\]/group" + foreach group [$root selectNodes $xp] { set groupid [$group @n] GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type triangle] } - set xp0 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='DEM-VelocityIC2D'\]/group" - foreach group [$root selectNodes $xp0] { + ## unassign all lines from all the groups in DEM conditions 2D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'DEMVelocity2D'\]/group" + foreach group [$root selectNodes $xp] { set groupid [$group @n] GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type linear] } - set xp0 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='DEM-VelocityBC'\]/group" - foreach group [$root selectNodes $xp0] { + + # ANGULAR VELOCITY + # should be: unassign all spheres from all the groups in FEM conditions . + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'FEMAngular'\]/group" + foreach group [$root selectNodes $xp] { + set groupid [$group @n] + GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type sphere] + } + + ## unassign all circles from all the groups in FEM conditions 2D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'FEMAngular2D'\]/group" + foreach group [$root selectNodes $xp] { + set groupid [$group @n] + GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type circle] + } + + ## unassign all triangles from all the groups in DEM conditions 3D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'DEMAngular'\]/group" + foreach group [$root selectNodes $xp] { set groupid [$group @n] GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type triangle] } - set xp0 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='DEM-VelocityBC2D'\]/group" - foreach group [$root selectNodes $xp0] { + ## unassign all lines from all the groups in DEM conditions 2D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'DEMAngular2D'\]/group" + foreach group [$root selectNodes $xp] { set groupid [$group @n] GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type linear] } - set xp0 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='DEM-GraphCondition'\]/group" - foreach group [$root selectNodes $xp0] { + + # FORCE + # should be: unassign all spheres from all the groups in FEM conditions . + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'FEMForce'\]/group" + foreach group [$root selectNodes $xp] { + set groupid [$group @n] + GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type sphere] + } + + ## unassign all circles from all the groups in FEM conditions 2D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'FEMForce2D'\]/group" + foreach group [$root selectNodes $xp] { + set groupid [$group @n] + GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type circle] + } + + ## unassign all triangles from all the groups in DEM conditions 3D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'DEMForce'\]/group" + foreach group [$root selectNodes $xp] { + set groupid [$group @n] + GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type triangle] + } + + ## unassign all lines from all the groups in DEM conditions 2D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'DEMForce2D'\]/group" + foreach group [$root selectNodes $xp] { + set groupid [$group @n] + GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type linear] + } + + + # TORQUE + # should be: unassign all spheres from all the groups in FEM conditions . + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'FEMTorque'\]/group" + foreach group [$root selectNodes $xp] { + set groupid [$group @n] + GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type sphere] + } + + ## unassign all circles from all the groups in FEM conditions 2D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'FEMTorque2D'\]/group" + foreach group [$root selectNodes $xp] { + set groupid [$group @n] + GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type circle] + } + + ## unassign all triangles from all the groups in DEM conditions 3D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'DEMTorque'\]/group" + foreach group [$root selectNodes $xp] { set groupid [$group @n] GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type triangle] } - set xp0 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='DEM-GraphCondition2D'\]/group" - foreach group [$root selectNodes $xp0] { + ## unassign all lines from all the groups in DEM conditions 2D. + set xp "[spdAux::getRoute DEMParts]/condition\[@n = 'DEMTorque2D'\]/group" + foreach group [$root selectNodes $xp] { set groupid [$group @n] GiD_EntitiesGroups unassign $groupid -also_lower_entities elements [GiD_EntitiesGroups get $groupid elements -element_type linear] } + + # Delete all linear/triangle/quadrilateral from sphere_skin + # Unassign all linear/triangle from sphere_skin if [GiD_Groups exists SKIN_SPHERE_DO_NOT_DELETE] { GiD_Mesh delete element [GiD_EntitiesGroups get SKIN_SPHERE_DO_NOT_DELETE elements -element_type quadrilateral] - GiD_EntitiesGroups unassign SKIN_SPHERE_DO_NOT_DELETE elements [GiD_EntitiesGroups get SKIN_SPHERE_DO_NOT_DELETE elements -element_type linear] - GiD_EntitiesGroups unassign SKIN_SPHERE_DO_NOT_DELETE elements [GiD_EntitiesGroups get SKIN_SPHERE_DO_NOT_DELETE elements -element_type triangle] - GiD_EntitiesGroups unassign SKIN_SPHERE_DO_NOT_DELETE elements [GiD_EntitiesGroups get SKIN_SPHERE_DO_NOT_DELETE elements -element_type quadrilateral] + GiD_Mesh delete element [GiD_EntitiesGroups get SKIN_SPHERE_DO_NOT_DELETE elements -element_type triangle] + GiD_Mesh delete element [GiD_EntitiesGroups get SKIN_SPHERE_DO_NOT_DELETE elements -element_type linear] + + # GiD_EntitiesGroups unassign SKIN_SPHERE_DO_NOT_DELETE elements [GiD_EntitiesGroups get SKIN_SPHERE_DO_NOT_DELETE elements -element_type linear] + # GiD_EntitiesGroups unassign SKIN_SPHERE_DO_NOT_DELETE elements [GiD_EntitiesGroups get SKIN_SPHERE_DO_NOT_DELETE elements -element_type triangle] } # set without_window [GidUtils::AreWindowsDisabled]; diff --git a/kratos.gid/apps/DEM/write/write.tcl b/kratos.gid/apps/DEM/write/write.tcl index 26d7b63e5..31cc0310f 100644 --- a/kratos.gid/apps/DEM/write/write.tcl +++ b/kratos.gid/apps/DEM/write/write.tcl @@ -6,6 +6,7 @@ namespace eval ::DEM::write { variable partsProperties variable inletProperties variable wallsProperties + variable DEMProperties variable phantomwallsProperties variable last_property_id variable delete_previous_mdpa @@ -20,8 +21,10 @@ proc ::DEM::write::Init { } { SetAttribute properties_location [::DEM::GetWriteProperty properties_location] SetAttribute parts_un [::DEM::GetUniqueName parts] SetAttribute materials_un [::DEM::GetUniqueName materials] + # SetAttribute init_conditions_un [::DEM::GetUniqueName init_conditions] SetAttribute conditions_un [::DEM::GetUniqueName conditions] - SetAttribute nodal_conditions_un [::DEM::GetUniqueName nodal_conditions] + SetAttribute loads_un [::DEM::GetUniqueName loads] + SetAttribute injectors_un [::DEM::GetUniqueName injectors] SetAttribute materials_file [::DEM::GetWriteProperty materials_file] SetAttribute main_launch_file [::DEM::GetAttribute main_launch_file] @@ -34,6 +37,9 @@ proc ::DEM::write::Init { } { variable wallsProperties set wallsProperties [dict create] + variable DEMProperties + set DEMProperties [dict create] + variable phantomwallsProperties set phantomwallsProperties [dict create] @@ -73,7 +79,7 @@ proc ::DEM::write::writeModelPartEvent { } { WriteMDPAParts write::CloseFile - # MDPA Inlet + # MDPA Inlet - de momento offline write::OpenFile "[Kratos::GetModelName]DEM_Inlet.mdpa" WriteMDPAInlet write::CloseFile diff --git a/kratos.gid/apps/DEM/write/writeMDPA_Inlet.tcl b/kratos.gid/apps/DEM/write/writeMDPA_Inlet.tcl index cef36c46f..ccc97cc58 100644 --- a/kratos.gid/apps/DEM/write/writeMDPA_Inlet.tcl +++ b/kratos.gid/apps/DEM/write/writeMDPA_Inlet.tcl @@ -8,47 +8,48 @@ proc ::DEM::write::WriteMDPAInlet { } { # Properties section writeMaterialsInlet - # Nodal coordinates (only for DEM Parts ) - write::writeNodalCoordinatesOnGroups [GetInletGroups] + set inlet_groups_list [list] + foreach group_node [::DEM::write::GetInletPartGroupNodes] {lappend inlet_groups_list [$group_node @n]} + write::writeNodalCoordinatesOnGroups $inlet_groups_list - # SubmodelParts - - writeInletMeshes + writeInletConditionMeshes #Copy cluster files (.clu) - copyClusterFiles + #TODO:copyClusterFiles +} + + +proc ::DEM::write::GetInletPartGroupNodes { } { + return [[customlib::GetBaseRoot] selectNodes "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_Inlet-FEM'\]/group"] } proc ::DEM::write::GetInletConditionName { } { - set condition_name Inlet + set condition_name Parts_Inlet-FEM if {$::Model::SpatialDimension eq "2D"} { - set condition_name Inlet2D + set condition_name DEMInlet2D } return $condition_name } proc ::DEM::write::GetInletConditionXpath { } { set condition_name [GetInletConditionName] - set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = '$condition_name'\]" + set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/condition\[@n = '$condition_name'\]" return $xp1 } -# That can be all or active / All by default proc ::DEM::write::GetInletGroups { {that all}} { set groups [list ] - foreach group [[customlib::GetBaseRoot] selectNodes [DEM::write::GetInletConditionXpath]/group] { set groupid [$group @n] - if {$that eq "active"} { - set active_inlet [write::getValueByNodeChild $group SetActive] - if {[write::isBooleanFalse $active_inlet]} {continue} - } + # if {$that eq "active"} { + # set active_inlet [write::getValueByNodeChild $group SetActive] + # if {[write::isBooleanFalse $active_inlet]} {continue} + # } lappend groups [write::GetWriteGroupName $groupid] } return $groups } - proc ::DEM::write::copyClusterFiles { } { set dir [write::GetConfigurationAttribute dir] @@ -99,6 +100,174 @@ proc ::DEM::write::GetUsedClusters { } { return [list $clusters_list $custom_clusters_list] } + + +proc ::DEM::write::writeInletConditionMeshes { } { + variable inletProperties + + foreach group_node [::DEM::write::GetInletPartGroupNodes] { + set group [$group_node @n] + set mid [write::AddSubmodelpart Parts_Inlet-FEM $group] + set props [DEM::write::FindPropertiesBySubmodelpart $inletProperties $mid] + writeInletConditionMesh Parts_Inlet-FEM $group $props + } +} + +proc ::DEM::write::writeInletConditionMesh { condition group props } { + + set mid [write::AddSubmodelpart $condition $group] + + write::WriteString "Begin SubModelPart $mid // $condition - group identifier: $group" + write::WriteString " Begin SubModelPartData // $condition. Group name: $group" + if {$props ne ""} { + set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/condition\[@n = 'Parts_Inlet-FEM'\]/group\[@n = '$group'\]" + set group_node [[customlib::GetBaseRoot] selectNodes $xp1] + write::WriteString " RIGID_BODY_OPTION 1" + + set mass [dict get $props Material Variables InputMass] + write::WriteString " RIGID_BODY_MASS $mass" + + lassign [dict get $props Material Variables InputCenter] cX cY cZ + if {$::Model::SpatialDimension eq "2D"} {write::WriteString " RIGID_BODY_CENTER_OF_ROTATION \[3\] ($cX,$cY,0.0)" + } else {write::WriteString " RIGID_BODY_CENTER_OF_ROTATION \[3\] ($cX,$cY,$cZ)"} + + set inertias [dict get $props Material Variables InputInertia] + if {$::Model::SpatialDimension eq "2D"} { + set iX $inertias + write::WriteString " RIGID_BODY_INERTIAS \[3\] (0.0,0.0,$iX)" + } else { + lassign $inertias iX iY iZ + write::WriteString " RIGID_BODY_INERTIAS \[3\] ($iX,$iY,$iZ)" + } + + lassign [dict get $props Material Variables InputOrientation] oX oY oZ + lassign [MathUtils::VectorNormalized [list $oX $oY $oZ]] oX oY oZ + #La direccion del eje tiene que darse normalizada. Assert oX*oX+oY*oY+oZ*oZ = 1 + set angle [dict get $props Material Variables InputModule] + set mod [expr {sin($angle/2.0)}] + set qx [expr {$oX * [expr $mod]}] + set qy [expr {$oY * [expr $mod]}] + set qz [expr {$oZ * [expr $mod]}] + set qw [expr {cos($angle/2.0) }] + + write::WriteString " ORIENTATION \[4\] ($qx, $qy, $qz, $qw)" + write::WriteString " IDENTIFIER [write::transformGroupName $group]" + + DEM::write::DefineFEMExtraConditions $props + } else {W "Error - Properties empty for submodelpart $condition $group"} + write::WriteString " End SubModelPartData" + + write::WriteString " Begin SubModelPartNodes" + GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $group] [subst "%10i\n"]] + write::WriteString " End SubModelPartNodes" + + write::WriteString "" + write::WriteString "End SubModelPart" + write::WriteString "" +} + +proc ::DEM::write::GetClusterFileNameAndReplaceInletElementType {inlet_element_type} { + if {$inlet_element_type eq "LineCluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "linecluster3D.clu" + } elseif {$inlet_element_type eq "RingCluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ringcluster3D.clu" + } elseif {$inlet_element_type eq "Wheat5Cluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "wheat5cluster3D.clu" + } elseif {$inlet_element_type eq "SoyBeanCluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "soybeancluster3D.clu" + } elseif {$inlet_element_type eq "CornKernel3Cluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "corn3cluster3D.clu" + } elseif {$inlet_element_type eq "CornKernelCluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "cornkernelcluster3D.clu" + } elseif {$inlet_element_type eq "Rock1Cluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "rock1cluster3D.clu" + } elseif {$inlet_element_type eq "Rock2Cluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "rock2cluster3D.clu" + } elseif {$inlet_element_type eq "Ballast1Cluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast1cluster3D.clu" + } elseif {$inlet_element_type eq "Ballast1Cluster3Dred"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast1cluster3Dred.clu" + } elseif {$inlet_element_type eq "Ballast2Cluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast2cluster3D.clu" + } elseif {$inlet_element_type eq "Ballast2Cluster3Dred"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast2cluster3Dred.clu" + } elseif {$inlet_element_type eq "Ballast3Cluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast3cluster3D.clu" + } elseif {$inlet_element_type eq "Ballast3Cluster3Dred"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast3cluster3Dred.clu" + } elseif {$inlet_element_type eq "Ballast4Cluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast4cluster3D.clu" + } elseif {$inlet_element_type eq "Ballast4Cluster3Dred"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast4cluster3Dred.clu" + } elseif {$inlet_element_type eq "Ballast5Cluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast5cluster3D.clu" + } elseif {$inlet_element_type eq "Ballast5Cluster3Dred"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast5cluster3Dred.clu" + } elseif {$inlet_element_type eq "Ballast6Cluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast6cluster3D.clu" + } elseif {$inlet_element_type eq "Ballast6Cluster3Dred"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "ballast6cluster3Dred.clu" + } elseif {$inlet_element_type eq "SoyBean3Cluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "soybean3cluster3D.clu" + } elseif {$inlet_element_type eq "CapsuleCluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "capsulecluster3D.clu" + } elseif {$inlet_element_type eq "SingleSphereCluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "singlespherecluster3D.clu" + } elseif {$inlet_element_type eq "Rock3RefinedCluster3D"} { + set inlet_element_type "Cluster3D" + set cluster_file_name "rock3refinedcluster3D.clu" + } else { + error "No cluster found" + } + + return [list $inlet_element_type $cluster_file_name] +} + +proc ::DEM::write::writeMaterialsInlet { } { + + write::WriteString "Begin Properties 0" + write::WriteString "End Properties" + write::WriteString "" + +} + +proc ::DEM::write::processInletMaterials { } { + write::processMaterials "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_Inlet-FEM'\]/group" + + variable inletProperties + set inletProperties [write::getPropertiesListByConditionXPath "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_Inlet-FEM'\]" 0 DEMInletPart] + W $inletProperties +} + + + + +########################## Deprecated procs ################### + + proc ::DEM::write::DefineInletConditions {inletProperties mid contains_clusters} { set inlet_element_type [DEM::write::GetInletElementType] if {[dict get $inletProperties Material Variables InletElementType] eq "Cluster3D"} { @@ -133,6 +302,8 @@ proc ::DEM::write::GetInjectorElementType {} { return [DEM::write::GetInletElementType] } + + proc ::DEM::write::writeInletMeshes { } { variable inletProperties @@ -140,6 +311,7 @@ proc ::DEM::write::writeInletMeshes { } { foreach groupid [DEM::write::GetInletGroups] { set what nodal + #TODO: revisar ese eq 0 en el submodelpartID del inlet if {[write::getSubModelPartId $condition_name $groupid] eq 0} { set mid [write::AddSubmodelpart $condition_name $groupid] set props [DEM::write::FindPropertiesBySubmodelpart $inletProperties $mid] @@ -328,99 +500,3 @@ proc ::DEM::write::writeInletMeshes { } { write::WriteString " " } } - -proc ::DEM::write::GetClusterFileNameAndReplaceInletElementType {inlet_element_type} { - if {$inlet_element_type eq "LineCluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "linecluster3D.clu" - } elseif {$inlet_element_type eq "RingCluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ringcluster3D.clu" - } elseif {$inlet_element_type eq "Wheat5Cluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "wheat5cluster3D.clu" - } elseif {$inlet_element_type eq "SoyBeanCluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "soybeancluster3D.clu" - } elseif {$inlet_element_type eq "CornKernel3Cluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "corn3cluster3D.clu" - } elseif {$inlet_element_type eq "CornKernelCluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "cornkernelcluster3D.clu" - } elseif {$inlet_element_type eq "Rock1Cluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "rock1cluster3D.clu" - } elseif {$inlet_element_type eq "Rock2Cluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "rock2cluster3D.clu" - } elseif {$inlet_element_type eq "Ballast1Cluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast1cluster3D.clu" - } elseif {$inlet_element_type eq "Ballast1Cluster3Dred"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast1cluster3Dred.clu" - } elseif {$inlet_element_type eq "Ballast2Cluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast2cluster3D.clu" - } elseif {$inlet_element_type eq "Ballast2Cluster3Dred"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast2cluster3Dred.clu" - } elseif {$inlet_element_type eq "Ballast3Cluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast3cluster3D.clu" - } elseif {$inlet_element_type eq "Ballast3Cluster3Dred"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast3cluster3Dred.clu" - } elseif {$inlet_element_type eq "Ballast4Cluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast4cluster3D.clu" - } elseif {$inlet_element_type eq "Ballast4Cluster3Dred"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast4cluster3Dred.clu" - } elseif {$inlet_element_type eq "Ballast5Cluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast5cluster3D.clu" - } elseif {$inlet_element_type eq "Ballast5Cluster3Dred"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast5cluster3Dred.clu" - } elseif {$inlet_element_type eq "Ballast6Cluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast6cluster3D.clu" - } elseif {$inlet_element_type eq "Ballast6Cluster3Dred"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "ballast6cluster3Dred.clu" - } elseif {$inlet_element_type eq "SoyBean3Cluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "soybean3cluster3D.clu" - } elseif {$inlet_element_type eq "CapsuleCluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "capsulecluster3D.clu" - } elseif {$inlet_element_type eq "SingleSphereCluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "singlespherecluster3D.clu" - } elseif {$inlet_element_type eq "Rock3RefinedCluster3D"} { - set inlet_element_type "Cluster3D" - set cluster_file_name "rock3refinedcluster3D.clu" - } else { - error "No cluster found" - } - - return [list $inlet_element_type $cluster_file_name] -} - -proc ::DEM::write::writeMaterialsInlet { } { - - write::WriteString "Begin Properties 0" - write::WriteString "End Properties" - write::WriteString "" - -} - -proc ::DEM::write::processInletMaterials { } { - variable inletProperties - set inlet_xpath [DEM::write::GetInletConditionXpath] - write::processMaterials $inlet_xpath/group - set inletProperties [write::getPropertiesListByConditionXPath $inlet_xpath 0 DEMInletPart] - -} \ No newline at end of file diff --git a/kratos.gid/apps/DEM/write/writeMDPA_Parts.tcl b/kratos.gid/apps/DEM/write/writeMDPA_Parts.tcl index f4229fd40..e64ae5b3e 100644 --- a/kratos.gid/apps/DEM/write/writeMDPA_Parts.tcl +++ b/kratos.gid/apps/DEM/write/writeMDPA_Parts.tcl @@ -1,40 +1,191 @@ proc ::DEM::write::WriteMDPAParts { } { # Headers write::writeModelPartData - - # Process properties - DEM::write::processPartMaterials - - # Write Materials + + # Process DEM materials + DEM::write::processDEMMaterials + + # Write legacy Properties into mdpa + # TODO: This is legacy, no Properties are being written with writeMaterialsParts. writeMaterialsParts - - # Nodal coordinates (only for DEM Parts ) - WriteNodalCoordinatesParts - - # Element connectivities (Groups on Parts) + + set dem_groups_list [list] + foreach group_node [::DEM::write::GetDEMPartGroupNodes] {lappend dem_groups_list [$group_node @n]} + + write::writeNodalCoordinatesOnGroups $dem_groups_list + + # Element connectivities (Groups on DEM Parts only) PrepareCustomMeshedParts - write::writeElementConnectivities + write::writeElementConnectivities Parts_DEM RestoreCustomMeshedParts - - # Element radius + writeSphereRadius - + writeElements + # SubmodelParts - write::writePartSubModelPart + # write::writePartSubModelPart writeDEMConditionMeshes - + # CustomSubmodelParts WriteCustomDEMSmp } -proc ::DEM::write::WriteNodalCoordinatesParts { } { - write::writeNodalCoordinatesOnParts - write::writeNodalCoordinatesOnGroups [DEM::write::GetDEMGroupNamesCustomSubmodelpart] - write::writeNodalCoordinatesOnGroups [GetDEMGroupsInitialC] - write::writeNodalCoordinatesOnGroups [GetDEMGroupsBoundaryC] - write::writeNodalCoordinatesOnGroups [GetNodesForGraphs] +proc ::DEM::write::writeElements { } { + foreach group_node [::DEM::write::GetDEMPartGroupNodes] { + set elem [write::getValueByNode [$group_node selectNodes ".//value\[@n='Element']"] ] + # write as condition (check element WriteAsBlock) + write::writeGroupElementConnectivities $group_node $elem + } +} + +proc ::DEM::write::processDEMMaterials { } { + write::processMaterials "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_DEM'\]/group" + + variable DEMProperties + set DEMProperties [write::getPropertiesListByConditionXPath "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_DEM'\]" 0 SpheresPart] +} + +proc ::DEM::write::writeDEMConditionMeshes { } { + variable DEMProperties + + foreach group_node [::DEM::write::GetDEMPartGroupNodes] { + set group [$group_node @n] + set mid [write::AddSubmodelpart Parts_DEM $group] + set props [DEM::write::FindPropertiesBySubmodelpart $DEMProperties $mid] + writeDEMConditionMesh Parts_DEM $group $props + } +} + +proc ::DEM::write::writeDEMConditionMesh { condition group props } { + + set mid [write::AddSubmodelpart $condition $group] + + write::WriteString "Begin SubModelPart $mid // $condition - group identifier: $group" + write::WriteString " Begin SubModelPartData // $condition. Group name: $group" + # set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/condition\[@n = 'Parts_DEM'\]/group\[@n = '$group'\]" + write::WriteString " End SubModelPartData" + + write::WriteString " Begin SubModelPartNodes" + GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $group] [subst "%10i\n"]] + write::WriteString " End SubModelPartNodes" + + write::WriteString "Begin SubModelPartElements" + set gdict [dict create] + set f "%10i\n" + set f [subst $f] + dict set gdict $group $f + GiD_WriteCalculationFile elements -sorted $gdict + write::WriteString "End SubModelPartElements" + write::WriteString "" + write::WriteString "End SubModelPart" + write::WriteString "" +} + +proc ::DEM::write::GetDEMPartGroupNodes { } { + return [[customlib::GetBaseRoot] selectNodes "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_DEM'\]/group"] +} + +proc ::DEM::write::writeSphereRadius { } { + set root [customlib::GetBaseRoot] + set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/condition\[@n='Parts_DEM'\]/group" + foreach group [$root selectNodes $xp1] { + DEM::write::writeSphereRadiusOnGroup $group + } +} + +proc ::DEM::write::writeSphereRadiusOnGroup { group } { + set groupid [$group @n] + set print_groupid [write::GetWriteGroupName $groupid] + write::WriteString "Begin NodalData RADIUS // GUI group identifier: $print_groupid" + GiD_WriteCalculationFile connectivities [dict create $groupid "%.0s %10d 0 %10g\n"] + write::WriteString "End NodalData" + write::WriteString "" } +proc ::DEM::write::writeMaterialsParts { } { + write::WriteString "Begin Properties 0" + write::WriteString "End Properties" + write::WriteString "" +} + +proc ::DEM::write::PrepareCustomMeshedParts { } { + variable restore_ov + set root [customlib::GetBaseRoot] + #set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/group" + set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/condition\[@n='Parts_DEM'\]/group" + foreach group [$root selectNodes $xp1] { + set groupid [$group @n] + if {[$group hasAttribute ov]} {set prev_ov [$group @ov]} {set prev_ov [[$group parent] @ov]} + dict set restore_ov $groupid $prev_ov + # We must force it to be volume/surface because anything applied to Parts will be converted into Spheres/Circles + if {$::Model::SpatialDimension eq "3D"} { + $group setAttribute ov volume + } else { + $group setAttribute ov surface + } + } +} + +proc ::DEM::write::RestoreCustomMeshedParts { } { + variable restore_ov + set root [customlib::GetBaseRoot] + #set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/group" + set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/condition\[@n='Parts_DEM'\]/group" + foreach group [$root selectNodes $xp1] { + set groupid [$group @n] + if {$groupid in [dict keys $restore_ov]} { + set prev_ov [dict get $restore_ov $groupid] + # Bring back to original entities (Check PrepareCustomMeshedParts) + $group setAttribute ov $prev_ov + } + } + set restore_ov [dict create] +} + +proc ::DEM::write::WriteCustomDEMSmp { } { + set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-CustomSmp'\]/group" + foreach group [[customlib::GetBaseRoot] selectNodes $xp1] { + set group_id [$group @n] + + set destination_mdpa [write::getValueByNode [$group selectNodes "./value\[@n='WhatMdpa'\]"]] + if {$destination_mdpa == "DEM"} { + set mid [write::AddSubmodelpart DEM-CustomSmp $group_id] + write::WriteString "Begin SubModelPart $mid \/\/ Custom SubModelPart. Group name: $group_id" + write::WriteString "Begin SubModelPartData" + write::WriteString "End SubModelPartData" + write::WriteString "Begin SubModelPartNodes" + GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $group_id] [subst "%10i\n"]] + write::WriteString "End SubModelPartNodes" + write::WriteString "End SubModelPart" + write::WriteString "" + } + } +} + + + + + + + + + + + + + + + +######################################################## +# Unused & deprecated procs to be removed in the future. +######################################################## + + +proc ::DEM::write::processPartMaterials { } { + # unused + variable partsProperties + set partsProperties [write::getPropertiesList [GetAttribute parts_un] 0 SpheresPart] +} proc ::DEM::write::GetDEMGroupNamesCustomSubmodelpart { } { set groups [list ] @@ -44,6 +195,7 @@ proc ::DEM::write::GetDEMGroupNamesCustomSubmodelpart { } { } return $groups } + proc ::DEM::write::GetDEMGroupsCustomSubmodelpart { } { set groups [list ] set xp2 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-CustomSmp'\]/group" @@ -56,9 +208,20 @@ proc ::DEM::write::GetDEMGroupsCustomSubmodelpart { } { return $groups } +proc ::DEM::write::WriteNodalCoordinatesParts { } { + # Unused. Deprecated. + # Writing nodal coordinates are currently being done for all particle groups in the write_parts proc. + # This implies all groups must be defined as parts beforehand, including custom and graphs. + write::writeNodalCoordinatesOnParts + write::writeNodalCoordinatesOnGroups [DEM::write::GetDEMGroupNamesCustomSubmodelpart] + write::writeNodalCoordinatesOnGroups [GetDEMGroupsBoundaryC] + write::writeNodalCoordinatesOnGroups [GetNodesForGraphs] +} + proc ::DEM::write::GetDEMGroupsInitialC { } { + # Unused & deprecated. set groups [list ] - if {$::Model::SpatialDimension eq "2D"} { + if {$::Model::SpatialDimension eq "2D"} { set xp3 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-VelocityIC2D'\]/group" } else { set xp3 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-VelocityIC'\]/group" @@ -71,8 +234,9 @@ proc ::DEM::write::GetDEMGroupsInitialC { } { } proc ::DEM::write::GetDEMGroupsBoundaryC { } { + # Unused & deprecated. set groups [list ] - if {$::Model::SpatialDimension eq "2D"} { + if {$::Model::SpatialDimension eq "2D"} { set xp4 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-VelocityBC2D'\]/group" } else { set xp4 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-VelocityBC'\]/group" @@ -84,9 +248,67 @@ proc ::DEM::write::GetDEMGroupsBoundaryC { } { return $groups } +proc ::DEM::write::GetSpheresGroupsListInConditions { } { + # unused. + set conds_groups_dict [dict create ] + set groups [list ] + + # Get all the groups with spheres + foreach group [GetSpheresGroups] { + foreach surface [GiD_EntitiesGroups get $group nodes] { + foreach involved_group [GiD_EntitiesGroups entity_groups nodes $surface] { + set involved_group_id [write::GetWriteGroupName $involved_group] + if {$involved_group_id ni $groups} {lappend groups $involved_group_id} + } + } + } + + # Find the relations condition -> group + set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition" + foreach cond [[customlib::GetBaseRoot] selectNodes $xp1] { + set condid [$cond @n] + foreach cond_group [$cond selectNodes "group"] { + set group [write::GetWriteGroupName [$cond_group @n]] + if {$group in $groups} {dict lappend conds_groups_dict $condid [$cond_group @n]} + } + } + return $conds_groups_dict +} + +proc ::DEM::write::GetSpheresGroups { } { + set groups [list ] + + set conditions_list {DEM-VelocityBC DEM-VelocityIC DEM-GraphCondition} + if {$::Model::SpatialDimension eq "2D"} { + set conditions_list {DEM-VelocityBC2D DEM-VelocityIC2D DEM-GraphCondition2D} + } + + foreach condition $conditions_list { + set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = '$condition'\]/group" + foreach group [[customlib::GetBaseRoot] selectNodes $xp1] { + set groupid [$group @n] + lappend groups [write::GetWriteGroupName $groupid] + } + } + + return $groups +} + +proc ::DEM::write::DefineDEMExtraConditions {group_node group} { + set GraphPrint [write::getValueByNode [$group_node selectNodes "./value\[@n='GraphPrint'\]"]] + if {$GraphPrint == "true"} { + set GraphPrintval 1 + } else { + set GraphPrintval 0 + } + write::WriteString " FORCE_INTEGRATION_GROUP $GraphPrintval" + write::WriteString " IDENTIFIER [write::transformGroupName $group]" +} + proc ::DEM::write::GetNodesForGraphs { } { + # Unused & deprecated. set groups [list ] - if {$::Model::SpatialDimension eq "2D"} { + if {$::Model::SpatialDimension eq "2D"} { set xp5 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-GraphCondition2D'\]/group" } else { set xp5 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-GraphCondition'\]/group" @@ -98,24 +320,7 @@ proc ::DEM::write::GetNodesForGraphs { } { return $groups } -proc ::DEM::write::writeSphereRadius { } { - set root [customlib::GetBaseRoot] - set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/group" - foreach group [$root selectNodes $xp1] { - DEM::write::writeSphereRadiusOnGroup $group - } -} - -proc ::DEM::write::writeSphereRadiusOnGroup { group } { - set groupid [$group @n] - set print_groupid [write::GetWriteGroupName $groupid] - write::WriteString "Begin NodalData RADIUS // GUI group identifier: $print_groupid" - GiD_WriteCalculationFile connectivities [dict create $groupid "%.0s %10d 0 %10g\n"] - write::WriteString "End NodalData" - write::WriteString "" -} - -proc ::DEM::write::writeDEMConditionMeshes { } { +proc ::DEM::write::old_writeDEMConditionMeshes { } { foreach {cond group_list} [GetSpheresGroupsListInConditions] { if {$cond in {"DEM-VelocityBC" "DEM-VelocityBC2D"}} { #set cnd [Model::getCondition $cond] @@ -125,13 +330,13 @@ proc ::DEM::write::writeDEMConditionMeshes { } { write::WriteString " Begin SubModelPartData // DEM-VelocityBC. Group name: $group" set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = '$cond'\]/group\[@n = '$group'\]" set group_node [[customlib::GetBaseRoot] selectNodes $xp1] - + set prescribeMotion_flag [write::getValueByNode [$group_node selectNodes "./value\[@n='PrescribeMotion_flag'\]"]] if {[write::isBooleanTrue $prescribeMotion_flag]} { - + set motion_type [write::getValueByNode [$group_node selectNodes "./value\[@n='DEM-VelocityBCMotion'\]"]] if {$motion_type == "LinearPeriodic"} { - + # Linear velocity set velocity [write::getValueByNode [$group_node selectNodes "./value\[@n='VelocityModulus'\]"]] lassign [write::getValueByNode [$group_node selectNodes "./value\[@n='DirectionVector'\]"]] velocity_X velocity_Y velocity_Z @@ -143,14 +348,14 @@ proc ::DEM::write::writeDEMConditionMeshes { } { lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y $velocity_Z]] velocity_X velocity_Y velocity_Z lassign [MathUtils::ScalarByVectorProd $velocity [list $velocity_X $velocity_Y $velocity_Z] ] vx vy vz write::WriteString " LINEAR_VELOCITY \[3\] ($vx, $vy, $vz)"} - + # Period set periodic [write::getValueByNode [$group_node selectNodes "./value\[@n='LinearPeriodic'\]"]] if {[write::isBooleanTrue $periodic]} { set period [write::getValueByNode [$group_node selectNodes "./value\[@n='LinearPeriod'\]"]] } else {set period 0.0} write::WriteString " VELOCITY_PERIOD $period" - + # Angular velocity set avelocity [write::getValueByNode [$group_node selectNodes "./value\[@n='AngularVelocityModulus'\]"]] if {$::Model::SpatialDimension eq "2D"} {write::WriteString " ANGULAR_VELOCITY \[3\] (0.0,0.0,$avelocity)" @@ -159,12 +364,12 @@ proc ::DEM::write::writeDEMConditionMeshes { } { lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y $velocity_Z]] velocity_X velocity_Y velocity_Z lassign [MathUtils::ScalarByVectorProd $avelocity [list $velocity_X $velocity_Y $velocity_Z] ] wX wY wZ write::WriteString " ANGULAR_VELOCITY \[3\] ($wX,$wY,$wZ)"} - + # Angular center of rotation lassign [write::getValueByNode [$group_node selectNodes "./value\[@n='CenterOfRotation'\]"]] oX oY oZ if {$::Model::SpatialDimension eq "2D"} {write::WriteString " ROTATION_CENTER \[3\] ($oX,$oY,0.0)" } else {write::WriteString " ROTATION_CENTER \[3\] ($oX,$oY,$oZ)"} - + # Angular Period set angular_periodic [write::getValueByNode [$group_node selectNodes "./value\[@n='AngularPeriodic'\]"]] if {[write::isBooleanTrue $angular_periodic]} { @@ -173,7 +378,7 @@ proc ::DEM::write::writeDEMConditionMeshes { } { set angular_period 0.0 } write::WriteString " ANGULAR_VELOCITY_PERIOD $angular_period" - + set LinearStartTime [write::getValueByNode [$group_node selectNodes "./value\[@n='LinearStartTime'\]"]] set LinearEndTime [write::getValueByNode [$group_node selectNodes "./value\[@n='LinearEndTime'\]"]] set AngularStartTime [write::getValueByNode [$group_node selectNodes "./value\[@n='AngularStartTime'\]"]] @@ -184,10 +389,10 @@ proc ::DEM::write::writeDEMConditionMeshes { } { write::WriteString " ANGULAR_VELOCITY_START_TIME $AngularStartTime" write::WriteString " ANGULAR_VELOCITY_STOP_TIME $AngularEndTime" write::WriteString " RIGID_BODY_MOTION $rigid_body_motion" - + } elseif {$motion_type == "FixedDOFs"} { set rigid_body_motion 0 - + # DOFS set Ax [write::getValueByNode [$group_node selectNodes "./value\[@n='Ax'\]"]] set Ay [write::getValueByNode [$group_node selectNodes "./value\[@n='Ay'\]"]] @@ -224,10 +429,10 @@ proc ::DEM::write::writeDEMConditionMeshes { } { write::WriteString " VELOCITY_START_TIME $VStart" write::WriteString " VELOCITY_STOP_TIME $VEnd" write::WriteString " RIGID_BODY_MOTION $rigid_body_motion" - + } } - + DefineDEMExtraConditions $group_node $group write::WriteString " End SubModelPartData" write::WriteString " Begin SubModelPartNodes" @@ -245,10 +450,10 @@ proc ::DEM::write::writeDEMConditionMeshes { } { write::WriteString " Begin SubModelPartData // DEM-VelocityIC. Group name: $group" set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = '$cond'\]/group\[@n = '$group'\]" set group_node [[customlib::GetBaseRoot] selectNodes $xp1] - + set prescribeMotion_flag [write::getValueByNode [$group_node selectNodes "./value\[@n='PrescribeMotion_flag'\]"]] if {[write::isBooleanTrue $prescribeMotion_flag]} { - + # Linear velocity set velocity [write::getValueByNode [$group_node selectNodes "./value\[@n='InitialVelocityModulus'\]"]] lassign [write::getValueByNode [$group_node selectNodes "./value\[@n='iDirectionVector'\]"]] velocity_X velocity_Y velocity_Z @@ -265,7 +470,7 @@ proc ::DEM::write::writeDEMConditionMeshes { } { write::WriteString " INITIAL_VELOCITY_X_VALUE $vx" write::WriteString " INITIAL_VELOCITY_Y_VALUE $vy" write::WriteString " INITIAL_VELOCITY_Z_VALUE $vz"} - + # Angular velocity set avelocity [write::getValueByNode [$group_node selectNodes "./value\[@n='InitialAngularVelocityModulus'\]"]] if {$::Model::SpatialDimension eq "2D"} { @@ -283,7 +488,7 @@ proc ::DEM::write::writeDEMConditionMeshes { } { #Hardcoded write::WriteString " RIGID_BODY_MOTION $rigid_body_motion" DefineDEMExtraConditions $group_node $group - + write::WriteString " End SubModelPartData" write::WriteString " Begin SubModelPartNodes" GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $group] [subst "%10i\n"]] @@ -293,15 +498,15 @@ proc ::DEM::write::writeDEMConditionMeshes { } { } } elseif {$cond in {"DEM-GraphCondition" "DEM-GraphCondition2D"}} { foreach group $group_list { - + set mid [write::AddSubmodelpart $cond $group] write::WriteString "Begin SubModelPart $mid // GUI DEM-GraphCondition - $cond - group identifier: $group" write::WriteString " Begin SubModelPartData // DEM-GraphCondition. Group name: $group" set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = '$cond'\]/group\[@n = '$group'\]" set group_node [[customlib::GetBaseRoot] selectNodes $xp1] - + DefineDEMExtraConditions $group_node $group - + write::WriteString " End SubModelPartData" write::WriteString " Begin SubModelPartNodes" GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $group] [subst "%10i\n"]] @@ -311,129 +516,4 @@ proc ::DEM::write::writeDEMConditionMeshes { } { } } } -} - -proc ::DEM::write::DefineDEMExtraConditions {group_node group} { - set GraphPrint [write::getValueByNode [$group_node selectNodes "./value\[@n='GraphPrint'\]"]] - if {$GraphPrint == "true"} { - set GraphPrintval 1 - } else { - set GraphPrintval 0 - } - write::WriteString " FORCE_INTEGRATION_GROUP $GraphPrintval" - write::WriteString " IDENTIFIER [write::transformGroupName $group]" -} - -# TODO: This code is extremely inefficient -> find a simple way to solve it -proc ::DEM::write::GetSpheresGroupsListInConditions { } { - set conds_groups_dict [dict create ] - set groups [list ] - - # Get all the groups with spheres - foreach group [GetSpheresGroups] { - foreach surface [GiD_EntitiesGroups get $group nodes] { - foreach involved_group [GiD_EntitiesGroups entity_groups nodes $surface] { - set involved_group_id [write::GetWriteGroupName $involved_group] - if {$involved_group_id ni $groups} {lappend groups $involved_group_id} - } - } - } - - # Find the relations condition -> group - set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition" - foreach cond [[customlib::GetBaseRoot] selectNodes $xp1] { - set condid [$cond @n] - foreach cond_group [$cond selectNodes "group"] { - set group [write::GetWriteGroupName [$cond_group @n]] - if {$group in $groups} {dict lappend conds_groups_dict $condid [$cond_group @n]} - } - } - return $conds_groups_dict -} - -proc ::DEM::write::GetSpheresGroups { } { - set groups [list ] - - set conditions_list {DEM-VelocityBC DEM-VelocityIC DEM-GraphCondition} - if {$::Model::SpatialDimension eq "2D"} { - set conditions_list {DEM-VelocityBC2D DEM-VelocityIC2D DEM-GraphCondition2D} - } - - foreach condition $conditions_list { - set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = '$condition'\]/group" - foreach group [[customlib::GetBaseRoot] selectNodes $xp1] { - set groupid [$group @n] - lappend groups [write::GetWriteGroupName $groupid] - } - } - - return $groups -} - - -proc ::DEM::write::processPartMaterials { } { - variable partsProperties - # Materials for parts are already processed - #W [write::processMaterials] - set partsProperties [write::getPropertiesList [GetAttribute parts_un] 0 SpheresPart] -} - -proc ::DEM::write::writeMaterialsParts { } { - - write::WriteString "Begin Properties 0" - write::WriteString "End Properties" - write::WriteString "" -} - -proc ::DEM::write::PrepareCustomMeshedParts { } { - variable restore_ov - set root [customlib::GetBaseRoot] - set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/group" - foreach group [$root selectNodes $xp1] { - set groupid [$group @n] - if {[$group hasAttribute ov]} {set prev_ov [$group @ov]} {set prev_ov [[$group parent] @ov]} - dict set restore_ov $groupid $prev_ov - # We must force it to be volume/surface because anything applied to Parts will be converted into Spheres/Circles - if {$::Model::SpatialDimension eq "3D"} { - $group setAttribute ov volume - } else { - $group setAttribute ov surface - } - } -} - -proc ::DEM::write::RestoreCustomMeshedParts { } { - variable restore_ov - set root [customlib::GetBaseRoot] - set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/group" - foreach group [$root selectNodes $xp1] { - set groupid [$group @n] - if {$groupid in [dict keys $restore_ov]} { - set prev_ov [dict get $restore_ov $groupid] - # Bring back to original entities (Check PrepareCustomMeshedParts) - $group setAttribute ov $prev_ov - } - } - set restore_ov [dict create] -} - - -proc ::DEM::write::WriteCustomDEMSmp { } { - set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-CustomSmp'\]/group" - foreach group [[customlib::GetBaseRoot] selectNodes $xp1] { - set group_id [$group @n] - - set destination_mdpa [write::getValueByNode [$group selectNodes "./value\[@n='WhatMdpa'\]"]] - if {$destination_mdpa == "DEM"} { - set mid [write::AddSubmodelpart DEM-CustomSmp $group_id] - write::WriteString "Begin SubModelPart $mid \/\/ Custom SubModelPart. Group name: $group_id" - write::WriteString "Begin SubModelPartData" - write::WriteString "End SubModelPartData" - write::WriteString "Begin SubModelPartNodes" - GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $group_id] [subst "%10i\n"]] - write::WriteString "End SubModelPartNodes" - write::WriteString "End SubModelPart" - write::WriteString "" - } - } } \ No newline at end of file diff --git a/kratos.gid/apps/DEM/write/writeMDPA_Walls.tcl b/kratos.gid/apps/DEM/write/writeMDPA_Walls.tcl index 0acec9eb2..021fc48a3 100644 --- a/kratos.gid/apps/DEM/write/writeMDPA_Walls.tcl +++ b/kratos.gid/apps/DEM/write/writeMDPA_Walls.tcl @@ -2,26 +2,24 @@ proc ::DEM::write::WriteMDPAWalls { } { # Headers write::writeModelPartData - # Material + # Process FEM materials DEM::write::processRigidWallMaterials - if {$::Model::SpatialDimension ne "2D"} { - DEM::write::processPhantomWallMaterials - } - # Properties section + # Write Properties into mdpa + #TODO: This is legacy, no Properties are being written here. WriteRigidWallProperties # Nodal coordinates (only for Walls ) - write::writeNodalCoordinatesOnGroups [DEM::write::GetWallsGroups] + set fem_groups_list [list] + foreach group_node [::DEM::write::GetFEMPartGroupNodes] {lappend fem_groups_list [$group_node @n]} + + write::writeNodalCoordinatesOnGroups $fem_groups_list if {$::Model::SpatialDimension ne "2D"} { - write::writeNodalCoordinatesOnGroups [DEM::write::GetWallsGroupsSmp] + write::writeNodalCoordinatesOnGroups [DEM::write::GetWallsGroupsSmp] } # Nodal conditions and conditions writeConditions - if {$::Model::SpatialDimension ne "2D"} { - writePhantomConditions - } # SubmodelParts writeWallConditionMeshes @@ -31,486 +29,91 @@ proc ::DEM::write::WriteMDPAWalls { } { } proc ::DEM::write::processRigidWallMaterials { } { - variable wallsProperties - set walls_xpath [DEM::write::GetRigidWallXPath] - write::processMaterials $walls_xpath/group - set wallsProperties [write::getPropertiesListByConditionXPath $walls_xpath 0 RigidFacePart] -} + write::processMaterials "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_FEM'\]/group" -proc ::DEM::write::processPhantomWallMaterials { } { - variable phantomwallsProperties - set phantom_walls_xpath [DEM::write::GetPhantomWallXPath] - write::processMaterials $phantom_walls_xpath/group - set phantomwallsProperties [write::getPropertiesListByConditionXPath $phantom_walls_xpath 0] + # It defines the associated properties of the corresponding Part (mass, inertia,..). + variable wallsProperties + set wallsProperties [write::getPropertiesListByConditionXPath "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_FEM'\]" 0 RigidFacePart] } proc ::DEM::write::WriteRigidWallProperties { } { - - write::WriteString "Begin Properties 0" + # Legacy proc. Current properties are located in the Materials.json file + write::WriteString "Begin Properties 0 // Check materials.json" write::WriteString "End Properties" write::WriteString "" } -proc ::DEM::write::WritePhantomWallProperties { } { - set wall_properties [dict create ] - set condition_name "Phantom-Wall" - set cnd [Model::getCondition $condition_name] - - set xp1 [DEM::write::GetPhantomWallXPath] - - #set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-FEM-Wall'\]/group" - set i $DEM::write::last_property_id - foreach group [[customlib::GetBaseRoot] selectNodes $xp1] { - incr i - write::WriteString "Begin Properties $i" - #foreach {prop obj} [$cnd getAllInputs] { - # if {$prop in $print_list} { - # set v [write::getValueByNode [$group selectNodes "./value\[@n='$prop'\]"]] - # write::WriteString " $prop $v" - # } - #} - set friction_value [write::getValueByNode [$group selectNodes "./value\[@n='friction_angle'\]"]] - set pi $MathUtils::PI - set propvalue [expr {tan($friction_value*$pi/180.0)}] - write::WriteString " FRICTION $propvalue" - # write::WriteString " FRICTION [write::getValueByNode [$group selectNodes "./value\[@n='friction_coeff'\]"]]" - write::WriteString " WALL_COHESION [write::getValueByNode [$group selectNodes "./value\[@n='WallCohesion'\]"]]" - set compute_wear_bool [write::getValueByNode [$group selectNodes "./value\[@n='DEM_Wear'\]"]] - if {[write::isBooleanTrue $compute_wear_bool]} { - set compute_wear 1 - set severiy_of_wear [write::getValueByNode [$group selectNodes "./value\[@n='K_Abrasion'\]"]] - set impact_wear_severity [write::getValueByNode [$group selectNodes "./value\[@n='K_Impact'\]"]] - set brinell_hardness [write::getValueByNode [$group selectNodes "./value\[@n='H_Brinell'\]"]] - } else { - set compute_wear 0 - set severiy_of_wear 0.001 - set impact_wear_severity 0.001 - set brinell_hardness 200.0 - } - set rigid_structure_bool [write::getValueByNode [$group selectNodes "./value\[@n='RigidPlane'\]"]] - if {[write::isBooleanTrue $rigid_structure_bool]} { - set young_modulus [write::getValueByNode [$group selectNodes "./value\[@n='YoungModulus'\]"]] - set poisson_ratio [write::getValueByNode [$group selectNodes "./value\[@n='PoissonRatio'\]"]] - } else { - set young_modulus 1e20 - set poisson_ratio 0.25 - } - write::WriteString " COMPUTE_WEAR $compute_wear" - write::WriteString " SEVERITY_OF_WEAR $severiy_of_wear" - write::WriteString " IMPACT_WEAR_SEVERITY $impact_wear_severity" - write::WriteString " BRINELL_HARDNESS $brinell_hardness" - write::WriteString " YOUNG_MODULUS $young_modulus" - write::WriteString " POISSON_RATIO $poisson_ratio" - - write::WriteString "End Properties" - set groupid [$group @n] - dict set wall_properties $groupid $i - incr DEM::write::last_property_id - } - write::WriteString "" - return $wall_properties -} - - -proc ::DEM::write::WriteWallCustomSmp { } { - set condition_name "DEM-CustomSmp" - set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-CustomSmp'\]/group" - - foreach group [[customlib::GetBaseRoot] selectNodes $xp1] { - - set groupid [$group @n] - set destination_mdpa [write::getValueByNode [$group selectNodes "./value\[@n='WhatMdpa'\]"]] - if {$destination_mdpa == "FEM"} { - set mid [write::AddSubmodelpart $condition_name $groupid] - write::WriteString "Begin SubModelPart $mid \/\/ Custom SubModelPart. Group name: $groupid" - write::WriteString "Begin SubModelPartData // DEM-FEM-Wall. Group name: $groupid" - write::WriteString "End SubModelPartData" - write::WriteString "Begin SubModelPartNodes" - GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $groupid] [subst "%10i\n"]] - write::WriteString "End SubModelPartNodes" - write::WriteString "End SubModelPart" - write::WriteString "" - } - } -} - - proc ::DEM::write::writeConditions { } { - variable wallsProperties - ::write::writeConditionsByGiDId DEMConditions [GetRigidWallConditionName] $wallsProperties -} - -proc ::DEM::write::writePhantomConditions { } { - variable phantomwallsProperties - ::write::writeConditionsByGiDId DEMConditions [GetPhantomWallConditionName] $phantomwallsProperties -} - -proc ::DEM::write::GetWallsGroups { } { - set groups [list ] - set groups_rigid [GetRigidWallsGroups] - set groups_phantom [GetPhantomWallsGroups] - set groups [concat $groups_rigid $groups_phantom] - return $groups -} - -proc ::DEM::write::GetRigidWallConditionName {} { - set condition_name "DEM-FEM-Wall" - if {$::Model::SpatialDimension eq "2D"} { - set condition_name "DEM-FEM-Wall2D" + # foreach fem part + foreach group_node [::DEM::write::GetFEMPartGroupNodes] { + set elem [write::getValueByNode [$group_node selectNodes ".//value\[@n='Element']"] ] + # write as condition (check element WriteAsBlock) + write::writeGroupElementConnectivities $group_node $elem } - return $condition_name -} -proc ::DEM::write::GetPhantomWallConditionName {} { - set condition_name "Phantom-Wall" - if {$::Model::SpatialDimension eq "2D"} { - set condition_name "Phantom-Wall2D" - } - return $condition_name -} -proc ::DEM::write::GetRigidWallXPath { } { - set condition_name [GetRigidWallConditionName] - return "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = '$condition_name'\]" -} -proc ::DEM::write::GetPhantomWallXPath { } { - set condition_name [GetPhantomWallConditionName] - return "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = '$condition_name'\]" -} - -proc ::DEM::write::GetRigidWallsGroups { } { - set groups [list ] - - foreach group [[customlib::GetBaseRoot] selectNodes "[DEM::write::GetRigidWallXPath]/group"] { - set groupid [$group @n] - lappend groups [write::GetWriteGroupName $groupid] - } - return $groups -} - -proc ::DEM::write::GetPhantomWallsGroups { } { - set groups [list ] - - foreach group [[customlib::GetBaseRoot] selectNodes "[DEM::write::GetPhantomWallXPath]/group"] { - set groupid [$group @n] - lappend groups [write::GetWriteGroupName $groupid] - } - return $groups -} - -proc ::DEM::write::GetWallsGroupsSmp { } { - set groups [list ] - set xp2 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = 'DEM-CustomSmp'\]/group" - foreach group [[customlib::GetBaseRoot] selectNodes $xp2] { - set destination_mdpa [write::getValueByNode [$group selectNodes "./value\[@n='WhatMdpa'\]"]] - if {$destination_mdpa == "FEM"} { - set groupid [$group @n] - lappend groups [write::GetWriteGroupName $groupid] - } - } - return $groups -} - -## TODO: UNDER REVISION, UNUSED PROC -proc ::DEM::write::GetWallsGroupsListInConditions { } { - set conds_groups_dict [dict create ] - set groups [list ] - - # Get all the groups with surfaces involved in walls - foreach group [GetRigidWallsGroups] { - foreach surface [GiD_EntitiesGroups get $group surfaces] { - foreach involved_group [GiD_EntitiesGroups entity_groups surfaces $surface] { - set involved_group_id [write::GetWriteGroupName $involved_group] - if {$involved_group_id ni $groups} {lappend groups $involved_group_id} - } - } - } - - foreach group [GetRigidWallsGroups] { - foreach line [GiD_EntitiesGroups get $group lines] { - foreach involved_group [GiD_EntitiesGroups entity_groups lines $line] { - set involved_group_id [write::GetWriteGroupName $involved_group] - if {$involved_group_id ni $groups} {lappend groups $involved_group_id} - } - } - } - - # Find the relations condition -> group - set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition" - foreach cond [[customlib::GetBaseRoot] selectNodes $xp1] { - set condid [$cond @n] - foreach cond_group [$cond selectNodes "group"] { - set group [write::GetWriteGroupName [$cond_group @n]] - if {$group in $groups} {dict lappend conds_groups_dict $condid [$cond_group @n]} - } - } - return $conds_groups_dict -} - - -## TODO: UNDER REVISION, UNUSED PROC -proc ::DEM::write::GetConditionsGroups { } { - set groups [list ] - set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition/group" - foreach group [[customlib::GetBaseRoot] selectNodes $xp1] { - set groupid [$group @n] - lappend groups [write::GetWriteGroupName $groupid] - } - return $groups } proc ::DEM::write::writeWallConditionMeshes { } { variable wallsProperties - variable phantomwallsProperties - set condition_name [GetRigidWallConditionName] - foreach group [GetRigidWallsGroups] { - set mid [write::AddSubmodelpart $condition_name $group] + foreach group_node [::DEM::write::GetFEMPartGroupNodes] { + set group [$group_node @n] + set mid [write::AddSubmodelpart Parts_FEM $group] set props [DEM::write::FindPropertiesBySubmodelpart $wallsProperties $mid] - writeWallConditionMesh $condition_name $group $props - } - - if {$::Model::SpatialDimension ne "2D"} { - set condition_name [GetPhantomWallConditionName] - foreach group [GetPhantomWallsGroups] { - set mid [write::AddSubmodelpart $condition_name $group] - set props [DEM::write::FindPropertiesBySubmodelpart $phantomwallsProperties $mid] - writeWallConditionMesh $condition_name $group $props - } + writeWallConditionMesh Parts_FEM $group $props } } +# Print the submodelpart based on the parts -> FEM proc ::DEM::write::writeWallConditionMesh { condition group props } { set mid [write::AddSubmodelpart $condition $group] write::WriteString "Begin SubModelPart $mid // $condition - group identifier: $group" write::WriteString " Begin SubModelPartData // $condition. Group name: $group" - set xp1 "[spdAux::getRoute [GetAttribute conditions_un]]/condition\[@n = '$condition'\]/group\[@n = '$group'\]" - set group_node [[customlib::GetBaseRoot] selectNodes $xp1] - - set is_active [dict get $props Material Variables SetActive] - if {[write::isBooleanTrue $is_active]} { - set motion_type [dict get $props Material Variables DEM-ImposedMotion] - if {$motion_type == "LinearPeriodic"} { - # Linear velocity - set velocity [dict get $props Material Variables VelocityModulus] - lassign [dict get $props Material Variables DirectionVector] velocity_X velocity_Y velocity_Z - if {$::Model::SpatialDimension eq "2D"} { - lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y]] velocity_X velocity_Y - lassign [MathUtils::ScalarByVectorProd $velocity [list $velocity_X $velocity_Y] ] vx vy - write::WriteString " LINEAR_VELOCITY \[3\] ($vx, $vy, 0.0)" - } else { - lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y $velocity_Z]] velocity_X velocity_Y velocity_Z - lassign [MathUtils::ScalarByVectorProd $velocity [list $velocity_X $velocity_Y $velocity_Z] ] vx vy vz - write::WriteString " LINEAR_VELOCITY \[3\] ($vx, $vy, $vz)" - } - # set vX [dict get $props Material Variables LinearVelocityX'\]"]] - - # Period - set periodic [dict get $props Material Variables LinearPeriodic] - if {[write::isBooleanTrue $periodic]} { - set period [dict get $props Material Variables LinearPeriod] - } else { - set period 0.0 - } - write::WriteString " VELOCITY_PERIOD $period" - - # Angular velocity - set avelocity [dict get $props Material Variables AngularVelocityModulus] - if {$::Model::SpatialDimension eq "2D"} { - write::WriteString " ANGULAR_VELOCITY \[3\] (0.0,0.0,$avelocity)" - } else { - lassign [dict get $props Material Variables AngularDirectionVector] velocity_X velocity_Y velocity_Z - lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y $velocity_Z]] velocity_X velocity_Y velocity_Z - lassign [MathUtils::ScalarByVectorProd $avelocity [list $velocity_X $velocity_Y $velocity_Z] ] wx wy wz - write::WriteString " ANGULAR_VELOCITY \[3\] ($wx,$wy,$wz)"} - - # Angular center of rotation - lassign [dict get $props Material Variables CenterOfRotation] oX oY oZ - if {$::Model::SpatialDimension eq "2D"} {write::WriteString " ROTATION_CENTER \[3\] ($oX,$oY,0.0)" - } else {write::WriteString " ROTATION_CENTER \[3\] ($oX,$oY,$oZ)"} - - # Angular Period - set angular_periodic [dict get $props Material Variables AngularPeriodic] - set angular_period 0.0 - if {[write::isBooleanTrue $angular_periodic]} { - set angular_period [dict get $props Material Variables AngularPeriod] - } - write::WriteString " ANGULAR_VELOCITY_PERIOD $angular_period" - - # set intervals - set LinearStartTime [dict get $props Material Variables LinearStartTime] - set LinearEndTime [dict get $props Material Variables LinearEndTime] - set AngularStartTime [dict get $props Material Variables AngularStartTime] - set AngularEndTime [dict get $props Material Variables AngularEndTime] - write::WriteString " VELOCITY_START_TIME $LinearStartTime" - write::WriteString " VELOCITY_STOP_TIME $LinearEndTime" - write::WriteString " ANGULAR_VELOCITY_START_TIME $AngularStartTime" - write::WriteString " ANGULAR_VELOCITY_STOP_TIME $AngularEndTime" - - set fixed_mesh_option_bool [dict get $props Material Variables fixed_wall] - set fixed_mesh_option 0 - if {[write::isBooleanTrue $fixed_mesh_option_bool]} { - set fixed_mesh_option 1 - } - set rigid_body_motion 1 - set free_body_motion 0 - #Hardcoded - write::WriteString " FIXED_MESH_OPTION $fixed_mesh_option" - write::WriteString " RIGID_BODY_MOTION $rigid_body_motion" - write::WriteString " FREE_BODY_MOTION $free_body_motion" - - } elseif {$motion_type == "FreeMotion"} { - set fixed_mesh_option 0 - set rigid_body_motion 0 - set free_body_motion 1 - - set mass [dict get $props Material Variables Mass] - write::WriteString " RIGID_BODY_MASS $mass" - - lassign [dict get $props Material Variables CenterOfMass] cX cY cZ - if {$::Model::SpatialDimension eq "2D"} {write::WriteString " RIGID_BODY_CENTER_OF_MASS \[3\] ($cX,$cY,0.0)" - } else {write::WriteString " RIGID_BODY_CENTER_OF_MASS \[3\] ($cX,$cY,$cZ)"} - - set inertias [dict get $props Material Variables Inertia] - if {$::Model::SpatialDimension eq "2D"} { - set iX $inertias - write::WriteString " RIGID_BODY_INERTIAS \[3\] (0.0,0.0,$iX)" - } else { - lassign $inertias iX iY iZ - write::WriteString " RIGID_BODY_INERTIAS \[3\] ($iX,$iY,$iZ)" - } - - # DOFS - set Ax [dict get $props Material Variables Ax] - set Ay [dict get $props Material Variables Ay] - set Az [dict get $props Material Variables Az] - set Bx [dict get $props Material Variables Bx] - set By [dict get $props Material Variables By] - set Bz [dict get $props Material Variables Bz] - if {$Ax == "Constant"} { - set fix_vx [dict get $props Material Variables Vx] - write::WriteString " IMPOSED_VELOCITY_X_VALUE $fix_vx" - } - if {$Ay == "Constant"} { - set fix_vy [dict get $props Material Variables Vy] - write::WriteString " IMPOSED_VELOCITY_Y_VALUE $fix_vy" - } - if {$Az == "Constant"} { - set fix_vz [dict get $props Material Variables Vz] - if {$::Model::SpatialDimension eq "2D"} {write::WriteString " IMPOSED_VELOCITY_Z_VALUE 0.0" - } else {write::WriteString " IMPOSED_VELOCITY_Z_VALUE $fix_vz"} - - } - if {$Bx == "Constant"} { - set fix_avx [dict get $props Material Variables AVx] - if {$::Model::SpatialDimension eq "2D"} {write::WriteString " IMPOSED_ANGULAR_VELOCITY_X_VALUE 0.0" - } else {write::WriteString " IMPOSED_ANGULAR_VELOCITY_X_VALUE $fix_avx"} - - } - if {$By == "Constant"} { - set fix_avy [dict get $props Material Variables AVy] - if {$::Model::SpatialDimension eq "2D"} {write::WriteString " IMPOSED_ANGULAR_VELOCITY_Y_VALUE 0.0" - } else {write::WriteString " IMPOSED_ANGULAR_VELOCITY_Y_VALUE $fix_avy"} - - } - if {$Bz == "Constant"} { - set fix_avz [dict get $props Material Variables AVz] - write::WriteString " IMPOSED_ANGULAR_VELOCITY_Z_VALUE $fix_avz" - } - set VStart [dict get $props Material Variables VStart] - set VEnd [dict get $props Material Variables VEnd] - write::WriteString " VELOCITY_START_TIME $VStart" - write::WriteString " VELOCITY_STOP_TIME $VEnd" - - # initial conditions - set iAx [dict get $props Material Variables iAx] - set iAy [dict get $props Material Variables iAy] - set iAz [dict get $props Material Variables iAz] - set iBx [dict get $props Material Variables iBx] - set iBy [dict get $props Material Variables iBy] - set iBz [dict get $props Material Variables iBz] - if {$iAx == "true"} { - set fix_vx [dict get $props Material Variables iVx] - write::WriteString " INITIAL_VELOCITY_X_VALUE $fix_vx" - } - if {$iAy == "true"} { - set fix_vy [dict get $props Material Variables iVy] - write::WriteString " INITIAL_VELOCITY_Y_VALUE $fix_vy" - } - if {$iAz == "true"} { - set fix_vz [dict get $props Material Variables iVz] - if {$::Model::SpatialDimension eq "2D"} {write::WriteString " INITIAL_VELOCITY_Z_VALUE 0.0" - } else {write::WriteString " INITIAL_VELOCITY_Z_VALUE $fix_vz"} - - } - if {$iBx == "true"} { - set fix_avx [dict get $props Material Variables iAVx] - if {$::Model::SpatialDimension eq "2D"} {write::WriteString " INITIAL_ANGULAR_VELOCITY_X_VALUE 0.0" - } else {write::WriteString " INITIAL_ANGULAR_VELOCITY_X_VALUE $fix_avx"} - - } - if {$iBy == "true"} { - set fix_avy [dict get $props Material Variables iAVy] - if {$::Model::SpatialDimension eq "2D"} {write::WriteString " INITIAL_ANGULAR_VELOCITY_Y_VALUE 0.0" - } else {write::WriteString " INITIAL_ANGULAR_VELOCITY_Y_VALUE $fix_avy"} - - } - if {$iBz == "true"} { - set fix_avz [dict get $props Material Variables iAVz] - write::WriteString " INITIAL_ANGULAR_VELOCITY_Z_VALUE $fix_avz" - } - - # impose forces and moments - set ExternalForceX [dict get $props Material Variables ExternalForceX] - set ExternalForceY [dict get $props Material Variables ExternalForceY] - set ExternalForceZ [dict get $props Material Variables ExternalForceZ] - set ExternalMomentX [dict get $props Material Variables ExternalMomentX] - set ExternalMomentY [dict get $props Material Variables ExternalMomentY] - set ExternalMomentZ [dict get $props Material Variables ExternalMomentZ] - - if {$ExternalForceX == "true"} { - set FX [dict get $props Material Variables FX] - write::WriteString " EXTERNAL_APPLIED_FORCE_X $FX" - } - if {$ExternalForceY == "true"} { - set FY [dict get $props Material Variables FY] - write::WriteString " EXTERNAL_APPLIED_FORCE_Y $FY" - } - if {$ExternalForceZ == "true"} { - set FZ [dict get $props Material Variables FZ] - write::WriteString " EXTERNAL_APPLIED_FORCE_Z $FZ" - } - if {$ExternalMomentX == "true"} { - set MX [dict get $props Material Variables MX] - write::WriteString " EXTERNAL_APPLIED_MOMENT_X $MX" - } - if {$ExternalMomentY == "true"} { - set MY [dict get $props Material Variables MY] - write::WriteString " EXTERNAL_APPLIED_MOMENT_Y $MY" - } - if {$ExternalMomentZ == "true"} { - set MZ [dict get $props Material Variables MZ] - write::WriteString " EXTERNAL_APPLIED_MOMENT_Z $MZ" - } - #Hardcoded - write::WriteString " FIXED_MESH_OPTION $fixed_mesh_option" - write::WriteString " RIGID_BODY_MOTION $rigid_body_motion" - write::WriteString " FREE_BODY_MOTION $free_body_motion" - } - - #Hardcoded - set is_ghost [dict get $props Material Variables IsGhost] - if {$is_ghost == "true"} { - write::WriteString " IS_GHOST 1" - } else { - write::WriteString " IS_GHOST 0" - } - write::WriteString " IDENTIFIER [write::transformGroupName $group]" - - DEM::write::DefineFEMExtraConditions $props - - } + if {$props ne ""} { + set xp1 "[spdAux::getRoute [GetAttribute parts_un]]/condition\[@n = 'Parts_FEM'\]/group\[@n = '$group'\]" + #TODO do we need this group node? + set group_node [[customlib::GetBaseRoot] selectNodes $xp1] + write::WriteString " RIGID_BODY_OPTION 1" + + set mass [dict get $props Material Variables InputMass] + write::WriteString " RIGID_BODY_MASS $mass" + + lassign [dict get $props Material Variables InputCenter] cX cY cZ + if {$::Model::SpatialDimension eq "2D"} {write::WriteString " RIGID_BODY_CENTER_OF_ROTATION \[3\] ($cX,$cY,0.0)" + } else {write::WriteString " RIGID_BODY_CENTER_OF_ROTATION \[3\] ($cX,$cY,$cZ)"} + + set inertias [dict get $props Material Variables InputInertia] + if {$::Model::SpatialDimension eq "2D"} { + set iX $inertias + write::WriteString " RIGID_BODY_INERTIAS \[3\] (0.0,0.0,$iX)" + } else { + lassign $inertias iX iY iZ + write::WriteString " RIGID_BODY_INERTIAS \[3\] ($iX,$iY,$iZ)" + } + + lassign [dict get $props Material Variables InputOrientation] oX oY oZ + lassign [MathUtils::VectorNormalized [list $oX $oY $oZ]] oX oY oZ + #La direccion del eje tiene que darse normalizada. Assert oX*oX+oY*oY+oZ*oZ = 1 + set angle [dict get $props Material Variables InputModule] + + set mod [expr {sin($angle/2.0)}] + set qx [expr {$oX * [expr $mod]}] + set qy [expr {$oY * [expr $mod]}] + set qz [expr {$oZ * [expr $mod]}] + set qw [expr {cos($angle/2.0) }] + + #write::WriteString " ORIENTATION \[4\] ($oX,$oY,$oZ, 0.0)" + write::WriteString " ORIENTATION \[4\] ($qx, $qy, $qz, $qw)" + + write::WriteString " IDENTIFIER [write::transformGroupName $group]" + + set ghost [dict get $props Material Variables InputGhost] + write::WriteString " IS_GHOST $ghost" + + DEM::write::DefineFEMExtraConditions $props + } else {W "Error - Properties empty for submodelpart $condition $group"} write::WriteString " End SubModelPartData" write::WriteString " Begin SubModelPartNodes" @@ -530,6 +133,7 @@ proc ::DEM::write::writeWallConditionMesh { condition group props } { } proc ::DEM::write::DefineFEMExtraConditions {props} { + return set GraphPrint [dict get $props Material Variables GraphPrint] set GraphPrintval 0 if {[write::isBooleanTrue $GraphPrint]} { @@ -537,3 +141,43 @@ proc ::DEM::write::DefineFEMExtraConditions {props} { } write::WriteString " FORCE_INTEGRATION_GROUP $GraphPrintval" } + +proc ::DEM::write::GetFEMPartGroupNodes { } { + return [[customlib::GetBaseRoot] selectNodes "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_FEM'\]/group"] +} + +proc ::DEM::write::GetWallsGroupsSmp { } { + set groups [list ] + set xp2 "[spdAux::getRoute DEMCustom]/condition\[@n = 'DEM-CustomSmp'\]/group" + foreach group [[customlib::GetBaseRoot] selectNodes $xp2] { + set destination_mdpa [write::getValueByNode [$group selectNodes "./value\[@n='WhatMdpa'\]"]] + if {$destination_mdpa == "FEM"} { + set groupid [$group @n] + lappend groups [write::GetWriteGroupName $groupid] + } + } + return $groups +} + +proc ::DEM::write::WriteWallCustomSmp { } { + set condition_name "DEM-CustomSmp" + set xp1 "[spdAux::getRoute DEMCustom]/condition\[@n = 'DEM-CustomSmp'\]/group" + + foreach group [[customlib::GetBaseRoot] selectNodes $xp1] { + + set groupid [$group @n] + set destination_mdpa [write::getValueByNode [$group selectNodes "./value\[@n='WhatMdpa'\]"]] + if {$destination_mdpa == "FEM"} { + set mid [write::AddSubmodelpart $condition_name $groupid] + write::WriteString "Begin SubModelPart $mid \/\/ Custom SubModelPart. Group name: $groupid" + write::WriteString "Begin SubModelPartData // DEM-FEM-Wall. Group name: $groupid" + write::WriteString "End SubModelPartData" + write::WriteString "Begin SubModelPartNodes" + GiD_WriteCalculationFile nodes -sorted [dict create [write::GetWriteGroupName $groupid] [subst "%10i\n"]] + write::WriteString "End SubModelPartNodes" + write::WriteString "End SubModelPart" + write::WriteString "" + } + } +} + diff --git a/kratos.gid/apps/DEM/write/writeMaterials.tcl b/kratos.gid/apps/DEM/write/writeMaterials.tcl index 23f08f1e1..4fc26b240 100644 --- a/kratos.gid/apps/DEM/write/writeMaterials.tcl +++ b/kratos.gid/apps/DEM/write/writeMaterials.tcl @@ -2,7 +2,7 @@ proc ::DEM::write::getDEMMaterialsDict { } { # TODO: Remove properties in mdpas ? Check with MA. Probably remove material properties but check the process properties # TODO: Check 2d dem fem wall is written twice, also as phantom # TODO: Materials have more properties than expected. Write from properties variables, not from xml - + # Loop over parts, inlets and walls to list the materials to print. For each material used print: DENSITY, YOUNG_MODULUS, POISSON_RATIO # print COMPUTE_WEAR as false always, too (temporal fix) # While looping, create the assignation_table_list @@ -26,7 +26,7 @@ proc ::DEM::write::getDEMMaterialsDict { } { dict set processed_mats $mat_name $matid } } - + # Loop over the material relations, which is a new menu in the tree linking each possible pair of materials set material_relations_node_list [DEM::write::GetMaterialRelationsNodeList] set material_relations_list [list ] @@ -48,7 +48,7 @@ proc ::DEM::write::getDEMMaterialsDict { } { lappend material_relations_list $mat_rel } } - + # Submodelpart - material assignation set assignation_table_list [list ] foreach mnode $materials_node_list { @@ -63,25 +63,26 @@ proc ::DEM::write::getDEMMaterialsDict { } { set group_name [write::GetWriteGroupName [$gnode @n]] set cond_name [[$gnode parent] @n] set submodelpart_id [write::getSubModelPartId $cond_name $group_name] - set modelpart_parent [DEM::write::GetModelPartParentNameFromGroup $group_name] + set modelpart_parent [DEM::write::GetModelPartParentNameFromGroup $cond_name] lappend assignation_table_list [list ${modelpart_parent}.${submodelpart_id} $mat_name] - + } - - + + dict set global_dict "materials" $materials_list dict set global_dict "material_relations" $material_relations_list dict set global_dict "material_assignation_table" $assignation_table_list - + ValidateMaterialRelations $materials_list $material_relations_list $assignation_table_list return $global_dict } -proc ::DEM::write::GetModelPartParentNameFromGroup {group} { +proc ::DEM::write::GetModelPartParentNameFromGroup {condition} { + set model_part_parent SpheresPart - if {$group in [DEM::write::GetWallsGroups]} {set model_part_parent "RigidFacePart"} - if {$group in [DEM::write::GetInletGroups]} {set model_part_parent "DEMInletPart"} + if {$condition in [list "Parts_FEM" "FEMVelocity" "FEMAngular" "FEMForce" "FEMTorque" "FEMVelocity2D" "FEMAngular2D" " "]} {set model_part_parent "RigidFacePart"} + if {$condition in [list "Parts_Inlet-FEM" "DEMInlet" " "]} {set model_part_parent "DEMInletPart"} return $model_part_parent } diff --git a/kratos.gid/apps/DEM/write/writeProjectParameters.tcl b/kratos.gid/apps/DEM/write/writeProjectParameters.tcl index cd6563df9..e97c75575 100644 --- a/kratos.gid/apps/DEM/write/writeProjectParameters.tcl +++ b/kratos.gid/apps/DEM/write/writeProjectParameters.tcl @@ -45,16 +45,35 @@ proc ::DEM::write::getParametersDict { } { set material_import_settings [dict create] dict set material_import_settings "materials_filename" [GetAttribute materials_file] - dict set strategy_parameters_dict "material_import_settings" $material_import_settings + dict set strategy_parameters_dict "material_import_settings" $material_import_settings dict set project_parameters_dict "solver_settings" $strategy_parameters_dict + + # Boundary conditions processes + set processes [dict create] + + # Kinematics + dict set processes constraints_process_list [write::getConditionsParametersDict [GetAttribute conditions_un] Condition Parts_DEM] + dict lappend processes constraints_process_list {*}[write::getConditionsParametersDict [GetAttribute conditions_un] Condition Parts_FEM] + + # Loads + dict set processes loads_process_list [write::getConditionsParametersDict [GetAttribute loads_un] Condition Parts_DEM] + dict lappend processes loads_process_list {*}[write::getConditionsParametersDict [GetAttribute loads_un] Condition Parts_FEM] + + # Injectors-core + #dict set processes injectors_process_list [write::getConditionsParametersDict [GetAttribute injectors_un] Condition Parts_Inlet-FEM] + + # Injectors-custom + dict set processes injectors_process_list [DEM::write::getInjectorProcessDictList] + + dict set project_parameters_dict processes $processes + dict set project_parameters_dict "VirtualMassCoefficient" [write::getValue AdvOptions VirtualMassCoef] dict set project_parameters_dict "RollingFrictionOption" [write::getValue AdvOptions RollingFriction] dict set project_parameters_dict "GlobalDamping" [write::getValue AdvOptions GlobalDamping] dict set project_parameters_dict "ContactMeshOption" [write::getValue BondElem ContactMeshOption] dict set project_parameters_dict "OutputFileType" [write::getValue GiDOptions GiDPostMode] dict set project_parameters_dict "Multifile" [write::getValue GiDOptions GiDMultiFileFlag] - dict set project_parameters_dict "ElementType" [GetElementType] dict set project_parameters_dict "TranslationalIntegrationScheme" [write::getValue DEMTranslationalScheme] @@ -111,31 +130,175 @@ proc ::DEM::write::getParametersDict { } { return $project_parameters_dict } + +proc ::DEM::write::getInjectorProcessDictList {} { + + set root [customlib::GetBaseRoot] + set process_list [list ] + + set xp1 "[spdAux::getRoute [GetAttribute injectors_un]]/condition\[@n='DEMInlet'\]/group" + set groups [$root selectNodes $xp1] + + foreach group $groups { + set groupName [$group @n] + set groupName [write::GetWriteGroupName $groupName] + set cid [[$group parent] @n] + W $groupName + W $cid + set submodelpart [::write::getSubModelPartId $cid $groupName] + set submodelpart_id [write::getSubModelPartId $group $groupName] + + # lappend assignation_table_list [list ${modelpart_parent}.${submodelpart_id} $mat_name] + # set write_output [write::getStringBinaryFromValue [write::getValueByNode [$group selectNodes "./value\[@n='write'\]"]]] + # set print_screen [write::getStringBinaryFromValue [write::getValueByNode [$group selectNodes "./value\[@n='print'\]"]]] + set interval_name [write::getValueByNode [$group selectNodes "./value\[@n='Interval'\]"]] + set pdict [dict create] + dict set pdict "python_module" "apply_particle_injection_process" + dict set pdict "kratos_module" "KratosMultiphysics.DEMApplication" + set params [dict create] + + # dict set params "model_part_name" [write::GetModelPartNameWithParent $submodelpart] + set modelpart_parent [DEM::write::GetModelPartParentNameFromGroup $cid] + dict set params "model_part_name" ${modelpart_parent}.${groupName} + + + ######### granulometry specifications + set subparams [dict create] + dict set subparams "ParticleDiameter" [write::getValueByNode [$group selectNodes "./value\[@n='ParticleDiameter'\]"]] + dict set subparams "ProbabilityDistribution" [write::getValueByNode [$group selectNodes "./value\[@n='ProbabilityDistribution'\]"]] + dict set subparams "StandardDeviation" [write::getValueByNode [$group selectNodes "./value\[@n='StandardDeviation'\]"]] + + dict set params "granulometry_settings" $subparams + + + ########## flow settings + set type_of_measurement [write::getValueByNode [$group selectNodes "./value\[@n='TypeOfFlowMeasurement'\]"]] + if {$type_of_measurement eq "Kilograms"} { + set mass_flow_option 1 + } else { + set mass_flow_option 0 + } + + set subparams [dict create] + dict set subparams "TypeOfFlowMeasurement" $type_of_measurement + + if {$mass_flow_option == 0} { + dict set subparams "NumberOfParticles" [write::getValueByNode [$group selectNodes "./value\[@n='NumberOfParticles'\]"]] + } + + if {$mass_flow_option == 1} { + dict set subparams "InletMassFlow" [write::getValueByNode [$group selectNodes "./value\[@n='InletMassFlow'\]"]] + + dict set subparams "InletLimitedVelocity" [write::getValueByNode [$group selectNodes "./value\[@n='InletLimitedVelocity'\]"]] + + dict set subparams "DenseInletOption" [write::getValueByNode [$group selectNodes "./value\[@n='DenseInletOption'\]"]] + } + + dict set params "flow_settings" $subparams + + + ########## injection specifications + set subparams [dict create] + set velocity_modulus [write::getValueByNode [$group selectNodes "./value\[@n='InVelocityModulus'\]"]] + + lassign [write::getValueByNode [$group selectNodes "./value\[@n='InDirectionVector'\]"]] velocity_X velocity_Y velocity_Z + + if {$velocity_Z eq ""} {set velocity_Z 0.0} + lassign [MathUtils::VectorNormalized [list $velocity_X $velocity_Y $velocity_Z]] velocity_X velocity_Y velocity_Z + + lassign [MathUtils::ScalarByVectorProd $velocity_modulus [list $velocity_X $velocity_Y $velocity_Z] ] vx vy vz + + dict set subparams "InjectedVelocity" [list $vx $vy $vz] + + dict set subparams "VelocityDeviation" [write::getValueByNode [$group selectNodes "./value\[@n='VelocityDeviation'\]"]] + + + ####### cluster specifications + # set injector_element_type [write::getValueByNode [$group selectNodes "./value\[@n='injector_element_type'\]"]] + # dict set subparams "injector_element_type" $injector_element_type + + set injected_element_type [write::getValueByNode [$group selectNodes "./value\[@n='InletElementType'\]"]] + dict set subparams "InletElementType" $injected_element_type + + if {$injected_element_type eq "SingleSphereCluster3D"} { + + dict set subparams "Excentricity" [write::getValueByNode [$group selectNodes "./value\[@n='Excentricity'\]"]] + + dict set subparams "ProbabilityDistributionOfExcentricity" [write::getValueByNode [$group selectNodes "./value\[@n='ProbabilityDistributionOfExcentricity'\]"]] + + dict set subparams "StandardDeviationOfExcentricity" [write::getValueByNode [$group selectNodes "./value\[@n='StandardDeviationOfExcentricity'\]"]] + + } + + if {$injected_element_type eq "Cluster3D"} { + + + dict set subparams "ClusterType" [write::getValueByNode [$group selectNodes "./value\[@n='ClusterType'\]"]] + + dict set subparams "ClusterFilename" [write::getValueByNode [$group selectNodes "./value\[@n='ClusterFilename'\]"]] + + } + + set RandomOrientation [write::getValueByNode [$group selectNodes "./value\[@n='RandomOrientation'\]"]] + + dict set subparams "RandomOrientation" $RandomOrientation + + if {$RandomOrientation == 0} { + + dict set subparams "OrientationX" [write::getValueByNode [$group selectNodes "./value\[@n='OrientationX'\]"]] + } + + ####### end cluster specifications + + dict set params "injection_settings" $subparams + + dict set params "interval" [write::getInterval $interval_name] + dict set pdict "Parameters" $params + + lappend process_list $pdict + return $pdict + } +} + + +proc ::DEM::write::GetUsedElements {} { + set root [customlib::GetBaseRoot] + + set xp1 "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_DEM'\]/group" + + set lista [list ] + foreach gNode [[customlib::GetBaseRoot] selectNodes $xp1] { + set g $gNode + set name [write::getValueByNode [$gNode selectNodes ".//value\[@n='Element']"] ] + if {$name ni $lista} {lappend lista $name} + } + + return $lista +} + proc ::DEM::write::GetElementType { } { - set used_elements [spdAux::GetUsedElements] + set used_elements [DEM::write::GetUsedElements] set element_type [lindex $used_elements 0] return $element_type } proc ::DEM::write::GetDemStrategyName { } { - return sphere_strategy - # set ElementType [::wkcf::GetElementType] # TODO: check old ::wkcf::GetElementType functionalities if required - # set used_elements [spdAux::GetUsedElements] - - # set ElementType SphericPartDEMElement3D - # if {$ElementType eq "SphericPartDEMElement3D" || $ElementType eq "CylinderPartDEMElement2D"} { - # set dem_strategy "sphere_strategy" - # } elseif {$ElementType eq "SphericContPartDEMElement3D" || $ElementType eq "CylinderContPartDEMElement3D"} { - # set dem_strategy "continuum_sphere_strategy" - # } elseif {$ElementType eq "ThermalSphericPartDEMElement3D"} { - # set dem_strategy "thermal_sphere_strategy" - # } elseif {$ElementType eq "ThermalSphericContPartDEMElement3D"} { - # set dem_strategy "thermal_continuum_sphere_strategy" - # } elseif {$ElementType eq "SinteringSphericConPartDEMElement3D"} { - # set dem_strategy "thermal_continuum_sphere_strategy" - # } elseif {$ElementType eq "IceContPartDEMElement3D"} { - # set dem_strategy "ice_continuum_sphere_strategy" - # } + + set ElementType [::DEM::write::GetElementType] + if {$ElementType eq "SphericPartDEMElement3D" || $ElementType eq "CylinderPartDEMElement2D"} { + set dem_strategy "sphere_strategy" + } elseif {$ElementType eq "SphericContPartDEMElement3D" || $ElementType eq "CylinderContPartDEMElement3D"} { + set dem_strategy "continuum_sphere_strategy" + } elseif {$ElementType eq "ThermalSphericPartDEMElement3D"} { + set dem_strategy "thermal_sphere_strategy" + } elseif {$ElementType eq "ThermalSphericContPartDEMElement3D"} { + set dem_strategy "thermal_continuum_sphere_strategy" + } elseif {$ElementType eq "SinteringSphericConPartDEMElement3D"} { + set dem_strategy "thermal_continuum_sphere_strategy" + } elseif {$ElementType eq "IceContPartDEMElement3D"} { + set dem_strategy "ice_continuum_sphere_strategy" + } + return $dem_strategy } proc ::DEM::write::GetTimeSettings { } { diff --git a/kratos.gid/apps/DEM/write/write_utils.tcl b/kratos.gid/apps/DEM/write/write_utils.tcl index c8d9ba38c..0f8656446 100644 --- a/kratos.gid/apps/DEM/write/write_utils.tcl +++ b/kratos.gid/apps/DEM/write/write_utils.tcl @@ -1,8 +1,9 @@ # utility for advanced meshing features in DEM proc ::DEM::write::Elements_Substitution {} { + # updated to work with the new gidinterface set root [customlib::GetBaseRoot] - set xp1 "[spdAux::getRoute DEMParts]/group" + set xp1 "[spdAux::getRoute DEMParts]/condition\[@n = 'Parts_DEM'\]/group" package require math::statistics set seed [expr srand(0)] set fail 0 @@ -11,8 +12,8 @@ proc ::DEM::write::Elements_Substitution {} { foreach group [$root selectNodes $xp1] { set groupid [$group @n] set advanced_meshing_features [write::getValueByNode [$group selectNodes "./value\[@n='AdvancedMeshingFeatures'\]"]] - if {[write::isBooleanTrue $advanced_meshing_features]} { + if {[write::isBooleanTrue $advanced_meshing_features]} { set AdvancedMeshingFeaturesAlgorithmType [write::getValueByNode [$group selectNodes "./value\[@n='AdvancedMeshingFeaturesAlgorithmType'\]"]] set FEMtoDEM [write::getValueByNode [$group selectNodes "./value\[@n='FEMtoDEM'\]"]] set Diameter [write::getValueByNode [$group selectNodes "./value\[@n='Diameter'\]"]] @@ -237,6 +238,7 @@ proc ::DEM::write::Elements_Substitution {} { } proc ::DEM::write::Compute_External_Elements {ndime cgroupid element_ids} { + # not currently used set mesh_elements [GiD_EntitiesGroups get $cgroupid all_mesh] set real_mesh_elements [lindex $mesh_elements 1] @@ -280,6 +282,7 @@ proc ::DEM::write::Compute_External_Elements {ndime cgroupid element_ids} { } proc ::DEM::write::Delete_Unnecessary_Elements_From_Mesh {cgroupid} { + # removes all non spheric particles at the end of the advanced meshing option. set elem_types [list line triangle quadrilateral tetrahedra hexahedra] foreach elem_type $elem_types { if {[GiD_EntitiesGroups get $cgroupid elements -count -element_type $elem_type] > 0} { @@ -289,6 +292,7 @@ proc ::DEM::write::Delete_Unnecessary_Elements_From_Mesh {cgroupid} { } proc ::DEM::write::Cleaning_Up_Skin_And_Removing_Isolated_Nodes {final_list_of_isolated_nodes} { + # remove left over nodes from the fem mesh when using advanced meshing option. # GiD_EntitiesGroups unassign SKIN_SPHERE_DO_NOT_DELETE nodes # # GiD_Mesh delete element [GiD_EntitiesGroups get SKIN_SPHERE_DO_NOT_DELETE elements -element_type triangle] @@ -308,9 +312,6 @@ proc ::DEM::write::NormalDistribution {mean standard_deviation min_rad max_rad} if {$standard_deviation} { set max_iterations 1000 ; #set a maximun number of iterations to avoid an infinite loop for {set i 0} {$i < $max_iterations} {incr i} { - set u1 [::tcl::mathfunc::rand] - set u2 [::tcl::mathfunc::rand] - #set distribution [expr {$mean + $standard_deviation * sqrt(-2.0 * log($u1)) * cos(6.28318530717958647692 * $u2)}] set distribution [math::statistics::random-normal $mean $standard_deviation 1] ; # We use the math::statistics library instead if {$distribution > $min_rad && $distribution < $max_rad} { return $distribution @@ -333,6 +334,7 @@ proc ::DEM::write::LognormalDistribution {mean standard_deviation min_rad max_ra } proc ::DEM::write::Destroy_Skin_Sphere_Group {what_dempack_package} { + # removes continuum specific group from granular interface. if {$what_dempack_package eq "G-DEMPack"} { if [GiD_Groups exists SKIN_SPHERE_DO_NOT_DELETE] { GiD_Groups delete SKIN_SPHERE_DO_NOT_DELETE @@ -478,39 +480,31 @@ proc ::DEM::write::FindBoundariesOfNonSphericElements {entity} { # Note: This procedure in the same used in the fluid_only problem type set root [customlib::GetBaseRoot] - set xp1 "[spdAux::getRoute DEMParts]/group" + set xp1 "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_DEM'\]/group" set groups_to_spherize_list [list ] foreach group [$root selectNodes $xp1] { set groupid [$group @n] lappend groups_to_spherize_list $groupid } - # set groups_to_spherize_list [::xmlutils::setXmlContainerIds {DEM//c.DEM-Elements//c.DEM-Element}] foreach volume_id [GiD_Geometry list volume 1:end] { set volume_info [GiD_Info list_entities volume $volume_id] set is_spheric [regexp {Elemtype=9} $volume_info] foreach group_that_includes_this_volume [GiD_EntitiesGroups entity_groups volumes $volume_id] { #next we search $group_that_includes_this_volume among $groups_to_spherize_list: - if {[lsearch $groups_to_spherize_list $group_that_includes_this_volume] >= 0} { - set is_spheric 1 - } - } + if {[lsearch $groups_to_spherize_list $group_that_includes_this_volume] >= 0} {set is_spheric 1}} if {$is_spheric==0} { foreach item [lrange [GiD_Geometry get volume $volume_id] 2 end] { set surface_id [lindex $item 0] - incr surfaces_higher_entities_list($surface_id) - } - } + incr surfaces_higher_entities_list($surface_id)}} } set boundarylist [list] foreach surface_id [lsort -integer [array names surfaces_higher_entities_list]] { - if {$surfaces_higher_entities_list($surface_id) == 1} { - lappend boundarylist $surface_id - } - } + if {$surfaces_higher_entities_list($surface_id) == 1} {lappend boundarylist $surface_id}} + return $boundarylist } @@ -563,7 +557,6 @@ proc ::DEM::write::AssignGeometricalEntitiesToSkinSphere2D {} { GiD_EntitiesGroups assign SKIN_SPHERE_DO_NOT_DELETE all_geometry $total_skin_circle_list } - proc ::DEM::write::AssignGeometricalEntitiesToSkinSphere3D {} { set list_of_points [GiD_Geometry list point 1:end] @@ -641,73 +634,75 @@ proc ::DEM::write::AssignConditionToGroupGID {entity elist groupid} { } proc ::DEM::write::AssignSpecialBoundaries {entitylist} { - #set DEMApplication "No" - #catch {set DEMApplication [::xmlutils::setXml {GeneralApplicationData//c.ApplicationTypes//i.DEM} dv]} - #if {$DEMApplication eq "Yes"} { - - # Automatic Kratos Group for all DEM boundary lines - set groupid "-AKGDEMSkinMesh3D" - set entitytype "line" - DEM::write::CleanAutomaticConditionGroupGiD $entitytype $groupid - - # Get all end line list from the boundary surfaces - set endlinelist [list] - foreach surfid $entitylist { - set surfprop [GiD_Geometry get surface $surfid] - set surfacetype [lindex $surfprop 0] - set nline [lindex $surfprop 2] - set lineprop [list] - if {$surfacetype eq "nurbssurface"} { - set lineprop [lrange $surfprop 9 [expr {9+$nline-1}]] - } else { - set lineprop [lrange $surfprop 3 [expr {3+$nline-1}]] - } - foreach lprop $lineprop { - lassign $lprop lineid orientation - lappend endlinelist $lineid - } + + # Automatic Kratos Group for all DEM boundary lines + set groupid "-AKGDEMSkinMesh3D" + set entitytype "line" + DEM::write::CleanAutomaticConditionGroupGiD $entitytype $groupid + + # Get all end line list from the boundary surfaces + set endlinelist [list] + foreach surfid $entitylist { + set surfprop [GiD_Geometry get surface $surfid] + set surfacetype [lindex $surfprop 0] + set nline [lindex $surfprop 2] + set lineprop [list] + if {$surfacetype eq "nurbssurface"} { + set lineprop [lrange $surfprop 9 [expr {9+$nline-1}]] + } else { + set lineprop [lrange $surfprop 3 [expr {3+$nline-1}]] + } + foreach lprop $lineprop { + lassign $lprop lineid orientation + lappend endlinelist $lineid } - set endlinelist [lsort -integer -unique $endlinelist] + } + set endlinelist [lsort -integer -unique $endlinelist] - # Assign the boundary condition - DEM::write::AssignConditionToGroupGID $entitytype $endlinelist $groupid + # Assign the boundary condition + DEM::write::AssignConditionToGroupGID $entitytype $endlinelist $groupid - #} } proc ::DEM::write::ForceTheMeshingOfDEMFEMWallGroups {} { + # This proc forces the surface of FEM parts to be meshed. set root [customlib::GetBaseRoot] - set xp1 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='DEM-FEM-Wall'\]/group" - foreach group [$root selectNodes $xp1] { - set groupid [$group @n] - GiD_Process Mescape Meshing MeshCriteria Mesh Surfaces {*}[lindex [GiD_EntitiesGroups get $groupid all_geometry] 2] escape + #set xp1 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='DEM-FEM-Wall'\]/group" + set xp1 "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_FEM'\]/group" + if {$::Model::SpatialDimension eq "3D"} { + foreach group [$root selectNodes $xp1] { + set groupid [$group @n] + GiD_Process Mescape Meshing MeshCriteria Mesh Surfaces {*}[lindex [GiD_EntitiesGroups get $groupid all_geometry] 2] escape + } } - set xp1 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='DEM-FEM-Wall2D'\]/group" - foreach group [$root selectNodes $xp1] { - set groupid [$group @n] - GiD_Process Mescape Meshing MeshCriteria Mesh Lines {*}[lindex [GiD_EntitiesGroups get $groupid all_geometry] 1] escape + if {$::Model::SpatialDimension eq "2D"} { + foreach group [$root selectNodes $xp1] { + set groupid [$group @n] + GiD_Process Mescape Meshing MeshCriteria Mesh Lines {*}[lindex [GiD_EntitiesGroups get $groupid all_geometry] 1] escape + } } } proc ::DEM::write::ForceTheMeshingOfDEMInletGroups {} { + # This proc forces the inlet geometry to be meshed. set root [customlib::GetBaseRoot] - set xp1 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='Inlet'\]/group" - foreach group [$root selectNodes $xp1] { - set groupid [$group @n] - GiD_Process Mescape Meshing MeshCriteria Mesh Surfaces {*}[lindex [GiD_EntitiesGroups get $groupid all_geometry] 2] escape - } - set xp1 "[spdAux::getRoute "DEMConditions"]/condition\[@n ='Inlet2D'\]/group" - foreach group [$root selectNodes $xp1] { - set groupid [$group @n] - GiD_Process Mescape Meshing MeshCriteria Mesh Lines {*}[lindex [GiD_EntitiesGroups get $groupid all_geometry] 2] escape - } + set xp1 "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_Inlet-FEM'\]/group" + if {$::Model::SpatialDimension eq "3D"} { + foreach group [$root selectNodes $xp1] { + set groupid [$group @n] + GiD_Process Mescape Meshing MeshCriteria Mesh Surfaces {*}[lindex [GiD_EntitiesGroups get $groupid all_geometry] 2] escape}} + + if {$::Model::SpatialDimension eq "2D"} { + foreach group [$root selectNodes $xp1] { + set groupid [$group @n] + GiD_Process Mescape Meshing MeshCriteria Mesh Lines {*}[lindex [GiD_EntitiesGroups get $groupid all_geometry] 2] escape}} } proc ::DEM::write::FindBoundariesOfCircularElements {entity} { - set root [customlib::GetBaseRoot] - set xp1 "[spdAux::getRoute DEMParts]/group" + #set xp1 "[spdAux::getRoute DEMParts]/group" + set xp1 "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_DEM'\]/group" set groups_to_circularize_list [list ] foreach group [$root selectNodes $xp1] { set groupid [$group @n] @@ -750,12 +745,10 @@ proc ::DEM::write::FindBoundariesOfCircularElements {entity} { return $boundarylist } - - proc ::DEM::write::FindBoundariesOfSphericElements {entity} { set root [customlib::GetBaseRoot] - set xp1 "[spdAux::getRoute DEMParts]/group" + set xp1 "[spdAux::getRoute [::DEM::write::GetAttribute parts_un]]/condition\[@n='Parts_DEM'\]/group" set groups_to_spherize_list [list ] foreach group [$root selectNodes $xp1] { set groupid [$group @n] diff --git a/kratos.gid/apps/DEM/xml/BoundaryConditions.spd b/kratos.gid/apps/DEM/xml/BoundaryConditions.spd new file mode 100644 index 000000000..1960ce7bf --- /dev/null +++ b/kratos.gid/apps/DEM/xml/BoundaryConditions.spd @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/kratos.gid/apps/DEM/xml/Conditions.xml b/kratos.gid/apps/DEM/xml/Conditions.xml index 81111ee38..a02af2c16 100644 --- a/kratos.gid/apps/DEM/xml/Conditions.xml +++ b/kratos.gid/apps/DEM/xml/Conditions.xml @@ -1,6 +1,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9,72 +40,113 @@ - + - + - + + - + - + - - + - + - - - + + + - - + + + + - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + - + @@ -82,10 +154,26 @@ - + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/kratos.gid/apps/DEM/xml/CustomGraph.spd b/kratos.gid/apps/DEM/xml/CustomGraph.spd new file mode 100644 index 000000000..a3ba04aaa --- /dev/null +++ b/kratos.gid/apps/DEM/xml/CustomGraph.spd @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/kratos.gid/apps/DEM/xml/CustomSmp.spd b/kratos.gid/apps/DEM/xml/CustomSmp.spd new file mode 100644 index 000000000..dad9d12e0 --- /dev/null +++ b/kratos.gid/apps/DEM/xml/CustomSmp.spd @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/kratos.gid/apps/DEM/xml/Elements.xml b/kratos.gid/apps/DEM/xml/Elements.xml index b269df7cc..391ffebf2 100644 --- a/kratos.gid/apps/DEM/xml/Elements.xml +++ b/kratos.gid/apps/DEM/xml/Elements.xml @@ -2,7 +2,7 @@ - + @@ -14,6 +14,15 @@ + + + + + + + + + @@ -34,4 +43,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kratos.gid/apps/DEM/xml/InitialConditions.spd b/kratos.gid/apps/DEM/xml/InitialConditions.spd new file mode 100644 index 000000000..f24d18190 --- /dev/null +++ b/kratos.gid/apps/DEM/xml/InitialConditions.spd @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/kratos.gid/apps/DEM/xml/InjectorConditions.spd b/kratos.gid/apps/DEM/xml/InjectorConditions.spd new file mode 100644 index 000000000..1e4be69ae --- /dev/null +++ b/kratos.gid/apps/DEM/xml/InjectorConditions.spd @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/kratos.gid/apps/DEM/xml/Loads.spd b/kratos.gid/apps/DEM/xml/Loads.spd new file mode 100644 index 000000000..797db6ad0 --- /dev/null +++ b/kratos.gid/apps/DEM/xml/Loads.spd @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/kratos.gid/apps/DEM/xml/Main.spd b/kratos.gid/apps/DEM/xml/Main.spd index de12e931a..577493056 100644 --- a/kratos.gid/apps/DEM/xml/Main.spd +++ b/kratos.gid/apps/DEM/xml/Main.spd @@ -1,11 +1,17 @@ - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/kratos.gid/apps/DEM/xml/NodalConditions.xml b/kratos.gid/apps/DEM/xml/NodalConditions.xml deleted file mode 100644 index 36f5ca0e6..000000000 --- a/kratos.gid/apps/DEM/xml/NodalConditions.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/kratos.gid/apps/DEM/xml/Old_Processes.xml b/kratos.gid/apps/DEM/xml/Old_Processes.xml new file mode 100644 index 000000000..bfdbff032 --- /dev/null +++ b/kratos.gid/apps/DEM/xml/Old_Processes.xml @@ -0,0 +1,420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kratos.gid/apps/DEM/xml/Parts.spd b/kratos.gid/apps/DEM/xml/Parts.spd index 510b88e31..e626ccfd8 100644 --- a/kratos.gid/apps/DEM/xml/Parts.spd +++ b/kratos.gid/apps/DEM/xml/Parts.spd @@ -1,18 +1,4 @@ - - - - - - - - - - - - - - - - - + + + diff --git a/kratos.gid/apps/DEM/xml/Processes.xml b/kratos.gid/apps/DEM/xml/Processes.xml index bfdbff032..0ff33bc4a 100644 --- a/kratos.gid/apps/DEM/xml/Processes.xml +++ b/kratos.gid/apps/DEM/xml/Processes.xml @@ -1,333 +1,95 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - - --> - - - - + + + + + + + - + > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + > - - - - - - - + + + + + - + + + + + + + - + + + + @@ -356,6 +116,8 @@ + + @@ -378,17 +140,10 @@ - - - - - - - @@ -398,23 +153,65 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kratos.gid/apps/DEM/xml/Procs.spd b/kratos.gid/apps/DEM/xml/Procs.spd index 10a6b738f..eaff5fd66 100644 --- a/kratos.gid/apps/DEM/xml/Procs.spd +++ b/kratos.gid/apps/DEM/xml/Procs.spd @@ -15,6 +15,11 @@ return [DEM::xml::ProcGetDEMPartsOvWhat $domNode $args] ]]> + + + diff --git a/kratos.gid/apps/DEM/xml/XmlController.tcl b/kratos.gid/apps/DEM/xml/XmlController.tcl index c7cc2b4d0..84b35a050 100644 --- a/kratos.gid/apps/DEM/xml/XmlController.tcl +++ b/kratos.gid/apps/DEM/xml/XmlController.tcl @@ -1,7 +1,7 @@ namespace eval ::DEM::xml { namespace path ::DEM Kratos::AddNamespace [namespace current] - + variable dir } @@ -11,14 +11,21 @@ proc ::DEM::xml::Init { } { Model::getSolutionStrategies Strategies.xml Model::getElements Elements.xml - Model::getConstitutiveLaws ConstitutiveLaws.xml Model::getMaterials Materials.xml + Model::getConstitutiveLaws ConstitutiveLaws.xml Model::getProcesses "../../Common/xml/Processes.xml" Model::getProcesses Processes.xml Model::getConditions Conditions.xml Model::getMaterialRelations "material_relations/MaterialRelations.xml" + +} + +proc ::DEM::xml::ProcGetPartsGroupsList {domNode args} { + return [GiD_Groups list] } + + proc ::DEM::xml::getUniqueName {name} { return [::DEM::GetAttribute prefix]$name } @@ -46,9 +53,15 @@ proc ::DEM::xml::CustomTree { args } { gid_groups_conds::setAttributes $3dinlet_xpath [list values "SphericParticle3D,Cluster3D,SingleSphereCluster" ] set 2dinlet_xpath "[spdAux::getRoute DEMConditions]/condition\[@n='Inlet2D'\]/value\[@n='InletElementType'\]" gid_groups_conds::setAttributes $2dinlet_xpath [list values "CylinderParticle2D" ] - - # spdAux::parseRoutes + # set new unique names for parts groups + set parts_path "[spdAux::getRoute DEMParts]/condition" + foreach part_type [[customlib::GetBaseRoot] selectNodes $parts_path] { + set part_type_name [$part_type @n] + $part_type setAttribute un DEMParts_$part_type_name + } + spdAux::parseRoutes + spdAux::processDynamicNodes [customlib::GetBaseRoot] } @@ -104,7 +117,7 @@ proc ::DEM::xml::InertiaType { args } { } proc ::DEM::xml::injectMaterialRelations { basenode args } { - + set base [$basenode parent] set materials_relations [Model::GetMaterialRelations {*}$args] foreach mat $materials_relations { diff --git a/kratos.gid/scripts/Writing/WriteConditionsByGiDId.tcl b/kratos.gid/scripts/Writing/WriteConditionsByGiDId.tcl index d3a29f96a..ba0ce8963 100644 --- a/kratos.gid/scripts/Writing/WriteConditionsByGiDId.tcl +++ b/kratos.gid/scripts/Writing/WriteConditionsByGiDId.tcl @@ -24,7 +24,6 @@ proc write::writeConditionsByGiDId { baseUN {force_write_cond_id ""} {properties } } - proc write::writeGroupNodeConditionByGiDId {groupNode condid {mid 0}} { set groupid [get_domnode_attribute $groupNode n] set groupid [GetWriteGroupName $groupid] diff --git a/kratos.gid/scripts/Writing/WriteElements.tcl b/kratos.gid/scripts/Writing/WriteElements.tcl index 73c715e98..26a6db751 100644 --- a/kratos.gid/scripts/Writing/WriteElements.tcl +++ b/kratos.gid/scripts/Writing/WriteElements.tcl @@ -35,10 +35,12 @@ proc write::writeGroupElementConnectivities { gNode kelemtype} { if {$nnodes ne ""} { if {$etype ne "none"} { set elem [::Model::getElement $kelemtype] + set block_name [$elem getAttribute WriteAsBlock] + if {$block_name eq ""} {set block_name Elements} set topology [$elem getTopologyFeature $etype $nnodes] if {$topology ne ""} { set kratos_element_type [$topology getKratosName] - write::writeGroupElementConnectivitiesFor $kratos_element_type $nnodes $group $mid + write::writeGroupElementConnectivitiesFor $kratos_element_type $nnodes $group $mid $block_name } else { error [= "Element $kelemtype $etype ($nnodes nodes) not available for $ov entities on group $group"] } @@ -49,13 +51,13 @@ proc write::writeGroupElementConnectivities { gNode kelemtype} { error [= "You have not assigned a proper entity to group $group"] } } -proc write::writeGroupElementConnectivitiesFor { kratos_element_type nnodes group mid } { +proc write::writeGroupElementConnectivitiesFor { kratos_element_type nnodes group mid block_name} { set s [mdpaIndent] - WriteString "${s}Begin Elements $kratos_element_type// GUI group identifier: $group" + WriteString "${s}Begin $block_name $kratos_element_type// GUI group identifier: $group" incr ::write::current_mdpa_indent_level set formats [GetFormatDict $group $mid $nnodes] GiD_WriteCalculationFile connectivities $formats incr ::write::current_mdpa_indent_level -1 - WriteString "${s}End Elements" + WriteString "${s}End $block_name" WriteString "" } \ No newline at end of file diff --git a/kratos.gid/scripts/Writing/WriteProcess.tcl b/kratos.gid/scripts/Writing/WriteProcess.tcl index 8d8c5a905..0878305b9 100644 --- a/kratos.gid/scripts/Writing/WriteProcess.tcl +++ b/kratos.gid/scripts/Writing/WriteProcess.tcl @@ -1,20 +1,20 @@ proc write::GetRestartProcess { {un ""} {name "" } } { - + set root [customlib::GetBaseRoot] - + set resultDict [dict create ] if {$un eq ""} {set un "Restart"} if {$name eq ""} {set name "RestartOptions"} - + dict set resultDict "python_module" "restart_process" dict set resultDict "kratos_module" "KratosMultiphysics.SolidMechanicsApplication" dict set resultDict "help" "This process writes restart files" dict set resultDict "process_name" "RestartProcess" - + set params [dict create] set saveValue [write::getStringBinaryValue $un SaveRestart] - + set model_name [Kratos::GetModelName] dict set params "model_part_name" [write::GetModelPartNameWithParent $model_name] dict set params "save_restart" $saveValue @@ -27,7 +27,7 @@ proc write::GetRestartProcess { {un ""} {name "" } } { if {$output_control eq "time"} {dict set params "output_interval" [getValue $un RestartDeltaTime]} {dict set params "output_interval" [getValue $un RestartDeltaStep]} set jsonoutput [write::getStringBinaryValue $un json_output] dict set params "json_output" $jsonoutput - + dict set resultDict "Parameters" $params return $resultDict } @@ -42,23 +42,23 @@ proc write::GetProcessHeader {group process condition {groupId ""}} { } set paramDict [dict create ] dict set paramDict model_part_name [write::GetModelPartNameWithParent $groupId] - + set process_attributes [$process getAttributes] - + dict set process_attributes process_name [dict get $process_attributes n] dict unset process_attributes n dict unset process_attributes pn if {[dict exists $process_attributes help]} {dict unset process_attributes help} #if {[dict exists $process_attributes process_name]} {dict unset process_attributes process_name} if {[dict exists $process_attributes write_command]} {dict unset process_attributes write_command} - + set processDict [dict merge $processDict $process_attributes] if {[$condition hasAttribute VariableName]} { set variable_name [$condition getAttribute VariableName] # "lindex" is a rough solution. Look for a better one. if {$variable_name ne ""} {dict set paramDict variable_name [lindex $variable_name 0]} } - + if {[$group find n Interval] ne ""} {dict set paramDict interval [write::getInterval [get_domnode_attribute [$group find n Interval] v]] } dict set processDict Parameters $paramDict return $processDict @@ -66,7 +66,7 @@ proc write::GetProcessHeader {group process condition {groupId ""}} { proc write::ProcessAxisToVectorComponents { groupNode condition process} { set processDict [write::GetProcessHeader $groupNode $process $condition] - + set axis [write::getValueByXPath [$groupNode toXPath] Axis] set const [write::GetInputValue $groupNode [$process getInputPn constrained]] set val [write::GetInputValue $groupNode [$process getInputPn value]] @@ -79,15 +79,15 @@ proc write::ProcessAxisToVectorComponents { groupNode condition process} { lappend value $val } } - + dict set processDict Parameters constrained $constrained dict set processDict Parameters value $value - + return $processDict } -proc write::ProcessVectorFunctionComponents { groupNode condition process} { - set processDict [write::GetProcessHeader $groupNode $process $condition] +proc write::ProcessVectorFunctionComponents { groupNode condition process {group_id ""}} { + set processDict [write::GetProcessHeader $groupNode $process $condition $group_id] set val [write::GetInputValue $groupNode [$process getInputPn component]] foreach i $val { if {$i == "null"} { @@ -98,10 +98,10 @@ proc write::ProcessVectorFunctionComponents { groupNode condition process} { lappend value $i } } - + dict set processDict Parameters constrained $constrained dict set processDict Parameters value $value - + return $processDict } @@ -117,7 +117,7 @@ proc write::GetInputValue {group in_obj} { set ValZ [expr False] if {[$group find n ${inputName}Z] ne ""} {set ValZ [expr [get_domnode_attribute [$group find n ${inputName}Z] v] ? True : False]} } elseif {$vector_type eq "double"} { - + foreach i [list "X" "Y" "Z"] { set printed 0 if {[$in_obj getAttribute "function"] eq "1"} { @@ -129,16 +129,16 @@ proc write::GetInputValue {group in_obj} { set value [write::getValueByNode [$group find n $function_component] ] set Val$i $value set printed 1 - } + } "ByValue" { - + } "Not" { set Val$i null set printed 1 } } - + } if {!$printed} { set value_component "value_${inputName}_${i}" @@ -146,7 +146,7 @@ proc write::GetInputValue {group in_obj} { set Val$i $value } } - + } elseif {$vector_type eq "tablefile" || $vector_type eq "file"} { set ValX "[get_domnode_attribute [$group find n value_${inputName}_X] v]" set ValY "[get_domnode_attribute [$group find n value_${inputName}_Y] v]" diff --git a/kratos.gid/scripts/Writing/WriteProjectParameters.tcl b/kratos.gid/scripts/Writing/WriteProjectParameters.tcl index ff35b7b32..3d3a28a89 100644 --- a/kratos.gid/scripts/Writing/WriteProjectParameters.tcl +++ b/kratos.gid/scripts/Writing/WriteProjectParameters.tcl @@ -228,7 +228,7 @@ proc write::getSolversParametersDict { {appid ""} } { return $solverSettingsDict } -proc write::getConditionsParametersDict {un {condition_type "Condition"}} { +proc write::getConditionsParametersDict {un {condition_type "Condition"} {forced_parent_cond_name ""} } { set root [customlib::GetBaseRoot] set bcCondsList [list ] @@ -243,8 +243,13 @@ proc write::getConditionsParametersDict {un {condition_type "Condition"}} { foreach group $groups { set groupName [$group @n] set cid [[$group parent] @n] + if {$forced_parent_cond_name eq ""} { + set smp_cid $cid + } else { + set smp_cid $forced_parent_cond_name + } set groupName [write::GetWriteGroupName $groupName] - set groupId [::write::getSubModelPartId $cid $groupName] + set groupId [::write::getSubModelPartId $smp_cid $groupName] set grouping_by "" if {$condition_type eq "Condition"} { set condition [::Model::getCondition $cid] @@ -260,6 +265,7 @@ proc write::getConditionsParametersDict {un {condition_type "Condition"}} { lappend grouped_conditions $cid } } else { + if {[write::isBooleanFalse $groupId]} {continue} set processName [$condition getProcessName] set process [::Model::GetProcess $processName] set processDict [dict create] @@ -276,7 +282,7 @@ proc write::getConditionsParametersDict {un {condition_type "Condition"}} { } } else { - set processDict [$processWriteCommand $group $condition $process] + set processDict [$processWriteCommand $group $condition $process $groupId] } lappend bcCondsList $processDict }