LCOV - code coverage report
Current view: top level - src/kernels - INSADBoussinesqBodyForce.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 25 27 92.6 %
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 "INSADBoussinesqBodyForce.h"
      11             : #include "INSADObjectTracker.h"
      12             : #include "FEProblemBase.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", INSADBoussinesqBodyForce);
      15             : 
      16             : InputParameters
      17         263 : INSADBoussinesqBodyForce::validParams()
      18             : {
      19         263 :   InputParameters params = ADVectorKernelValue::validParams();
      20         263 :   params.addClassDescription("Computes a body force for natural convection buoyancy.");
      21         526 :   params.addRequiredCoupledVar("temperature", "temperature variable, for off diagonal jacobian");
      22         526 :   params.addRequiredParam<RealVectorValue>("gravity", "Direction of the gravity vector");
      23         526 :   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         526 :   params.addParam<MaterialPropertyName>(
      28             :       "ref_temp", "temp_ref", "The name of the reference temperature");
      29         263 :   return params;
      30           0 : }
      31             : 
      32         154 : INSADBoussinesqBodyForce::INSADBoussinesqBodyForce(const InputParameters & parameters)
      33             :   : ADVectorKernelValue(parameters),
      34         154 :     _boussinesq_strong_residual(
      35         154 :         getADMaterialProperty<RealVectorValue>("boussinesq_strong_residual"))
      36             : {
      37         308 :   if (coupledComponents("temperature") != 1)
      38           0 :     paramError("temperature", "Only one variable should be used for 'temperature'");
      39             : 
      40         154 :   if (_tid == 0)
      41             :   {
      42             :     // Bypass the UserObjectInterface method because it requires a UserObjectName param which we
      43             :     // don't need
      44         109 :     auto & obj_tracker = _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker");
      45             : 
      46         109 :     const auto alpha_name = getMaterialPropertyName("alpha_name");
      47         109 :     const auto ref_temp = getMaterialPropertyName("ref_temp");
      48             : 
      49         218 :     for (const auto block_id : blockIDs())
      50             :     {
      51         109 :       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         109 :       obj_tracker.set("alpha", alpha_name, block_id);
      58         109 :       obj_tracker.set("ref_temp", ref_temp, block_id);
      59             : 
      60         218 :       obj_tracker.set("temperature", getVar("temperature", 0)->name(), block_id);
      61         327 :       obj_tracker.set("gravity", getParam<RealVectorValue>("gravity"), block_id);
      62             :     }
      63             :   }
      64         154 : }
      65             : 
      66             : ADRealVectorValue
      67    15462624 : INSADBoussinesqBodyForce::precomputeQpResidual()
      68             : {
      69    15462624 :   return _boussinesq_strong_residual[_qp];
      70             : }

Generated by: LCOV version 1.14