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 4551 : INSFVElementalKernel::validParams() 14 : { 15 4551 : auto params = FVElementalKernel::validParams(); 16 4551 : params += INSFVMomentumResidualObject::validParams(); 17 4551 : return params; 18 0 : } 19 : 20 2776 : INSFVElementalKernel::INSFVElementalKernel(const InputParameters & params) 21 2776 : : FVElementalKernel(params), INSFVMomentumResidualObject(*this) 22 : { 23 2776 : } 24 : 25 : void 26 5042986 : INSFVElementalKernel::computeResidual() 27 : { 28 5042986 : if (_rc_uo.segregated()) 29 : { 30 810000 : prepareVectorTag(_assembly, _var.number()); 31 810000 : _local_re(0) += 32 810000 : MetaPhysicL::raw_value(computeSegregatedContribution() * _assembly.elemVolume()); 33 810000 : accumulateTaggedLocalResidual(); 34 : } 35 5042986 : } 36 : 37 : void 38 9000 : INSFVElementalKernel::computeJacobian() 39 : { 40 9000 : 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 9000 : } 47 : 48 : void 49 810000 : INSFVElementalKernel::computeResidualAndJacobian() 50 : { 51 810000 : if (_rc_uo.segregated()) 52 : { 53 810000 : const auto r = computeSegregatedContribution() * _assembly.elemVolume(); 54 810000 : addResidualsAndJacobian( 55 1620000 : _assembly, std::array<ADReal, 1>{{r}}, _var.dofIndices(), _var.scalingFactor()); 56 : } 57 810000 : } 58 : 59 : void 60 7491052 : INSFVElementalKernel::addResidualAndJacobian(const ADReal & residual, const dof_id_type dof_index) 61 : { 62 7491052 : addResidualsAndJacobian(_assembly, 63 14982104 : std::array<ADReal, 1>{{residual}}, 64 7491052 : std::array<dof_id_type, 1>{{dof_index}}, 65 7491052 : _var.scalingFactor()); 66 7491052 : }