LCOV - code coverage report
Current view: top level - src/bcs - INSADMomentumNoBCBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 31 31 100.0 %
Date: 2025-08-14 10:14:56 Functions: 3 3 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 "INSADMomentumNoBCBC.h"
      11             : #include "MooseMesh.h"
      12             : #include "INSADObjectTracker.h"
      13             : #include "NS.h"
      14             : 
      15             : registerMooseObject("NavierStokesApp", INSADMomentumNoBCBC);
      16             : 
      17             : InputParameters
      18         142 : INSADMomentumNoBCBC::validParams()
      19             : {
      20         142 :   InputParameters params = ADVectorIntegratedBC::validParams();
      21             : 
      22         142 :   params.addClassDescription("This class implements the 'No BC' boundary condition based on the "
      23             :                              "'Laplace' form of the viscous stress tensor.");
      24         142 :   params.addRequiredCoupledVar(NS::pressure, "pressure");
      25         284 :   params.addParam<bool>("integrate_p_by_parts",
      26         284 :                         true,
      27             :                         "Allows simulations to be run with pressure BC if set to false");
      28         284 :   MooseEnum viscous_form("traction laplace", "laplace");
      29         284 :   params.addParam<MooseEnum>("viscous_form",
      30             :                              viscous_form,
      31             :                              "The form of the viscous term. Options are 'traction' or 'laplace'");
      32             : 
      33             :   // Optional parameters
      34         284 :   params.addParam<MaterialPropertyName>("mu_name", "mu", "The name of the dynamic viscosity");
      35         142 :   return params;
      36         142 : }
      37             : 
      38          77 : INSADMomentumNoBCBC::INSADMomentumNoBCBC(const InputParameters & parameters)
      39             :   : ADVectorIntegratedBC(parameters),
      40         154 :     _p(adCoupledValue(NS::pressure)),
      41         154 :     _integrate_p_by_parts(getParam<bool>("integrate_p_by_parts")),
      42         154 :     _mu(getADMaterialProperty<Real>("mu_name")),
      43         308 :     _form(getParam<MooseEnum>("viscous_form"))
      44             : {
      45             :   std::set<SubdomainID> connected_blocks;
      46         154 :   for (const auto bnd_id : boundaryIDs())
      47             :   {
      48          77 :     const auto & these_blocks = _mesh.getBoundaryConnectedBlocks(bnd_id);
      49          77 :     connected_blocks.insert(these_blocks.begin(), these_blocks.end());
      50             :   }
      51             :   auto & obj_tracker = const_cast<INSADObjectTracker &>(
      52         154 :       _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker"));
      53         154 :   for (const auto block_id : connected_blocks)
      54             :   {
      55          77 :     obj_tracker.set("viscous_form", _form, block_id);
      56         154 :     obj_tracker.set("integrate_p_by_parts", _integrate_p_by_parts, block_id);
      57             :   }
      58          77 : }
      59             : 
      60             : ADReal
      61      229644 : INSADMomentumNoBCBC::computeQpResidual()
      62             : {
      63             :   // The viscous term
      64             :   ADReal residual;
      65      229644 :   if (_form == "laplace")
      66      361368 :     residual = -_mu[_qp] * (_grad_u[_qp] * _normals[_qp]) * _test[_i][_qp];
      67             :   else
      68             :     residual =
      69       97920 :         -_mu[_qp] * ((_grad_u[_qp] + _grad_u[_qp].transpose()) * _normals[_qp]) * _test[_i][_qp];
      70             : 
      71      229644 :   if (_integrate_p_by_parts)
      72             :     // pIn * test
      73      169020 :     residual += _p[_qp] * _normals[_qp] * _test[_i][_qp];
      74             : 
      75      229644 :   return residual;
      76             : }

Generated by: LCOV version 1.14