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 "INSFVElementalKernel.h" 11 : 12 : InputParameters 13 2664 : INSFVElementalKernel::validParams() 14 : { 15 2664 : auto params = FVElementalKernel::validParams(); 16 2664 : params += INSFVMomentumResidualObject::validParams(); 17 2664 : return params; 18 0 : } 19 : 20 1591 : INSFVElementalKernel::INSFVElementalKernel(const InputParameters & params) 21 1591 : : FVElementalKernel(params), INSFVMomentumResidualObject(*this) 22 : { 23 1591 : } 24 : 25 : void 26 3389276 : INSFVElementalKernel::computeResidual() 27 : { 28 3389276 : if (_rc_uo.segregated()) 29 : { 30 675000 : prepareVectorTag(_assembly, _var.number()); 31 675000 : _local_re(0) += 32 675000 : MetaPhysicL::raw_value(computeSegregatedContribution() * _assembly.elemVolume()); 33 675000 : accumulateTaggedLocalResidual(); 34 : } 35 3389276 : } 36 : 37 : void 38 6000 : INSFVElementalKernel::computeJacobian() 39 : { 40 6000 : if (_rc_uo.segregated()) 41 : { 42 0 : const auto r = computeSegregatedContribution() * _assembly.elemVolume(); 43 : mooseAssert(_var.dofIndices().size() == 1, "We're currently built to use CONSTANT MONOMIALS"); 44 0 : addJacobian(_assembly, std::array<ADReal, 1>{{r}}, _var.dofIndices(), _var.scalingFactor()); 45 : } 46 6000 : } 47 : 48 : void 49 675000 : INSFVElementalKernel::computeResidualAndJacobian() 50 : { 51 675000 : if (_rc_uo.segregated()) 52 : { 53 675000 : const auto r = computeSegregatedContribution() * _assembly.elemVolume(); 54 675000 : addResidualsAndJacobian( 55 1350000 : _assembly, std::array<ADReal, 1>{{r}}, _var.dofIndices(), _var.scalingFactor()); 56 : } 57 675000 : } 58 : 59 : void 60 4794494 : INSFVElementalKernel::addResidualAndJacobian(const ADReal & residual, const dof_id_type dof_index) 61 : { 62 4794494 : addResidualsAndJacobian(_assembly, 63 9588988 : std::array<ADReal, 1>{{residual}}, 64 4794494 : std::array<dof_id_type, 1>{{dof_index}}, 65 4794494 : _var.scalingFactor()); 66 4794494 : }