Line data Source code
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 : 18 : InputParameters 19 1440 : INSADMomentumPressure::validParams() 20 : { 21 1440 : InputParameters params = ADVectorKernel::validParams(); 22 1440 : params.addClassDescription("Adds the pressure term to the INS momentum equation"); 23 1440 : params.addRequiredCoupledVar(NS::pressure, "The pressure"); 24 2880 : params.addParam<bool>( 25 2880 : "integrate_p_by_parts", true, "Whether to integrate the pressure term by parts"); 26 1440 : return params; 27 0 : } 28 : 29 769 : INSADMomentumPressure::INSADMomentumPressure(const InputParameters & parameters) 30 : : ADVectorKernel(parameters), 31 769 : _integrate_p_by_parts(getParam<bool>("integrate_p_by_parts")), 32 769 : _p(adCoupledValue(NS::pressure)), 33 769 : _grad_p(adCoupledGradient(NS::pressure)), 34 769 : _coord_sys(_assembly.coordSystem()), 35 1538 : _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 769 : _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker")); 41 1548 : for (const auto block_id : blockIDs()) 42 1558 : obj_tracker.set("integrate_p_by_parts", _integrate_p_by_parts, block_id); 43 769 : } 44 : 45 : ADReal 46 248430656 : INSADMomentumPressure::computeQpResidual() 47 : { 48 248430656 : if (_integrate_p_by_parts) 49 : { 50 239290556 : ADReal residual = -_p[_qp] * _grad_test[_i][_qp].tr(); 51 239290556 : if (_coord_sys == Moose::COORD_RZ) 52 : { 53 55933704 : const auto r_component_residual = -_p[_qp] / _ad_q_point[_qp](_rz_radial_coord); 54 : ADRealVectorValue rz_residual; 55 27966852 : rz_residual(_rz_radial_coord) = r_component_residual; 56 27966852 : residual += rz_residual * _test[_i][_qp]; 57 : } 58 239290556 : return residual; 59 : } 60 : else 61 9140100 : return _test[_i][_qp] * _grad_p[_qp]; 62 : }