Skip to content

Commit 5559dff

Browse files
Merge pull request #157 from KratosMultiphysics/feature-solid-develop
Solid and Pfem developments
2 parents 67c79f3 + c19afe9 commit 5559dff

34 files changed

+1683
-475
lines changed

kratos.gid/apps/Pfem/images/logo.png

10.2 KB
Loading
14 Bytes
Loading
273 Bytes
Loading

kratos.gid/apps/Pfem/python/script.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def GetParallelSize():
8484
# Defining the model_part
8585
main_model_part = KratosMultiphysics.ModelPart(ProjectParameters["problem_data"]["model_part_name"].GetString())
8686

87-
main_model_part.ProcessInfo.SetValue(KratosMultiphysics.DOMAIN_SIZE, ProjectParameters["problem_data"]["domain_size"].GetInt())
87+
main_model_part.ProcessInfo.SetValue(KratosMultiphysics.DIMENSION, ProjectParameters["problem_data"]["dimension"].GetInt())
88+
main_model_part.ProcessInfo.SetValue(KratosMultiphysics.DOMAIN_SIZE, ProjectParameters["problem_data"]["dimension"].GetInt())
8889
main_model_part.ProcessInfo.SetValue(KratosMultiphysics.DELTA_TIME, ProjectParameters["problem_data"]["time_step"].GetDouble())
8990
main_model_part.ProcessInfo.SetValue(KratosMultiphysics.TIME, ProjectParameters["problem_data"]["start_time"].GetDouble())
9091
if( ProjectParameters["problem_data"].Has("gravity_vector") ):

kratos.gid/apps/Pfem/write/ProjectParameters.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"problem_data" : {
33
"problem_name" : "problem_name",
44
"model_part_name" : "Main Model",
5-
"domain_size" : 3,
5+
"dimension" : 3,
66
"time_step" : 0.001,
77
"start_time" : 0.0,
88
"end_time" : 0.002,
@@ -58,7 +58,6 @@
5858
"meshing_domains" : [
5959
{
6060
"python_module": "meshing_domain",
61-
"mesh_id": 1,
6261
"model_part_name": "body_1",
6362
"alpha_shape": 2.4,
6463
"offset_factor": 0.0,
@@ -136,7 +135,6 @@
136135
"parametric_walls" : [
137136
{
138137
"python_module": "parametric_wall",
139-
"mesh_id": 0,
140138
"model_part_name" : "model_part_name",
141139
"rigid_body_settings":{
142140
"rigid_body_element_type": "TranslatoryRigidElement3D1N",
@@ -227,7 +225,6 @@
227225
"help" : "This process applies contact domain search by remeshing outer boundaries",
228226
"process_name" : "ContactDomainProcess",
229227
"Parameters" : {
230-
"mesh_id" : 0,
231228
"model_part_name" : "model_part_name",
232229
"meshing_control_type" : "step",
233230
"meshing_frequency" : 1.0,
@@ -269,7 +266,6 @@
269266
"help" : "This process imposes a constraint",
270267
"process_name" : "AssignValueToVectorComponentsProcess",
271268
"Parameters" : {
272-
"mesh_id" : 0,
273269
"model_part_name" : "DISPLACEMENT_Displacement_Auto1",
274270
"variable_name" : "DISPLACEMENT",
275271
"interval" : [0.0, 100],
@@ -284,7 +280,6 @@
284280
"help" : "This process assigns a load value on conditions",
285281
"process_name" : "AssignVectorToConditionsProcess",
286282
"Parameters" : {
287-
"mesh_id" : 0,
288283
"model_part_name" : "load_y",
289284
"variable_name" : "LINE_LOAD",
290285
"interval" : [0.0, 100],

kratos.gid/apps/Pfem/write/write.tcl

+123
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,127 @@ proc Pfem::write::writeCustomFilesEvent { } {
100100
#write::RenameFileInModel "ProjectParameters.json" "ProjectParameters.py"
101101
}
102102

103+
104+
proc Pfem::write::getConditionsParametersDict {un {condition_type "Condition"}} {
105+
106+
set root [customlib::GetBaseRoot]
107+
108+
set bcCondsDict [list ]
109+
110+
set xp1 "[spdAux::getRoute $un]/condition/group"
111+
set groups [$root selectNodes $xp1]
112+
if {$groups eq ""} {
113+
set xp1 "[spdAux::getRoute $un]/group"
114+
set groups [$root selectNodes $xp1]
115+
}
116+
foreach group $groups {
117+
set groupName [$group @n]
118+
set cid [[$group parent] @n]
119+
set groupName [write::GetWriteGroupName $groupName]
120+
set groupId [::write::getMeshId $cid $groupName]
121+
set condId [[$group parent] @n]
122+
if {$condition_type eq "Condition"} {
123+
set condition [::Model::getCondition $condId]
124+
} {
125+
set condition [::Model::getNodalConditionbyId $condId]
126+
}
127+
set processName [$condition getProcessName]
128+
set process [::Model::GetProcess $processName]
129+
set processDict [dict create]
130+
set paramDict [dict create]
131+
dict set paramDict model_part_name $groupId
132+
133+
set process_attributes [$process getAttributes]
134+
set process_parameters [$process getInputs]
135+
136+
dict set process_attributes process_name [dict get $process_attributes n]
137+
dict unset process_attributes n
138+
dict unset process_attributes pn
139+
140+
set processDict [dict merge $processDict $process_attributes]
141+
if {[$condition hasAttribute VariableName]} {
142+
set variable_name [$condition getAttribute VariableName]
143+
# "lindex" is a rough solution. Look for a better one.
144+
if {$variable_name ne ""} {dict set paramDict variable_name [lindex $variable_name 0]}
145+
}
146+
foreach {inputName in_obj} $process_parameters {
147+
set in_type [$in_obj getType]
148+
if {$in_type eq "vector"} {
149+
set vector_type [$in_obj getAttribute "vectorType"]
150+
if {$vector_type eq "bool"} {
151+
set ValX [expr [get_domnode_attribute [$group find n ${inputName}X] v] ? True : False]
152+
set ValY [expr [get_domnode_attribute [$group find n ${inputName}Y] v] ? True : False]
153+
set ValZ [expr False]
154+
if {[$group find n ${inputName}Z] ne ""} {set ValZ [expr [get_domnode_attribute [$group find n ${inputName}Z] v] ? True : False]}
155+
dict set paramDict $inputName [list $ValX $ValY $ValZ]
156+
} {
157+
if {[$in_obj getAttribute "enabled"] in [list "1" "0"]} {
158+
foreach i [list "X" "Y" "Z"] {
159+
if {[expr [get_domnode_attribute [$group find n Enabled_$i] v] ] ne "Yes"} {
160+
set Val$i null
161+
} else {
162+
set printed 0
163+
if {[$in_obj getAttribute "function"] eq "1"} {
164+
if {[get_domnode_attribute [$group find n "ByFunction$i"] v] eq "Yes"} {
165+
set funcinputName "${i}function_$inputName"
166+
set value [get_domnode_attribute [$group find n $funcinputName] v]
167+
set Val$i $value
168+
set printed 1
169+
}
170+
}
171+
if {!$printed} {
172+
set value [expr [gid_groups_conds::convert_value_to_default [$group find n ${inputName}$i] ] ]
173+
set Val$i $value
174+
}
175+
}
176+
}
177+
} elseif {$vector_type eq "tablefile" || $vector_type eq "file"} {
178+
set ValX "[get_domnode_attribute [$group find n ${inputName}X] v]"
179+
set ValY "[get_domnode_attribute [$group find n ${inputName}Y] v]"
180+
set ValZ "0"
181+
if {[$group find n ${inputName}Z] ne ""} {set ValZ "[get_domnode_attribute [$group find n ${inputName}Z] v]"}
182+
} else {
183+
set ValX [expr [gid_groups_conds::convert_value_to_default [$group find n ${inputName}X] ] ]
184+
set ValY [expr [gid_groups_conds::convert_value_to_default [$group find n ${inputName}Y] ] ]
185+
set ValZ [expr 0.0]
186+
if {[$group find n ${inputName}Z] ne ""} {set ValZ [expr [gid_groups_conds::convert_value_to_default [$group find n ${inputName}Z] ]]}
187+
}
188+
dict set paramDict $inputName [list $ValX $ValY $ValZ]
189+
}
190+
} elseif {$in_type eq "double" || $in_type eq "integer"} {
191+
set printed 0
192+
if {[$in_obj getAttribute "function"] eq "1"} {
193+
if {[get_domnode_attribute [$group find n "ByFunction"] v] eq "Yes"} {
194+
set funcinputName "function_$inputName"
195+
set value [get_domnode_attribute [$group find n $funcinputName] v]
196+
dict set paramDict $inputName $value
197+
set printed 1
198+
}
199+
}
200+
if {!$printed} {
201+
set value [gid_groups_conds::convert_value_to_default [$group find n $inputName]]
202+
#set value [get_domnode_attribute [$group find n $inputName] v]
203+
dict set paramDict $inputName [expr $value]
204+
}
205+
} elseif {$in_type eq "bool"} {
206+
set value [get_domnode_attribute [$group find n $inputName] v]
207+
set value [expr $value ? True : False]
208+
dict set paramDict $inputName [expr $value]
209+
} elseif {$in_type eq "tablefile"} {
210+
set value [get_domnode_attribute [$group find n $inputName] v]
211+
dict set paramDict $inputName $value
212+
} else {
213+
if {[get_domnode_attribute [$group find n $inputName] state] ne "hidden" } {
214+
set value [get_domnode_attribute [$group find n $inputName] v]
215+
dict set paramDict $inputName $value
216+
}
217+
}
218+
}
219+
if {[$group find n Interval] ne ""} {dict set paramDict interval [write::getInterval [get_domnode_attribute [$group find n Interval] v]] }
220+
dict set processDict Parameters $paramDict
221+
lappend bcCondsDict $processDict
222+
}
223+
return $bcCondsDict
224+
}
225+
103226
Pfem::write::Init

kratos.gid/apps/Pfem/write/writeProjectParameters.tcl

+4-8
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ proc Pfem::write::getParametersDict { } {
1919
dict set projectParametersDict problem_process_list $problemProcessList
2020

2121
##### constraints_process_list
22-
set group_constraints [write::getConditionsParametersDict PFEM_NodalConditions "Nodal"]
22+
set group_constraints [Pfem::write::getConditionsParametersDict PFEM_NodalConditions "Nodal"]
2323
set body_constraints [Pfem::write::getBodyConditionsParametersDict PFEM_NodalConditions "Nodal"]
2424
dict set projectParametersDict constraints_process_list [concat $group_constraints $body_constraints]
2525

2626
##### loads_process_list
27-
dict set projectParametersDict loads_process_list [write::getConditionsParametersDict PFEM_Loads]
27+
dict set projectParametersDict loads_process_list [Pfem::write::getConditionsParametersDict PFEM_Loads]
2828

2929
##### Restart
3030
set output_process_list [GetPFEM_OutputProcessList]
@@ -48,7 +48,7 @@ proc Pfem::write::GetPFEM_ProblemDataDict { } {
4848
dict set problemDataDict model_part_name "Main Domain"
4949
set nDim $::Model::SpatialDimension
5050
set nDim [expr [string range [write::getValue nDim] 0 0] ]
51-
dict set problemDataDict domain_size $nDim
51+
dict set problemDataDict dimension $nDim
5252

5353
dict set problemDataDict time_step [write::getValue PFEM_TimeParameters DeltaTime]
5454
dict set problemDataDict start_time [write::getValue PFEM_TimeParameters StartTime]
@@ -68,7 +68,7 @@ proc Pfem::write::GetPFEM_SolverSettingsDict { } {
6868

6969
set solverSettingsDict [dict create]
7070
set currentStrategyId [write::getValue PFEM_SolStrat]
71-
set strategy_write_name [[::Model::GetSolutionStrategy $currentStrategyId] getAttribute "ImplementedInPythonFile"]
71+
set strategy_write_name [[::Model::GetSolutionStrategy $currentStrategyId] getAttribute "python_module"]
7272
dict set solverSettingsDict solver_type $strategy_write_name
7373

7474
set problemtype [write::getValue PFEM_DomainType]
@@ -147,7 +147,6 @@ proc Pfem::write::GetPFEM_ContactDict { } {
147147
dict set contact_dict "help" "This process applies contact domain search by remeshing outer boundaries"
148148
dict set contact_dict "process_name" "ContactDomainProcess"
149149
set params [dict create]
150-
dict set params "mesh_id" 0
151150
dict set params "model_part_name" "model_part_name"
152151
dict set params "meshing_control_type" "step"
153152
dict set params "meshing_frequency" 1.0
@@ -223,7 +222,6 @@ proc Pfem::write::GetPFEM_RemeshDict { } {
223222
set bodyDict [dict create ]
224223
set body_name [dict get $body body_name]
225224
dict set bodyDict "python_module" "meshing_domain"
226-
dict set bodyDict "mesh_id" 0
227225
dict set bodyDict "model_part_name" $body_name
228226
dict set bodyDict "alpha_shape" 2.4
229227
dict set bodyDict "offset_factor" 0.0
@@ -337,7 +335,6 @@ proc Pfem::write::GetPFEM_FluidRemeshDict { } {
337335
foreach body $bodies_list {
338336
set bodyDict [dict create ]
339337
set body_name [dict get $body body_name]
340-
dict set bodyDict "mesh_id" 0
341338
dict set bodyDict "model_part_name" $body_name
342339
dict set bodyDict "python_module" "fluid_meshing_domain"
343340
set nDim $::Model::SpatialDimension
@@ -571,7 +568,6 @@ proc Pfem::write::getBodyConditionsParametersDict {un {condition_type "Condition
571568
set process [::Model::GetProcess $processName]
572569
set processDict [dict create]
573570
set paramDict [dict create]
574-
dict set paramDict mesh_id 0
575571
dict set paramDict model_part_name $bodyId
576572
set vatiable_name [$condition getAttribute VariableName]
577573
dict set paramDict variable_name [lindex $vatiable_name 0]

kratos.gid/apps/Pfem/xml/ConstitutiveLaws.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<ConstitutiveLaws>
33
<!--linear elastic laws-->
4-
<CLaw n="Newtonian" pn="Newtonian" ProductionReady="ProductionReady" help="Newtonian fluid" App="Pfem" ImplementedInApplication="PfemFluidDynamicsApplication">
4+
<CLaw n="Newtonian" pn="Newtonian" ProductionReady="ProductionReady" help="Newtonian fluid" App="Pfem" kratos_module="PfemFluidDynamicsApplication">
55
<inputs>
66
<parameter n="DENSITY" pn="Density" unit_magnitude="Density" units="kg/m^3" v="1000"/>
77
<parameter n="VISCOSITY" pn="Dynamic viscosity" unit_magnitude="P*T" units="Pa*s" v="1e-3" help="Set the dynamic viscosity."/>
@@ -10,7 +10,7 @@
1010
<outputs>
1111
</outputs>
1212
</CLaw>
13-
<CLaw n="Hypoelastic" pn="Hypoelastic" ProductionReady="ProductionReady" help="Hypoelastic solid" App="Pfem" ImplementedInApplication="PfemFluidDynamicsApplication">
13+
<CLaw n="Hypoelastic" pn="Hypoelastic" ProductionReady="ProductionReady" help="Hypoelastic solid" App="Pfem" kratos_module="PfemFluidDynamicsApplication">
1414
<inputs>
1515
<parameter n="DENSITY" pn="Density" unit_magnitude="Density" units="kg/m^3" v="1000"/>
1616
<parameter n="YOUNG_MODULUS" pn="Young modulus" unit_magnitude="P" units="Pa" v="2.1e+11" help="Set the Young modulus."/>

0 commit comments

Comments
 (0)