LCOV - code coverage report
Current view: top level - src/bcs - NavierStokesLHDGVelocityDirichletBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 93 95 97.9 %
Date: 2025-08-14 10:14:56 Functions: 7 7 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 "NavierStokesLHDGVelocityDirichletBC.h"
      11             : 
      12             : registerMooseObject("NavierStokesApp", NavierStokesLHDGVelocityDirichletBC);
      13             : 
      14             : InputParameters
      15        1264 : NavierStokesLHDGVelocityDirichletBC::validParams()
      16             : {
      17        1264 :   auto params = IntegratedBC::validParams();
      18        1264 :   params += NavierStokesLHDGAssemblyHelper::validParams();
      19        1264 :   params.addClassDescription("Weakly imposes Dirichlet boundary conditions for the velocity for a "
      20             :                              "hybridized discretization of the Navier-Stokes equations");
      21        2528 :   params.addRequiredParam<MooseFunctorName>("dirichlet_u",
      22             :                                             "The Dirichlet value for the x-component of velocity");
      23        2528 :   params.addRequiredParam<MooseFunctorName>("dirichlet_v",
      24             :                                             "The Dirichlet value for the y-component of velocity");
      25        2528 :   params.addParam<MooseFunctorName>(
      26        2528 :       "dirichlet_w", 0, "The Dirichlet value for the z-component of velocity");
      27        2528 :   params.renameParam("variable", "u", "The x-component of velocity");
      28        1264 :   return params;
      29           0 : }
      30             : 
      31         632 : NavierStokesLHDGVelocityDirichletBC::NavierStokesLHDGVelocityDirichletBC(
      32         632 :     const InputParameters & parameters)
      33             :   : IntegratedBC(parameters),
      34         632 :     NavierStokesLHDGAssemblyHelper(this, this, this, this, _fe_problem, _sys, _mesh, _tid),
      35         632 :     _cached_side(libMesh::invalid_uint)
      36             : {
      37         632 :   if (_mesh.dimension() > 2 && !isParamSetByUser("dirichlet_w"))
      38           0 :     paramError("dirichlet_w",
      39             :                "For a 3D simulation, the Dirichlet value of the z-velocity must be supplied");
      40             : 
      41        1264 :   _dirichlet_vel[0] = &getFunctor<Real>("dirichlet_u");
      42        1264 :   _dirichlet_vel[1] = &getFunctor<Real>("dirichlet_v");
      43        1264 :   _dirichlet_vel[2] = &getFunctor<Real>("dirichlet_w");
      44         632 : }
      45             : 
      46             : void
      47         632 : NavierStokesLHDGVelocityDirichletBC::initialSetup()
      48             : {
      49             :   // This check must occur after FEProblemBase::init()
      50         632 :   checkCoupling();
      51         632 : }
      52             : 
      53             : void
      54        2216 : NavierStokesLHDGVelocityDirichletBC::jacobianSetup()
      55             : {
      56        2216 :   _cached_elem = nullptr;
      57        2216 :   _cached_side = libMesh::invalid_uint;
      58        2216 : }
      59             : 
      60             : void
      61      272496 : NavierStokesLHDGVelocityDirichletBC::computeOffDiagJacobian(const unsigned int)
      62             : {
      63      272496 :   if ((_cached_elem != _current_elem) || (_cached_side != _current_side))
      64             :   {
      65       38928 :     computeJacobian();
      66       38928 :     _cached_elem = _current_elem;
      67       38928 :     _cached_side = _current_side;
      68             :   }
      69      272496 : }
      70             : 
      71             : void
      72      135448 : NavierStokesLHDGVelocityDirichletBC::computeResidual()
      73             : {
      74      135448 :   _grad_u_vel_re.resize(_qu_dof_indices.size());
      75      135448 :   _u_vel_re.resize(_u_dof_indices.size());
      76      135448 :   _lm_u_vel_re.resize(_lm_u_dof_indices.size());
      77      135448 :   _grad_v_vel_re.resize(_qv_dof_indices.size());
      78      135448 :   _v_vel_re.resize(_v_dof_indices.size());
      79      135448 :   _lm_v_vel_re.resize(_lm_v_dof_indices.size());
      80      135448 :   _p_re.resize(_p_dof_indices.size());
      81             : 
      82             :   // qu, u, lm_u
      83      135448 :   vectorDirichletResidual(*_dirichlet_vel[0],
      84             :                           _JxW,
      85      135448 :                           *_qrule,
      86             :                           _normals,
      87      135448 :                           _current_elem,
      88      135448 :                           _current_side,
      89             :                           _q_point,
      90             :                           _grad_u_vel_re);
      91      135448 :   scalarDirichletResidual(_qu_sol,
      92             :                           _u_sol,
      93             :                           0,
      94      135448 :                           _dirichlet_vel,
      95             :                           _JxW,
      96      135448 :                           *_qrule,
      97             :                           _normals,
      98      135448 :                           _current_elem,
      99      135448 :                           _current_side,
     100             :                           _q_point,
     101             :                           _u_vel_re);
     102             : 
     103             :   // qv, v, lm_v
     104      135448 :   vectorDirichletResidual(*_dirichlet_vel[1],
     105             :                           _JxW,
     106      135448 :                           *_qrule,
     107             :                           _normals,
     108      135448 :                           _current_elem,
     109      135448 :                           _current_side,
     110             :                           _q_point,
     111             :                           _grad_v_vel_re);
     112      135448 :   scalarDirichletResidual(_qv_sol,
     113             :                           _v_sol,
     114             :                           1,
     115             :                           _dirichlet_vel,
     116             :                           _JxW,
     117      135448 :                           *_qrule,
     118             :                           _normals,
     119      135448 :                           _current_elem,
     120      135448 :                           _current_side,
     121             :                           _q_point,
     122             :                           _v_vel_re);
     123             : 
     124             :   // p
     125      135448 :   pressureDirichletResidual(
     126      135448 :       _dirichlet_vel, _JxW, *_qrule, _normals, _current_elem, _current_side, _q_point, _p_re);
     127             : 
     128             :   // Set the LMs on these Dirichlet boundary faces to 0
     129      135448 :   createIdentityResidual(_JxW, *_qrule, _lm_phi_face, _lm_u_sol, _lm_u_vel_re);
     130      135448 :   createIdentityResidual(_JxW, *_qrule, _lm_phi_face, _lm_v_sol, _lm_v_vel_re);
     131             : 
     132      135448 :   addResiduals(_assembly, _grad_u_vel_re, _qu_dof_indices, _grad_u_var.scalingFactor());
     133      135448 :   addResiduals(_assembly, _u_vel_re, _u_dof_indices, _u_var.scalingFactor());
     134      135448 :   addResiduals(_assembly, _lm_u_vel_re, _lm_u_dof_indices, _u_face_var.scalingFactor());
     135      135448 :   addResiduals(_assembly, _grad_v_vel_re, _qv_dof_indices, _grad_v_var.scalingFactor());
     136      135448 :   addResiduals(_assembly, _v_vel_re, _v_dof_indices, _v_var.scalingFactor());
     137      135448 :   addResiduals(_assembly, _lm_v_vel_re, _lm_v_dof_indices, _v_face_var.scalingFactor());
     138      135448 :   addResiduals(_assembly, _p_re, _p_dof_indices, _pressure_var.scalingFactor());
     139      135448 : }
     140             : 
     141             : void
     142       38928 : NavierStokesLHDGVelocityDirichletBC::computeJacobian()
     143             : {
     144       38928 :   _u_grad_u_jac.resize(_u_dof_indices.size(), _qu_dof_indices.size());
     145       38928 :   _u_u_jac.resize(_u_dof_indices.size(), _u_dof_indices.size());
     146       38928 :   _u_p_jac.resize(_u_dof_indices.size(), _p_dof_indices.size());
     147       38928 :   _v_grad_v_jac.resize(_v_dof_indices.size(), _qv_dof_indices.size());
     148       38928 :   _v_v_jac.resize(_v_dof_indices.size(), _v_dof_indices.size());
     149       38928 :   _v_p_jac.resize(_v_dof_indices.size(), _p_dof_indices.size());
     150       38928 :   _lm_u_lm_u_jac.resize(_lm_u_dof_indices.size(), _lm_u_dof_indices.size());
     151       38928 :   _lm_v_lm_v_jac.resize(_lm_v_dof_indices.size(), _lm_v_dof_indices.size());
     152             : 
     153             :   // qu, u, lm_u
     154       38928 :   scalarDirichletJacobian(0, _JxW, *_qrule, _normals, _u_grad_u_jac, _u_u_jac, _u_p_jac);
     155             : 
     156             :   // qv, v, lm_v
     157       38928 :   scalarDirichletJacobian(1, _JxW, *_qrule, _normals, _v_grad_v_jac, _v_v_jac, _v_p_jac);
     158             : 
     159             :   // Set the LMs on these Dirichlet boundary faces to 0
     160       38928 :   createIdentityJacobian(_JxW, *_qrule, _lm_phi_face, _lm_u_lm_u_jac);
     161       38928 :   createIdentityJacobian(_JxW, *_qrule, _lm_phi_face, _lm_v_lm_v_jac);
     162             : 
     163       38928 :   addJacobian(_assembly, _u_grad_u_jac, _u_dof_indices, _qu_dof_indices, _u_var.scalingFactor());
     164       38928 :   addJacobian(_assembly, _u_u_jac, _u_dof_indices, _u_dof_indices, _u_var.scalingFactor());
     165       38928 :   addJacobian(_assembly, _u_p_jac, _u_dof_indices, _p_dof_indices, _u_var.scalingFactor());
     166       38928 :   addJacobian(_assembly, _v_grad_v_jac, _v_dof_indices, _qv_dof_indices, _v_var.scalingFactor());
     167       38928 :   addJacobian(_assembly, _v_v_jac, _v_dof_indices, _v_dof_indices, _v_var.scalingFactor());
     168       38928 :   addJacobian(_assembly, _v_p_jac, _v_dof_indices, _p_dof_indices, _v_var.scalingFactor());
     169       38928 :   addJacobian(
     170       38928 :       _assembly, _lm_u_lm_u_jac, _lm_u_dof_indices, _lm_u_dof_indices, _u_face_var.scalingFactor());
     171       38928 :   addJacobian(
     172       38928 :       _assembly, _lm_v_lm_v_jac, _lm_v_dof_indices, _lm_v_dof_indices, _v_face_var.scalingFactor());
     173       38928 : }

Generated by: LCOV version 1.14