LCOV - code coverage report
Current view: top level - src/kernels - INSADMomentumCoupledForce.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 22 24 91.7 %
Date: 2025-08-14 10:14:56 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 "INSADMomentumCoupledForce.h"
      11             : #include "INSADObjectTracker.h"
      12             : #include "FEProblemBase.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", INSADMomentumCoupledForce);
      15             : 
      16             : InputParameters
      17         527 : INSADMomentumCoupledForce::validParams()
      18             : {
      19         527 :   InputParameters params = ADVectorKernelValue::validParams();
      20         527 :   params.addClassDescription(
      21             :       "Computes a body force due to a coupled vector variable or a vector function");
      22        1054 :   params.addCoupledVar(
      23             :       "coupled_vector_var",
      24             :       "The coupled vector variable applying the force. Positive variable components represent "
      25             :       "momentum sources in that component direction, e.g. if the x-component is positive then this "
      26             :       "object imposes a momentum source in the +x direction. Multiple variable names can be "
      27             :       "provided; the result will be a summed force.");
      28        1054 :   params.addParam<std::vector<FunctionName>>(
      29             :       "vector_function",
      30             :       "A vector function which can be used to stand-in for the 'coupled_vector_var' param. "
      31             :       "Multiple function names can be provided; the result will be a summed force");
      32         527 :   return params;
      33           0 : }
      34             : 
      35         286 : INSADMomentumCoupledForce::INSADMomentumCoupledForce(const InputParameters & parameters)
      36             :   : ADVectorKernelValue(parameters),
      37         286 :     _coupled_force_strong_residual(
      38         286 :         getADMaterialProperty<RealVectorValue>("coupled_force_strong_residual"))
      39             : {
      40         286 :   bool has_coupled = isCoupled("coupled_vector_var");
      41         286 :   bool has_function = isParamValid("vector_function");
      42         286 :   if (!has_coupled && !has_function)
      43           0 :     mooseError("Either the 'coupled_vector_var' or 'vector_function' param must be set for the "
      44             :                "'INSADMomentumCoupledForce' object");
      45             : 
      46             :   // Bypass the UserObjectInterface method because it requires a UserObjectName param which we
      47             :   // don't need
      48             :   auto & obj_tracker = const_cast<INSADObjectTracker &>(
      49         286 :       _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker"));
      50         572 :   for (const auto block_id : blockIDs())
      51             :   {
      52         286 :     obj_tracker.set("has_coupled_force", true, block_id);
      53         286 :     if (has_coupled)
      54         528 :       obj_tracker.set(
      55             :           "coupled_force_var", getParam<std::vector<VariableName>>("coupled_vector_var"), block_id);
      56         286 :     if (has_function)
      57         462 :       obj_tracker.set("coupled_force_vector_function",
      58             :                       getParam<std::vector<FunctionName>>("vector_function"),
      59             :                       block_id);
      60             :   }
      61         286 : }
      62             : 
      63             : ADRealVectorValue
      64     1668432 : INSADMomentumCoupledForce::precomputeQpResidual()
      65             : {
      66     1668432 :   return _coupled_force_strong_residual[_qp];
      67             : }

Generated by: LCOV version 1.14