diff --git a/kratos.gid/apps/PfemLauncher/app.json b/kratos.gid/apps/PfemLauncher/app.json
index d3c66d509..5ffd2c86a 100644
--- a/kratos.gid/apps/PfemLauncher/app.json
+++ b/kratos.gid/apps/PfemLauncher/app.json
@@ -6,7 +6,7 @@
],
"start_script":"::PfemLauncher::Init",
"requirements":{
- "display_apps":["PfemFluid", "DEMPFEM", "PfemThermic", "PfemMelting"],
+ "display_apps":["PfemFluid", "DEMPFEM", "PfemThermic", "PfemMelting", "PfemSw"],
"minimum_gid_version":"15.1.3d"
},
"permissions": {
diff --git a/kratos.gid/apps/PfemSw/app.json b/kratos.gid/apps/PfemSw/app.json
new file mode 100644
index 000000000..fdd7cbd95
--- /dev/null
+++ b/kratos.gid/apps/PfemSw/app.json
@@ -0,0 +1,50 @@
+{
+ "id": "PfemSw",
+ "name": "Pfem SW Coupling",
+ "prefix": "PfemSw_",
+ "themed": false,
+ "kratos_name": "PfemShallowWaterApplication",
+ "python_packages": [
+ "KratosPfemFluidDynamicsApplication",
+ "KratosShallowWaterApplication",
+ "KratosMappingApplication"
+ ],
+ "dimensions": [
+ "2D"
+ ],
+ "script_files": [
+ "start.tcl",
+ "xml/XmlController.tcl",
+ "write/write.tcl",
+ "write/writeProjectParameters.tcl"
+ ],
+ "start_script": "::PfemSw::Init",
+ "requirements":{
+ "apps":["ShallowWater", "PfemFluid"],
+ "minimum_gid_version": "15.1.3d"
+ },
+ "permissions": {
+ "open_tree": true,
+ "show_toolbar": true,
+ "intervals": true,
+ "wizard": false
+ },
+ "unique_names": {
+ // "parts": "STParts",
+ // "initial_conditions": "STInitialConditions",
+ // "nodal_conditions": "STNodalConditions",
+ // "conditions": "STLoads",
+ // "time_parameters": "STTimeParameters",
+ // "results": "STResults",
+ // "materials": "STMaterials"
+ },
+ "write": {
+ "coordinates": "all",
+ "materials_file": "StructuralMaterials.json",
+ "properties_location": "json",
+ "model_part_name": "Structure",
+ "enable_dynamic_substepping": false
+ },
+ "main_launch_file": "../../exec/MainKratos.py",
+ "examples": "examples/examples.xml"
+}
diff --git a/kratos.gid/apps/PfemSw/images/coupling.png b/kratos.gid/apps/PfemSw/images/coupling.png
new file mode 100644
index 000000000..628d643f7
Binary files /dev/null and b/kratos.gid/apps/PfemSw/images/coupling.png differ
diff --git a/kratos.gid/apps/PfemSw/images/logo.png b/kratos.gid/apps/PfemSw/images/logo.png
new file mode 100644
index 000000000..d4c65fe21
Binary files /dev/null and b/kratos.gid/apps/PfemSw/images/logo.png differ
diff --git a/kratos.gid/apps/PfemSw/start.tcl b/kratos.gid/apps/PfemSw/start.tcl
new file mode 100644
index 000000000..c89260dd7
--- /dev/null
+++ b/kratos.gid/apps/PfemSw/start.tcl
@@ -0,0 +1,23 @@
+namespace eval ::PfemSw {
+ Kratos::AddNamespace [namespace current]
+
+ # Variable declaration
+ variable dir
+ variable _app
+
+ 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]}
+}
+
+proc ::PfemSw::Init { app } {
+ # Variable initialization
+ variable dir
+ variable _app
+
+ set _app $app
+ set dir [apps::getMyDir "PfemSw"]
+
+ ::PfemSw::xml::Init
+ ::PfemSw::write::Init
+}
diff --git a/kratos.gid/apps/PfemSw/write/write.tcl b/kratos.gid/apps/PfemSw/write/write.tcl
new file mode 100644
index 000000000..91c46f187
--- /dev/null
+++ b/kratos.gid/apps/PfemSw/write/write.tcl
@@ -0,0 +1,39 @@
+namespace eval ::PfemSw::write {
+ namespace path ::PfemSw
+ Kratos::AddNamespace [namespace current]
+
+ variable pfem_project_parameters
+ variable sw_project_parameters
+ variable mdpa_names
+}
+
+proc ::PfemSw::write::Init { } {
+ variable pfem_project_parameters
+ variable sw_project_parameters
+ set pfem_project_parameters [dict create ]
+ set sw_project_parameters [dict create ]
+
+ variable mdpa_names
+ set mdpa_names [dict create ]
+}
+
+# Events
+proc ::PfemSw::write::writeModelPartEvent { } {
+ variable mdpa_names
+ set filename [Kratos::GetModelName]
+
+ # check folder exists
+
+ PfemFluid::write::Init
+ PfemFluid::write::InitConditionsMap
+ PfemFluid::write::SetCoordinatesByGroups 1
+ write::writeAppMDPA PfemFluid
+ dict set mdpa_names PfemFluid "${filename}_PFEM"
+ write::RenameFileInModel "$filename.mdpa" "pfem/[dict get $mdpa_names PfemFluid].mdpa"
+
+ ShallowWater::write::Init
+ ShallowWater::write::SetCoordinatesByGroups 1
+ write::writeAppMDPA ShallowWater
+ dict set mdpa_names ShallowWater "${filename}_SW"
+ write::RenameFileInModel "$filename.mdpa" "sw/[dict get $mdpa_names ShallowWater].mdpa"
+}
diff --git a/kratos.gid/apps/PfemSw/write/writeProjectParameters.tcl b/kratos.gid/apps/PfemSw/write/writeProjectParameters.tcl
new file mode 100644
index 000000000..56dff0dfb
--- /dev/null
+++ b/kratos.gid/apps/PfemSw/write/writeProjectParameters.tcl
@@ -0,0 +1,47 @@
+# Project Parameters
+proc ::PfemSw::write::getParametersDict { } {
+ set projectParametersDict [dict create]
+
+ return $projectParametersDict
+}
+
+proc ::PfemSw::write::writeParametersEvent { } {
+ set projectParametersDict [getParametersDict]
+ InitExternalProjectParameters
+ write::WriteJSON $PfemSw::write::pfem_project_parameters
+ write::WriteJSON $PfemSw::write::sw_project_parameters
+}
+
+proc ::PfemSw::write::GetProcessesDict { } {
+ set processes_dict [dict create]
+
+ return $processes_dict
+}
+
+proc ::PfemSw::write::GetOutputProcessesDict { } {
+ set output_processes_dict [dict create]
+
+ return $output_processes_dict
+}
+
+proc ::PfemSw::write::UpdateUniqueNames { appid } {
+ set unList [list "Results"]
+ foreach un $unList {
+ set current_un [apps::getAppUniqueName $appid $un]
+ spdAux::setRoute $un [spdAux::getRoute $current_un]
+ }
+}
+
+proc ::PfemSw::write::InitExternalProjectParameters { } {
+ # Pfem Fluid section
+ UpdateUniqueNames PfemFluid
+ apps::setActiveAppSoft PfemFluid
+ set PfemSw::write::pfem_project_parameters [PfemFluid::write::getParametersDict]
+
+ # Shallow water section
+ UpdateUniqueNames ShallowWater
+ apps::setActiveAppSoft ShallowWater
+ set PfemSw::write::sw_project_parameters [ShallowWater::write::getParametersDict]
+
+ apps::setActiveAppSoft PfemSw
+}
\ No newline at end of file
diff --git a/kratos.gid/apps/PfemSw/xml/CouplingConditions.xml b/kratos.gid/apps/PfemSw/xml/CouplingConditions.xml
new file mode 100644
index 000000000..4da1d58a9
--- /dev/null
+++ b/kratos.gid/apps/PfemSw/xml/CouplingConditions.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/kratos.gid/apps/PfemSw/xml/Main.spd b/kratos.gid/apps/PfemSw/xml/Main.spd
new file mode 100644
index 000000000..cd2c15104
--- /dev/null
+++ b/kratos.gid/apps/PfemSw/xml/Main.spd
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/kratos.gid/apps/PfemSw/xml/PfemCouplingConditions.spd b/kratos.gid/apps/PfemSw/xml/PfemCouplingConditions.spd
new file mode 100644
index 000000000..3ffb98786
--- /dev/null
+++ b/kratos.gid/apps/PfemSw/xml/PfemCouplingConditions.spd
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/kratos.gid/apps/PfemSw/xml/Processes.xml b/kratos.gid/apps/PfemSw/xml/Processes.xml
new file mode 100644
index 000000000..7d6046311
--- /dev/null
+++ b/kratos.gid/apps/PfemSw/xml/Processes.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/kratos.gid/apps/PfemSw/xml/Procs.spd b/kratos.gid/apps/PfemSw/xml/Procs.spd
new file mode 100644
index 000000000..96d7cf417
--- /dev/null
+++ b/kratos.gid/apps/PfemSw/xml/Procs.spd
@@ -0,0 +1,8 @@
+
+
+
+
+
+
diff --git a/kratos.gid/apps/PfemSw/xml/SwCouplingConditions.spd b/kratos.gid/apps/PfemSw/xml/SwCouplingConditions.spd
new file mode 100644
index 000000000..f70b848e1
--- /dev/null
+++ b/kratos.gid/apps/PfemSw/xml/SwCouplingConditions.spd
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/kratos.gid/apps/PfemSw/xml/XmlController.tcl b/kratos.gid/apps/PfemSw/xml/XmlController.tcl
new file mode 100644
index 000000000..df3be5b63
--- /dev/null
+++ b/kratos.gid/apps/PfemSw/xml/XmlController.tcl
@@ -0,0 +1,65 @@
+namespace eval ::PfemSw::xml {
+ namespace path ::PfemSw
+ Kratos::AddNamespace [namespace current]
+
+ # Namespace variables declaration
+ variable dir
+}
+
+proc ::PfemSw::xml::Init { } {
+ # Namespace variables initialization
+ variable dir
+ Model::InitVariables dir $::PfemSw::dir
+
+ Model::getConditions CouplingConditions.xml
+ Model::getProcesses Processes.xml
+
+ # Model::ForgetSolutionStrategies
+ # Model::getSolutionStrategies "../../Fluid/xml/Strategies.xml"
+ # Model::getSolutionStrategies "../../Structural/xml/Strategies.xml"
+ # Model::ForgetSolutionStrategy Eigen
+ # Model::getSolutionStrategies Strategies.xml
+ # Model::getConditions Conditions.xml
+
+ # Model::ForgetSolvers
+ # Model::getSolvers "../../Common/xml/Solvers.xml"
+ # Model::getSolvers "../../Structural/xml/Solvers.xml"
+ # Model::getSolvers Coupling_solvers.xml
+}
+
+proc ::PfemSw::xml::getUniqueName {name} {
+ return [::PfemSw::GetAttribute prefix]${name}
+}
+
+proc ::PfemSw::xml::MultiAppEvent {args} {
+ if {$args eq "init"} {
+ catch {::Structural::xml::MultiAppEvent init}
+ }
+}
+
+
+proc ::PfemSw::xml::CustomTree { args } {
+ PfemSw::write::UpdateUniqueNames PfemFluid
+ apps::setActiveAppSoft PfemFluid
+ PfemFluid::xml::CustomTree
+
+ PfemSw::write::UpdateUniqueNames SW
+ apps::setActiveAppSoft ShallowWater
+ ShallowWater::xml::CustomTree
+
+ PfemSw::write::UpdateUniqueNames PfemSw
+ apps::setActiveAppSoft PfemSw
+
+
+
+ # remove Nodal results from PFEM Fluid Data / Results / Nodal Results
+ set pfem_base_root [[customlib::GetBaseRoot] selectNodes "//container\[@n = 'PfemFluid'\]"]
+ set pfem_nodal_results_node [$pfem_base_root selectNodes "//container\[@un = 'NodalResults'\]"]
+
+ set pfem_nodal_results_delete_list [list "InitialWaterLevel" "InitialPerturbation" "Topography" "MOMENTUM" "FREE_SURFACE_ELEVATION" "INLET" "ANGULAR_VELOCITY"]
+ foreach name $pfem_nodal_results_delete_list {
+ set result_node [$pfem_nodal_results_node selectNodes "./value\[@n = '$name'\]"]
+ if {$result_node ne "" } {$result_node setAttribute "state" "hidden"}
+ if {$result_node ne "" } {$result_node setAttribute "v" "No"}
+ }
+}
diff --git a/kratos.gid/kratos_default.spd b/kratos.gid/kratos_default.spd
index a421d1f61..cfcfdaff7 100644
--- a/kratos.gid/kratos_default.spd
+++ b/kratos.gid/kratos_default.spd
@@ -23,6 +23,7 @@
+