LCOV - code coverage report
Current view: top level - src/bcs - INSMomentumNoBCBCTractionForm.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 33 39 84.6 %
Date: 2025-08-14 10:14:56 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          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 "INSMomentumNoBCBCTractionForm.h"
      11             : #include "MooseMesh.h"
      12             : 
      13             : registerMooseObject("NavierStokesApp", INSMomentumNoBCBCTractionForm);
      14             : 
      15             : InputParameters
      16          82 : INSMomentumNoBCBCTractionForm::validParams()
      17             : {
      18          82 :   InputParameters params = INSMomentumNoBCBCBase::validParams();
      19             : 
      20          82 :   params.addClassDescription("This class implements the 'No BC' boundary condition based on the "
      21             :                              "'traction' form of the viscous stress tensor.");
      22          82 :   return params;
      23           0 : }
      24             : 
      25          44 : INSMomentumNoBCBCTractionForm::INSMomentumNoBCBCTractionForm(const InputParameters & parameters)
      26          44 :   : INSMomentumNoBCBCBase(parameters)
      27             : {
      28          44 : }
      29             : 
      30             : Real
      31       26928 : INSMomentumNoBCBCTractionForm::computeQpResidual()
      32             : {
      33             :   // Compute n . sigma . v, where n is unit normal and v is the test function.
      34             :   RealTensorValue sigma;
      35             : 
      36             :   // First row
      37       26928 :   sigma(0, 0) = 2. * _mu[_qp] * _grad_u_vel[_qp](0);
      38       26928 :   sigma(0, 1) = _mu[_qp] * (_grad_u_vel[_qp](1) + _grad_v_vel[_qp](0));
      39       26928 :   sigma(0, 2) = _mu[_qp] * (_grad_u_vel[_qp](2) + _grad_w_vel[_qp](0));
      40             : 
      41             :   // Second row
      42       26928 :   sigma(1, 0) = _mu[_qp] * (_grad_v_vel[_qp](0) + _grad_u_vel[_qp](1));
      43       26928 :   sigma(1, 1) = 2. * _mu[_qp] * _grad_v_vel[_qp](1);
      44       26928 :   sigma(1, 2) = _mu[_qp] * (_grad_v_vel[_qp](2) + _grad_w_vel[_qp](1));
      45             : 
      46             :   // Third row
      47       26928 :   sigma(2, 0) = _mu[_qp] * (_grad_w_vel[_qp](0) + _grad_u_vel[_qp](2));
      48       26928 :   sigma(2, 1) = _mu[_qp] * (_grad_w_vel[_qp](1) + _grad_v_vel[_qp](2));
      49       26928 :   sigma(2, 2) = 2. * _mu[_qp] * _grad_w_vel[_qp](2);
      50             : 
      51             :   // If the pressure term is integrated by parts, it is part of the
      52             :   // no-BC-BC, otherwise, it is not.
      53       26928 :   if (_integrate_p_by_parts)
      54             :   {
      55           0 :     sigma(0, 0) -= _p[_qp];
      56           0 :     sigma(1, 1) -= _p[_qp];
      57           0 :     sigma(2, 2) -= _p[_qp];
      58             :   }
      59             : 
      60             :   // Set up test function
      61             :   RealVectorValue test;
      62       26928 :   test(_component) = _test[_i][_qp];
      63             : 
      64       26928 :   return -_normals[_qp] * (sigma * test);
      65             : }
      66             : 
      67             : Real
      68      121824 : INSMomentumNoBCBCTractionForm::computeQpJacobian()
      69             : {
      70             :   // The extra contribution comes from the "2" on the diagonal of the viscous stress tensor
      71      121824 :   return -_mu[_qp] *
      72      121824 :          (_grad_phi[_j][_qp] * _normals[_qp] +
      73      121824 :           _grad_phi[_j][_qp](_component) * _normals[_qp](_component)) *
      74      121824 :          _test[_i][_qp];
      75             : }
      76             : 
      77             : Real
      78      182736 : INSMomentumNoBCBCTractionForm::computeQpOffDiagJacobian(unsigned jvar)
      79             : {
      80      182736 :   if (jvar == _u_vel_var_number)
      81       60912 :     return -_mu[_qp] * _grad_phi[_j][_qp](_component) * _normals[_qp](0) * _test[_i][_qp];
      82             : 
      83      121824 :   else if (jvar == _v_vel_var_number)
      84       60912 :     return -_mu[_qp] * _grad_phi[_j][_qp](_component) * _normals[_qp](1) * _test[_i][_qp];
      85             : 
      86       60912 :   else if (jvar == _w_vel_var_number)
      87           0 :     return -_mu[_qp] * _grad_phi[_j][_qp](_component) * _normals[_qp](2) * _test[_i][_qp];
      88             : 
      89       60912 :   else if (jvar == _p_var_number)
      90             :   {
      91       60912 :     if (_integrate_p_by_parts)
      92           0 :       return _phi[_j][_qp] * _normals[_qp](_component) * _test[_i][_qp];
      93             :     else
      94             :       return 0.;
      95             :   }
      96             : 
      97             :   else
      98             :     return 0.;
      99             : }

Generated by: LCOV version 1.14