LCOV - code coverage report
Current view: top level - src/markers - ValueRangeMarker.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 23 26 88.5 %
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 "ValueRangeMarker.h"
      11             : #include "FEProblem.h"
      12             : #include "MooseEnum.h"
      13             : 
      14             : registerMooseObject("MooseApp", ValueRangeMarker);
      15             : 
      16             : InputParameters
      17       14365 : ValueRangeMarker::validParams()
      18             : {
      19       14365 :   InputParameters params = QuadraturePointMarker::validParams();
      20             : 
      21       14365 :   params.addRequiredParam<Real>("lower_bound", "The lower bound value for the range.");
      22       14365 :   params.addRequiredParam<Real>("upper_bound", "The upper bound value for the range.");
      23       43095 :   params.addParam<Real>("buffer_size",
      24       28730 :                         0.0,
      25             :                         "A buffer zone value added to both ends of the range "
      26             :                         "where a third_state marker can be returned.");
      27             : 
      28       14365 :   params.addClassDescription("Mark elements for adaptivity based on the supplied upper and lower "
      29             :                              "bounds and the specified variable.");
      30       14365 :   return params;
      31           0 : }
      32             : 
      33          52 : ValueRangeMarker::ValueRangeMarker(const InputParameters & parameters)
      34             :   : QuadraturePointMarker(parameters),
      35          52 :     _lower_bound(parameters.get<Real>("lower_bound")),
      36          52 :     _upper_bound(parameters.get<Real>("upper_bound")),
      37          52 :     _buffer_size(parameters.get<Real>("buffer_size")),
      38          52 :     _inside(getParam<bool>("invert") ? COARSEN : REFINE),
      39         104 :     _outside(getParam<bool>("invert") ? REFINE : COARSEN)
      40             : {
      41          52 :   if (_upper_bound < _lower_bound)
      42           0 :     mooseError("Invalid bounds specified (upper_bound < lower_bound)");
      43             : 
      44          52 :   if (_buffer_size < 0.0)
      45           0 :     mooseError("Buffer size must be non-negative: ", _buffer_size);
      46          52 : }
      47             : 
      48             : Marker::MarkerValue
      49       24320 : ValueRangeMarker::computeQpMarker()
      50             : {
      51             :   // Is the variable value inside the range?
      52       24320 :   if (_u[_qp] >= _lower_bound && _u[_qp] <= _upper_bound)
      53       11696 :     return _inside;
      54             : 
      55             :   // How about the buffer zone?
      56       12624 :   if (_u[_qp] >= _lower_bound - _buffer_size && _u[_qp] <= _upper_bound + _buffer_size)
      57        7376 :     return _third_state;
      58             : 
      59             :   // Must be outside the range
      60        5248 :   return _outside;
      61             : }

Generated by: LCOV version 1.14