LCOV - code coverage report
Current view: top level - src/bcs - ADConservativeAdvectionBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 32 36 88.9 %
Date: 2025-07-17 01:28:37 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 "ADConservativeAdvectionBC.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("MooseApp", ADConservativeAdvectionBC);
      14             : 
      15             : InputParameters
      16       14315 : ADConservativeAdvectionBC::validParams()
      17             : {
      18       14315 :   InputParameters params = ADIntegratedBC::validParams();
      19       14315 :   params.addParam<MaterialPropertyName>(
      20             :       "velocity_mat_prop",
      21             :       "Velocity vector as a material property. Should be provided when we want the velocity value "
      22             :       "to be determined implicitly (e.g. we don't have a Dirichlet condition)");
      23       14315 :   params.addParam<FunctionName>("velocity_function",
      24             :                                 "Function describing the values of velocity on the boundary.");
      25       14315 :   params.addClassDescription(
      26             :       "Boundary condition for advection when it is integrated by parts. Supports Dirichlet "
      27             :       "(inlet-like) and implicit (outlet-like) conditions.");
      28       14315 :   params.addParam<MaterialPropertyName>("advected_quantity",
      29             :                                         "An optional material property to be advected. If not "
      30             :                                         "supplied, then the variable will be used.");
      31       14315 :   params.addParam<FunctionName>("primal_dirichlet_value",
      32             :                                 "The value of the primal variable on the boundary.");
      33       42945 :   params.addParam<MaterialPropertyName>(
      34             :       "primal_coefficient",
      35       28630 :       1,
      36             :       "If a primal Dirichlet value is supplied, then a coefficient may be optionally multiplied "
      37             :       "that multiples the Dirichlet value");
      38       14315 :   return params;
      39           0 : }
      40             : 
      41          26 : ADConservativeAdvectionBC::ADConservativeAdvectionBC(const InputParameters & parameters)
      42             :   : ADIntegratedBC(parameters),
      43          52 :     _velocity_mat_prop(isParamValid("velocity_mat_prop")
      44          26 :                            ? &getADMaterialProperty<RealVectorValue>("velocity_mat_prop")
      45             :                            : nullptr),
      46          26 :     _velocity_function(isParamValid("velocity_function") ? &getFunction("velocity_function")
      47             :                                                          : nullptr),
      48          52 :     _adv_quant(isParamValid("advected_quantity")
      49          26 :                    ? getADMaterialProperty<Real>("advected_quantity").get()
      50             :                    : _u),
      51          26 :     _primal_dirichlet(
      52          26 :         isParamValid("primal_dirichlet_value") ? &getFunction("primal_dirichlet_value") : nullptr),
      53          52 :     _primal_coeff(getADMaterialProperty<Real>("primal_coefficient"))
      54             : {
      55          26 :   if (isParamSetByUser("primal_coefficient") && !_primal_dirichlet)
      56           0 :     paramError("primal_coefficient",
      57             :                "This parameter should only be provided when 'primal_dirichlet_value' is provided");
      58          26 :   if (static_cast<bool>(_primal_dirichlet) + isParamValid("advected_quantity") > 1)
      59           0 :     mooseError("Only one of 'primal_dirichlet_value' or 'advected_quantity' should be provided");
      60          26 :   if (static_cast<bool>(_velocity_mat_prop) + static_cast<bool>(_velocity_function) != 1)
      61           0 :     mooseError("Exactly one of 'velocity_mat_prop' or 'velocity_function' should be provided");
      62          26 : }
      63             : 
      64             : ADReal
      65        2688 : ADConservativeAdvectionBC::computeQpResidual()
      66             : {
      67             :   const auto vdotn =
      68        5376 :       (_velocity_mat_prop ? (*_velocity_mat_prop)[_qp]
      69        1344 :                           : ADRealVectorValue(_velocity_function->vectorValue(_t, _q_point[_qp]))) *
      70        5376 :       _normals[_qp];
      71             : 
      72        2688 :   if (_primal_dirichlet)
      73        2688 :     return _test[_i][_qp] * vdotn * _primal_dirichlet->value(_t, _q_point[_qp]) *
      74        2688 :            _primal_coeff[_qp];
      75             :   else
      76        2688 :     return _test[_i][_qp] * vdotn * _adv_quant[_qp];
      77        2688 : }

Generated by: LCOV version 1.14