https://mooseframework.inl.gov
INSADMomentumPressure.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 "INSADMomentumPressure.h"
11 #include "Assembly.h"
12 #include "INSADObjectTracker.h"
13 #include "FEProblemBase.h"
14 #include "NS.h"
15 
16 registerMooseObject("NavierStokesApp", INSADMomentumPressure);
17 
20 {
22  params.addClassDescription("Adds the pressure term to the INS momentum equation");
23  params.addRequiredCoupledVar(NS::pressure, "The pressure");
24  params.addParam<bool>(
25  "integrate_p_by_parts", true, "Whether to integrate the pressure term by parts");
26  return params;
27 }
28 
30  : ADVectorKernel(parameters),
31  _integrate_p_by_parts(getParam<bool>("integrate_p_by_parts")),
32  _p(adCoupledValue(NS::pressure)),
33  _grad_p(adCoupledGradient(NS::pressure)),
34  _coord_sys(_assembly.coordSystem()),
35  _rz_radial_coord(_mesh.getAxisymmetricRadialCoord())
36 {
37  // Bypass the UserObjectInterface method because it requires a UserObjectName param which we
38  // don't need
39  auto & obj_tracker = const_cast<INSADObjectTracker &>(
40  _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker"));
41  for (const auto block_id : blockIDs())
42  obj_tracker.set("integrate_p_by_parts", _integrate_p_by_parts, block_id);
43 }
44 
45 ADReal
47 {
49  {
50  ADReal residual = -_p[_qp] * _grad_test[_i][_qp].tr();
52  {
53  const auto r_component_residual = -_p[_qp] / _ad_q_point[_qp](_rz_radial_coord);
54  ADRealVectorValue rz_residual;
55  rz_residual(_rz_radial_coord) = r_component_residual;
56  residual += rz_residual * _test[_i][_qp];
57  }
58  return residual;
59  }
60  else
61  return _test[_i][_qp] * _grad_p[_qp];
62 }
This class computes the momentum equation residual and Jacobian contributions for the pressure term o...
const ADTemplateVariableTestGradient< T > & _grad_test
T & getUserObject(const std::string &name, unsigned int tid=0) const
const ADVariableValue & _p
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.
virtual ADReal computeQpResidual() override
virtual const std::set< SubdomainID > & blockIDs() const
const ADTemplateVariableTestValue< T > & _test
DualNumber< Real, DNDerivativeType, true > ADReal
const Moose::CoordinateSystemType & _coord_sys
const unsigned int _rz_radial_coord
The radial coordinate index for RZ coordinate systems.
FEProblemBase & _fe_problem
const MooseArray< ADPoint > & _ad_q_point
unsigned int _i
INSADMomentumPressure(const InputParameters &parameters)
static InputParameters validParams()
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
const ADVariableGradient & _grad_p
static const std::string pressure
Definition: NS.h:56
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
registerMooseObject("NavierStokesApp", INSADMomentumPressure)
Object for tracking what kernels have been added to an INSAD simulation.
unsigned int _qp