LCOV - code coverage report
Current view: top level - src/userobjects - FlowChannelHeatStructureCouplerUserObject.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #33187 (5aa0b2) with base d7c4bd Lines: 45 48 93.8 %
Date: 2026-06-30 12:25:31 Functions: 7 7 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 "FlowChannelHeatStructureCouplerUserObject.h"
      11             : #include "THMUtils.h"
      12             : 
      13             : InputParameters
      14         320 : FlowChannelHeatStructureCouplerUserObject::validParams()
      15             : {
      16         320 :   InputParameters params = ElementUserObject::validParams();
      17         320 :   params += ADFunctorInterface::validParams();
      18         640 :   params.addRequiredParam<MeshAlignment *>("_mesh_alignment", "Mesh alignment object");
      19         320 :   params.addClassDescription(
      20             :       "Base class for caching quantities computed between flow channels and heat structures.");
      21         320 :   return params;
      22           0 : }
      23             : 
      24         173 : FlowChannelHeatStructureCouplerUserObject::FlowChannelHeatStructureCouplerUserObject(
      25         173 :     const InputParameters & parameters)
      26             :   : ElementUserObject(parameters),
      27             :     ADFunctorInterface(this),
      28         173 :     _fc_elem_id(0),
      29         173 :     _hs_elem_id(0),
      30         173 :     _fc_qp(0),
      31         173 :     _hs_qp(0),
      32         346 :     _mesh_alignment(*getParam<MeshAlignment *>("_mesh_alignment"))
      33             : {
      34         173 :   _mesh_alignment.buildCoupledElemQpIndexMap(_assembly);
      35         173 : }
      36             : 
      37             : void
      38       10995 : FlowChannelHeatStructureCouplerUserObject::initialize()
      39             : {
      40       10995 :   const auto map_ptrs = getCachedQuantityMaps();
      41       32985 :   for (const auto map_ptr : map_ptrs)
      42             :     map_ptr->clear();
      43       10995 : }
      44             : 
      45             : void
      46       56403 : FlowChannelHeatStructureCouplerUserObject::execute()
      47             : {
      48       56403 :   unsigned int n_qpts = _qrule->n_points();
      49             : 
      50       56403 :   _fc_elem_id = _current_elem->id();
      51       56403 :   _hs_elem_id = _mesh_alignment.getCoupledElemID(_fc_elem_id);
      52             : 
      53       56403 :   const auto map_ptrs = getCachedQuantityMaps();
      54      169209 :   for (const auto map_ptr : map_ptrs)
      55             :   {
      56      112806 :     (*map_ptr)[_fc_elem_id].resize(n_qpts);
      57      112806 :     (*map_ptr)[_hs_elem_id].resize(n_qpts);
      58             :   }
      59             : 
      60      169209 :   for (_fc_qp = 0; _fc_qp < n_qpts; _fc_qp++)
      61             :   {
      62      112806 :     _hs_qp = _mesh_alignment.getCoupledElemQpIndex(_fc_elem_id, _fc_qp);
      63      112806 :     computeQpCachedQuantities();
      64             :   }
      65       56403 : }
      66             : 
      67             : void
      68        1470 : FlowChannelHeatStructureCouplerUserObject::threadJoin(const UserObject & uo)
      69             : {
      70             :   const auto & fc_hs_uo = static_cast<const FlowChannelHeatStructureCouplerUserObject &>(uo);
      71             : 
      72        1470 :   const auto map_ptrs = getCachedQuantityMaps();
      73        1470 :   const auto other_map_ptrs = fc_hs_uo.getCachedQuantityMaps();
      74             : 
      75        4410 :   for (unsigned int i = 0; i < map_ptrs.size(); ++i)
      76        2940 :     for (auto & it : *other_map_ptrs[i])
      77           0 :       (*map_ptrs[i])[it.first] = it.second;
      78        1470 : }
      79             : 
      80             : void
      81        9525 : FlowChannelHeatStructureCouplerUserObject::finalize()
      82             : {
      83        9525 :   const auto map_ptrs = getCachedQuantityMaps();
      84       28575 :   for (const auto map_ptr : map_ptrs)
      85       19050 :     THM::allGatherADVectorMap(comm(), *map_ptr);
      86        9525 : }
      87             : 
      88             : const std::vector<ADReal> &
      89     1102260 : FlowChannelHeatStructureCouplerUserObject::getCachedQuantity(
      90             :     dof_id_type elem_id,
      91             :     const std::map<dof_id_type, std::vector<ADReal>> & elem_id_to_values,
      92             :     const std::string & description) const
      93             : {
      94             :   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
      95             : 
      96             :   auto it = elem_id_to_values.find(elem_id);
      97     1102260 :   if (it != elem_id_to_values.end())
      98     1102260 :     return it->second;
      99             :   else
     100           0 :     mooseError(name(),
     101             :                ": The ",
     102             :                description,
     103             :                " for element ",
     104             :                elem_id,
     105             :                " was requested but not computed.");
     106             : }

Generated by: LCOV version 1.14