https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
11#include "Assembly.h"
12#include "INSADObjectTracker.h"
13#include "FEProblemBase.h"
14#include "NS.h"
15
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
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}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("NavierStokesApp", INSADMomentumPressure)
const MooseArray< ADPoint > & _ad_q_point
const ADTemplateVariableTestValue< T > & _test
const ADTemplateVariableTestGradient< T > & _grad_test
static InputParameters validParams()
virtual const std::set< SubdomainID > & blockIDs() const
T & getUserObject(const std::string &name, unsigned int tid=0) const
This class computes the momentum equation residual and Jacobian contributions for the pressure term o...
static InputParameters validParams()
const ADVariableValue & _p
INSADMomentumPressure(const InputParameters &parameters)
virtual ADReal computeQpResidual() override
const Moose::CoordinateSystemType & _coord_sys
const ADVariableGradient & _grad_p
const unsigned int _rz_radial_coord
The radial coordinate index for RZ coordinate systems.
Object for tracking what kernels have been added to an INSAD simulation.
void set(const std::string &name, const T &value, SubdomainID sub_id)
Set the internal parameter name to value.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
unsigned int _qp
unsigned int _i
FEProblemBase & _fe_problem
static const std::string pressure
Definition NS.h:57