Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fsi geoms migration #996

Open
wants to merge 17 commits into
base: write-geoms-migration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions kratos.gid/apps/Buoyancy/write/write.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ proc ::Buoyancy::write::writeModelPartEvent { } {
if {$err ne ""} {error $err}

::Fluid::write::Init

set fluid_base_xpath [spdAux::getRoute Buoyancy_FL]
set fluid_base [[customlib::GetBaseRoot] selectNodes $fluid_base_xpath]
set ::Fluid::write::fluid_base $fluid_base

::Fluid::write::writeModelPartEvent

Expand Down
3 changes: 2 additions & 1 deletion kratos.gid/apps/ConjugateHeatTransfer/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"write": {
"coordinates": "groups",
"properties_location": "json",
"model_part_name": "ThermalModelPart"
"model_part_name": "ThermalModelPart",
"write_mdpa_mode": "geometries"
},
"main_launch_file": "../../exec/MainKratos.py",
"examples": "examples/examples.xml"
Expand Down
2 changes: 1 addition & 1 deletion kratos.gid/apps/ConjugateHeatTransfer/examples/BFS.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ proc ::ConjugateHeatTransfer::examples::BFS::TreeAssignation2D {args} {
# Solid parts
set parts [spdAux::getRoute "CNVDFFParts"]
set fluidNode [customlib::AddConditionGroupOnXPath $parts Heating]
set props [list Element EulerianConvDiff$nd DENSITY 0.0 CONDUCTIVITY 10 SPECIFIC_HEAT 0.0]
set props [list Element EulerianConvDiff$nd DENSITY 0.0 CONDUCTIVITY 10.0 SPECIFIC_HEAT 0.0]
spdAux::SetValuesOnBaseNode $fluidNode $props

# Solid thermal initial conditions
Expand Down
20 changes: 18 additions & 2 deletions kratos.gid/apps/ConjugateHeatTransfer/write/write.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace eval ::ConjugateHeatTransfer::write {
variable writeAttributes
variable fluid_domain_solver_settings
variable solid_domain_solver_settings

variable mdpa_files
}

proc ::ConjugateHeatTransfer::write::Init { } {
Expand All @@ -20,6 +22,7 @@ proc ::ConjugateHeatTransfer::write::Init { } {
SetAttribute model_part_name [::ConjugateHeatTransfer::GetWriteProperty model_part_name]

SetAttribute coordinates [::ConjugateHeatTransfer::GetWriteProperty coordinates]
SetAttribute write_mdpa_mode [::ConvectionDiffusion::GetWriteProperty write_mdpa_mode]

SetAttribute fluid_mdpa_suffix Fluid
SetAttribute solid_mdpa_suffix Solid
Expand All @@ -28,10 +31,14 @@ proc ::ConjugateHeatTransfer::write::Init { } {
variable solid_domain_solver_settings
set fluid_domain_solver_settings [dict create]
set solid_domain_solver_settings [dict create]

variable mdpa_files
set mdpa_files []
}

# Events
proc ::ConjugateHeatTransfer::write::writeModelPartEvent { } {
variable mdpa_files
# Validation
set err [Validate]
if {$err ne ""} {error $err}
Expand All @@ -41,13 +48,22 @@ proc ::ConjugateHeatTransfer::write::writeModelPartEvent { } {
# Buoyancy mdpa
::ConjugateHeatTransfer::write::PrepareBuoyancy
write::writeAppMDPA Buoyancy
write::RenameFileInModel "$filename.mdpa" "${filename}_[GetAttribute fluid_mdpa_suffix].mdpa"
set buoyancy_mdpa "${filename}_[GetAttribute fluid_mdpa_suffix]"
write::RenameFileInModel "$filename.mdpa" ${buoyancy_mdpa}.mdpa
lappend mdpa_files $buoyancy_mdpa

# Convection diffusion mdpa
ConvectionDiffusion::write::Init
ConvectionDiffusion::write::SetAttribute writeCoordinatesByGroups [GetAttribute coordinates]

set base_root_xpath [spdAux::getRoute CHTCNVDFF]
set base_root [[customlib::GetBaseRoot] selectNodes $base_root_xpath]
set ::ConvectionDiffusion::write::base_root $base_root

write::writeAppMDPA ConvectionDiffusion
write::RenameFileInModel "$filename.mdpa" "${filename}_[GetAttribute solid_mdpa_suffix].mdpa"
set convdif_mdpa "${filename}_[GetAttribute solid_mdpa_suffix]"
write::RenameFileInModel "$filename.mdpa" ${convdif_mdpa}.mdpa
lappend mdpa_files $convdif_mdpa
}

proc ::ConjugateHeatTransfer::write::writeCustomFilesEvent { } {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ proc ::ConjugateHeatTransfer::write::getParametersDict { } {
# processes
dict set projectParametersDict processes [ConjugateHeatTransfer::write::GetProcessList]

# modelers
set projectParametersDict [::write::GetModelersDict $projectParametersDict]
set projectParametersDict [::ConjugateHeatTransfer::write::PlaceMDPAImports $projectParametersDict]
set projectParametersDict [::ConjugateHeatTransfer::write::ModelersPrefix $projectParametersDict]

dict unset projectParametersDict solver_settings model_import_settings

return $projectParametersDict
}

Expand All @@ -41,16 +48,10 @@ proc ::ConjugateHeatTransfer::write::GetSolverSettingsDict {} {
set filename [Kratos::GetModelName]

# Prepare the solver strategies
# Buoyancy Fluid > model_import_settings -> mdpa fluid
dict set ConjugateHeatTransfer::write::fluid_domain_solver_settings solver_settings fluid_solver_settings model_import_settings input_filename "${filename}_[GetAttribute fluid_mdpa_suffix]"
# Buoyancy Thermic > model_import_settings -> none
dict set ConjugateHeatTransfer::write::fluid_domain_solver_settings solver_settings thermal_solver_settings model_import_settings input_filename "use_input_model_part"
dict unset ConjugateHeatTransfer::write::fluid_domain_solver_settings solver_settings thermal_solver_settings model_import_settings input_type
dict unset ConjugateHeatTransfer::write::fluid_domain_solver_settings model_import_settings
# Buoyancy Thermic > model_part_name
dict set ConjugateHeatTransfer::write::fluid_domain_solver_settings solver_settings thermal_solver_settings model_part_name "FluidThermalModelPart"
# Solid Thermic > Modelpart name -> mdpa solid
dict set ConjugateHeatTransfer::write::solid_domain_solver_settings solver_settings model_import_settings input_filename "${filename}_[GetAttribute solid_mdpa_suffix]"


dict set solver_settings_dict fluid_domain_solver_settings [dict get $ConjugateHeatTransfer::write::fluid_domain_solver_settings solver_settings]
dict set solver_settings_dict solid_domain_solver_settings thermal_solver_settings [dict get $ConjugateHeatTransfer::write::solid_domain_solver_settings solver_settings]

Expand All @@ -67,6 +68,8 @@ proc ::ConjugateHeatTransfer::write::GetSolverSettingsDict {} {
dict set coupling_settings solid_interfaces_list $solid_interfaces_list
dict set solver_settings_dict coupling_settings $coupling_settings

dict unset solver_settings_dict fluid_domain_solver_settings model_import_settings

return $solver_settings_dict
}

Expand Down Expand Up @@ -154,4 +157,63 @@ proc ::ConjugateHeatTransfer::write::InitExternalProjectParameters { } {
set ConjugateHeatTransfer::write::solid_domain_solver_settings [ConvectionDiffusion::write::getParametersDict]

apps::setActiveAppSoft ConjugateHeatTransfer
}

proc ::ConjugateHeatTransfer::write::PlaceMDPAImports { projectParametersDict } {
variable mdpa_files

set new_modelers [list]

set modelers [dict get $projectParametersDict modelers]
# remove the modelers that import the mdpa files (name = Modelers.KratosMultiphysics.ImportMDPAModeler)
set modelers [lsearch -all -inline -not -glob $modelers *ImportMDPAModeler*]
lappend new_modelers [dict create name "Modelers.KratosMultiphysics.ImportMDPAModeler" parameters [dict create input_filename [lindex $mdpa_files 0] model_part_name "FluidModelPart"]]
lappend new_modelers [dict create name "Modelers.KratosMultiphysics.ImportMDPAModeler" parameters [dict create input_filename [lindex $mdpa_files 1] model_part_name "ThermalModelPart"]]
set modelers [concat $new_modelers $modelers]
dict set projectParametersDict modelers $modelers
return $projectParametersDict
}

proc ::ConjugateHeatTransfer::write::ModelersPrefix { projectParametersDict } {
set modelers [dict get $projectParametersDict modelers]
set new_modelers [list]
set thermal_modelparts [dict get $projectParametersDict solver_settings solid_domain_solver_settings thermal_solver_settings processes_sub_model_part_list]
# W "Thermal modelparts: $thermal_modelparts"
foreach modeler $modelers {
set name [dict get $modeler name]
if {[string match "Modelers.KratosMultiphysics.CreateEntitiesFromGeometriesModeler" $name]} {
set new_parameters [dict create]
set new_modeler [dict create name $name parameters [dict create elements_list [dict create] conditions_list [dict create]]]
set new_element_list [list ]
foreach element [dict get $modeler parameters elements_list] {
set model_part_name [dict get $element model_part_name]
set raw_name [lindex [split $model_part_name "."] 1]

if {$raw_name in $thermal_modelparts} {
set new_element $element
} else {
set new_element [dict create model_part_name "FluidModelPart.$raw_name" element_name [dict get $element element_name]]
}
lappend new_element_list $new_element
dict set new_parameters elements_list $new_element_list
}
set new_conditions_list [list ]
foreach condition [dict get $modeler parameters conditions_list] {
set model_part_name [dict get $condition model_part_name]
set raw_name [lindex [split $model_part_name "."] 1]
if {$raw_name in $thermal_modelparts} {
set new_condition $condition
} else {
set new_condition [dict create model_part_name "FluidModelPart.$raw_name" condition_name [dict get $condition condition_name]]
}
lappend new_conditions_list $new_condition
dict set new_parameters conditions_list $new_conditions_list
}
dict set new_modeler parameters $new_parameters
set modeler $new_modeler
}
lappend new_modelers $modeler
}
dict set projectParametersDict modelers $new_modelers
return $projectParametersDict
}
4 changes: 2 additions & 2 deletions kratos.gid/apps/ConjugateHeatTransfer/xml/Main.spd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<container n="Buoyancy" pn="Buoyancy" icon="app" prefix="Buoyancy_" tree_state="open" open_window="0">

<container n="Fluid" pn="Fluid" icon="units" prefix="FL" tree_state="open" open_window="0">
<container n="Fluid" pn="Fluid" icon="units" un="Buoyancy_FL" prefix="FL" tree_state="open" open_window="0">
<include n="AnalysisType" active="1" path="apps/Fluid/xml/AnalysisType.spd"/>
<include n="Parts" active="1" un="FLParts" path="apps/Fluid/xml/Parts.spd"/>
<include n="InitialConditions" active="1" path="apps/Fluid/xml/InitialConditions.spd"/>
Expand All @@ -27,7 +27,7 @@

</container>

<container n="ConvectionDiffusion" pn="Convection-diffusion" icon="heat" prefix="CNVDFF" tree_state="open" open_window="0">
<container n="ConvectionDiffusion" pn="Convection-diffusion" icon="heat" un="CHTCNVDFF" prefix="CNVDFF" tree_state="open" open_window="0">
<include n="StageInfo" active="1" path="apps/ConvectionDiffusion/xml/StageInfo.spd"/>
<include n="Parts" active="1" path="apps/ConvectionDiffusion/xml/Parts.spd"/>
<include n="Intervals" active="1" path="apps/Common/xml/Intervals.spd"/>
Expand Down
7 changes: 6 additions & 1 deletion kratos.gid/apps/ConvectionDiffusion/write/write.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace eval ::ConvectionDiffusion::write {
variable ConvectionDiffusionConditions
variable writeCoordinatesByGroups
variable writeAttributes
variable base_root
}

proc ::ConvectionDiffusion::write::Init { } {
Expand All @@ -27,10 +28,14 @@ proc ::ConvectionDiffusion::write::Init { } {
SetAttribute output_model_part_name [::ConvectionDiffusion::GetWriteProperty output_model_part_name]
SetAttribute write_mdpa_mode [::ConvectionDiffusion::GetWriteProperty write_mdpa_mode]


variable base_root
set base_root [customlib::GetBaseRoot]
}

# Events
proc ::ConvectionDiffusion::write::writeModelPartEvent { } {
variable base_root
# Validation
set err [Validate]
if {$err ne ""} {error $err}
Expand All @@ -48,7 +53,7 @@ proc ::ConvectionDiffusion::write::writeModelPartEvent { } {
if {[GetAttribute write_mdpa_mode] eq "geometries"} {

# Get the list of groups in the spd
set lista [::spdAux::GetListOfSubModelParts]
set lista [::spdAux::GetListOfSubModelParts $base_root]

# Write the geometries
set ret [::write::writeGeometryConnectivities $lista]
Expand Down
2 changes: 1 addition & 1 deletion kratos.gid/apps/FSI/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"properties_location": "json",
"model_part_name": "Structure",
"enable_dynamic_substepping": false,
"write_mdpa_mode": "entities"
"write_mdpa_mode": "geometries"
},
"main_launch_file": "../../exec/MainKratos.py",
"examples": "examples/examples.xml"
Expand Down
6 changes: 6 additions & 0 deletions kratos.gid/apps/FSI/write/write.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ proc ::FSI::write::writeModelPartEvent { } {
::Fluid::write::SetAttribute write_mdpa_mode [::FSI::GetWriteProperty write_mdpa_mode]
Fluid::write::InitConditionsMap
Fluid::write::SetCoordinatesByGroups 1
set base_root_xpath [spdAux::getRoute FSIFluid]
set base_root [[customlib::GetBaseRoot] selectNodes $base_root_xpath]
set ::Fluid::write::base_root $base_root
write::writeAppMDPA Fluid
dict set mdpa_names Fluid "${filename}_Fluid"
write::RenameFileInModel "$filename.mdpa" "[dict get $mdpa_names Fluid].mdpa"

Structural::write::Init
Structural::write::SetCoordinatesByGroups 1
set base_root_xpath [spdAux::getRoute FSIStructural]
set base_root [[customlib::GetBaseRoot] selectNodes $base_root_xpath]
set ::Structural::write::base_root $base_root
write::writeAppMDPA Structural
dict set mdpa_names Structural "${filename}_Structural"
write::RenameFileInModel "$filename.mdpa" "[dict get $mdpa_names Structural].mdpa"
Expand Down
75 changes: 73 additions & 2 deletions kratos.gid/apps/FSI/write/writeProjectParameters.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ proc ::FSI::write::getParametersDict { } {
set output_processes [GetOutputProcessesDict]
dict set projectParametersDict output_processes $output_processes

set projectParametersDict [::write::GetModelersDict $projectParametersDict]
set projectParametersDict [PlaceMDPAImports $projectParametersDict]
set projectParametersDict [ModelersPrefix $projectParametersDict]

return $projectParametersDict
}

Expand Down Expand Up @@ -90,8 +94,10 @@ proc ::FSI::write::GetSolverSettingsDict { } {
dict set solver_settings_dict coupling_settings fluid_interfaces_list $fluid_interfaces_list

# Change the input_filenames
dict set solver_settings_dict structure_solver_settings model_import_settings input_filename [dict get $mdpa_names Structural]
dict set solver_settings_dict fluid_solver_settings model_import_settings input_filename [dict get $mdpa_names Fluid]
dict unset solver_settings_dict structure_solver_settings model_import_settings
dict set solver_settings_dict structure_solver_settings model_import_settings input_type use_input_model_part
dict unset solver_settings_dict fluid_solver_settings model_import_settings
dict set solver_settings_dict fluid_solver_settings model_import_settings input_type use_input_model_part

# Overwrite structural timestep with fluid timestep
dict set solver_settings_dict structure_solver_settings time_stepping [dict get $solver_settings_dict fluid_solver_settings time_stepping]
Expand Down Expand Up @@ -188,4 +194,69 @@ proc ::FSI::write::InitExternalProjectParameters { } {
set FSI::write::structure_project_parameters [Structural::write::getParametersDict]

apps::setActiveAppSoft FSI
}


proc ::FSI::write::PlaceMDPAImports { projectParametersDict } {
variable mdpa_names

set new_modelers [list]

set modelers [dict get $projectParametersDict modelers]
# remove the modelers that import the mdpa files (name = Modelers.KratosMultiphysics.ImportMDPAModeler)
set modelers [lsearch -all -inline -not -glob $modelers *ImportMDPAModeler*]
lappend new_modelers [dict create name "Modelers.KratosMultiphysics.ImportMDPAModeler" parameters [dict create input_filename [dict get $mdpa_names Fluid] model_part_name "FluidModelPart"]]
lappend new_modelers [dict create name "Modelers.KratosMultiphysics.ImportMDPAModeler" parameters [dict create input_filename [dict get $mdpa_names Structural] model_part_name "Structure"]]
set modelers [concat $new_modelers $modelers]
dict set projectParametersDict modelers $modelers
return $projectParametersDict
}

proc ::FSI::write::ModelersPrefix { projectParametersDict } {

set modelers [dict get $projectParametersDict modelers]
set new_modelers [list]
set fluid_modelparts [dict get $projectParametersDict solver_settings fluid_solver_settings skin_parts]
set more_fluid_modelparts [dict get $projectParametersDict solver_settings fluid_solver_settings no_skin_parts]
set fluid_volume [dict get $projectParametersDict solver_settings fluid_solver_settings volume_model_part_name]
set fluid_modelparts [concat $fluid_modelparts $more_fluid_modelparts]
lappend fluid_modelparts $fluid_volume
# W "Thermal modelparts: $thermal_modelparts"
foreach modeler $modelers {
set name [dict get $modeler name]
if {[string match "Modelers.KratosMultiphysics.CreateEntitiesFromGeometriesModeler" $name]} {
set new_parameters [dict create]
set new_modeler [dict create name $name parameters [dict create elements_list [dict create] conditions_list [dict create]]]
set new_element_list [list ]
foreach element [dict get $modeler parameters elements_list] {
set model_part_name [dict get $element model_part_name]
set raw_name [lindex [split $model_part_name "."] 1]

if {$raw_name in $fluid_modelparts} {
set new_element [dict create model_part_name "FluidModelPart.$raw_name" element_name [dict get $element element_name]]
} else {
set new_element $element
}
lappend new_element_list $new_element
dict set new_parameters elements_list $new_element_list
}
set new_conditions_list [list ]
foreach condition [dict get $modeler parameters conditions_list] {
set model_part_name [dict get $condition model_part_name]
set raw_name [lindex [split $model_part_name "."] 1]
if {$raw_name in $fluid_modelparts} {
set new_condition [dict create model_part_name "FluidModelPart.$raw_name" condition_name [dict get $condition condition_name]]
} else {
set new_condition $condition
}
lappend new_conditions_list $new_condition
dict set new_parameters conditions_list $new_conditions_list
}
dict set new_modeler parameters $new_parameters
set modeler $new_modeler
}
lappend new_modelers $modeler
}
dict set projectParametersDict modelers $new_modelers
return $projectParametersDict
}
4 changes: 2 additions & 2 deletions kratos.gid/apps/FSI/xml/Main.spd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<container n="FSI" pn="FSI" icon="app" prefix="FSI" tree_state="open" open_window="0">

<container n="Fluid" pn="Fluid" icon="units" prefix="FL" tree_state="open" open_window="0">
<container n="Fluid" pn="Fluid" icon="units" un="FSIFluid" prefix="FL" tree_state="open" open_window="0">
<include n="AnalysisType" active="1" path="apps/Fluid/xml/AnalysisType.spd"/>
<include n="Parts" active="1" path="apps/Fluid/xml/Parts.spd"/>
<include n="InitialConditions" active="1" path="apps/Fluid/xml/InitialConditions.spd"/>
Expand All @@ -12,7 +12,7 @@
<include n="Materials" active="1" path="apps/Fluid/xml/Materials.spd"/>
</container>

<container n="Structural" pn="Structure" icon="app" prefix="ST" tree_state="open" open_window="0">
<container n="Structural" pn="Structure" icon="app" un="FSIStructural" prefix="ST" tree_state="open" open_window="0">
<include n="StageInfo" active="1" path="apps/Structural/xml/StageInfo.spd"/>
<include n="Parts" active="1" path="apps/Structural/xml/Parts.spd"/>
<include n="BoundaryConditions" active="1" path="apps/Structural/xml/BoundaryConditions.spd"/>
Expand Down
Loading