Skip to content

Commit

Permalink
Merge pull request #960 from KratosMultiphysics/geo-print
Browse files Browse the repository at this point in the history
[Geomechanics] Add conditions and improve example
  • Loading branch information
jginternational authored Nov 8, 2023
2 parents f974403 + 22aa6c6 commit 237ce6b
Show file tree
Hide file tree
Showing 18 changed files with 489 additions and 88 deletions.
48 changes: 2 additions & 46 deletions kratos.gid/apps/Fluid/write/writeProjectParameters.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ proc ::Fluid::write::UpdateModelers { projectParametersDict {stage ""} } {
if {[GetAttribute write_mdpa_mode] eq "geometries"} {
# Add the entities creation modeler
set entities_modeler [dict create name "Modelers.KratosMultiphysics.CreateEntitiesFromGeometriesModeler"]
dict set entities_modeler "parameters" elements_list [Fluid::write::GetMatchSubModelPart element $stage]
dict set entities_modeler "parameters" conditions_list [Fluid::write::GetMatchSubModelPart condition $stage]
dict set entities_modeler "parameters" elements_list [::write::GetMatchSubModelPart element $stage]
dict set entities_modeler "parameters" conditions_list [::write::GetMatchSubModelPart condition $stage]
lappend modelerts_list $entities_modeler
}

Expand All @@ -116,50 +116,6 @@ proc ::Fluid::write::UpdateModelers { projectParametersDict {stage ""} } {
return $projectParametersDict
}

# what can be element, condition
proc Fluid::write::GetMatchSubModelPart { what {stage ""} } {
set model_part_basename [write::GetConfigurationAttribute model_part_name]
set entity_name element_name
if {$what == "condition"} {set entity_name condition_name}

set elements_list [list ]
set processed_groups_list [list ]
set groups [::Fluid::xml::GetListOfSubModelParts $stage]
foreach group $groups {
set good_name ""
# get the group and submodelpart name
set group_name [$group @n]

set group_name [write::GetWriteGroupName $group_name]
if {$group_name ni $processed_groups_list} {lappend processed_groups_list $group_name} {continue}
if {$what == "condition"} {set cid [[$group parent] @n]} {
set element_node [$group selectNodes "./value\[@n='Element']"]
if {[llength $element_node] == 0} {continue}
set cid [write::getValueByNode $element_node]
}
if {$cid eq ""} {continue}
if {$what == "condition"} {set entity [::Model::getCondition $cid]} {set entity [::Model::getElement $cid]}
if {$entity eq ""} {continue}
if {$what == "condition"} {
if {[$entity getGroupBy] eq "Condition"} {
set good_name "_HIDDEN_$cid"
if {$good_name ni $processed_groups_list} {lappend processed_groups_list $good_name} {continue}
}
}
if {$good_name eq ""} {set good_name [write::transformGroupName $group_name]}
# Get the entity (element or condition)
if {[$group hasAttribute ov]} {set ov [get_domnode_attribute $group ov]} {set ov [get_domnode_attribute [$group parent] ov]}

lassign [write::getEtype $ov $group_name] etype nnodes

set kname [$entity getTopologyKratosName $etype $nnodes]
set pair [ dict create model_part_name $model_part_basename.$good_name $entity_name $kname]

lappend elements_list $pair

}
return $elements_list
}

proc ::Fluid::write::writeParametersEvent { } {
set write_parameters_mode 0
Expand Down
4 changes: 2 additions & 2 deletions kratos.gid/apps/GeoMechanics/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"controllers/Python.tcl",
"controllers/PhreaticLine.tcl",
"examples/examples.tcl",
"examples/FirstExample.tcl"
"examples/Simple.tcl"
],
"start_script": "::GeoMechanics::Init",
"requirements": {
Expand All @@ -29,7 +29,7 @@
"permissions": {
"open_tree": true,
"show_toolbar": true,
"intervals": true,
"intervals": false,
"wizard": false,
"stages": true
},
Expand Down
75 changes: 59 additions & 16 deletions kratos.gid/apps/GeoMechanics/examples/FirstExample.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,15 @@ proc ::GeoMechanics::examples::FirstExample::AssignGroups {args} {

GiD_Groups create Clay_after_excavation
GiD_EntitiesGroups assign Clay_after_excavation surfaces 2
GiD_Groups edit color Clay_after_excavation "#995e05"

GiD_Groups create Excavated
GiD_EntitiesGroups assign Excavated surfaces 1
GiD_Groups edit color Excavated "#6e4aff"

GiD_Groups create Load
GiD_EntitiesGroups assign Load lines 8

GiD_Groups create Body
GiD_EntitiesGroups assign Body surfaces {1 2}

GiD_Groups create Hydrostatic_load_in_sloot
GiD_EntitiesGroups assign Hydrostatic_load_in_sloot lines {4 5 6}

Expand Down Expand Up @@ -104,7 +103,10 @@ proc ::GeoMechanics::examples::FirstExample::TreeAssignation {args} {

# Parts
set parts [spdAux::getRoute "GEOMParts" $stage]/condition\[@n='Parts_GeoSteadyState'\]
set body_node [customlib::AddConditionGroupOnXPath $parts Body]
set body_node [customlib::AddConditionGroupOnXPath $parts Clay_after_excavation]
set props [list YOUNG_MODULUS 1000 POISSON_RATIO 0.3]
spdAux::SetValuesOnBaseNode $body_node $props
set body_node [customlib::AddConditionGroupOnXPath $parts Excavated_clay]
set props [list YOUNG_MODULUS 1000 POISSON_RATIO 0.3]
spdAux::SetValuesOnBaseNode $body_node $props

Expand All @@ -117,8 +119,6 @@ proc ::GeoMechanics::examples::FirstExample::TreeAssignation {args} {
GiD_Groups edit parent Total Bottom
spdAux::AddIntervalGroup Bottom "Bottom//Total"
GiD_Groups edit state "Bottom//Total" hidden
GiD_Groups edit color "Bottom" "#25ff48"
GiD_Groups edit color "Bottom//Total" "#25ff48"
set displacement [spdAux::getRoute "GEOMNodalConditions" $stage]/condition\[@n='DISPLACEMENT'\]
set displacement_node [customlib::AddConditionGroupOnXPath $displacement "Bottom//Total"]
$displacement_node setAttribute ov line
Expand All @@ -130,8 +130,6 @@ proc ::GeoMechanics::examples::FirstExample::TreeAssignation {args} {
GiD_Groups edit parent Total Side_sliders
spdAux::AddIntervalGroup Side_sliders "Side_sliders//Total"
GiD_Groups edit state "Side_sliders//Total" hidden
GiD_Groups edit color "Side_sliders" "#ff2548"
GiD_Groups edit color "Side_sliders//Total" "#ff2548"
set displacement [spdAux::getRoute "GEOMNodalConditions" $stage]/condition\[@n='DISPLACEMENT'\]
set displacement_node [customlib::AddConditionGroupOnXPath $displacement "Side_sliders//Total"]
$displacement_node setAttribute ov line
Expand All @@ -143,34 +141,79 @@ proc ::GeoMechanics::examples::FirstExample::TreeAssignation {args} {
GiD_Groups edit parent Total Body
spdAux::AddIntervalGroup Body "Body//Total"
GiD_Groups edit state "Body//Total" hidden
GiD_Groups edit color "Body" "#ff2548"
GiD_Groups edit color "Body//Total" "#ff2548"
set gravity [spdAux::getRoute "GEOMLoads" $stage]/condition\[@n='SelfWeight2D'\]
set gravity_node [customlib::AddConditionGroupOnXPath $gravity "Body//Total"]
$gravity_node setAttribute ov surface
set props [list modulus 9.81 value_direction_Y -1.0 Interval Total]
spdAux::SetValuesOnBaseNode $gravity_node $props


# Stage 2
::GeoMechanics::xml::NewStage "Stage 2"
set stage [$root selectNodes ".//container\[@n='stages'\]/blockdata\[@name = 'Stage 2'\]"]

# Top Pressure
GiD_Groups clone Load Total
GiD_Groups edit parent Total Load
spdAux::AddIntervalGroup Body "Load//Total"
spdAux::AddIntervalGroup Load "Load//Total"
GiD_Groups edit state "Load//Total" hidden
GiD_Groups edit color "Load" "#ff2548"
GiD_Groups edit color "Load//Total" "#ff2548"
set pressure [spdAux::getRoute "GEOMLoads" $stage]/condition\[@n='LinePressure2D'\]
set pressure_node [customlib::AddConditionGroupOnXPath $pressure "Load//Total"]
$pressure_node setAttribute ov line
set props [list value 5000 Interval Total]
spdAux::SetValuesOnBaseNode $pressure_node $props

# Stage 3
::GeoMechanics::xml::NewStage "Stage 3"
set stage [$root selectNodes ".//container\[@n='stages'\]/blockdata\[@name = 'Stage 3'\]"]

# Remove body to split into excavated and clay
gid_groups_conds::delete ".//container\[@n='stages'\]/blockdata\[@name = 'Stage 3'\]/container\[@n = 'Parts']/condition/group"
gid_groups_conds::delete ".//container\[@n='stages'\]/blockdata\[@name = 'Stage 3'\]/container\[@n = 'Loads']/condition\[@n='SelfWeight2D'\]/group"

# Parts
set parts [spdAux::getRoute "GEOMParts" $stage]/condition\[@n='Parts_GeoSteadyState'\]
set body_node [customlib::AddConditionGroupOnXPath $parts Clay_after_excavation]
set props [list YOUNG_MODULUS 1000 POISSON_RATIO 0.3]
spdAux::SetValuesOnBaseNode $body_node $props

set parts [spdAux::getRoute "GEOMParts" $stage]/condition\[@n='Parts_GeoSteadyState'\]
set body_node [customlib::AddConditionGroupOnXPath $parts Excavated]
set props [list YOUNG_MODULUS 1000 POISSON_RATIO 0.3]
spdAux::SetValuesOnBaseNode $body_node $props

# Prepare stages
::GeoMechanics::xml::NewStage "Stage 2"
::GeoMechanics::xml::NewStage "Stage 3"

# Gravity
GiD_Groups clone Clay_after_excavation Total
GiD_Groups edit parent Total Clay_after_excavation
spdAux::AddIntervalGroup Body "Clay_after_excavation//Total"
GiD_Groups edit state "Clay_after_excavation//Total" hidden
set gravity [spdAux::getRoute "GEOMLoads" $stage]/condition\[@n='SelfWeight2D'\]
set gravity_node [customlib::AddConditionGroupOnXPath $gravity "Clay_after_excavation//Total"]
$gravity_node setAttribute ov surface
set props [list modulus 9.81 value_direction_Y -1.0 Interval Total]
spdAux::SetValuesOnBaseNode $gravity_node $props

GiD_Groups clone Excavated Total
GiD_Groups edit parent Total Excavated
spdAux::AddIntervalGroup Body "Excavated//Total"
GiD_Groups edit state "Excavated//Total" hidden
set gravity [spdAux::getRoute "GEOMLoads" $stage]/condition\[@n='SelfWeight2D'\]
set gravity_node [customlib::AddConditionGroupOnXPath $gravity "Excavated//Total"]
$gravity_node setAttribute ov surface
set props [list modulus 9.81 value_direction_Y -1.0 Interval Total]
spdAux::SetValuesOnBaseNode $gravity_node $props


# Stage 4
::GeoMechanics::xml::NewStage "Stage 4"
set stage [$root selectNodes ".//container\[@n='stages'\]/blockdata\[@name = 'Stage 4'\]"]

# Remove excavated
gid_groups_conds::delete ".//container\[@n='stages'\]/blockdata\[@name = 'Stage 4'\]/container\[@n = 'Parts']/condition/group\[@n='Excavated'\]"
gid_groups_conds::delete ".//container\[@n='stages'\]/blockdata\[@name = 'Stage 4'\]/container\[@n = 'Loads']/condition\[@n='SelfWeight2D'\]/group\[@n='Excavated//Total'\]"


spdAux::parseRoutes

::GeoMechanics::PrevStage
Expand Down
Loading

0 comments on commit 237ce6b

Please sign in to comment.