www.mooseframework.org
MomentumFreeSlipBC.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 #include "MomentumFreeSlipBC.h"
11 #include "MooseMesh.h"
12 #include "MooseVariable.h"
13 #include "SystemBase.h"
14 #include "FEProblemBase.h"
15 #include "libmesh/numeric_vector.h"
16 
17 registerMooseObject("NavierStokesApp", MomentumFreeSlipBC);
18 
19 template <>
20 InputParameters
22 {
23  InputParameters params = validParams<NodalNormalBC>();
24  params.addRequiredCoupledVar("rho_u", "x-component of velocity");
25  params.addCoupledVar("rho_v", "y-component of velocity");
26  params.addCoupledVar("rho_w", "z-component of velocity");
27 
28  return params;
29 }
30 
31 MomentumFreeSlipBC::MomentumFreeSlipBC(const InputParameters & parameters)
32  : NodalNormalBC(parameters),
33  _mesh_dimension(_mesh.dimension()),
34  _rho_u(coupledValue("rho_u")),
35  _rho_v(_mesh_dimension >= 2 ? coupledValue("rho_v") : _zero),
36  _rho_w(_mesh_dimension >= 3 ? coupledValue("rho_w") : _zero)
37 {
38 }
39 
41 
42 bool
44 {
45  // this prevents zeroing out the row
46  return !_fe_problem.currentlyComputingJacobian();
47 }
48 
49 Real
51 {
52  for (auto tag : _vector_tags)
53  if (_sys.hasVector(tag) && _var.isNodalDefined())
54  {
55  auto & residual = _sys.getVector(tag);
56 
57  if (_mesh_dimension == 1)
58  {
59  mooseError(name(), ": Not implemented yet");
60  }
61  else if (_mesh_dimension == 2)
62  {
63  MooseVariable & rho_u_var = *getVar("rho_u", 0);
64  auto && rho_u_dof_idx = rho_u_var.nodalDofIndex();
65 
66  MooseVariable & rho_v_var = *getVar("rho_v", 0);
67  auto && rho_v_dof_idx = rho_v_var.nodalDofIndex();
68 
69  Real rho_un = _normal(0) * _rho_u[0] + _normal(1) * _rho_v[0];
70  Real Re_u = residual(rho_u_dof_idx);
71  Real Re_v = residual(rho_v_dof_idx);
72 
73  // We obtain these contributions in 3 steps:
74  // 1.) Tranform the momentum residuals into (tangential, normal)
75  // components by left-multiplying the residual by:
76  // R = [tx ty] = [-ny nx]
77  // [nx ny] [ nx ny]
78  // 2.) Impose the no-normal-flow BC, rho_un = 0, in the normal momentum component's
79  // residual.
80  // 3.) Transform back to (x,y) momentum components by left-multiplying the residual by
81  // R^{-1} = R^T.
82  Real rho_u_val =
83  (Re_u * _normal(1) * _normal(1) - Re_v * _normal(0) * _normal(1)) + rho_un * _normal(0);
84  Real rho_v_val = (-Re_u * _normal(0) * _normal(1) + Re_v * _normal(0) * _normal(0)) +
85  rho_un * _normal(1);
86 
87  // NOTE: we have to handle all components at the same time, otherwise we'd work with the
88  // modified residual and we do not want that
89  residual.set(rho_u_dof_idx, rho_u_val);
90  residual.set(rho_v_dof_idx, rho_v_val);
91  }
92  else if (_mesh_dimension == 3)
93  {
94  mooseError(name(), ": Not implemented yet");
95  }
96  }
97 
98  // The return value is not used for anything, so we simply return 0.
99  return 0.;
100 }
MomentumFreeSlipBC::shouldApply
virtual bool shouldApply() override
Definition: MomentumFreeSlipBC.C:43
MomentumFreeSlipBC::computeQpResidual
virtual Real computeQpResidual() override
Definition: MomentumFreeSlipBC.C:50
MomentumFreeSlipBC::_mesh_dimension
const unsigned int _mesh_dimension
The dimension of the mesh.
Definition: MomentumFreeSlipBC.h:34
validParams< MomentumFreeSlipBC >
InputParameters validParams< MomentumFreeSlipBC >()
Definition: MomentumFreeSlipBC.C:21
MomentumFreeSlipBC
Boundary condition that applies free slip condition at nodes.
Definition: MomentumFreeSlipBC.h:22
registerMooseObject
registerMooseObject("NavierStokesApp", MomentumFreeSlipBC)
MomentumFreeSlipBC::MomentumFreeSlipBC
MomentumFreeSlipBC(const InputParameters &parameters)
Definition: MomentumFreeSlipBC.C:31
name
const std::string name
Definition: Setup.h:21
MomentumFreeSlipBC::_rho_v
const VariableValue & _rho_v
Momentum in y-direction.
Definition: MomentumFreeSlipBC.h:39
MomentumFreeSlipBC.h
MomentumFreeSlipBC::~MomentumFreeSlipBC
virtual ~MomentumFreeSlipBC()
Definition: MomentumFreeSlipBC.C:40
MomentumFreeSlipBC::_rho_u
const VariableValue & _rho_u
Momentum in x-direction.
Definition: MomentumFreeSlipBC.h:37