-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #945 from KratosMultiphysics/migrate-geomechanics-…
…to-geometries Advances in Geomechanics write
- Loading branch information
Showing
42 changed files
with
1,003 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ dist | |
|
||
*.zip | ||
*.tgz | ||
null | ||
null | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
kratos.gid/apps/GeoMechanics/controllers/PhreaticLine.tcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
30 changes: 30 additions & 0 deletions
30
kratos.gid/apps/GeoMechanics/controllers/geomechanics_import_plaxis.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Oops, something went wrong.