LCOV - code coverage report
Current view: top level - src/markers - ComboMarker.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 30 31 96.8 %
Date: 2026-05-29 20:35:17 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 "ComboMarker.h"
      11             : #include "FEProblemBase.h"
      12             : 
      13             : registerMooseObject("MooseApp", ComboMarker);
      14             : 
      15             : InputParameters
      16        3207 : ComboMarker::validParams()
      17             : {
      18        3207 :   InputParameters params = Marker::validParams();
      19       12828 :   params.addRequiredParam<std::vector<MarkerName>>(
      20             :       "markers", "A list of marker names to combine into a single marker.");
      21        3207 :   params.addClassDescription("A marker that converts many markers into a single marker by "
      22             :                              "considering the maximum value of the listed markers (i.e., "
      23             :                              "refinement takes precedent).");
      24        3207 :   return params;
      25           0 : }
      26             : 
      27          76 : ComboMarker::ComboMarker(const InputParameters & parameters)
      28             :   : Marker(parameters),
      29          76 :     _names(getParam<std::vector<MarkerName>>("markers")),
      30         152 :     _block_restriction_mismatch(false)
      31             : {
      32         241 :   for (const auto & marker_name : _names)
      33         165 :     _markers.push_back(&getMarkerValue(marker_name));
      34             : 
      35          76 :   std::string other_block_restricted = "";
      36         241 :   for (const auto & marker_name : _names)
      37             :   {
      38         165 :     const auto var_ptr = &_subproblem.getVariable(_tid, marker_name);
      39         165 :     _marker_variables.push_back(var_ptr);
      40             : 
      41             :     // Check block restrictions
      42         165 :     if (blockIDs() != var_ptr->blockIDs())
      43          26 :       other_block_restricted += (other_block_restricted == "" ? "" : ", ") + marker_name;
      44             :   }
      45             : 
      46          76 :   if (other_block_restricted != "")
      47             :   {
      48          13 :     _block_restriction_mismatch = true;
      49          13 :     paramInfo(
      50             :         "markers",
      51          26 :         "Combo marker and markers '" + other_block_restricted +
      52             :             "' do not share the same block restrictions. Markers outside their block restriction "
      53             :             "will not mark.");
      54             :   }
      55          76 : }
      56             : 
      57             : Marker::MarkerValue
      58       33078 : ComboMarker::computeElementMarker()
      59             : {
      60             :   // We start with DONT_MARK because it's -1
      61       33078 :   MarkerValue marker_value = DONT_MARK;
      62             : 
      63             :   // No need to check block restrictions if they all match
      64       33078 :   if (!_block_restriction_mismatch)
      65      105338 :     for (const auto & var : _markers)
      66       74364 :       marker_value = std::max(marker_value, static_cast<MarkerValue>((*var)[0]));
      67             :   else
      68        6312 :     for (const auto i : index_range(_markers))
      69        4208 :       if (_marker_variables[i]->hasBlocks(_current_elem->subdomain_id()))
      70        2104 :         marker_value = std::max(marker_value, static_cast<MarkerValue>((*_markers[i])[0]));
      71             : 
      72       33078 :   return marker_value;
      73             : }

Generated by: LCOV version 1.14