Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c817d8f
first steps
jginternational Jul 6, 2023
a8a985f
Merge branch 'master' into migrate-geomechanics-to-geometries
jginternational Jul 6, 2023
9ddec4c
identify submodelparts with conditions
jginternational Jul 6, 2023
a325267
write geometries submodelpart
jginternational Jul 6, 2023
27251f6
write mdpa by geometries splitted by stage
jginternational Jul 6, 2023
8a7537f
json knows if mdpa is multi file
jginternational Jul 6, 2023
2cacc92
Create example with geometry
jginternational Jul 7, 2023
e0a61d4
Create example groups
jginternational Jul 7, 2023
916c1bf
Enable the creation of new stage (clone last)
jginternational Jul 7, 2023
9ba3412
Prepare example for multi stage
jginternational Jul 7, 2023
dc946f2
orquestrator
jginternational Jul 7, 2023
32efde3
prepare json
jginternational Jul 7, 2023
6cf058d
Add body stage 1
jginternational Jul 10, 2023
6582b86
Add displacement fix
jginternational Jul 10, 2023
8521039
Getvalue must replace all @v
jginternational Jul 10, 2023
a458644
Add side sliders and gravity
jginternational Jul 10, 2023
8b58fac
add pressure
jginternational Jul 10, 2023
36f910d
add excavation
jginternational Jul 11, 2023
bdf5399
Remove initial conditions
jginternational Jul 11, 2023
67a02c0
add public name to element types
jginternational Jul 11, 2023
59f7b8f
use pelementype
jginternational Jul 11, 2023
f321011
Removed formfinding and eigenvalue analysis
avdg81 Jul 11, 2023
ec35c6c
Added a section for water conditions
avdg81 Jul 11, 2023
fcfabdb
drop
jginternational Jul 11, 2023
b4f3f2a
allow icons in conditions
jginternational Jul 11, 2023
242441c
Add phreatic level controller
jginternational Jul 12, 2023
6b3d210
Change logo of GeoMechanics application
Jul 13, 2023
c434bd1
Move phreatic to a new file
jginternational Jul 13, 2023
67be7e7
Improved way to get the element ID when writing (by Javi)
avdg81 Jul 13, 2023
a1b30b8
GeoMechanics now has its own `MainKratos.py` script
avdg81 Jul 13, 2023
62708a1
append the phreatic water process
jginternational Jul 13, 2023
c2ac562
Merge branch 'migrate-geomechanics-to-geometries' of github.com:Krato…
jginternational Jul 13, 2023
8cc6bac
write the coordinates in 3d
jginternational Jul 13, 2023
7b0f874
geometries in process are better this way
jginternational Jul 13, 2023
319ec50
remove comment
jginternational Jul 13, 2023
434c929
set settings for write
jginternational Jul 13, 2023
dc9fc47
Added dummy nodal condition for GeoMechanics
avdg81 Jul 13, 2023
dbb693b
Add empty python script to import Plaxis models
Jul 13, 2023
a617273
preprocess and postprocess in Geomechanics
jginternational Jul 13, 2023
deedb92
example geo - move stage creation to last
jginternational Jul 13, 2023
294bb0f
remove quotes
jginternational Jul 13, 2023
c018ff2
First stage active for example
jginternational Jul 13, 2023
ea0b27a
Delete phreatic lines and allow only 2 points
jginternational Jul 13, 2023
291233d
Change active stage during display water
jginternational Jul 13, 2023
f8e5b4d
Move parallel configuration to common
jginternational Jul 13, 2023
635d0b7
Merge branch 'migrate-geomechanics-to-geometries' of github.com:Krato…
jginternational Jul 13, 2023
9d9be4c
add splash window template
jginternational Jul 24, 2023
ed710a4
Merge branch 'master' into migrate-geomechanics-to-geometries
jginternational Aug 16, 2023
10ddf35
add pycache to gitignore
jginternational Aug 16, 2023
f483c09
Safety on directory read
jginternational Aug 16, 2023
52b0654
Merge branch 'master' into migrate-geomechanics-to-geometries
jginternational Aug 26, 2023
b5a72c5
Model part importer
jginternational Sep 15, 2023
a3f5ab3
import stages files
jginternational Sep 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ dist

*.zip
*.tgz
null
null
__pycache__
8 changes: 4 additions & 4 deletions kratos.gid/apps/Common/xml/Parallelism.spd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<container n="ParallelType" pn="Parallel configuration" un="Parallelization" help="Parallel type" icon="parallel" open_window="1">
<value n="ParallelSolutionType" pn="Parallelization" un="ParallelType" v="OpenMP" values="OpenMP,MPI" help="Parallelization type" actualize="1" />
<value n="MPINumberOfProcessors" pn="Number of nodes" v="1" help="Number of processors" state="[checkStateByUniqueName ParallelType MPI]"/>
<value n="OpenMPNumberOfThreads" pn="Number of processors" v="1" help="Number of threads" state="[checkStateByUniqueName ParallelType OpenMP]"/>
</container>
<value n="ParallelSolutionType" pn="Parallelization" un="ParallelType" v="OpenMP" values="OpenMP,MPI" help="Parallelization type" actualize="1" />
<value n="MPINumberOfProcessors" pn="Number of nodes" v="1" help="Number of processors" state="[getStateFromXPathValue {string(../value[@n='ParallelSolutionType']/@v)} MPI]"/>
<value n="OpenMPNumberOfThreads" pn="Number of processors" v="1" help="Number of threads" state="[getStateFromXPathValue {string(../value[@n='ParallelSolutionType']/@v)} OpenMP]"/>
</container>
1 change: 1 addition & 0 deletions kratos.gid/apps/Examples/xml/examples.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
<link path="apps/PfemThermic/examples/examples.xml"/>
<link path="apps/ShallowWater/examples/examples.xml"/>
<link path="apps/FreeSurface/examples/examples.xml"/>
<link path="apps/GeoMechanics/examples/examples.xml"/>
</examples>
45 changes: 45 additions & 0 deletions kratos.gid/apps/GeoMechanics/MainKratos.py
Original file line number Diff line number Diff line change
@@ -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()
16 changes: 10 additions & 6 deletions kratos.gid/apps/GeoMechanics/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": ""
}
}
139 changes: 139 additions & 0 deletions kratos.gid/apps/GeoMechanics/controllers/PhreaticLine.tcl
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 10 additions & 0 deletions kratos.gid/apps/GeoMechanics/controllers/Python.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
26 changes: 26 additions & 0 deletions kratos.gid/apps/GeoMechanics/controllers/SplashWindow.tcl
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"
Loading