www.mooseframework.org
AddNavierStokesBCsAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 // Navier-Stokes includes
9 #include "NS.h"
11 
12 // MOOSE includes
13 #include "FEProblem.h"
14 #include "MooseMesh.h"
15 
16 template <>
17 InputParameters
19 {
20  InputParameters params = validParams<MooseObjectAction>();
21  params.addClassDescription("This class allows us to have a section of the input file like the "
22  "following which adds BC objects for each requested boundary "
23  "condition.");
24  return params;
25 }
26 
28  : MooseObjectAction(parameters)
29 {
30 }
31 
33 
34 void
36 {
37  // The Mesh dimension tells us how many momentum BCs to add.
38  _dim = _mesh->dimension();
39 
40  if (_type == "NSWeakStagnationInletBC")
41  {
44  for (unsigned int component = 0; component < _dim; ++component)
46  }
47 
48  else if (_type == "NSNoPenetrationBC")
49  {
50  for (unsigned int component = 0; component < _dim; ++component)
52  }
53 
54  else if (_type == "NSStaticPressureOutletBC")
55  {
58  for (unsigned int component = 0; component < _dim; ++component)
60  }
61 }
62 
63 void
65 {
66  const std::string kernel_type = "NSMassWeakStagnationBC";
67  InputParameters params = _factory.getValidParams(kernel_type);
68  params.set<NonlinearVariableName>("variable") = NS::density;
69  setCommonParams(params);
70 
71  // Pick up values specific to this BC from the Action's params.
72  // This includes things like boundary, stagnation_pressure,
73  // stagnation_temperature, etc. This extra InputParameters object
74  // is provided by the MooseObjectAction base class.
75  params += _moose_object_pars;
76 
77  _problem->addBoundaryCondition(kernel_type, "weak_stagnation_mass_inflow", params);
78 }
79 
80 void
82 {
83  const std::string kernel_type = "NSEnergyWeakStagnationBC";
84  InputParameters params = _factory.getValidParams(kernel_type);
85  params.set<NonlinearVariableName>("variable") = NS::total_energy;
86  setCommonParams(params);
87  params += _moose_object_pars;
88  _problem->addBoundaryCondition(kernel_type, "weak_stagnation_energy_inflow", params);
89 }
90 
91 void
93 {
94  const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
95 
96  // Convective part
97  {
98  const std::string kernel_type = "NSMomentumConvectiveWeakStagnationBC";
99  InputParameters params = _factory.getValidParams(kernel_type);
100  params.set<NonlinearVariableName>("variable") = momentums[component];
101  setCommonParams(params);
102  params += _moose_object_pars;
103 
104  // Momentum Kernels also need the component.
105  params.set<unsigned int>("component") = component;
106 
107  _problem->addBoundaryCondition(kernel_type,
108  std::string("weak_stagnation_") + momentums[component] +
109  std::string("_convective_inflow"),
110  params);
111  }
112 
113  // Pressure part
114  {
115  const std::string kernel_type = "NSMomentumPressureWeakStagnationBC";
116  InputParameters params = _factory.getValidParams(kernel_type);
117  params.set<NonlinearVariableName>("variable") = momentums[component];
118  setCommonParams(params);
119  params += _moose_object_pars;
120 
121  // Momentum Kernels also need the component.
122  params.set<unsigned int>("component") = component;
123 
124  _problem->addBoundaryCondition(kernel_type,
125  std::string("weak_stagnation_") + momentums[component] +
126  std::string("_pressure_inflow"),
127  params);
128  }
129 }
130 
131 void
133 {
134  const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
135  const std::string kernel_type = "NSPressureNeumannBC";
136  InputParameters params = _factory.getValidParams(kernel_type);
137  params.set<NonlinearVariableName>("variable") = momentums[component];
138  setCommonParams(params);
139  params += _moose_object_pars;
140 
141  // These BCs also need the component and couping to the pressure.
142  params.set<unsigned int>("component") = component;
143  params.set<CoupledName>(NS::pressure) = {NS::pressure};
144 
145  _problem->addBoundaryCondition(
146  kernel_type, momentums[component] + std::string("_no_penetration"), params);
147 }
148 
149 void
151 {
152  const std::string kernel_type = "NSMassUnspecifiedNormalFlowBC";
153  InputParameters params = _factory.getValidParams(kernel_type);
154  params.set<NonlinearVariableName>("variable") = NS::density;
155  setCommonParams(params);
156  params += _moose_object_pars;
157  _problem->addBoundaryCondition(kernel_type, "mass_outflow", params);
158 }
159 
160 void
162 {
163  const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
164  const std::string kernel_type = "NSMomentumInviscidSpecifiedPressureBC";
165  InputParameters params = _factory.getValidParams(kernel_type);
166  params.set<NonlinearVariableName>("variable") = momentums[component];
167  setCommonParams(params);
168  params += _moose_object_pars;
169 
170  // These BCs also need the component.
171  params.set<unsigned int>("component") = component;
172 
173  _problem->addBoundaryCondition(
174  kernel_type, momentums[component] + std::string("_specified_pressure_outflow"), params);
175 }
176 
177 void
179 {
180  const std::string kernel_type = "NSEnergyInviscidSpecifiedPressureBC";
181  InputParameters params = _factory.getValidParams(kernel_type);
182  params.set<NonlinearVariableName>("variable") = NS::total_energy;
183  setCommonParams(params);
184  params += _moose_object_pars;
185  // This BC also requires the current value of the temperature.
187  _problem->addBoundaryCondition(kernel_type, "rhoE_specified_pressure_outflow", params);
188 }
189 
190 void
192 {
193  // coupled variables
194  params.set<CoupledName>(NS::density) = {NS::density};
196 
197  // Couple the appropriate number of velocities
198  coupleVelocities(params);
199  coupleMomentums(params);
200 }
201 
202 void
204 {
205  params.set<CoupledName>(NS::velocity_x) = {NS::velocity_x};
206 
207  if (_dim >= 2)
208  params.set<CoupledName>(NS::velocity_y) = {NS::velocity_y};
209 
210  if (_dim >= 3)
211  params.set<CoupledName>(NS::velocity_z) = {NS::velocity_z};
212 }
213 
214 void
216 {
217  params.set<CoupledName>(NS::momentum_x) = {NS::momentum_x};
218 
219  if (_dim >= 2)
220  params.set<CoupledName>(NS::momentum_y) = {NS::momentum_y};
221 
222  if (_dim >= 3)
223  params.set<CoupledName>(NS::momentum_z) = {NS::momentum_z};
224 }
const std::string momentum_x
Definition: NS.h:16
void coupleMomentums(InputParameters &params)
InputParameters validParams< AddNavierStokesBCsAction >()
void addNSMomentumWeakStagnationBC(unsigned int component)
const std::string velocity_z
Definition: NS.h:23
void setCommonParams(InputParameters &params)
const std::string density
Definition: NS.h:15
Real component(const SymmTensor &symm_tensor, unsigned int index)
void addNoPenetrationBC(unsigned int component)
const std::string velocity_x
Definition: NS.h:21
const std::string temperature
Definition: NS.h:25
AddNavierStokesBCsAction(InputParameters parameters)
void addNSMomentumInviscidSpecifiedPressureBC(unsigned int component)
const std::string velocity_y
Definition: NS.h:22
const std::string momentum_y
Definition: NS.h:17
std::vector< VariableName > CoupledName
const std::string pressure
Definition: NS.h:24
const std::string total_energy
Definition: NS.h:19
const std::string momentum_z
Definition: NS.h:18
void coupleVelocities(InputParameters &params)