diff --git a/.gitignore b/.gitignore
index 62dfde449..2cc966151 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,4 +13,5 @@ dist
*.zip
*.tgz
-null
\ No newline at end of file
+null
+__pycache__
diff --git a/kratos.gid/apps/Common/xml/Parallelism.spd b/kratos.gid/apps/Common/xml/Parallelism.spd
index b233967de..c74d22db5 100644
--- a/kratos.gid/apps/Common/xml/Parallelism.spd
+++ b/kratos.gid/apps/Common/xml/Parallelism.spd
@@ -1,6 +1,6 @@
-
-
-
-
+
+
+
+
diff --git a/kratos.gid/apps/Examples/xml/examples.xml b/kratos.gid/apps/Examples/xml/examples.xml
index 09adbbf88..a90df0dc5 100644
--- a/kratos.gid/apps/Examples/xml/examples.xml
+++ b/kratos.gid/apps/Examples/xml/examples.xml
@@ -24,4 +24,5 @@
+
diff --git a/kratos.gid/apps/GeoMechanics/MainKratos.py b/kratos.gid/apps/GeoMechanics/MainKratos.py
new file mode 100644
index 000000000..3e2a5867c
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/MainKratos.py
@@ -0,0 +1,45 @@
+import sys
+import time
+import importlib
+
+import KratosMultiphysics
+
+def CreateAnalysisStageWithFlushInstance(cls, global_model, parameters):
+ class AnalysisStageWithFlush(cls):
+
+ def __init__(self, model,project_parameters, flush_frequency=10.0):
+ super().__init__(model,project_parameters)
+ self.flush_frequency = flush_frequency
+ self.last_flush = time.time()
+ sys.stdout.flush()
+
+ def Initialize(self):
+ super().Initialize()
+ sys.stdout.flush()
+
+ def FinalizeSolutionStep(self):
+ super().FinalizeSolutionStep()
+
+ if self.parallel_type == "OpenMP":
+ now = time.time()
+ if now - self.last_flush > self.flush_frequency:
+ sys.stdout.flush()
+ self.last_flush = now
+
+ return AnalysisStageWithFlush(global_model, parameters)
+
+if __name__ == "__main__":
+
+ with open("ProjectParameters.json", 'r') as parameter_file:
+ parameters = KratosMultiphysics.Parameters(parameter_file.read())
+
+ analysis_stage_module_name = parameters["stages"]["Stage 1"]["analysis_stage"].GetString()
+ analysis_stage_class_name = analysis_stage_module_name.split('.')[-1]
+ analysis_stage_class_name = ''.join(x.title() for x in analysis_stage_class_name.split('_'))
+
+ analysis_stage_module = importlib.import_module(analysis_stage_module_name)
+ analysis_stage_class = getattr(analysis_stage_module, analysis_stage_class_name)
+
+ global_model = KratosMultiphysics.Model()
+ simulation = CreateAnalysisStageWithFlushInstance(analysis_stage_class, global_model, parameters)
+ simulation.Run()
diff --git a/kratos.gid/apps/GeoMechanics/app.json b/kratos.gid/apps/GeoMechanics/app.json
index cadd7c3b7..39f91ce27 100644
--- a/kratos.gid/apps/GeoMechanics/app.json
+++ b/kratos.gid/apps/GeoMechanics/app.json
@@ -16,7 +16,10 @@
"controllers/Toolbar.tcl",
"write/write.tcl",
"write/writeProjectParameters.tcl",
- "controllers/Python.tcl"
+ "controllers/Python.tcl",
+ "controllers/PhreaticLine.tcl",
+ "examples/examples.tcl",
+ "examples/FirstExample.tcl"
],
"start_script": "::GeoMechanics::Init",
"requirements": {
@@ -43,11 +46,12 @@
"coordinates": "all",
"materials_file": "Materials.json",
"properties_location": "json",
- "model_part_name": "ModelPart",
+ "model_part_name": "PorousDomain",
"output_model_part_name": "computational_model_part",
- "multistage_write_mdpa_mode": "different_files",
- "multistage_write_json_mode": "single_file"
+ "write_mdpa_mode": "geometries",
+ "multistage_write_json_mode": "single_file",
+ "multistage_write_mdpa_file_mode": "single_file"
},
- "main_launch_file": "../../exec/MainKratos.py",
+ "main_launch_file": "MainKratos.py",
"description": ""
-}
\ No newline at end of file
+}
diff --git a/kratos.gid/apps/GeoMechanics/controllers/PhreaticLine.tcl b/kratos.gid/apps/GeoMechanics/controllers/PhreaticLine.tcl
new file mode 100644
index 000000000..3bf1d8089
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/controllers/PhreaticLine.tcl
@@ -0,0 +1,139 @@
+
+proc ::GeoMechanics::PhreaticButton { } {
+ variable curr_stage
+ variable state_phreatic_line
+
+ # Get the current active stage
+ set stages [::GeoMechanics::xml::GetStages]
+ set stage [lindex $stages $curr_stage]
+
+ # If the state is none, the user clicked because he wants to create a phreatic line
+ if {$state_phreatic_line eq "none"} {
+
+ # Get the current stage phreatic points
+ set current_phreatic_points [::GeoMechanics::xml::GetPhreaticPoints $stage]
+ # If there are no phreatic points, create a new line
+ if {[llength $current_phreatic_points] eq 0} {
+ set state_phreatic_line creating
+ ::GeoMechanics::CreatePhreaticLine $stage
+ } else {
+ # If there are phreatic points, display it somehow
+ ::GeoMechanics::DisplayPhreaticLine
+ }
+ } elseif {$state_phreatic_line in [list "creating" "displaying"]} {
+ ::GeoMechanics::EndCreatePhreaticLine
+ }
+}
+
+proc ::GeoMechanics::DeletePhreaticButton { } {
+ variable curr_stage
+
+ # Get the current active stage
+ set stages [::GeoMechanics::xml::GetStages]
+ set stage [lindex $stages $curr_stage]
+
+ ::GeoMechanics::xml::DeletePhreaticPoints $stage
+ ::GeoMechanics::EndCreatePhreaticLine
+}
+
+proc ::GeoMechanics::CreatePhreaticLine {stage} {
+ variable state_phreatic_line
+ variable creating_phreatic_previous_layer
+ set creating_phreatic_previous_layer [GiD_Layers get to_use]
+ set stage_name [$stage @name]
+ if {[GiD_Layers exists PhreaticLine_$stage_name]} {
+ GiD_Layers delete PhreaticLine_$stage_name
+ }
+ GiD_Layers create PhreaticLine_$stage_name
+ GiD_Layers edit to_use PhreaticLine_$stage_name
+ GiD_RegisterEvent GiD_Event_AfterCreateLine ::GeoMechanics::AfterCreatePhreaticLine PROBLEMTYPE Kratos
+ GiD_Process MEscape Mescape Geometry Create Line
+}
+
+proc ::GeoMechanics::AfterCreatePhreaticLine { line } {
+ variable curr_stage
+ variable state_phreatic_line
+ if {$state_phreatic_line eq "creating"} {
+
+ # Get the current active stage
+ set stages [::GeoMechanics::xml::GetStages]
+ set stage [lindex $stages $curr_stage]
+
+ # Get line points
+ lassign [GiD_Geometry get line $line] a b p1 p2
+ # Get point coordinates
+ lassign [GiD_Geometry get point $p1] a x1 y1 z1
+ lassign [GiD_Geometry get point $p2] a x2 y2 z2
+ # Add coordinates to xml
+ if {[llength [::GeoMechanics::xml::GetPhreaticPoints $stage]] == 0} {
+ ::GeoMechanics::xml::AddPhreaticPoint $stage $x1 $y1 $z1
+ }
+ ::GeoMechanics::xml::AddPhreaticPoint $stage $x2 $y2 $z2
+ } else {
+
+ }
+
+ # TODO: at this moment we only allow 2 points, in the future, will see
+ set num [llength [::GeoMechanics::xml::GetPhreaticPoints $stage]]
+ if {$num >= 2} {
+ ::GeoMechanics::EndCreatePhreaticLine
+ ::GeoMechanics::DisplayPhreaticLine
+ }
+}
+proc ::GeoMechanics::EndCreatePhreaticLine { } {
+ variable state_phreatic_line
+ set state_phreatic_line none
+
+ # Delete the phreatic line
+ ::GeoMechanics::DeleteVisiblePhreaticLine
+
+ # Delete the lines from the variable list
+ variable creating_phreatic_previous_layer
+ GiD_Layers edit to_use $creating_phreatic_previous_layer
+ catch {GiD_UnRegisterEvent GiD_Event_AfterCreateLine ::GeoMechanics::AfterCreatePhreaticLine PROBLEMTYPE Kratos}
+ spdAux::RequestRefresh
+}
+
+proc ::GeoMechanics::DeleteVisiblePhreaticLine { } {
+ variable curr_stage
+
+ # Get the current active stage
+ set stages [::GeoMechanics::xml::GetStages]
+ set stage [lindex $stages $curr_stage]
+
+ set stage_name [$stage @name]
+ # Delete the lines from the variable list
+ if {[GiD_Layers exists PhreaticLine_$stage_name]} {GiD_Layers delete PhreaticLine_$stage_name}
+ GiD_Process MEscape 'Redraw escape
+}
+
+proc ::GeoMechanics::DisplayPhreaticLine {} {
+ variable state_phreatic_line
+ set state_phreatic_line displaying
+
+ # Get the current active stage
+ variable curr_stage
+ set stages [::GeoMechanics::xml::GetStages]
+ set stage [lindex $stages $curr_stage]
+
+ set stage_name [$stage @name]
+ set layer_name PhreaticLine_$stage_name
+ if {[GiD_Layers exists $layer_name]} {
+ GiD_Layers delete $layer_name
+ }
+ GiD_Layers create $layer_name
+ # GiD_Layers edit to_use $layer_name
+ set current_phreatic_points [::GeoMechanics::xml::GetPhreaticPoints $stage]
+ set point_list [list ]
+ foreach point $current_phreatic_points {
+ lassign $point x y
+ lappend point_list [GiD_Geometry -v2 create point append $layer_name $x $y 0.0]
+ }
+ # set coordinates ""
+ set ini [lindex $point_list 0]
+ foreach end [lrange $point_list 1 end] {
+ GiD_Geometry -v2 create line append stline $layer_name $ini $end
+ set ini $end
+ }
+ GiD_Process MEscape 'Redraw escape
+}
\ No newline at end of file
diff --git a/kratos.gid/apps/GeoMechanics/controllers/Python.tcl b/kratos.gid/apps/GeoMechanics/controllers/Python.tcl
index e708b5843..f2fab2ac5 100644
--- a/kratos.gid/apps/GeoMechanics/controllers/Python.tcl
+++ b/kratos.gid/apps/GeoMechanics/controllers/Python.tcl
@@ -3,4 +3,14 @@ proc ::GeoMechanics::PythonButton { } {
GiD_Python_Source [file join $::GeoMechanics::dir controllers geomechanics_script.py]
set result_python [GiD_Python_Call geomechanics_script.my_python_procedure $param1]
W $result_python
+}
+
+proc ::GeoMechanics::PythonButtonImportPlaxis { } {
+ set directory [MessageBoxGetFilename directory read [_ "Select Plaxis model to import"]]
+ if {$directory == ""} {
+ return
+ }
+ GiD_Python_Source [file join $::GeoMechanics::dir controllers geomechanics_import_plaxis.py]
+ set result_python [GiD_Python_Call geomechanics_import_plaxis.import_plaxis_procedure $directory]
+ W $result_python
}
\ No newline at end of file
diff --git a/kratos.gid/apps/GeoMechanics/controllers/SplashWindow.tcl b/kratos.gid/apps/GeoMechanics/controllers/SplashWindow.tcl
new file mode 100644
index 000000000..4db2d96b1
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/controllers/SplashWindow.tcl
@@ -0,0 +1,26 @@
+# Create the main window
+set mainWindow .gid.maingui
+toplevel $mainWindow
+wm title $mainWindow "Two Sections Window"
+wm geometry $mainWindow 400x200
+
+# Create the first section with two big square buttons
+frame $mainWindow.section1 -background white
+button $mainWindow.section1.button1 -text "Button 1" -width 10 -height 10
+button $mainWindow.section1.button2 -text "Button 2" -width 10 -height 10
+grid $mainWindow.section1.button1 -row 0 -column 0 -padx 20 -pady 20
+grid $mainWindow.section1.button2 -row 0 -column 1 -padx 20 -pady 20
+
+# Create the second section with text and a small button
+frame $mainWindow.section2 -background white
+text $mainWindow.section2.text -width 30 -height 5
+button $mainWindow.section2.button -text "Small Button" -width 10
+grid $mainWindow.section2.text -row 0 -column 0 -padx 20 -pady 20
+grid $mainWindow.section2.button -row 1 -column 0 -padx 20 -pady 10
+
+# Place the sections in the main window
+grid $mainWindow.section1 -row 0 -column 0 -sticky news
+grid $mainWindow.section2 -row 0 -column 1 -sticky news
+
+# Start the event loop
+tkwait window $mainWindow
\ No newline at end of file
diff --git a/kratos.gid/apps/GeoMechanics/controllers/geomechanics_import_plaxis.py b/kratos.gid/apps/GeoMechanics/controllers/geomechanics_import_plaxis.py
new file mode 100644
index 000000000..d742264cb
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/controllers/geomechanics_import_plaxis.py
@@ -0,0 +1,30 @@
+import os
+import tohil
+
+# To create functions and variables for all tcl available ones
+tcl=tohil.import_tcl()
+
+
+def import_plaxis_procedure(directory):
+
+ tcl.W(f"Importing Plaxi model from: {directory}")
+
+ # Print evertying that is known by the tcl object
+ # object_info = tcl.__dict__
+ # for object_function in object_info:
+ # tcl.W(object_function)
+
+ tcl.W("Found files to import")
+ for filename in os.listdir(directory):
+ file = os.path.join(directory, filename)
+ tcl.W(file)
+
+ p1 = tcl.GiD_Geometry("create", "point", "append", "Layer0", "-8.87755","3.26531","0")
+ tcl.W(p1)
+ p2 = tcl.GiD_Geometry("create", "point", "append", "Layer0", "4.95465","3.44671","0")
+ result = tcl.GiD_Geometry("create", "line", "append", "stline", "Layer0", p1, p2)
+
+ # Force redraw otherwise it triggers much later than end of script
+ tcl.GiD_Redraw()
+
+ return "Done importing model"
diff --git a/kratos.gid/apps/GeoMechanics/examples/FirstExample.tcl b/kratos.gid/apps/GeoMechanics/examples/FirstExample.tcl
new file mode 100644
index 000000000..ba949eff4
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/examples/FirstExample.tcl
@@ -0,0 +1,256 @@
+namespace eval ::GeoMechanics::examples::FirstExample {
+ namespace path ::GeoMechanics::examples
+ Kratos::AddNamespace [namespace current]
+
+}
+
+proc ::GeoMechanics::examples::FirstExample::Init {args} {
+ if {![Kratos::IsModelEmpty]} {
+ set txt "We are going to draw the example geometry.\nDo you want to lose your previous work?"
+ set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel]
+ if { $retval == "cancel" } { return }
+ }
+ Kratos::ResetModel
+
+ DrawGeometry
+ AssignGroups
+ AssignMeshSizes
+ TreeAssignation
+ MeshGenerationOKDo 1
+
+ GiD_Process 'Redraw
+ GidUtils::UpdateWindow GROUPS
+ GidUtils::UpdateWindow LAYER
+ GiD_Process 'Zoom Frame
+}
+
+proc ::GeoMechanics::examples::FirstExample::DrawGeometry {args} {
+
+ Kratos::ResetModel
+ set layer_in_use Model
+ GiD_Layers create $layer_in_use
+ GiD_Layers edit to_use $layer_in_use
+
+ set points [list {0 -15 0} {30 -15 0} {30 0 0} {29 0 0} {26 -3 0} {25 -3 0} {22 0 0} {20 0 0} {10 0 0} {0 0 0} ]
+ set model_points [list ]
+ foreach point $points {
+ lassign $point x y z
+ lappend model_points [GiD_Geometry create point append $layer_in_use $x $y $z]
+ }
+
+ set model_lines [list ]
+ set initial [lindex $model_points 0]
+ foreach point [lrange $model_points 1 end] {
+ lappend model_lines [GiD_Geometry create line append stline $layer_in_use $initial $point]
+ set initial $point
+ }
+ lappend model_lines [GiD_Geometry create line append stline $layer_in_use $initial [lindex $model_points 0]]
+ lappend model_lines [GiD_Geometry create line append stline $layer_in_use 4 7]
+
+ GiD_Process Mescape Geometry Create NurbsSurface 4 5 6 11 escape escape
+ GiD_Process Mescape Geometry Create NurbsSurface 1 2 10 7 8 9 3 4 5 6 escape escape
+
+}
+
+proc ::GeoMechanics::examples::FirstExample::AssignGroups {args} {
+ # Fluid group creation
+ GiD_Groups create Bottom
+ GiD_EntitiesGroups assign Bottom lines 1
+
+ GiD_Groups create Clay_after_excavation
+ GiD_EntitiesGroups assign Clay_after_excavation surfaces 2
+
+ GiD_Groups create Excavated
+ GiD_EntitiesGroups assign Excavated surfaces 1
+
+ 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}
+
+ GiD_Groups create Side_sliders
+ GiD_EntitiesGroups assign Side_sliders lines {2 10}
+
+}
+
+
+proc ::GeoMechanics::examples::FirstExample::AssignMeshSizes {args} {
+
+}
+
+proc ::GeoMechanics::examples::FirstExample::TreeAssignation {args} {
+ set nd $::Model::SpatialDimension
+ set root [customlib::GetBaseRoot]
+
+ # Stage 1
+ set stage [$root selectNodes ".//container\[@n='stages'\]/blockdata\[@name = 'Stage 1'\]"]
+
+ # Solution type
+ set xpath [spdAux::getRoute "GEOMSoluType" $stage]
+ [[customlib::GetBaseRoot] selectNodes $xpath] setAttribute v "Quasi-static"
+
+ # Time parameters
+ set parameters [list StartTime 0.0 EndTime 1.0]
+ set xpath [spdAux::getRoute "GEOMTimeParameters" $stage]
+ spdAux::SetValuesOnBasePath $xpath $parameters
+
+ set parameters [list DeltaTime 1.0 StartTime 0]
+ set xpath "[spdAux::getRoute GEOMTimeParameters $stage]/container\[@n = 'TimeStep'\]/blockdata"
+ spdAux::SetValuesOnBasePath $xpath $parameters
+
+ # Parts
+ set parts [spdAux::getRoute "GEOMParts" $stage]/condition\[@n='Parts_GeoSteadyState'\]
+ set body_node [customlib::AddConditionGroupOnXPath $parts Body]
+ set props [list YOUNG_MODULUS 1000 POISSON_RATIO 0.3]
+ spdAux::SetValuesOnBaseNode $body_node $props
+
+ # Phreatic line
+ ::GeoMechanics::xml::AddPhreaticPoint $stage 0.0 -1.0 0.0
+ ::GeoMechanics::xml::AddPhreaticPoint $stage 30.0 -1.0 0.0
+
+ # Fix ground
+ GiD_Groups clone Bottom Total
+ 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
+ set props [list selector_component_X ByValue value_component_X 0.0 selector_component_Y ByValue selector_component_Z Not Interval Total]
+ spdAux::SetValuesOnBaseNode $displacement_node $props
+
+ # Fix sides only X
+ GiD_Groups clone Side_sliders Total
+ 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
+ set props [list selector_component_X ByValue value_component_X 0.0 selector_component_Y Not selector_component_Z Not Interval Total]
+ spdAux::SetValuesOnBaseNode $displacement_node $props
+
+ # Gravity
+ GiD_Groups clone Body Total
+ 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
+
+ # Top Pressure
+ GiD_Groups clone Load Total
+ GiD_Groups edit parent Total Load
+ spdAux::AddIntervalGroup Body "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
+
+
+
+
+ # Prepare stages
+ ::GeoMechanics::xml::NewStage "Stage 2"
+ ::GeoMechanics::xml::NewStage "Stage 3"
+ ::GeoMechanics::xml::NewStage "Stage 4"
+ spdAux::parseRoutes
+
+ ::GeoMechanics::PrevStage
+ return ""
+
+
+ # Time parameters
+ set parameters [list EndTime 40.0 DeltaTime 0.05]
+ set xpath [spdAux::getRoute "FLTimeParameters"]
+
+ spdAux::SetValuesOnBasePath $xpath $parameters
+
+ # Output
+ set parameters [list OutputControlType time OutputDeltaTime 1.0]
+ set xpath "[spdAux::getRoute FLResults]/container\[@n='GiDOutput'\]/container\[@n='GiDOptions'\]"
+
+ spdAux::SetValuesOnBasePath $xpath $parameters
+
+ # Fluid domain strategy settings
+ set parameters [list relative_velocity_tolerance "1e-8" absolute_velocity_tolerance "1e-10" relative_pressure_tolerance "1e-8" absolute_pressure_tolerance "1e-10" maximum_iterations "20"]
+ set xpath [spdAux::getRoute FLStratParams]
+
+ spdAux::SetValuesOnBasePath $xpath $parameters
+
+ # Structural
+ gid_groups_conds::setAttributesF {container[@n='FSI']/container[@n='Structural']/container[@n='StageInfo']/value[@n='SolutionType']} {v Dynamic}
+
+ # Structural Parts
+
+ set structParts [spdAux::getRoute "STParts"]/condition\[@n='Parts_Solid'\]
+ set structPartsNode [customlib::AddConditionGroupOnXPath $structParts Structure]
+ $structPartsNode setAttribute ov surface
+ set constLawNameStruc "LinearElasticPlaneStress2DLaw"
+ set props [list Element TotalLagrangianElement$nd ConstitutiveLaw $constLawNameStruc DENSITY 7850 YOUNG_MODULUS 206.9e9 POISSON_RATIO 0.29 THICKNESS 0.1]
+ spdAux::SetValuesOnBaseNode $structPartsNode $props
+
+ # Structural Displacement
+ GiD_Groups clone Ground Total
+ GiD_Groups edit parent Total Ground
+ spdAux::AddIntervalGroup Ground "Ground//Total"
+ GiD_Groups edit state "Ground//Total" hidden
+ set structDisplacement {container[@n='FSI']/container[@n='Structural']/container[@n='Boundary Conditions']/condition[@n='DISPLACEMENT']}
+ set structDisplacementNode [customlib::AddConditionGroupOnXPath $structDisplacement Ground]
+ $structDisplacementNode setAttribute ov line
+ set props [list selector_component_X ByValue value_component_X 0.0 selector_component_Y ByValue value_component_Y 0.0 selector_component_Z ByValue value_component_Z 0.0 Interval Total]
+ spdAux::SetValuesOnBaseNode $structDisplacementNode $props
+
+ # Structure domain time parameters
+ set parameters [list EndTime 40.0 DeltaTime 0.05]
+ set xpath [spdAux::getRoute STTimeParameters]
+ spdAux::SetValuesOnBasePath $xpath $parameters
+
+ # Structural Interface
+ customlib::AddConditionGroupOnXPath "container\[@n='FSI'\]/container\[@n='Structural'\]/container\[@n='Loads'\]/condition\[@n='StructureInterface$nd'\]" InterfaceStructure
+
+ # Structure domain output parameters
+ set parameters [list OutputControlType time OutputDeltaTime 1.0]
+ set xpath "[spdAux::getRoute STResults]/container\[@n='GiDOutput'\]/container\[@n='GiDOptions'\]"
+ spdAux::SetValuesOnBasePath $xpath $parameters
+
+ # Structure Bossak scheme setting
+ spdAux::SetValueOnTreeItem v "bossak" STScheme
+
+ # Structure domain strategy settings
+ set parameters [list echo_level 0 residual_relative_tolerance "1e-8" residual_absolute_tolerance "1e-10" max_iteration "20"]
+ set xpath [spdAux::getRoute STStratParams]
+ spdAux::SetValuesOnBasePath $xpath $parameters
+
+ # Coupling settings
+ set parameters [list ParallelSolutionType OpenMP OpenMPNumberOfThreads 4]
+ set xpath [spdAux::getRoute "Parallelization"]
+ spdAux::SetValuesOnBasePath $xpath $parameters
+
+ set parameters [list nl_tol "1e-8" nl_max_it 25]
+ set xpath [spdAux::getRoute FSIStratParams]
+ spdAux::SetValuesOnBasePath $xpath $parameters
+
+ set parameters [list Solver Relaxation]
+ set xpath [spdAux::getRoute FSIPartitionedcoupling_strategy]
+ spdAux::SetValuesOnBasePath $xpath $parameters
+
+ spdAux::RequestRefresh
+}
diff --git a/kratos.gid/apps/GeoMechanics/examples/examples.tcl b/kratos.gid/apps/GeoMechanics/examples/examples.tcl
new file mode 100644
index 000000000..73432d67f
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/examples/examples.tcl
@@ -0,0 +1,5 @@
+namespace eval ::GeoMechanics::examples {
+ namespace path ::GeoMechanics::examples
+ Kratos::AddNamespace [namespace current]
+
+}
diff --git a/kratos.gid/apps/GeoMechanics/examples/examples.xml b/kratos.gid/apps/GeoMechanics/examples/examples.xml
new file mode 100644
index 000000000..695e0b178
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/examples/examples.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/kratos.gid/apps/GeoMechanics/images/DeltaresGeoMechanicsGiD.svg b/kratos.gid/apps/GeoMechanics/images/DeltaresGeoMechanicsGiD.svg
new file mode 100644
index 000000000..4d8101647
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/images/DeltaresGeoMechanicsGiD.svg
@@ -0,0 +1,44 @@
+
diff --git a/kratos.gid/apps/GeoMechanics/images/FirstExample.png b/kratos.gid/apps/GeoMechanics/images/FirstExample.png
new file mode 100644
index 000000000..098912334
Binary files /dev/null and b/kratos.gid/apps/GeoMechanics/images/FirstExample.png differ
diff --git a/kratos.gid/apps/GeoMechanics/images/drop.png b/kratos.gid/apps/GeoMechanics/images/drop.png
new file mode 100644
index 000000000..eb9ebee00
Binary files /dev/null and b/kratos.gid/apps/GeoMechanics/images/drop.png differ
diff --git a/kratos.gid/apps/GeoMechanics/images/logo.png b/kratos.gid/apps/GeoMechanics/images/logo.png
index 38a1b0a03..a996e6528 100644
Binary files a/kratos.gid/apps/GeoMechanics/images/logo.png and b/kratos.gid/apps/GeoMechanics/images/logo.png differ
diff --git a/kratos.gid/apps/GeoMechanics/images/wave.png b/kratos.gid/apps/GeoMechanics/images/wave.png
new file mode 100644
index 000000000..8034bf806
Binary files /dev/null and b/kratos.gid/apps/GeoMechanics/images/wave.png differ
diff --git a/kratos.gid/apps/GeoMechanics/images/wave16.png b/kratos.gid/apps/GeoMechanics/images/wave16.png
new file mode 100644
index 000000000..a23a15d5c
Binary files /dev/null and b/kratos.gid/apps/GeoMechanics/images/wave16.png differ
diff --git a/kratos.gid/apps/GeoMechanics/images/wave_cross.png b/kratos.gid/apps/GeoMechanics/images/wave_cross.png
new file mode 100644
index 000000000..2c16000b5
Binary files /dev/null and b/kratos.gid/apps/GeoMechanics/images/wave_cross.png differ
diff --git a/kratos.gid/apps/GeoMechanics/start.tcl b/kratos.gid/apps/GeoMechanics/start.tcl
index bfcc84fc4..4097674b6 100644
--- a/kratos.gid/apps/GeoMechanics/start.tcl
+++ b/kratos.gid/apps/GeoMechanics/start.tcl
@@ -6,6 +6,10 @@ namespace eval ::GeoMechanics {
variable dir
variable curr_stage
+ variable state_phreatic_line
+ variable creating_phreatic_lines
+ variable creating_phreatic_previous_layer
+
proc GetAttribute {name} {variable _app; return [$_app getProperty $name]}
proc GetUniqueName {name} {variable _app; return [$_app getUniqueName $name]}
proc GetWriteProperty {name} {variable _app; return [$_app getWriteProperty $name]}
@@ -16,6 +20,7 @@ proc ::GeoMechanics::Init { app } {
variable _app
variable dir
variable curr_stage
+ variable state_phreatic_line
set _app $app
set dir [apps::getMyDir "GeoMechanics"]
@@ -27,6 +32,7 @@ proc ::GeoMechanics::Init { app } {
set curr_stage 0
+ set state_phreatic_line none
}
proc ::GeoMechanics::CustomToolbarItems { } {
@@ -36,12 +42,21 @@ proc ::GeoMechanics::CustomToolbarItems { } {
Kratos::ToolbarAddItem "DrawStage" "pie.png" [list -np- ::GeoMechanics::DrawStage] [= "Draw stage"]
Kratos::ToolbarAddItem "NextStage" "next.png" [list -np- ::GeoMechanics::NextStage] [= "Next stage"]
Kratos::ToolbarAddItem "SpacerGeoMechanics1" "" "" ""
+ Kratos::ToolbarAddItem "WaterLevel" "wave.png" [list -np- ::GeoMechanics::PhreaticButton] [= "Phreatic line"]
+ Kratos::ToolbarAddItem "WaterLevelDelete" "wave_cross.png" [list -np- ::GeoMechanics::DeletePhreaticButton] [= "Delete phreatic line"]
Kratos::ToolbarAddItem "callPython" "python.png" [list -np- ::GeoMechanics::PythonButton] [= "Python click"]
+ Kratos::ToolbarAddItem "callPython" "python.png" [list -np- ::GeoMechanics::PythonButtonImportPlaxis] [= "Import Plaxis model"]
}
proc ::GeoMechanics::PrevStage { } {
variable curr_stage
+ variable state_phreatic_line
+ set prev_state_phreatic_line $state_phreatic_line
+
set stages [::GeoMechanics::xml::GetStages]
+ # try to end the line creation or displaying
+ catch {::GeoMechanics::EndCreatePhreaticLine}
+
incr curr_stage -1
if {$curr_stage < 0} {
set curr_stage 0
@@ -49,10 +64,18 @@ proc ::GeoMechanics::PrevStage { } {
::GeoMechanics::xml::CloseStages
::GeoMechanics::xml::OpenStage [[lindex $stages $curr_stage] @name]
spdAux::RequestRefresh
+ ::GeoMechanics::WarnActiveStage
+ if {$prev_state_phreatic_line eq "displaying"} {::GeoMechanics::DisplayPhreaticLine}
}
proc ::GeoMechanics::NextStage { } {
variable curr_stage
+ variable state_phreatic_line
+ set prev_state_phreatic_line $state_phreatic_line
+
+ # try to end the line creation or displaying
+ catch {::GeoMechanics::EndCreatePhreaticLine}
+
set stages [::GeoMechanics::xml::GetStages]
incr curr_stage 1
set max [llength [::GeoMechanics::xml::GetStages]]
@@ -62,13 +85,24 @@ proc ::GeoMechanics::NextStage { } {
::GeoMechanics::xml::CloseStages
::GeoMechanics::xml::OpenStage [[lindex $stages $curr_stage] @name]
spdAux::RequestRefresh
+ ::GeoMechanics::WarnActiveStage
+
+ if {$prev_state_phreatic_line eq "displaying"} {::GeoMechanics::DisplayPhreaticLine}
}
proc ::GeoMechanics::DrawStage { } {
variable curr_stage
-
+
set stages [::GeoMechanics::xml::GetStages]
::GeoMechanics::xml::CloseStages
::GeoMechanics::xml::DrawStage [[lindex $stages $curr_stage] @name]
+ ::GeoMechanics::WarnActiveStage
+}
+# Print the current stage
+proc ::GeoMechanics::WarnActiveStage { } {
+ variable curr_stage
+ set stages [::GeoMechanics::xml::GetStages]
+ set stage [lindex $stages $curr_stage]
+ ::GidUtils::SetWarnLine "Current active stage: [$stage @name]"
}
\ No newline at end of file
diff --git a/kratos.gid/apps/GeoMechanics/write/write.tcl b/kratos.gid/apps/GeoMechanics/write/write.tcl
index a4005779e..c3f692125 100644
--- a/kratos.gid/apps/GeoMechanics/write/write.tcl
+++ b/kratos.gid/apps/GeoMechanics/write/write.tcl
@@ -43,18 +43,87 @@ proc ::GeoMechanics::write::Init { } {
SetAttribute model_part_name [::GeoMechanics::GetWriteProperty model_part_name]
SetAttribute output_model_part_name [::GeoMechanics::GetWriteProperty output_model_part_name]
- SetAttribute multistage_write_mdpa_mode [::GeoMechanics::GetWriteProperty multistage_write_mdpa_mode]
+ # multistage_write_mdpa_file_mode can be single_file or multiple_files
+ SetAttribute multistage_write_mdpa_file_mode [::GeoMechanics::GetWriteProperty multistage_write_mdpa_file_mode]
SetAttribute multistage_write_json_mode [::GeoMechanics::GetWriteProperty multistage_write_json_mode]
+ SetAttribute write_mdpa_mode [::GeoMechanics::GetWriteProperty write_mdpa_mode]
+
}
proc ::GeoMechanics::write::writeModelPartEvent { } {
+
variable mdpa_list
set mdpa_list [list ]
::Structural::write::Init
write::initWriteConfiguration [GetAttributes]
- if { [GetAttribute multistage_write_mdpa_mode] == "single_file" } {
+ if { [GetAttribute write_mdpa_mode] == "geometries" } {
+ write::writeModelPartFileAsGeometries
+ } else {
+ write::writeModelPartFileOld
+ }
+
+}
+
+proc ::GeoMechanics::write::writeModelPartFileAsGeometries { } {
+ if { [GetAttribute multistage_write_mdpa_file_mode] == "single_file" } {
+
+ # Headers
+ write::writeModelPartData
+ write::WriteString "Begin Properties 0"
+ write::WriteString "End Properties"
+
+ write::writeNodalCoordinates
+
+ # Write geometries
+ # Get the list of groups in the spd
+ set lista [::GeoMechanics::xml::GetListOfSubModelParts]
+
+ # Write the geometries
+ set ret [::write::writeGeometryConnectivities $lista]
+
+ # Write the submodelparts
+ foreach group $lista {
+ write::writeGroupSubModelPartAsGeometry [$group @n]
+ }
+
+ } else {
+ variable mdpa_list
+ write::CloseFile
+
+ set stages [::GeoMechanics::xml::GetStages]
+ foreach stage $stages {
+ write::OpenFile "[$stage @name].mdpa"
+ lappend mdpa_list "[$stage @name].mdpa"
+
+ # Headers
+ write::writeModelPartData
+ write::WriteString "Begin Properties 0"
+ write::WriteString "End Properties"
+
+ write::writeNodalCoordinatesOnParts $stage
+
+ # Write geometries
+ # Get the list of groups in the spd
+ set lista [::GeoMechanics::xml::GetListOfSubModelParts $stage]
+
+ # Write the geometries
+ set ret [::write::writeGeometryConnectivities $lista]
+
+ # Write the submodelparts
+ foreach group $lista {
+ write::writeGroupSubModelPartAsGeometry [$group @n]
+ }
+
+ write::CloseFile
+ }
+ }
+}
+
+
+proc ::GeoMechanics::write::writeModelPartFileOld { } {
+ if { [GetAttribute multistage_write_mdpa_file_mode] == "single_file" } {
# Headers
write::writeModelPartData
@@ -92,7 +161,7 @@ proc ::GeoMechanics::write::writeModelPartEvent { } {
Structural::write::writeMeshes $stage
}
} else {
-
+ variable mdpa_list
write::CloseFile
set stages [::GeoMechanics::xml::GetStages]
@@ -136,6 +205,7 @@ proc ::GeoMechanics::write::writeModelPartEvent { } {
}
}
+
proc ::GeoMechanics::write::writeElementConnectivities { {stage ""} } {
set root [customlib::GetBaseRoot]
set xp1 "//container\[@n = 'Parts'\]/condition/group"
diff --git a/kratos.gid/apps/GeoMechanics/write/writeProjectParameters.tcl b/kratos.gid/apps/GeoMechanics/write/writeProjectParameters.tcl
index 93b95cab5..7e6d8a96f 100644
--- a/kratos.gid/apps/GeoMechanics/write/writeProjectParameters.tcl
+++ b/kratos.gid/apps/GeoMechanics/write/writeProjectParameters.tcl
@@ -4,23 +4,54 @@ proc ::GeoMechanics::write::getParametersDict { stage } {
# Get the base dictionary for the project parameters
set project_parameters_dict [Structural::write::getParametersDict $stage]
-
+
+ if { [GetAttribute multistage_write_mdpa_file_mode] != "single_file" } {
+ dict set project_parameters_dict solver_settings model_import_settings input_filename [$stage @name]
+ }
+
+ # add the phreatic water properties
+ set list_of_processes [dict get $project_parameters_dict processes constraints_process_list]
+ lappend list_of_processes [::GeoMechanics::write::getPhreaticWaterProperties $stage]
+ dict set project_parameters_dict processes constraints_process_list $list_of_processes
+
+ # Modify the analysis stage
+ dict set project_parameters_dict analysis_stage "KratosMultiphysics.GeoMechanicsApplication.staged_geo_mechanics_analysis"
+
return $project_parameters_dict
}
+
proc ::GeoMechanics::write::GetSingleFileStageProjectParameters { } {
# Get the base dictionary for the project parameters
set project_parameters_dict [dict create]
- # Set the list of stages
- dict set project_parameters_dict "execution_list" [::GeoMechanics::xml::GetStages "names"]
+ # Get the stages
+ set stages_list [::GeoMechanics::xml::GetStages]
+ set stages_names [list ]
+ foreach stage $stages_list {
+ lappend stages_names [$stage @name]
+ }
+
+ # Set the orchestrator
+ dict set project_parameters_dict orchestrator [::write::GetOrchestratorDict $stages_names]
# Set the stages
set stages [dict create]
- foreach stage [::GeoMechanics::xml::GetStages] {
+ set i 0
+ foreach stage $stages_list {
set stage_name [$stage @name]
- dict set stages $stage_name [::GeoMechanics::write::getParametersDict $stage]
+ set stage_content [::GeoMechanics::write::getParametersDict $stage]
+ # In first iteration we add the mdpa importer
+ if {$i == 0} {
+ set parameters_modeler [dict create input_filename [Kratos::GetModelName] model_part_name [write::GetConfigurationAttribute model_part_name]]
+ dict set stages $stage_name stage_preprocess [::write::getPreprocessForStage $stage $parameters_modeler]
+ } else {
+ dict set stages $stage_name stage_preprocess [::write::getPreprocessForStage $stage]
+ }
+ dict set stages $stage_name stage_settings $stage_content
+ dict set stages $stage_name stage_postprocess [::write::getPostprocessForStage $stage]
+ incr i
}
dict set project_parameters_dict "stages" $stages
@@ -28,6 +59,7 @@ proc ::GeoMechanics::write::GetSingleFileStageProjectParameters { } {
return $project_parameters_dict
}
+
proc ::GeoMechanics::write::writeParametersEvent { } {
if { [GetAttribute multistage_write_json_mode] == "single_file" } {
write::WriteJSON [::GeoMechanics::write::GetSingleFileStageProjectParameters]
@@ -38,5 +70,28 @@ proc ::GeoMechanics::write::writeParametersEvent { } {
write::OpenFile "ProjectParameters[$stage @name].json"
write::WriteJSON [::GeoMechanics::write::getParametersDict $stage]
}
+
+ # TODO: add the orchestrator in ProjectParameters.json
}
}
+
+# Get the phreatic water properties for the stage
+proc ::GeoMechanics::write::getPhreaticWaterProperties { stage } {
+ # Get the points from the tree
+ set points [::GeoMechanics::xml::GetPhreaticPoints $stage]
+
+ # TODO: AT THIS MOMENT WE ONLY ALLOW 2 POINTS
+ set p1 [lindex $points 0]
+ set point_1 [lappend p1 0.0]
+ set p2 [lindex $points end]
+ set point_2 [lappend p2 0.0]
+
+ set phreatic_water_process [dict create]
+ dict set phreatic_water_process python_module apply_constant_phreatic_line_pressure_process
+ dict set phreatic_water_process kratos_module KratosMultiphysics.GeoMechanicsApplication
+ dict set phreatic_water_process process_name ApplyConstantPhreaticLinePressureProcess
+ dict set phreatic_water_process Parameters model_part_name [GetAttribute model_part_name]
+ dict set phreatic_water_process Parameters variable_name WATER_PRESSURE
+ dict set phreatic_water_process Parameters first_reference_coordinate $point_1
+ dict set phreatic_water_process Parameters second_reference_coordinate $point_2
+}
\ No newline at end of file
diff --git a/kratos.gid/apps/GeoMechanics/xml/BoundaryConditions.spd b/kratos.gid/apps/GeoMechanics/xml/BoundaryConditions.spd
new file mode 100644
index 000000000..f253e885f
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/xml/BoundaryConditions.spd
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/kratos.gid/apps/GeoMechanics/xml/Conditions.xml b/kratos.gid/apps/GeoMechanics/xml/Conditions.xml
index 7f9c9313e..582e496e6 100644
--- a/kratos.gid/apps/GeoMechanics/xml/Conditions.xml
+++ b/kratos.gid/apps/GeoMechanics/xml/Conditions.xml
@@ -5,7 +5,7 @@
ImplementedInApplication="GeoMechanicsApplication" MinimumKratosVersion="9000"
WorkingSpaceDimension="2D" LocalSpaceDimension="0" RequiresLocalAxes="False"
ElementType="Line" ProcessName="MyCustomProcess" VariableName="VOLUME_ACCELERATION"
- help="Self weight application by means of the AssignVectorByDirectionProcess in the core" units="m/s^2" unit_magnitude="Acceleration">
+ help="Self weight application by means of the AssignVectorByDirectionProcess in the core" units="m/s^2" unit_magnitude="Acceleration" Water="True">
@@ -19,6 +19,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/kratos.gid/apps/GeoMechanics/xml/Elements.xml b/kratos.gid/apps/GeoMechanics/xml/Elements.xml
index 8550ad7e0..3d55a7357 100644
--- a/kratos.gid/apps/GeoMechanics/xml/Elements.xml
+++ b/kratos.gid/apps/GeoMechanics/xml/Elements.xml
@@ -2,7 +2,7 @@
-
+
@@ -25,8 +25,7 @@
-
-
+
@@ -39,7 +38,7 @@
-
+
@@ -59,8 +58,7 @@
-
-
+
diff --git a/kratos.gid/apps/GeoMechanics/xml/Loads.spd b/kratos.gid/apps/GeoMechanics/xml/Loads.spd
index 9c85640dd..342a62561 100644
--- a/kratos.gid/apps/GeoMechanics/xml/Loads.spd
+++ b/kratos.gid/apps/GeoMechanics/xml/Loads.spd
@@ -1,4 +1,4 @@
-
-
\ No newline at end of file
+
+
diff --git a/kratos.gid/apps/GeoMechanics/xml/Main.spd b/kratos.gid/apps/GeoMechanics/xml/Main.spd
index c4d51a6f4..9c43e8bd0 100644
--- a/kratos.gid/apps/GeoMechanics/xml/Main.spd
+++ b/kratos.gid/apps/GeoMechanics/xml/Main.spd
@@ -1,21 +1,22 @@
-
-
-
+
+
+
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
diff --git a/kratos.gid/apps/GeoMechanics/xml/NodalConditions.xml b/kratos.gid/apps/GeoMechanics/xml/NodalConditions.xml
new file mode 100644
index 000000000..5052ebfab
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/xml/NodalConditions.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/kratos.gid/apps/GeoMechanics/xml/Processes.xml b/kratos.gid/apps/GeoMechanics/xml/Processes.xml
index fec1ced4d..5feba3609 100644
--- a/kratos.gid/apps/GeoMechanics/xml/Processes.xml
+++ b/kratos.gid/apps/GeoMechanics/xml/Processes.xml
@@ -6,5 +6,15 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/kratos.gid/apps/GeoMechanics/xml/Settings.spd b/kratos.gid/apps/GeoMechanics/xml/Settings.spd
new file mode 100644
index 000000000..02209d9e1
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/xml/Settings.spd
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/kratos.gid/apps/GeoMechanics/xml/Water.spd b/kratos.gid/apps/GeoMechanics/xml/Water.spd
new file mode 100644
index 000000000..132bbb386
--- /dev/null
+++ b/kratos.gid/apps/GeoMechanics/xml/Water.spd
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/kratos.gid/apps/GeoMechanics/xml/XmlController.tcl b/kratos.gid/apps/GeoMechanics/xml/XmlController.tcl
index e4daeda5b..11dbc8457 100644
--- a/kratos.gid/apps/GeoMechanics/xml/XmlController.tcl
+++ b/kratos.gid/apps/GeoMechanics/xml/XmlController.tcl
@@ -11,12 +11,17 @@ proc ::GeoMechanics::xml::Init { } {
Model::ForgetElements
Model::getElements Elements.xml
+ foreach condition [Model::GetConditions] {
+ $condition setAttribute Water False
+ }
Model::getConditions Conditions.xml
Model::getConstitutiveLaws ConstitutiveLaws.xml
Model::ForgetMaterials
Model::getMaterials Materials.xml
+ Model::getNodalConditions NodalConditions.xml
+
Model::getProcesses Processes.xml
# Structural strategies and schemes filter elements by ImplementedInApplication StructuralMechanicsApplication
@@ -73,6 +78,15 @@ proc ::GeoMechanics::xml::CustomTree { args } {
# Stress test
# for {set index 0} {$index < 200} {incr index} {::snit::RT.CallInstance ::boundary_conds::Snit_inst1 copy_block_data}
+ set xpath [spdAux::getRoute GEOMSoluType]
+ set solution_type_node [[customlib::GetBaseRoot] selectNodes $xpath]
+ $solution_type_node setAttribute values "Static,Quasi-static,Dynamic"
+
+ set xpath "[spdAux::getRoute STStratSection]/container\[@n='ParallelType'\]"
+ set old_parallel [[customlib::GetBaseRoot] selectNodes $xpath]
+ $old_parallel delete
+
+ ::GeoMechanics::WarnActiveStage
}
proc ::GeoMechanics::xml::ProcCheckGeometryGeoMechanics {domNode args} {
@@ -291,4 +305,56 @@ proc ::GeoMechanics::xml::EndDrawStage { } {
variable is_drawing_stage
set is_drawing_stage 0
GiD_Groups end_draw
-}
\ No newline at end of file
+}
+
+proc ::GeoMechanics::xml::NewStage { stage_name } {
+ set root [customlib::GetBaseRoot]
+ set stages [$root selectNodes ".//container\[@n='stages'\]/blockdata"]
+ set newstage [[lindex $stages end] cloneNode -deep]
+ $newstage setAttribute name $stage_name
+ $newstage setAttribute tree_state "open"
+ [$root selectNodes ".//container\[@n='stages'\]"] appendChild $newstage
+ spdAux::RequestRefresh
+}
+
+proc ::GeoMechanics::xml::GetListOfSubModelParts { {stage ""} } {
+ set root [customlib::GetBaseRoot]
+ if {$stage ne ""} {set root $stage}
+ set all_raw [$root selectNodes ".//condition/group"]
+ return $all_raw
+}
+
+proc ::GeoMechanics::xml::GetPhreaticPoints {stage} {
+ set root [customlib::GetBaseRoot]
+ if {$stage ne ""} {set root $stage}
+ set all_raw [$root selectNodes ".//container\[@n='PhreaticPoints'\]/value"]
+
+ set result [list ]
+ foreach point $all_raw {
+ lappend result [write::getValueByNode $point]
+ }
+ return $result
+}
+proc ::GeoMechanics::xml::DeletePhreaticPoints {stage} {
+ set root [customlib::GetBaseRoot]
+ if {$stage ne ""} {set root $stage}
+ set all_raw [$root selectNodes ".//container\[@n='PhreaticPoints'\]/value"]
+
+ foreach point $all_raw {
+ $point delete
+ }
+}
+
+proc ::GeoMechanics::xml::AddPhreaticPoint {stage x1 y1 z1} {
+ set root [customlib::GetBaseRoot]
+ if {$stage ne ""} {set root $stage}
+ set base [$root selectNodes ".//container\[@n='PhreaticPoints'\]"]
+
+ set all_raw [$base selectNodes "./value"]
+ set num [llength $all_raw]
+ set v "$x1,$y1"
+ set node ""
+ $base appendXML $node
+ set result [$base selectNodes "./value\[@n=p_$num\]"]
+ return $result
+}
diff --git a/kratos.gid/apps/MdpaGenerator/app.json b/kratos.gid/apps/MdpaGenerator/app.json
index 59e8d25bb..a233d1e7b 100644
--- a/kratos.gid/apps/MdpaGenerator/app.json
+++ b/kratos.gid/apps/MdpaGenerator/app.json
@@ -22,6 +22,9 @@
"unique_names": {
"parts": "GenericSubmodelPart"
},
+ "write": {
+ "write_mdpa_mode": "geometries"
+ },
"main_launch_file": null,
"description": "MDPA generator \n-Useful tool to generate modelparts"
}
diff --git a/kratos.gid/apps/MdpaGenerator/write/write.tcl b/kratos.gid/apps/MdpaGenerator/write/write.tcl
index 3d50b4348..2fec55d26 100644
--- a/kratos.gid/apps/MdpaGenerator/write/write.tcl
+++ b/kratos.gid/apps/MdpaGenerator/write/write.tcl
@@ -21,6 +21,7 @@ proc ::MdpaGenerator::write::Init { } {
set writeAttributes [dict create ]
SetAttribute parts_un [::MdpaGenerator::GetUniqueName parts]
+ SetAttribute write_mdpa_mode [::MdpaGenerator::GetWriteProperty write_mdpa_mode]
}
# MDPA write event
@@ -80,7 +81,7 @@ proc ::MdpaGenerator::write::writeGeometries { } {
# Write the submodelparts
set what "nodal"
append what "&Geometries"
- # Write conditions (By iterator, so need the app condition iterator)
+
foreach group $lista {
::write::writeGroupSubModelPart "GENERIC" [$group @n] $what
}
diff --git a/kratos.gid/apps/Structural/write/writeProjectParameters.tcl b/kratos.gid/apps/Structural/write/writeProjectParameters.tcl
index d7f7d00f6..a935004af 100644
--- a/kratos.gid/apps/Structural/write/writeProjectParameters.tcl
+++ b/kratos.gid/apps/Structural/write/writeProjectParameters.tcl
@@ -19,13 +19,13 @@ proc ::Structural::write::getOldParametersDict { {stage ""} } {
dict set problemDataDict end_time "1.0"
# Time stepping settings for static
- dict set timeSteppingDict "time_step" $time_step
+ dict set timeSteppingDict time_step $time_step
} {
set time_step_table [write::GetTimeStepIntervals]
# Time stepping settings for dynamic
- dict set timeSteppingDict "time_step_table" $time_step_table
+ dict set timeSteppingDict time_step_table $time_step_table
}
# Add section to document
@@ -256,7 +256,7 @@ proc ::Structural::write::UsingSpecificDofElements { SpecificDof {stage ""} } {
set elements [$root selectNodes $xp1]
set bool false
foreach element_node $elements {
- set elemid [$element_node @v]
+ set elemid [write::getValueByNode $element_node]
set elem [Model::getElement $elemid]
if {[write::isBooleanTrue [$elem getAttribute $SpecificDof]]} {set bool true; break}
}
@@ -270,7 +270,7 @@ proc ::Structural::write::UsingFileInPrestressedMembrane { {stage ""} } {
set elements [$root selectNodes $xp1]
set found false
foreach element_node $elements {
- set elemid [$element_node @v]
+ set elemid [write::getValueByNode $element_node]
if {$elemid eq "PrestressedMembraneElement"} {
set selector [write::getValueByNode [$element_node selectNodes "../value\[@n = 'PROJECTION_TYPE_COMBO'\]"]]
if {$selector eq "file"} {set found true; break}
diff --git a/kratos.gid/apps/Structural/xml/XmlController.tcl b/kratos.gid/apps/Structural/xml/XmlController.tcl
index 10a4b6fbe..f50e92bd9 100644
--- a/kratos.gid/apps/Structural/xml/XmlController.tcl
+++ b/kratos.gid/apps/Structural/xml/XmlController.tcl
@@ -96,7 +96,7 @@ proc ::Structural::xml::ProcCheckNodalConditionStateStructural {domNode args} {
set parts_xpath [spdAux::getRoute $parts_un $domNode]
set elems [$domNode selectNodes "$parts_xpath/condition/group/value\[@n='Element'\]"]
set elemnames [list ]
- foreach elem $elems { lappend elemnames [$elem @v]}
+ foreach elem $elems { lappend elemnames [write::getValueByNode $elem]}
set elemnames [lsort -unique $elemnames]
set solution_type_xpath [spdAux::getRoute STSoluType $domNode]
diff --git a/kratos.gid/kratos.tcl b/kratos.gid/kratos.tcl
index 7f0b9f907..d020b48e6 100644
--- a/kratos.gid/kratos.tcl
+++ b/kratos.gid/kratos.tcl
@@ -209,7 +209,7 @@ proc Kratos::LoadCommonScripts { } {
# Writing common scripts
foreach filename {Writing WriteHeadings WriteMaterials WriteNodes
WriteElements WriteConditions WriteGeometries WriteConditionsByGiDId WriteConditionsByUniqueId
- WriteProjectParameters WriteSubModelPart WriteProcess} {
+ WriteProjectParameters WriteSubModelPart WriteProcess WriteStages} {
uplevel #0 [list source [file join $kratos_private(Path) scripts Writing $filename.tcl]]
}
# Common scripts
@@ -577,10 +577,10 @@ proc Kratos::WriteCalculationFilesEvent { {filename ""} } {
} else {
::GidUtils::SetWarnLine "MDPA and JSON written OK"
}
- set end_time [clock seconds]
- set ttime [expr {$end_time-$ini_time}]
- Kratos::Log "Write calculation files in [Duration $ttime]"
- # W "Write calculation files in [Duration $ttime]"
+ if {[::write::GetConfigurationAttribute time_monitor]} { set endtime [clock seconds]; set ttime [expr {$endtime-$inittime}];
+ W "Nodal coordinates time: [Kratos::Duration $ttime]"
+ Kratos::Log "Write calculation files in [Duration $ttime]"
+ }
return $errcode
}
diff --git a/kratos.gid/scripts/Controllers/TreeInjections.tcl b/kratos.gid/scripts/Controllers/TreeInjections.tcl
index 658c44c29..66f75125c 100644
--- a/kratos.gid/scripts/Controllers/TreeInjections.tcl
+++ b/kratos.gid/scripts/Controllers/TreeInjections.tcl
@@ -223,6 +223,9 @@ proc spdAux::_injectCondsToTree {basenode cond_list {cond_type "normal"} args }
set um [$cnd getAttribute "unit_magnitude"]
set processName [$cnd getProcessName]
+ set icon [$cnd getAttribute "icon"]
+ if {$icon eq ""} {set icon "shells16"}
+
set process [::Model::GetProcess $processName]
if {$process eq ""} {error [= "Condition %s can't find its process: %s" $n $processName]}
set check [$process getAttribute "check"]
@@ -236,7 +239,7 @@ proc spdAux::_injectCondsToTree {basenode cond_list {cond_type "normal"} args }
if {[$cnd getAttribute Groups] ne ""} {
set allow_group_creation "allow_group_creation='0' groups_list='\[[$cnd getAttribute Groups]\]'"
}
- set node ""
+ set node ""
set symbol_data [$cnd getSymbol]
if { [llength $symbol_data] } {
set txt "
diff --git a/kratos.gid/scripts/Writing/WriteGeometries.tcl b/kratos.gid/scripts/Writing/WriteGeometries.tcl
index d9a44a970..c7b4ecbc8 100644
--- a/kratos.gid/scripts/Writing/WriteGeometries.tcl
+++ b/kratos.gid/scripts/Writing/WriteGeometries.tcl
@@ -1,5 +1,5 @@
-proc write::writeGeometryConnectivities { group_list} {
+proc write::writeGeometryConnectivities { group_list } {
# Foreach group in the list
foreach gNode $group_list {
diff --git a/kratos.gid/scripts/Writing/WriteStages.tcl b/kratos.gid/scripts/Writing/WriteStages.tcl
new file mode 100644
index 000000000..4fe5e2bec
--- /dev/null
+++ b/kratos.gid/scripts/Writing/WriteStages.tcl
@@ -0,0 +1,35 @@
+
+# Get the dictionary for the preprocess of the stage
+proc ::write::getPreprocessForStage {stage {mdpaimporter ""}} {
+ set stage_preprocess [dict create ]
+ set operation_parameters [dict create ]
+ dict set stage_preprocess operations [list [dict create name "user_operation.EmptyOperation" Parameters $operation_parameters]]
+
+ if { $mdpaimporter ne "" } {
+ # Get the modeler parameters
+ set modeler [dict create name "KratosMultiphysics.modelers.import_mdpa_modeler.ImportMDPAModeler" Parameters $mdpaimporter]
+ dict set stage_preprocess modelers [list $modeler]
+ }
+
+ return $stage_preprocess
+}
+
+# Get the dictionary for the postprocess of the stage
+proc ::write::getPostprocessForStage {stage} {
+ set stage_postprocess [dict create ]
+ dict set stage_postprocess operations [list [dict create name "user_operation.EmptyOperation" Parameters [dict create ] ]]
+
+ return $stage_postprocess
+}
+
+proc ::write::GetOrchestratorDict { stages_names } {
+
+ set orchestrator_dict [dict create]
+ dict set orchestrator_dict name "MultistageOrchestrators.KratosMultiphysics.SequentialMultistageOrchestrator"
+ dict set orchestrator_dict settings echo_level 0
+ dict set orchestrator_dict settings execution_list $stages_names
+ dict set orchestrator_dict settings stage_checkpoints true
+ dict set orchestrator_dict settings stage_checkpoints_folder new_checkpoints
+ # dict set orchestrator_dict settings load_from_checkpoint "new_checkpoints/fluid_stage"
+ return $orchestrator_dict
+}
diff --git a/kratos.gid/scripts/Writing/WriteSubModelPart.tcl b/kratos.gid/scripts/Writing/WriteSubModelPart.tcl
index f421a8880..e86e2fdcb 100644
--- a/kratos.gid/scripts/Writing/WriteSubModelPart.tcl
+++ b/kratos.gid/scripts/Writing/WriteSubModelPart.tcl
@@ -69,6 +69,53 @@ proc write::writeGroupSubModelPart { cid group {what "Elements"} {iniend ""} {ta
return $mid
}
+#
+proc write::writeGroupSubModelPartAsGeometry { group } {
+ variable submodelparts
+ variable formats_dict
+ variable geometry_cnd_name
+
+ set cid $geometry_cnd_name
+
+ set inittime [clock seconds]
+
+ set id_f [dict get $formats_dict ID]
+ set submodelpart_id ""
+ set group [GetWriteGroupName $group]
+ set submodelpart_id [write::getSubModelPartId "$cid" $group]
+ if {$submodelpart_id eq 0} {
+ # Add the submodelpart to the catalog
+ set submodelpart_id [write::AddSubmodelpart $cid $group]
+ # Prepare the print formats
+ incr ::write::current_mdpa_indent_level
+ set s1 [mdpaIndent]
+ incr ::write::current_mdpa_indent_level -1
+ incr ::write::current_mdpa_indent_level 2
+ set s2 [mdpaIndent]
+ set gdict [dict create]
+ set f "${s2}$id_f\n"
+ set f [subst $f]
+ dict set gdict $group $f
+ incr ::write::current_mdpa_indent_level -2
+
+ # Print header
+ set s [mdpaIndent]
+ WriteString "${s}Begin SubModelPart $submodelpart_id // Group $group"
+ # Print nodes
+ WriteString "${s1}Begin SubModelPartNodes"
+ GiD_WriteCalculationFile nodes -sorted $gdict
+ WriteString "${s1}End SubModelPartNodes"
+ # Print geometries
+ WriteString "${s1}Begin SubModelPartGeometries"
+ GiD_WriteCalculationFile elements -sorted $gdict
+ WriteString "${s1}End SubModelPartGeometries"
+
+ WriteString "${s}End SubModelPart"
+ }
+ if {[GetConfigurationAttribute time_monitor]} {set endtime [clock seconds]; set ttime [expr {$endtime-$inittime}]; W "writeGroupSubModelPart $group time: [Kratos::Duration $ttime]"}
+ return $submodelpart_id
+}
+
proc write::writeBasicSubmodelParts {cond_iter {un "GenericSubmodelPart"}} {
set inittime [clock seconds]
@@ -173,8 +220,12 @@ proc write::GetSubModelPartFromCondition { base_UN condition_id } {
}
proc write::GetSubModelPartName {condid group} {
+ variable geometry_cnd_name
set group_name [write::GetWriteGroupName $group]
set good_name [write::transformGroupName $group_name]
+ if {$condid eq $geometry_cnd_name} {
+ return "${good_name}"
+ }
return "${condid}_${good_name}"
}
@@ -191,6 +242,10 @@ proc write::AddSubmodelpart {condid group} {
proc write::getSubModelPartId {cid group} {
variable submodelparts
+ if { [GetConfigurationAttribute write_mdpa_mode] eq "geometries"} {
+ variable geometry_cnd_name
+ set cid $geometry_cnd_name
+ }
set find [list $cid ${group}]
if {[dict exists $submodelparts $find]} {
return [dict get $submodelparts [list $cid ${group}]]
diff --git a/kratos.gid/scripts/Writing/Writing.tcl b/kratos.gid/scripts/Writing/Writing.tcl
index 3f6d2fdff..938376ca4 100644
--- a/kratos.gid/scripts/Writing/Writing.tcl
+++ b/kratos.gid/scripts/Writing/Writing.tcl
@@ -14,6 +14,7 @@ namespace eval ::write {
variable current_mdpa_indent_level
variable formats_dict
variable properties_exclusion_list
+ variable geometry_cnd_name
}
proc write::Init { } {
@@ -43,6 +44,9 @@ proc write::Init { } {
set formats_dict [dict create]
variable properties_exclusion_list
set properties_exclusion_list [list "MID" "APPID" "ConstitutiveLaw" "Material" "Element"]
+
+ variable geometry_cnd_name
+ set geometry_cnd_name "-GEOMETRY-"
}
proc write::initWriteConfiguration {configuration} {