LCOV - code coverage report
Current view: top level - src/markers - ComboMarker.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 30 31 96.8 %
Date: 2025-07-17 01:28:37 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       14386 : ComboMarker::validParams()
      17             : {
      18       14386 :   InputParameters params = Marker::validParams();
      19       14386 :   params.addRequiredParam<std::vector<MarkerName>>(
      20             :       "markers", "A list of marker names to combine into a single marker.");
      21       14386 :   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       14386 :   return params;
      25           0 : }
      26             : 
      27          63 : ComboMarker::ComboMarker(const InputParameters & parameters)
      28             :   : Marker(parameters),
      29          63 :     _names(getParam<std::vector<MarkerName>>("markers")),
      30         126 :     _block_restriction_mismatch(false)
      31             : {
      32         202 :   for (const auto & marker_name : _names)
      33         139 :     _markers.push_back(&getMarkerValue(marker_name));
      34             : 
      35          63 :   std::string other_block_restricted = "";
      36         202 :   for (const auto & marker_name : _names)
      37             :   {
      38         139 :     const auto var_ptr = &_subproblem.getVariable(_tid, marker_name);
      39         139 :     _marker_variables.push_back(var_ptr);
      40             : 
      41             :     // Check block restrictions
      42         139 :     if (blockIDs() != var_ptr->blockIDs())
      43          26 :       other_block_restricted += (other_block_restricted == "" ? "" : ", ") + marker_name;
      44             :   }
      45             : 
      46          63 :   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          63 : }
      56             : 
      57             : Marker::MarkerValue
      58       29686 : ComboMarker::computeElementMarker()
      59             : {
      60             :   // We start with DONT_MARK because it's -1
      61       29686 :   MarkerValue marker_value = DONT_MARK;
      62             : 
      63             :   // No need to check block restrictions if they all match
      64       29686 :   if (!_block_restriction_mismatch)
      65       95162 :     for (const auto & var : _markers)
      66       67580 :       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       29686 :   return marker_value;
      73             : }

Generated by: LCOV version 1.14