LCOV - code coverage report
Current view: top level - src/bcs - DiffusionLHDGDirichletBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 54 55 98.2 %
Date: 2025-08-08 20:01:16 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 "DiffusionLHDGAssemblyHelper.h"
      11             : #include "DiffusionLHDGDirichletBC.h"
      12             : 
      13             : registerMooseObject("MooseApp", DiffusionLHDGDirichletBC);
      14             : 
      15             : InputParameters
      16       14757 : DiffusionLHDGDirichletBC::validParams()
      17             : {
      18       14757 :   auto params = IntegratedBC::validParams();
      19       14757 :   params.addClassDescription("Weakly imposes Dirichlet boundary conditions for a "
      20             :                              "hybridized discretization of a diffusion equation");
      21       14757 :   params.addRequiredParam<MooseFunctorName>("functor",
      22             :                                             "The Dirichlet value for the diffusing specie");
      23       14757 :   params += DiffusionLHDGAssemblyHelper::validParams();
      24       14757 :   params.setDocString("variable", "The diffusing specie concentration");
      25       14757 :   return params;
      26           0 : }
      27             : 
      28         247 : DiffusionLHDGDirichletBC::DiffusionLHDGDirichletBC(const InputParameters & parameters)
      29             :   : IntegratedBC(parameters),
      30         247 :     DiffusionLHDGAssemblyHelper(this, this, this, this, _fe_problem, _sys, _tid),
      31         247 :     _dirichlet_val(getFunctor<Real>("functor")),
      32         247 :     _cached_side(libMesh::invalid_uint)
      33             : {
      34         247 : }
      35             : 
      36             : void
      37         247 : DiffusionLHDGDirichletBC::initialSetup()
      38             : {
      39             :   // This check must occur after FEProblemBase::init()
      40         247 :   checkCoupling();
      41         247 : }
      42             : 
      43             : void
      44       33439 : DiffusionLHDGDirichletBC::computeResidual()
      45             : {
      46             :   // For notation, please read "A superconvergent LDG-hybridizable Galerkin method for second-order
      47             :   // elliptic problems" by Cockburn
      48             : 
      49       33439 :   _vector_re.resize(_qu_dof_indices.size());
      50       33439 :   _scalar_re.resize(_u_dof_indices.size());
      51       33439 :   _lm_re.resize(_lm_u_dof_indices.size());
      52             : 
      53             :   // qu, u
      54       33439 :   vectorDirichletResidual(
      55       33439 :       _dirichlet_val, _JxW, *_qrule, _normals, _current_elem, _current_side, _q_point, _vector_re);
      56       33439 :   scalarDirichletResidual(_qu_sol,
      57             :                           _u_sol,
      58             :                           _dirichlet_val,
      59             :                           _JxW,
      60       33439 :                           *_qrule,
      61             :                           _normals,
      62       33439 :                           _current_elem,
      63       33439 :                           _current_side,
      64             :                           _q_point,
      65       33439 :                           _scalar_re);
      66             : 
      67             :   // Set the LMs on these Dirichlet boundary faces to 0
      68       33439 :   createIdentityResidual(_JxW, *_qrule, _lm_phi_face, _lm_u_sol, _lm_re);
      69             : 
      70       33439 :   addResiduals(_assembly, _vector_re, _qu_dof_indices, _grad_u_var.scalingFactor());
      71       33439 :   addResiduals(_assembly, _scalar_re, _u_dof_indices, _u_var.scalingFactor());
      72       33439 :   addResiduals(_assembly, _lm_re, _lm_u_dof_indices, _u_face_var.scalingFactor());
      73       33439 : }
      74             : 
      75             : void
      76       21966 : DiffusionLHDGDirichletBC::computeJacobian()
      77             : {
      78       21966 :   _scalar_vector_jac.resize(_u_dof_indices.size(), _qu_dof_indices.size());
      79       21966 :   _scalar_scalar_jac.resize(_u_dof_indices.size(), _u_dof_indices.size());
      80       21966 :   _lm_lm_jac.resize(_lm_u_dof_indices.size(), _lm_u_dof_indices.size());
      81             : 
      82       21966 :   scalarDirichletJacobian(_JxW, *_qrule, _normals, _scalar_vector_jac, _scalar_scalar_jac);
      83       21966 :   createIdentityJacobian(_JxW, *_qrule, _lm_phi_face, _lm_lm_jac);
      84             : 
      85       43932 :   addJacobian(
      86       21966 :       _assembly, _scalar_vector_jac, _u_dof_indices, _qu_dof_indices, _u_var.scalingFactor());
      87       43932 :   addJacobian(
      88       21966 :       _assembly, _scalar_scalar_jac, _u_dof_indices, _u_dof_indices, _u_var.scalingFactor());
      89       43932 :   addJacobian(
      90       21966 :       _assembly, _lm_lm_jac, _lm_u_dof_indices, _lm_u_dof_indices, _u_face_var.scalingFactor());
      91       21966 : }
      92             : 
      93             : void
      94         466 : DiffusionLHDGDirichletBC::jacobianSetup()
      95             : {
      96         466 :   _cached_elem = nullptr;
      97         466 :   _cached_side = libMesh::invalid_uint;
      98         466 : }
      99             : 
     100             : void
     101       65898 : DiffusionLHDGDirichletBC::computeOffDiagJacobian(const unsigned int)
     102             : {
     103       65898 :   if ((_cached_elem != _current_elem) || (_cached_side != _current_side))
     104             :   {
     105       21966 :     computeJacobian();
     106       21966 :     _cached_elem = _current_elem;
     107       21966 :     _cached_side = _current_side;
     108             :   }
     109       65898 : }

Generated by: LCOV version 1.14