LCOV - code coverage report
Current view: top level - src/utils - THMUtils.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 26 26 100.0 %
Date: 2025-07-30 13:02:48 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 "THMUtils.h"
      11             : #include "MooseUtils.h"
      12             : #include "MooseTypes.h"
      13             : #include "libmesh/vector_value.h"
      14             : #include "metaphysicl/parallel_dualnumber.h"
      15             : #include "metaphysicl/parallel_numberarray.h"
      16             : #include "metaphysicl/parallel_semidynamicsparsenumberarray.h"
      17             : 
      18             : namespace THM
      19             : {
      20             : 
      21             : void
      22     4506927 : computeOrthogonalDirections(const RealVectorValue & n_unnormalized,
      23             :                             RealVectorValue & t1,
      24             :                             RealVectorValue & t2)
      25             : {
      26     4506927 :   const RealVectorValue n = n_unnormalized.unit();
      27             : 
      28     4506927 :   if (MooseUtils::absoluteFuzzyEqual(std::abs(n(0)), 1.0))
      29             :   {
      30     4444279 :     t1 = RealVectorValue(0, 1, 0);
      31     4444279 :     t2 = RealVectorValue(0, 0, 1);
      32             :   }
      33             :   else
      34             :   {
      35             :     // Gram-Schmidt process to get first
      36             :     RealVectorValue ex(1, 0, 0);
      37       62648 :     t1 = ex - (ex * n) * n;
      38       62648 :     t1 = t1.unit();
      39             : 
      40             :     // use cross-product to get second
      41       62648 :     t2 = n.cross(t1);
      42       62648 :     t2 = t2.unit();
      43             :   }
      44     4506927 : }
      45             : 
      46             : void
      47       62252 : allGatherADVectorMap(const Parallel::Communicator & comm,
      48             :                      std::map<dof_id_type, std::vector<ADReal>> & this_map)
      49             : {
      50             :   std::vector<std::map<dof_id_type, std::vector<ADReal>>> all_maps;
      51       62252 :   comm.allgather(this_map, all_maps);
      52      160576 :   for (auto & one_map : all_maps)
      53     2011340 :     for (auto & it : one_map)
      54     1913016 :       this_map[it.first] = it.second;
      55       62252 : }
      56             : 
      57             : void
      58        3692 : allGatherADVectorMapSum(const Parallel::Communicator & comm,
      59             :                         std::map<dof_id_type, std::vector<ADReal>> & this_map)
      60             : {
      61             :   std::vector<std::map<dof_id_type, std::vector<ADReal>>> all_maps;
      62        3692 :   comm.allgather(this_map, all_maps);
      63             :   this_map.clear();
      64       10224 :   for (auto & one_map : all_maps)
      65      235154 :     for (auto & it : one_map)
      66      228622 :       if (this_map.find(it.first) == this_map.end())
      67      221390 :         this_map[it.first] = it.second;
      68             :       else
      69             :       {
      70        7232 :         auto & existing = this_map[it.first];
      71       21696 :         for (const auto i : index_range(existing))
      72       14464 :           existing[i] += it.second[i];
      73             :       }
      74        3692 : }
      75             : }

Generated by: LCOV version 1.14