LCOV - code coverage report
Current view: top level - include/kernels - INSADMomentumMeshAdvection.h (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 17 19 89.5 %
Date: 2025-08-14 10:14:56 Functions: 4 4 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             : #pragma once
      11             : 
      12             : #include "ADKernelValue.h"
      13             : #include "INSADObjectTracker.h"
      14             : 
      15             : /**
      16             :  * Subtracts the mesh velocity from the convection term in the Navier-Stokes momentum equation
      17             :  */
      18             : class INSADMomentumMeshAdvection : public ADVectorKernelValue
      19             : {
      20             : public:
      21             :   static InputParameters validParams();
      22             :   static InputParameters displacementParams();
      23             :   template <typename T>
      24             :   static void setDisplacementParams(T & mesh_convection_obj);
      25             : 
      26             :   INSADMomentumMeshAdvection(const InputParameters & parameters);
      27             : 
      28             : protected:
      29             :   virtual ADRealVectorValue precomputeQpResidual() override;
      30             : 
      31             :   /// The strong residual for this object, computed by material classes to eliminate computation
      32             :   /// duplication in simulations in which we have stabilization
      33             :   const ADMaterialProperty<RealVectorValue> & _advected_mesh_strong_residual;
      34             : };
      35             : 
      36             : template <typename T>
      37             : void
      38          88 : INSADMomentumMeshAdvection::setDisplacementParams(T & mesh_convection_obj)
      39             : {
      40         352 :   auto check_coupled = [&](const auto & var_name)
      41             :   {
      42         528 :     if (mesh_convection_obj.coupledComponents(var_name) > 1)
      43           0 :       mesh_convection_obj.paramError(
      44             :           var_name, "Only one variable should be used for '", var_name, "'");
      45         528 :     if (mesh_convection_obj.isCoupledConstant(var_name))
      46           0 :       mesh_convection_obj.paramError(var_name, "Displacement variables cannot be constants");
      47             :   };
      48          88 :   check_coupled("disp_x");
      49          88 :   check_coupled("disp_y");
      50          88 :   check_coupled("disp_z");
      51             : 
      52          88 :   if (mesh_convection_obj._tid == 0)
      53             :   {
      54             :     // Bypass the UserObjectInterface method because it requires a UserObjectName param which we
      55             :     // don't need
      56          76 :     auto & obj_tracker = mesh_convection_obj._fe_problem.template getUserObject<INSADObjectTracker>(
      57             :         "ins_ad_object_tracker");
      58         152 :     for (const auto block_id : mesh_convection_obj.blockIDs())
      59             :     {
      60          76 :       obj_tracker.set("has_advected_mesh", true, block_id);
      61         152 :       obj_tracker.set("disp_x", mesh_convection_obj.coupledName("disp_x"), block_id);
      62         152 :       if (mesh_convection_obj.isParamValid("disp_y"))
      63         228 :         obj_tracker.set("disp_y", mesh_convection_obj.coupledName("disp_y"), block_id);
      64         152 :       if (mesh_convection_obj.isParamValid("disp_z"))
      65         114 :         obj_tracker.set("disp_z", mesh_convection_obj.coupledName("disp_z"), block_id);
      66             :     }
      67             :   }
      68          88 : }

Generated by: LCOV version 1.14