LCOV - code coverage report
Current view: top level - src/markers - ValueThresholdMarker.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 27 29 93.1 %
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 "ValueThresholdMarker.h"
      11             : #include "FEProblem.h"
      12             : #include "MooseEnum.h"
      13             : 
      14             : registerMooseObject("MooseApp", ValueThresholdMarker);
      15             : 
      16             : InputParameters
      17       14340 : ValueThresholdMarker::validParams()
      18             : {
      19       14340 :   InputParameters params = QuadraturePointMarker::validParams();
      20             : 
      21       14340 :   params.addParam<Real>("coarsen",
      22             :                         "The threshold value for coarsening.  Elements with variable "
      23             :                         "values beyond this will be marked for coarsening.");
      24       14340 :   params.addParam<Real>("refine",
      25             :                         "The threshold value for refinement.  Elements with variable "
      26             :                         "values beyond this will be marked for refinement.");
      27       14340 :   params.addClassDescription(
      28             :       "The refinement state based on a threshold value compared to the specified variable.");
      29       14340 :   return params;
      30           0 : }
      31             : 
      32          39 : ValueThresholdMarker::ValueThresholdMarker(const InputParameters & parameters)
      33             :   : QuadraturePointMarker(parameters),
      34          39 :     _coarsen_set(parameters.isParamValid("coarsen")),
      35          39 :     _coarsen(parameters.get<Real>("coarsen")),
      36          39 :     _refine_set(parameters.isParamValid("refine")),
      37          39 :     _refine(parameters.get<Real>("refine")),
      38          78 :     _invert(parameters.get<bool>("invert"))
      39             : {
      40          39 :   if (_refine_set && _coarsen_set)
      41             :   {
      42          26 :     Real diff = _refine - _coarsen;
      43          26 :     if ((diff > 0 && _invert) || (diff < 0 && !_invert))
      44           0 :       mooseError("Invalid combination of refine, coarsen, and invert values specified");
      45             :   }
      46          39 : }
      47             : 
      48             : Marker::MarkerValue
      49        9600 : ValueThresholdMarker::computeQpMarker()
      50             : {
      51        9600 :   if (!_invert)
      52             :   {
      53        6400 :     if (_refine_set && _u[_qp] > _refine)
      54        2368 :       return REFINE;
      55             : 
      56        4032 :     if (_coarsen_set && _u[_qp] < _coarsen)
      57         744 :       return COARSEN;
      58             :   }
      59             :   else
      60             :   {
      61        3200 :     if (_refine_set && _u[_qp] < _refine)
      62         744 :       return REFINE;
      63             : 
      64        2456 :     if (_coarsen_set && _u[_qp] > _coarsen)
      65         768 :       return COARSEN;
      66             :   }
      67             : 
      68        4976 :   return _third_state;
      69             : }

Generated by: LCOV version 1.14