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

MIGRATION - Write as geometries #985

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
07f7e89
Remove write mode from properties
jginternational Jul 11, 2024
ddb4e8a
Fluid gives no more chances to use old style by preferences
jginternational Jul 11, 2024
e2c64db
Write mdpa as geometries for buoyancy using fluid
jginternational Jul 11, 2024
3df6c3c
Make common code
jginternational Jul 11, 2024
34384e4
call modelers
jginternational Jul 11, 2024
0d75024
Fluid use common modelers func
jginternational Jul 11, 2024
18db6fa
Make common code
jginternational Jul 11, 2024
09743d5
Fluid use common modelers func
jginternational Jul 11, 2024
ca2543c
Enable write as geometries in potential flow app
jginternational Jul 18, 2024
d1ed236
modelers only in geom mode
jginternational Jul 18, 2024
fe05d6a
modelers only in geom mode
jginternational Jul 18, 2024
fbbd618
modelers only in geom mode
jginternational Jul 18, 2024
6c80229
Migrate structural
jginternational Jul 18, 2024
d7e4ad2
embedded working
jginternational Jul 18, 2024
a795465
free surface writes geometries
jginternational Jul 18, 2024
fa7c7c8
Only write geoms if there is at least 1 element
jginternational Jul 18, 2024
86d1b0d
Write compressible fluid as geometries
jginternational Jul 18, 2024
bc94236
Only write geoms if there is at least 1 element
jginternational Jul 18, 2024
6cc00a6
convection diffussion writes as geoms
jginternational Jul 18, 2024
5133366
material 0
jginternational Jul 19, 2024
b99f19b
material 0
jginternational Jul 19, 2024
48997c6
Merge branch 'write-geoms-migration' into compressible-migration-geoms
jginternational Jul 19, 2024
a33f174
Merge branch 'write-geoms-migration' into potential-geom-migration
jginternational Jul 19, 2024
638e092
Merge branch 'write-geoms-migration' into structural-migration-write-…
jginternational Jul 19, 2024
1d25c6b
comment
jginternational Jul 19, 2024
fd63405
comment
jginternational Jul 19, 2024
e3a4233
Merge branch 'write-geoms-migration' into freesurface-migration-geoms
jginternational Jul 19, 2024
ef6396c
Merge branch 'write-geoms-migration' into buoyancy-migration-as-geoms
jginternational Jul 19, 2024
1b22a19
Correct writing process
jginternational Jul 19, 2024
b0e653d
hotfix fluid write
jginternational Jul 19, 2024
6bbecaa
hotfix fluid write
jginternational Jul 19, 2024
f2d7526
Merge branch 'write-geoms-migration' into potential-geom-migration
jginternational Jul 19, 2024
40ed0f0
Merge pull request #986 from KratosMultiphysics/buoyancy-migration-as…
jginternational Jul 26, 2024
8caca1b
Merge pull request #988 from KratosMultiphysics/structural-migration-…
jginternational Jul 26, 2024
d167359
Merge branch 'write-geoms-migration' into convectiondiff-migration-geom
jginternational Jul 26, 2024
b92d409
Merge pull request #992 from KratosMultiphysics/convectiondiff-migrat…
jginternational Jul 26, 2024
a241c08
Merge pull request #991 from KratosMultiphysics/compressible-migratio…
jginternational Jul 26, 2024
9348ea9
Merge pull request #989 from KratosMultiphysics/embedded-migrate-geoms
jginternational Jul 26, 2024
58cffdf
protect
jginternational Jul 26, 2024
1fdc088
No need to write base
jginternational Jul 26, 2024
064636e
migrate shallow water
jginternational Jul 26, 2024
0d1dad9
Merge pull request #995 from KratosMultiphysics/shallowwater-migrate-…
jginternational Oct 9, 2024
4602a1c
Merge pull request #987 from KratosMultiphysics/potential-geom-migration
jginternational Oct 9, 2024
a70930e
Merge branch 'write-geoms-migration' into freesurface-migration-geoms
jginternational Oct 9, 2024
d6b9d9d
replace conditions name
jginternational Oct 10, 2024
ac96d70
reorder filters
jginternational Oct 10, 2024
20c449d
Merge pull request #990 from KratosMultiphysics/freesurface-migration…
jginternational Oct 10, 2024
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
2 changes: 1 addition & 1 deletion kratos.gid/apps/Buoyancy/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"coordinates": "all",
"properties_location": "json",
"model_part_name": "ThermalModelPart",
"write_mdpa_mode": "entities"
"write_mdpa_mode": "geometries"
},
"main_launch_file": "../../exec/MainKratos.py",
"examples": "examples/examples.xml"
Expand Down
48 changes: 15 additions & 33 deletions kratos.gid/apps/Buoyancy/write/write.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ proc ::Buoyancy::write::Init { } {
# Add thermal unique names to Fluid write variables
Fluid::write::SetAttribute thermal_bc_un [ConvectionDiffusion::write::GetAttribute conditions_un]
Fluid::write::SetAttribute thermal_initial_cnd_un [ConvectionDiffusion::write::GetAttribute nodal_conditions_un]

}

# Events
Expand All @@ -18,39 +19,13 @@ proc ::Buoyancy::write::writeModelPartEvent { } {
set err [Validate]
if {$err ne ""} {error $err}

# Start Fluid write variables
Fluid::write::Init
# Fluid has implemented the geometry mode, but we do not use it yet in inherited apps
::Fluid::write::SetAttribute write_mdpa_mode [::Buoyancy::GetWriteProperty write_mdpa_mode]
# Start Fluid write conditions map from scratch
Fluid::write::InitConditionsMap

# Init data
write::initWriteConfiguration [Fluid::write::GetAttributes]

# Headers
write::writeModelPartData
Fluid::write::writeProperties

# Nodal coordinates (1: Print only Fluid nodes <inefficient> | 0: the whole mesh <efficient>)
if {[Fluid::write::GetAttribute writeCoordinatesByGroups] ne "all"} {write::writeNodalCoordinatesOnParts} {write::writeNodalCoordinates}

# Element connectivities (Groups on FLParts)
write::writeElementConnectivities

# Nodal conditions and conditions
Fluid::write::writeConditions

# SubmodelParts
Fluid::write::writeMeshes
write::writeNodalConditions [GetAttribute thermal_initial_cnd_un]
Buoyancy::write::writeSubModelParts
::Fluid::write::Init

::Fluid::write::writeModelPartEvent

# Boussinesq nodes
Buoyancy::write::writeBoussinesqSubModelPart
# Write Boussinesq submodel part as nodals
::Buoyancy::write::writeBoussinesqSubModelPart

# Custom SubmodelParts
#write::writeBasicSubmodelParts [Fluid::write::getLastConditionId]
}

proc ::Buoyancy::write::writeCustomFilesEvent { } {
Expand All @@ -73,7 +48,14 @@ proc ::Buoyancy::write::WriteMaterialsFile {{write_const_law True} {include_mode
# Write Buoyancy materials file
set model_part_name ""
if {[write::isBooleanTrue $include_modelpart_name]} {set model_part_name [GetModelPartName]}
write::writePropertiesJsonFile [GetAttribute parts_un] "BuoyancyMaterials.json" $write_const_law $model_part_name

set mats [write::getPropertiesJson [GetAttribute parts_un] $write_const_law $model_part_name]
# keep only first entry
set clear_mat [dict get $mats properties]
set clear_mat [lindex $clear_mat 0]
dict set clear_mat model_part_name ThermalModelPart
set clear_mat [dict create properties [list $clear_mat]]
write::writePropertiesJsonFileDone "BuoyancyMaterials.json" $clear_mat
}

proc ::Buoyancy::write::writeSubModelParts { } {
Expand All @@ -100,7 +82,7 @@ proc ::Buoyancy::write::writeBoussinesqSubModelPart { } {
set groupid "_Boussinesq_hidden_"
GiD_Groups create $groupid
GiD_EntitiesGroups assign $groupid nodes [GiD_Mesh list node]
::write::writeGroupSubModelPart Boussinesq $groupid "Nodes"
::write::writeGroupSubModelPartAsGeometry $groupid
GiD_Groups delete $groupid
}

Expand Down
15 changes: 11 additions & 4 deletions kratos.gid/apps/Buoyancy/write/writeProjectParameters.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ proc ::Buoyancy::write::getParametersDict { } {
# processes
dict set projectParametersDict processes [Buoyancy::write::GetProcesses_Dict]

# modelers
set projectParametersDict [::write::GetModelersDict $projectParametersDict]

return $projectParametersDict
}

Expand Down Expand Up @@ -78,18 +81,22 @@ proc ::Buoyancy::write::GetSolverSettings_Dict { } {

# Fluid things
write::SetConfigurationAttributes [Fluid::write::GetAttributes]
#Fluid::write::SetAttribute materials_file "BuoyancyMaterials.json"
dict set settings fluid_solver_settings [Fluid::write::getSolverSettingsDict]
dict unset settings fluid_solver_settings model_import_settings
dict set settings fluid_solver_settings model_import_settings input_type "use_input_model_part"

set nDim [expr [string range [write::getValue nDim] 0 0]]
dict set settings fluid_solver_settings domain_size $nDim

# Thermal things
set prev [ConvectionDiffusion::write::GetAttribute materials_file]
ConvectionDiffusion::write::SetAttribute materials_file "BuoyancyMaterials.json"
write::SetConfigurationAttributes [ConvectionDiffusion::write::GetAttributes]
# write::SetConfigurationAttributes [ConvectionDiffusion::write::GetAttributes]
dict set settings thermal_solver_settings [ConvectionDiffusion::write::GetSolverSettingsDict]
ConvectionDiffusion::write::SetAttribute materials_file $prev

dict unset settings thermal_solver_settings model_import_settings
dict set settings thermal_solver_settings model_import_settings input_type "use_input_model_part"

dict set settings thermal_solver_settings problem_domain_sub_model_part_list [list [dict get $settings fluid_solver_settings volume_model_part_name]]

Expand All @@ -101,7 +108,7 @@ proc ::Buoyancy::write::GetProcesses_Dict { } {
write::SetConfigurationAttributes [Fluid::write::GetAttributes]
lappend constraints_process_list {*}[write::getConditionsParametersDict [Fluid::write::GetAttribute conditions_un] ]
lappend constraints_process_list {*}[write::getConditionsParametersDict [Fluid::write::GetAttribute nodal_conditions_un] "Nodal"]
write::SetConfigurationAttributes [ConvectionDiffusion::write::GetAttributes]
# write::SetConfigurationAttributes [ConvectionDiffusion::write::GetAttributes]
lappend constraints_process_list {*}[write::getConditionsParametersDict [ConvectionDiffusion::write::GetAttribute nodal_conditions_un] "Nodal"]
lappend constraints_process_list {*}[write::getConditionsParametersDict [ConvectionDiffusion::write::GetAttribute conditions_un]]
lappend constraints_process_list [GetBoussinesqProcess]
Expand All @@ -123,4 +130,4 @@ proc ::Buoyancy::write::GetBoussinesqProcess { } {
dict set process Parameters $params

return $process
}
}
2 changes: 1 addition & 1 deletion kratos.gid/apps/CompressibleFluid/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"properties_location": "json",
"model_part_name": "FluidModelPart",
"output_model_part_name": "fluid_computational_model_part",
"write_mdpa_mode": "entities"
"write_mdpa_mode": "geometries"
},
"main_launch_file": "python/MainKratos.py",
"examples": "examples/examples.xml",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
proc ::CompressibleFluid::write::writeParametersEvent { } {
set projectParametersDict [Fluid::write::getParametersDict]
set projectParametersDict [::write::GetModelersDict $projectParametersDict]

set shock_capturing_type [dict get $projectParametersDict solver_settings shock_capturing_type]
dict set projectParametersDict solver_settings shock_capturing_settings type $shock_capturing_type
Expand Down
2 changes: 1 addition & 1 deletion kratos.gid/apps/CompressibleFluid/xml/Conditions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
unit_magnitude="M/T/L^2">
<TopologyFeatures>
<item GeometryType="Line" nodes="2" KratosName="WallCondition2D2N"/>
<item GeometryType="Point" nodes="1" KratosName="WallCondition2D1N"/>
<item GeometryType="Point" nodes="1" KratosName="PointCondition3D1N"/>
</TopologyFeatures>
<DegreesOfFreedom></DegreesOfFreedom>
<inputs></inputs>
Expand Down
3 changes: 2 additions & 1 deletion kratos.gid/apps/ConvectionDiffusion/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"materials_file": "ConvectionDiffusionMaterials.json",
"properties_location": "json",
"model_part_name": "ThermalModelPart",
"output_model_part_name": ""
"output_model_part_name": "",
"write_mdpa_mode": "geometries"
},
"main_launch_file": "../../exec/MainKratos.py",
"examples": "examples/examples.xml"
Expand Down
32 changes: 24 additions & 8 deletions kratos.gid/apps/ConvectionDiffusion/write/write.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ proc ::ConvectionDiffusion::write::Init { } {
SetAttribute properties_location [::ConvectionDiffusion::GetWriteProperty properties_location]
SetAttribute model_part_name [::ConvectionDiffusion::GetWriteProperty model_part_name]
SetAttribute output_model_part_name [::ConvectionDiffusion::GetWriteProperty output_model_part_name]
SetAttribute write_mdpa_mode [::ConvectionDiffusion::GetWriteProperty write_mdpa_mode]

}

# Events
Expand All @@ -42,19 +44,33 @@ proc ::ConvectionDiffusion::write::writeModelPartEvent { } {

# Nodal coordinates (1: Print only Fluid nodes <inefficient> | 0: the whole mesh <efficient>)
if {[GetAttribute writeCoordinatesByGroups] ne "all"} {write::writeNodalCoordinatesOnParts} {write::writeNodalCoordinates}

if {[GetAttribute write_mdpa_mode] eq "geometries"} {

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

# Write the geometries
set ret [::write::writeGeometryConnectivities $lista]

foreach group $lista {
write::writeGroupSubModelPartAsGeometry [$group @n]
}

# Element connectivities (Groups on CNVDFFParts)
write::writeElementConnectivities
} else {

# Nodal conditions and conditions
writeConditions
# Element connectivities (Groups on CNVDFFParts)
write::writeElementConnectivities

# Custom SubmodelParts
write::writeBasicSubmodelParts [getLastConditionId]
# Nodal conditions and conditions
writeConditions

# SubmodelParts
writeMeshes
# Custom SubmodelParts
write::writeBasicSubmodelParts [getLastConditionId]

# SubmodelParts
writeMeshes
}
}

proc ::ConvectionDiffusion::write::writeCustomFilesEvent { } {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ proc ::ConvectionDiffusion::write::getParametersDict { } {
dict set restartDict Restart_Step 0
dict set projectParametersDict restart_options $restartDict

# Get the modelers
set projectParametersDict [write::GetModelersDict $projectParametersDict]

return $projectParametersDict
}
Expand Down
2 changes: 1 addition & 1 deletion kratos.gid/apps/EmbeddedFluid/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"coordinates": "all",
"materials_file": "FluidMaterials.json",
"properties_location": "json",
"write_mdpa_mode": "entities"
"write_mdpa_mode": "geometries"
},
"main_launch_file": "../../exec/MainKratos.py",
"examples": "examples/examples.xml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ proc ::EmbeddedFluid::write::getParametersDict { } {
dict set solverSettingsDict distance_reading_settings $dist_settings_dict

dict set param_dict solver_settings $solverSettingsDict

set param_dict [::write::GetModelersDict $param_dict]
return $param_dict
}

Expand Down
19 changes: 6 additions & 13 deletions kratos.gid/apps/Fluid/write/write.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ proc ::Fluid::write::Init { } {
SetAttribute model_part_name [::Fluid::GetWriteProperty model_part_name]
SetAttribute output_model_part_name [::Fluid::GetWriteProperty output_model_part_name]
SetAttribute write_mdpa_mode [::Fluid::GetWriteProperty write_mdpa_mode]
# Only write as geometries if the app says it AND the user allows it
# Note: Fluid will enable it but most of the apps that derive from Fluid are not ready for it
# Also user can disable it by setting the variable experimental_write_geometries to 0 in the preferences window
set write_geometries_enabled 0
if {[info exists Kratos::kratos_private(experimental_write_geometries)] && $Kratos::kratos_private(experimental_write_geometries)>0} {set write_geometries_enabled 1}
if {[GetAttribute write_mdpa_mode] eq "geometries" && $write_geometries_enabled ne 1} {
SetAttribute write_mdpa_mode "entities"
}

variable last_condition_iterator
set last_condition_iterator 0
Expand Down Expand Up @@ -133,11 +125,12 @@ proc Fluid::write::GetMaterialsFile { {write_const_law True} {include_modelpart_
set model_part_name ""
if {[write::isBooleanTrue $include_modelpart_name]} {set model_part_name [GetAttribute model_part_name]}
set parts [write::getPropertiesJson [GetAttribute parts_un] $write_const_law $model_part_name]
set base [dict create model_part_name [GetAttribute model_part_name] properties_id 0 Material null]
set old_list [dict get $parts properties]
set new_list [concat [list $base] $old_list]
set result [dict create properties $new_list]
return $result
# set base [dict create model_part_name [GetAttribute model_part_name] properties_id 0 Material null]
# set old_list [dict get $parts properties]
# set new_list [concat [list $base] $old_list]
# set result [dict create properties $new_list]
# return $result
return $parts
}

proc ::Fluid::write::Validate {} {
Expand Down
27 changes: 1 addition & 26 deletions kratos.gid/apps/Fluid/write/writeProjectParameters.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -92,36 +92,11 @@ proc ::Fluid::write::getParametersMultistageDict { } {
return $project_parameters_dict
}

# Update the modelers information
proc ::Fluid::write::UpdateModelers { projectParametersDict {stage ""} } {
set modelerts_list [list ]
# Move the import to the modelers
# set modelers [dict get $projectParametersDict solver_settings model_import_settings]
dict unset projectParametersDict solver_settings model_import_settings
dict set projectParametersDict solver_settings model_import_settings input_type use_input_model_part
set importer_modeler [dict create name "Modelers.KratosMultiphysics.ImportMDPAModeler"]
dict set importer_modeler "parameters" [dict create input_filename [Kratos::GetModelName] model_part_name [write::GetConfigurationAttribute model_part_name]]
lappend modelerts_list $importer_modeler

if {[GetAttribute write_mdpa_mode] eq "geometries"} {
# Add the entities creation modeler
set entities_modeler [dict create name "Modelers.KratosMultiphysics.CreateEntitiesFromGeometriesModeler"]
dict set entities_modeler "parameters" elements_list [::write::GetMatchSubModelPart element $stage]
dict set entities_modeler "parameters" conditions_list [::write::GetMatchSubModelPart condition $stage]
lappend modelerts_list $entities_modeler
}

dict set projectParametersDict "modelers" $modelerts_list

return $projectParametersDict
}


proc ::Fluid::write::writeParametersEvent { } {
set write_parameters_mode 0
if {$write_parameters_mode == 0} {
set projectParametersDict [getParametersDict]
set projectParametersDict [Fluid::write::UpdateModelers $projectParametersDict]
set projectParametersDict [::write::GetModelersDict $projectParametersDict]
} else {
set projectParametersDict [getParametersMultistageDict]
}
Expand Down
2 changes: 1 addition & 1 deletion kratos.gid/apps/FreeSurface/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"properties_location": "json",
"model_part_name": "FluidModelPart",
"output_model_part_name": "",
"write_mdpa_mode": "entities"
"write_mdpa_mode": "geometries"
},
"main_launch_file": "../../exec/MainKratos.py"
}
Loading