LCOV - code coverage report
Current view: top level - src/kernels - INSADBoussinesqBodyForce.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 25 27 92.6 %
Date: 2026-05-29 20:37:52 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 "INSADBoussinesqBodyForce.h"
      11             : #include "INSADObjectTracker.h"
      12             : #include "FEProblemBase.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", INSADBoussinesqBodyForce);
      15             : 
      16             : InputParameters
      17         161 : INSADBoussinesqBodyForce::validParams()
      18             : {
      19         161 :   InputParameters params = ADVectorKernelValue::validParams();
      20         161 :   params.addClassDescription("Computes a body force for natural convection buoyancy.");
      21         322 :   params.addRequiredCoupledVar("temperature", "temperature variable, for off diagonal jacobian");
      22         322 :   params.addRequiredParam<RealVectorValue>("gravity", "Direction of the gravity vector");
      23         322 :   params.addParam<MaterialPropertyName>("alpha_name",
      24             :                                         "alpha",
      25             :                                         "The name of the thermal expansion coefficient"
      26             :                                         "this is of the form rho = rho*(1-alpha (T-T_ref))");
      27         322 :   params.addParam<MaterialPropertyName>(
      28             :       "ref_temp", "temp_ref", "The name of the reference temperature");
      29         161 :   return params;
      30           0 : }
      31             : 
      32          94 : INSADBoussinesqBodyForce::INSADBoussinesqBodyForce(const InputParameters & parameters)
      33             :   : ADVectorKernelValue(parameters),
      34          94 :     _boussinesq_strong_residual(
      35          94 :         getADMaterialProperty<RealVectorValue>("boussinesq_strong_residual"))
      36             : {
      37         188 :   if (coupledComponents("temperature") != 1)
      38           0 :     paramError("temperature", "Only one variable should be used for 'temperature'");
      39             : 
      40          94 :   if (_tid == 0)
      41             :   {
      42             :     // Bypass the UserObjectInterface method because it requires a UserObjectName param which we
      43             :     // don't need
      44          67 :     auto & obj_tracker = _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker");
      45             : 
      46          67 :     const auto alpha_name = getMaterialPropertyName("alpha_name");
      47          67 :     const auto ref_temp = getMaterialPropertyName("ref_temp");
      48             : 
      49         134 :     for (const auto block_id : blockIDs())
      50             :     {
      51          67 :       obj_tracker.set("has_boussinesq", true, block_id);
      52             : 
      53             :       // We actually want to perform the material property requests during object construction in
      54             :       // order to ensure that material property dependency is recorded correctly (I don't think this
      55             :       // should actually matter for non-Material MaterialPropertyInterface classes, but might as
      56             :       // well be consistent)
      57          67 :       obj_tracker.set("alpha", alpha_name, block_id);
      58          67 :       obj_tracker.set("ref_temp", ref_temp, block_id);
      59             : 
      60         134 :       obj_tracker.set("temperature", getVar("temperature", 0)->name(), block_id);
      61         201 :       obj_tracker.set("gravity", getParam<RealVectorValue>("gravity"), block_id);
      62             :     }
      63             :   }
      64          94 : }
      65             : 
      66             : ADRealVectorValue
      67    12219984 : INSADBoussinesqBodyForce::precomputeQpResidual()
      68             : {
      69    12219984 :   return _boussinesq_strong_residual[_qp];
      70             : }

Generated by: LCOV version 1.14