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 14346 : ValueThresholdMarker::validParams() 18 : { 19 14346 : InputParameters params = QuadraturePointMarker::validParams(); 20 : 21 14346 : params.addParam<Real>("coarsen", 22 : "The threshold value for coarsening. Elements with variable " 23 : "values beyond this will be marked for coarsening."); 24 14346 : params.addParam<Real>("refine", 25 : "The threshold value for refinement. Elements with variable " 26 : "values beyond this will be marked for refinement."); 27 14346 : params.addClassDescription( 28 : "The refinement state based on a threshold value compared to the specified variable."); 29 14346 : return params; 30 0 : } 31 : 32 42 : ValueThresholdMarker::ValueThresholdMarker(const InputParameters & parameters) 33 : : QuadraturePointMarker(parameters), 34 42 : _coarsen_set(parameters.isParamValid("coarsen")), 35 42 : _coarsen(parameters.get<Real>("coarsen")), 36 42 : _refine_set(parameters.isParamValid("refine")), 37 42 : _refine(parameters.get<Real>("refine")), 38 84 : _invert(parameters.get<bool>("invert")) 39 : { 40 42 : if (_refine_set && _coarsen_set) 41 : { 42 28 : Real diff = _refine - _coarsen; 43 28 : if ((diff > 0 && _invert) || (diff < 0 && !_invert)) 44 0 : mooseError("Invalid combination of refine, coarsen, and invert values specified"); 45 : } 46 42 : } 47 : 48 : Marker::MarkerValue 49 10800 : ValueThresholdMarker::computeQpMarker() 50 : { 51 10800 : if (!_invert) 52 : { 53 7200 : if (_refine_set && _u[_qp] > _refine) 54 2664 : return REFINE; 55 : 56 4536 : if (_coarsen_set && _u[_qp] < _coarsen) 57 837 : return COARSEN; 58 : } 59 : else 60 : { 61 3600 : if (_refine_set && _u[_qp] < _refine) 62 837 : return REFINE; 63 : 64 2763 : if (_coarsen_set && _u[_qp] > _coarsen) 65 864 : return COARSEN; 66 : } 67 : 68 5598 : return _third_state; 69 : }