|
| 1 | +namespace eval ::CompressibleFluid::examples::SodShockTube { |
| 2 | + namespace path ::CompressibleFluid::examples |
| 3 | + Kratos::AddNamespace [namespace current] |
| 4 | +} |
| 5 | + |
| 6 | +proc ::CompressibleFluid::examples::SodShockTube::Init {args} { |
| 7 | + if {![Kratos::IsModelEmpty]} { |
| 8 | + set txt "We are going to draw the example geometry.\nDo you want to lose your previous work?" |
| 9 | + set retval [tk_messageBox -default ok -icon question -message $txt -type okcancel] |
| 10 | + if { $retval == "cancel" } { return } |
| 11 | + } |
| 12 | + |
| 13 | + Kratos::ResetModel |
| 14 | + DrawGeometry$::Model::SpatialDimension |
| 15 | + AssignGroups$::Model::SpatialDimension |
| 16 | + AssignMeshSizes$::Model::SpatialDimension |
| 17 | + TreeAssignation$::Model::SpatialDimension |
| 18 | + |
| 19 | + GiD_Process 'Redraw |
| 20 | + GidUtils::UpdateWindow GROUPS |
| 21 | + GidUtils::UpdateWindow LAYER |
| 22 | + GiD_Process 'Zoom Frame |
| 23 | +} |
| 24 | + |
| 25 | + |
| 26 | +# Draw Geometry |
| 27 | +proc ::CompressibleFluid::examples::SodShockTube::DrawGeometry3D {args} { |
| 28 | + # To be implemented |
| 29 | +} |
| 30 | + |
| 31 | +proc ::CompressibleFluid::examples::SodShockTube::DrawGeometry2D {args} { |
| 32 | + GiD_Layers create Fluid |
| 33 | + GiD_Layers edit to_use Fluid |
| 34 | + |
| 35 | + # Geometry creation |
| 36 | + ## Points ## |
| 37 | + set coordinates [list {0 0 0} {1 0 0} {1 0.1 0} {0 0.1 0} ] |
| 38 | + foreach point $coordinates { |
| 39 | + lassign $point x y z |
| 40 | + GiD_Geometry create point append Fluid $x $y $z |
| 41 | + } |
| 42 | + |
| 43 | + ## Lines ## |
| 44 | + GiD_Geometry create line append stline Fluid 1 2 |
| 45 | + GiD_Geometry create line append stline Fluid 2 3 |
| 46 | + GiD_Geometry create line append stline Fluid 3 4 |
| 47 | + GiD_Geometry create line append stline Fluid 4 1 |
| 48 | + |
| 49 | + ## Surface ## |
| 50 | + GiD_Process Mescape Geometry Create NurbsSurface 1 2 3 4 escape escape |
| 51 | +} |
| 52 | + |
| 53 | + |
| 54 | +# Group assign |
| 55 | +proc ::CompressibleFluid::examples::SodShockTube::AssignGroups2D {args} { |
| 56 | + # Create the groups |
| 57 | + GiD_Groups create Fluid |
| 58 | + GiD_Groups edit color Fluid "#26d1a8ff" |
| 59 | + GiD_EntitiesGroups assign Fluid surfaces 1 |
| 60 | + |
| 61 | + GiD_Groups create Left |
| 62 | + GiD_Groups edit color Left "#e0210fff" |
| 63 | + GiD_EntitiesGroups assign Left lines 4 |
| 64 | + |
| 65 | + GiD_Groups create Right |
| 66 | + GiD_Groups edit color Right "#42eb71ff" |
| 67 | + GiD_EntitiesGroups assign Right lines 2 |
| 68 | + |
| 69 | + GiD_Groups create Top |
| 70 | + GiD_Groups edit color Top "#3b3b3bff" |
| 71 | + GiD_EntitiesGroups assign Top lines 3 |
| 72 | + |
| 73 | + GiD_Groups create Bottom |
| 74 | + GiD_Groups edit color Bottom "#3b3b3bff" |
| 75 | + GiD_EntitiesGroups assign Bottom lines 1 |
| 76 | + |
| 77 | +} |
| 78 | +proc ::CompressibleFluid::examples::SodShockTube::AssignGroups3D {args} { |
| 79 | + # To be implemented |
| 80 | +} |
| 81 | + |
| 82 | + |
| 83 | +# Mesh sizes |
| 84 | +proc ::CompressibleFluid::examples::SodShockTube::AssignMeshSizes3D {args} { |
| 85 | + # To be implemented |
| 86 | +} |
| 87 | + |
| 88 | +proc ::CompressibleFluid::examples::SodShockTube::AssignMeshSizes2D {args} { |
| 89 | + # set fluid_mesh_size 30.0 |
| 90 | + # set walls_mesh_size 30.0 |
| 91 | + # set building_mesh_size 3.0 |
| 92 | + # GiD_Process Mescape Meshing AssignSizes Lines $walls_mesh_size {*}[GiD_EntitiesGroups get Inlet lines] escape escape |
| 93 | + # GiD_Process Mescape Meshing AssignSizes Lines $walls_mesh_size {*}[GiD_EntitiesGroups get Outlet lines] escape escape |
| 94 | + # GiD_Process Mescape Meshing AssignSizes Lines $walls_mesh_size {*}[GiD_EntitiesGroups get Top_Wall lines] escape escape |
| 95 | + # GiD_Process Mescape Meshing AssignSizes Lines $walls_mesh_size {*}[GiD_EntitiesGroups get Bottom_Wall lines] escape escape |
| 96 | + # GiD_Process Mescape Meshing AssignSizes Lines $building_mesh_size {*}[GiD_EntitiesGroups get InterfaceFluid lines] escape escape |
| 97 | + # GiD_Process Mescape Meshing AssignSizes Surfaces $fluid_mesh_size [GiD_EntitiesGroups get Fluid surfaces] escape escape |
| 98 | + # Kratos::Event_BeforeMeshGeneration $fluid_mesh_size |
| 99 | +} |
| 100 | + |
| 101 | + |
| 102 | +# Tree assign |
| 103 | +proc ::CompressibleFluid::examples::SodShockTube::TreeAssignation3D {args} { |
| 104 | + # To be implemented |
| 105 | +} |
| 106 | + |
| 107 | +proc ::CompressibleFluid::examples::SodShockTube::TreeAssignation2D {args} { |
| 108 | + set nd $::Model::SpatialDimension |
| 109 | + set root [customlib::GetBaseRoot] |
| 110 | + |
| 111 | + set condtype line |
| 112 | + if {$nd eq "3D"} { set condtype surface } |
| 113 | + |
| 114 | + # Monolithic solution strategy set |
| 115 | + # spdAux::SetValueOnTreeItem v "Monolithic" FLSolStrat |
| 116 | + |
| 117 | + # Fluid Parts |
| 118 | + set fluidParts [spdAux::getRoute "FLParts"] |
| 119 | + set fluidNode [customlib::AddConditionGroupOnXPath $fluidParts Fluid] |
| 120 | + set props [list ConstitutiveLaw Newtonian DENSITY 1.0 DYNAMIC_VISCOSITY 0.0 CONDUCTIVITY 0.0 SPECIFIC_HEAT 722.14 HEAT_CAPACITY_RATIO 1.4] |
| 121 | + spdAux::SetValuesOnBaseNode $fluidNode $props |
| 122 | + |
| 123 | + set initial_conditions [spdAux::getRoute "FLNodalConditions"] |
| 124 | + # Fluid density |
| 125 | + set fluid_density "$initial_conditions/condition\[@n='DENSITY'\]" |
| 126 | + set initial_density_node [customlib::AddConditionGroupOnXPath $fluid_density Fluid] |
| 127 | + $initial_density_node setAttribute ov surface |
| 128 | + set props [list ByFunction Yes function_value "1.0 if x < 0.5 else 0.125"] |
| 129 | + spdAux::SetValuesOnBaseNode $initial_density_node $props |
| 130 | + |
| 131 | + set fluid_energy "$initial_conditions/condition\[@n='TOTAL_ENERGY'\]" |
| 132 | + set initial_energy_node [customlib::AddConditionGroupOnXPath $fluid_energy Fluid] |
| 133 | + $initial_energy_node setAttribute ov surface |
| 134 | + set props [list ByFunction Yes function_value "2.5 if x < 0.5 else 0.25"] |
| 135 | + spdAux::SetValuesOnBaseNode $initial_energy_node $props |
| 136 | + |
| 137 | + set fluidConditions [spdAux::getRoute "FLBC"] |
| 138 | + |
| 139 | + # Fluid Conditions |
| 140 | + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='Slip$nd'\]" Top] setAttribute ov $condtype |
| 141 | + [customlib::AddConditionGroupOnXPath "$fluidConditions/condition\[@n='Slip$nd'\]" Bottom] setAttribute ov $condtype |
| 142 | + |
| 143 | + set momentum "$fluidConditions/condition\[@n='MomentumConstraints$nd'\]" |
| 144 | + foreach gr [list Left Right] { |
| 145 | + GiD_Groups create "$gr//Total" |
| 146 | + GiD_Groups edit state "$gr//Total" hidden |
| 147 | + spdAux::AddIntervalGroup $gr "$gr//Total" |
| 148 | + set momentum_node [customlib::AddConditionGroupOnXPath $momentum "$gr//Total"] |
| 149 | + $momentum_node setAttribute ov $condtype |
| 150 | + [$momentum_node selectNodes "./value\[@n = 'selector_component_X'\]"] setAttribute v "Not" |
| 151 | + } |
| 152 | + |
| 153 | + # Time parameters |
| 154 | + set parameters [list CFLNumber 0.7 EndTime 0.1 AutomaticDeltaTime Yes MinimumDeltaTime 1.0e-8] |
| 155 | + set xpath [spdAux::getRoute "FLTimeParameters"] |
| 156 | + spdAux::SetValuesOnBasePath $xpath $parameters |
| 157 | + |
| 158 | + # Output |
| 159 | + set parameters [list OutputControlType time OutputDeltaTime 0.01] |
| 160 | + set xpath "[spdAux::getRoute FLResults]/container\[@n='GiDOutput'\]/container\[@n='GiDOptions'\]" |
| 161 | + spdAux::SetValuesOnBasePath $xpath $parameters |
| 162 | + |
| 163 | + # Parallelism |
| 164 | + set parameters [list ParallelSolutionType OpenMP OpenMPNumberOfThreads 4] |
| 165 | + set xpath [spdAux::getRoute "Parallelization"] |
| 166 | + spdAux::SetValuesOnBasePath $xpath $parameters |
| 167 | + |
| 168 | + spdAux::RequestRefresh |
| 169 | +} |
0 commit comments