https://mooseframework.inl.gov
INSADMomentumNoBCBC.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 "INSADMomentumNoBCBC.h"
11 #include "MooseMesh.h"
12 #include "INSADObjectTracker.h"
13 #include "NS.h"
14 
15 registerMooseObject("NavierStokesApp", INSADMomentumNoBCBC);
16 
19 {
21 
22  params.addClassDescription("This class implements the 'No BC' boundary condition based on the "
23  "'Laplace' form of the viscous stress tensor.");
24  params.addRequiredCoupledVar(NS::pressure, "pressure");
25  params.addParam<bool>("integrate_p_by_parts",
26  true,
27  "Allows simulations to be run with pressure BC if set to false");
28  MooseEnum viscous_form("traction laplace", "laplace");
29  params.addParam<MooseEnum>("viscous_form",
30  viscous_form,
31  "The form of the viscous term. Options are 'traction' or 'laplace'");
32 
33  // Optional parameters
34  params.addParam<MaterialPropertyName>("mu_name", "mu", "The name of the dynamic viscosity");
35  return params;
36 }
37 
39  : ADVectorIntegratedBC(parameters),
40  _p(adCoupledValue(NS::pressure)),
41  _integrate_p_by_parts(getParam<bool>("integrate_p_by_parts")),
42  _mu(getADMaterialProperty<Real>("mu_name")),
43  _form(getParam<MooseEnum>("viscous_form"))
44 {
45  std::set<SubdomainID> connected_blocks;
46  for (const auto bnd_id : boundaryIDs())
47  {
48  const auto & these_blocks = _mesh.getBoundaryConnectedBlocks(bnd_id);
49  connected_blocks.insert(these_blocks.begin(), these_blocks.end());
50  }
51  auto & obj_tracker = const_cast<INSADObjectTracker &>(
52  _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker"));
53  for (const auto block_id : connected_blocks)
54  {
55  obj_tracker.set("viscous_form", _form, block_id);
56  obj_tracker.set("integrate_p_by_parts", _integrate_p_by_parts, block_id);
57  }
58 }
59 
60 ADReal
62 {
63  // The viscous term
64  ADReal residual;
65  if (_form == "laplace")
66  residual = -_mu[_qp] * (_grad_u[_qp] * _normals[_qp]) * _test[_i][_qp];
67  else
68  residual =
69  -_mu[_qp] * ((_grad_u[_qp] + _grad_u[_qp].transpose()) * _normals[_qp]) * _test[_i][_qp];
70 
72  // pIn * test
73  residual += _p[_qp] * _normals[_qp] * _test[_i][_qp];
74 
75  return residual;
76 }
MooseEnum _form
The form of the viscous term. Either laplace or traction.
const ADMaterialProperty< Real > & _mu
T & getUserObject(const std::string &name, unsigned int tid=0) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void set(const std::string &name, const T &value, SubdomainID sub_id)
Set the internal parameter name to value.
INSADMomentumNoBCBC(const InputParameters &parameters)
DualNumber< Real, DNDerivativeType, true > ADReal
static InputParameters validParams()
unsigned int _qp
const ADTemplateVariableGradient< T > & _grad_u
static InputParameters validParams()
FEProblemBase & _fe_problem
std::set< SubdomainID > getBoundaryConnectedBlocks(const BoundaryID bid) const
registerMooseObject("NavierStokesApp", INSADMomentumNoBCBC)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
ADReal computeQpResidual() override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This class implements the "No BC" boundary condition based on the "Laplace" form of the viscous stres...
const ADTemplateVariableTestValue< T > & _test
static const std::string pressure
Definition: NS.h:56
void addClassDescription(const std::string &doc_string)
const bool _integrate_p_by_parts
const ADVariableValue & _p
virtual const std::set< BoundaryID > & boundaryIDs() const
Object for tracking what kernels have been added to an INSAD simulation.
const MooseArray< ADPoint > & _normals