Line data Source code
1 : // Mastodon includes 2 : #include "MinimumElementSizeMarker.h" 3 : 4 : // libMesh includes 5 : #include "libmesh/error_vector.h" 6 : 7 : registerMooseObject("MastodonApp", MinimumElementSizeMarker); 8 : 9 : InputParameters 10 32 : MinimumElementSizeMarker::validParams() 11 : { 12 32 : InputParameters params = Marker::validParams(); 13 64 : params.addParam<IndicatorName>("indicator", "The name of the Indicator that this Marker uses."); 14 64 : params.addParam<Real>("element_size", "Minimum element size to be enforced in the mesh."); 15 64 : params.addParam<Real>("scale", 16 64 : 1.0, 17 : "Additional scale term to multiply with " 18 : "the computed minimum element size."); 19 64 : params.addParam<Real>( 20 64 : "factor", 0.0, "Additional factor to add to the computed minimum element size."); 21 32 : params.addClassDescription("Marks element for refinement based on the element size."); 22 32 : return params; 23 0 : } 24 : 25 16 : MinimumElementSizeMarker::MinimumElementSizeMarker(const InputParameters & parameters) 26 : : Marker(parameters), 27 22 : _element_size(isParamValid("element_size") ? &getParam<Real>("element_size") : nullptr), 28 32 : _scale(getParam<Real>("scale")), 29 32 : _factor(getParam<Real>("factor")), 30 16 : _error_vector(isParamValid("indicator") 31 29 : ? &getErrorVector(parameters.get<IndicatorName>("indicator")) 32 16 : : nullptr) 33 : { 34 22 : if (_element_size && isParamValid("indicator")) 35 0 : mooseError( 36 : "In block ", 37 : name(), 38 : ", both the element_size and the indicator should not be provided at the same time."); 39 55 : if (!_element_size && !isParamValid("indicator")) 40 0 : mooseError( 41 : "In block ", name(), ", either the element_size or the indicator should be provided."); 42 16 : } 43 : 44 : Marker::MarkerValue 45 54332 : MinimumElementSizeMarker::computeElementMarker() 46 : { 47 54332 : if (_error_vector) 48 51238 : _minimum_element_size = _scale * (*_error_vector)[_current_elem->id()] + _factor; 49 : else 50 3094 : _minimum_element_size = (*_element_size); 51 : 52 54332 : if (_minimum_element_size < _current_elem->hmin()) 53 958 : return REFINE; 54 : return DO_NOTHING; 55 : }