LCOV - code coverage report
Current view: top level - include/kernels - ConservativeAdvection.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31730 (e8b711) with base e0c998 Lines: 1 1 100.0 %
Date: 2025-10-29 16:49:47 Functions: 1 2 50.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             : #pragma once
      11             : 
      12             : #include "GenericKernel.h"
      13             : #include "libmesh/dense_vector.h"
      14             : 
      15             : /**
      16             :  * Advection of the variable by the velocity provided by the user.
      17             :  * Options for numerical stabilization are: none; full upwinding
      18             :  */
      19             : template <bool is_ad>
      20             : class ConservativeAdvectionTempl : public GenericKernel<is_ad>
      21             : {
      22             : public:
      23             :   static InputParameters generalParams();
      24             :   static InputParameters validParams();
      25             : 
      26             :   ConservativeAdvectionTempl(const InputParameters & parameters);
      27             : 
      28             : protected:
      29             :   virtual GenericReal<is_ad> computeQpResidual() override;
      30             :   virtual Real computeQpJacobian() override;
      31             :   virtual Real computeQpOffDiagJacobian(unsigned int jvar) override;
      32             :   virtual void computeResidual() override;
      33             :   virtual void computeJacobian() override;
      34      623080 :   virtual const GenericReal<is_ad> & getUNodal(const std::size_t n) const { return _u_nodal[n]; }
      35             : 
      36             :   /// Material property multiplied against the velocity to scale advection strength
      37             :   const GenericMaterialProperty<Real, is_ad> & _scalar;
      38             : 
      39             :   /// Flag to determine if coupled variable is present
      40             :   const bool _coupled_variable_present;
      41             : 
      42             :   /// Coupled variable variable number
      43             :   const unsigned int _coupled_variable_var;
      44             : 
      45             :   /// advection velocity
      46             :   const MooseArray<GenericRealVectorValue<is_ad>> * _velocity;
      47             : 
      48             :   /// Flag to determine if user supplied variable is used as advective quantity
      49             :   const bool _user_supplied_adv_quant;
      50             : 
      51             :   /// Quantity, as a variable value, that is advected. Defaults to the equation variable if unspecified
      52             :   const MooseArray<GenericReal<is_ad>> & _adv_quant;
      53             : 
      54             :   /// enum to make the code clearer
      55             :   enum class JacRes
      56             :   {
      57             :     CALCULATE_RESIDUAL = 0,
      58             :     CALCULATE_JACOBIAN = 1
      59             :   };
      60             : 
      61             :   /// Type of upwinding
      62             :   const enum class UpwindingType { none, full } _upwinding;
      63             : 
      64             :   /// Nodal value of u, used for full upwinding
      65             :   const GenericVariableValue<is_ad> & _u_nodal;
      66             : 
      67             :   /// In the full-upwind scheme, whether a node is an upwind node
      68             :   std::vector<bool> _upwind_node;
      69             : 
      70             :   /// In the full-upwind scheme d(total_mass_out)/d(variable_at_node_i)
      71             :   std::vector<GenericReal<is_ad>> _dtotal_mass_out;
      72             : 
      73             :   /// Returns - _grad_test * velocity
      74             :   virtual GenericReal<is_ad> negSpeedQp() const;
      75             : 
      76             :   /// Calculates the fully-upwind Residual and Jacobian (depending on res_or_jac)
      77             :   void fullUpwind(JacRes res_or_jac);
      78             : 
      79             :   usingGenericKernelMembers;
      80             : 
      81             : private:
      82             :   /// A container for holding the local residuals
      83             :   libMesh::DenseVector<GenericReal<is_ad>> _my_local_re;
      84             : };
      85             : 
      86             : typedef ConservativeAdvectionTempl<false> ConservativeAdvection;
      87             : typedef ConservativeAdvectionTempl<true> ADConservativeAdvection;

Generated by: LCOV version 1.14