www.mooseframework.org
NSImposedVelocityDirectionBC.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 // Navier-Stokes includes
12 #include "NS.h"
13 
14 // MOOSE includes
15 #include "MooseMesh.h"
16 
17 // Full specialization of the validParams function for this object
19 
20 template <>
21 InputParameters
23 {
24  // Initialize the params object from the base class
25  InputParameters params = validParams<NodalBC>();
26 
27  params.addClassDescription("This class imposes a velocity direction component as a Dirichlet "
28  "condition on the appropriate momentum equation.");
29  // Coupled variables
30  params.addRequiredCoupledVar(NS::density, "density");
31  params.addRequiredCoupledVar(NS::velocity_x, "x-velocity");
32  params.addCoupledVar(NS::velocity_y, "y-velocity"); // only required in >= 2D
33  params.addCoupledVar(NS::velocity_z, "z-velocity"); // only required in 3D
34 
35  // Coupled parameters
36  params.addRequiredParam<Real>("desired_unit_velocity_component", "");
37 
38  return params;
39 }
40 
42  : NodalBC(parameters),
43  _rho(coupledValue(NS::density)),
44  _u_vel(coupledValue(NS::velocity_x)),
45  _v_vel(_mesh.dimension() == 2 ? coupledValue(NS::velocity_y) : _zero),
46  _w_vel(_mesh.dimension() == 3 ? coupledValue(NS::velocity_z) : _zero),
47  _desired_unit_velocity_component(getParam<Real>("desired_unit_velocity_component"))
48 {
49 }
50 
51 Real
53 {
54  // The velocity vector
55  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
56 
57  // Specify desired velocity component
58  return _u[_qp] - _rho[_qp] * _desired_unit_velocity_component * vel.norm();
59 }
NS::velocity_x
const std::string velocity_x
Definition: NS.h:22
validParams< NSImposedVelocityDirectionBC >
InputParameters validParams< NSImposedVelocityDirectionBC >()
Definition: NSImposedVelocityDirectionBC.C:22
NS::velocity_y
const std::string velocity_y
Definition: NS.h:23
NS::velocity_z
const std::string velocity_z
Definition: NS.h:24
NSImposedVelocityDirectionBC::_w_vel
const VariableValue & _w_vel
Definition: NSImposedVelocityDirectionBC.h:56
NS
Definition: NS.h:14
NS::density
const std::string density
Definition: NS.h:16
NSImposedVelocityDirectionBC::_desired_unit_velocity_component
Real _desired_unit_velocity_component
Definition: NSImposedVelocityDirectionBC.h:59
NSImposedVelocityDirectionBC
This class imposes a velocity direction component as a Dirichlet condition on the appropriate momentu...
Definition: NSImposedVelocityDirectionBC.h:41
NSImposedVelocityDirectionBC::computeQpResidual
virtual Real computeQpResidual()
Definition: NSImposedVelocityDirectionBC.C:52
NSImposedVelocityDirectionBC::NSImposedVelocityDirectionBC
NSImposedVelocityDirectionBC(const InputParameters &parameters)
Definition: NSImposedVelocityDirectionBC.C:41
registerMooseObject
registerMooseObject("NavierStokesApp", NSImposedVelocityDirectionBC)
NSImposedVelocityDirectionBC::_v_vel
const VariableValue & _v_vel
Definition: NSImposedVelocityDirectionBC.h:55
NSImposedVelocityDirectionBC::_rho
const VariableValue & _rho
Definition: NSImposedVelocityDirectionBC.h:53
NS.h
NSImposedVelocityDirectionBC.h
NSImposedVelocityDirectionBC::_u_vel
const VariableValue & _u_vel
Definition: NSImposedVelocityDirectionBC.h:54