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 "ThresholdElementSubdomainModifier.h" 11 : 12 : InputParameters 13 14981 : ThresholdElementSubdomainModifier::validParams() 14 : { 15 14981 : InputParameters params = ElementSubdomainModifier::validParams(); 16 : 17 14981 : params.addRequiredParam<Real>("threshold", 18 : "The value above (or below) which to change the element subdomain"); 19 44943 : params.addParam<MooseEnum>("criterion_type", 20 29962 : MooseEnum("BELOW EQUAL ABOVE", "ABOVE"), 21 : "Criterion to use for the threshold"); 22 14981 : params.addRequiredParam<SubdomainID>("subdomain_id", 23 : "The subdomain ID of the element when the criterion is met"); 24 14981 : params.addParam<SubdomainID>( 25 : "complement_subdomain_id", 26 : "The subdomain ID of the element when the criterion is not met. If not provided, the element " 27 : "subdomain ID will not be modified if the criterion is not met."); 28 14981 : return params; 29 0 : } 30 : 31 373 : ThresholdElementSubdomainModifier::ThresholdElementSubdomainModifier( 32 373 : const InputParameters & parameters) 33 : : ElementSubdomainModifier(parameters), 34 373 : _threshold(getParam<Real>("threshold")), 35 373 : _criterion_type(getParam<MooseEnum>("criterion_type").getEnum<CriterionType>()), 36 373 : _subdomain_id(getParam<SubdomainID>("subdomain_id")), 37 746 : _complement_subdomain_id(isParamValid("complement_subdomain_id") 38 373 : ? getParam<SubdomainID>("complement_subdomain_id") 39 373 : : Moose::INVALID_BLOCK_ID) 40 : { 41 373 : } 42 : 43 : SubdomainID 44 716786 : ThresholdElementSubdomainModifier::computeSubdomainID() 45 : { 46 716786 : Real criterion = computeValue(); 47 : 48 716786 : bool criterion_met = false; 49 716786 : switch (_criterion_type) 50 : { 51 0 : case CriterionType::Equal: 52 0 : criterion_met = MooseUtils::absoluteFuzzyEqual(criterion - _threshold, 0); 53 0 : break; 54 : 55 665680 : case CriterionType::Below: 56 665680 : criterion_met = criterion < _threshold; 57 665680 : break; 58 : 59 51106 : case CriterionType::Above: 60 51106 : criterion_met = criterion > _threshold; 61 51106 : break; 62 : } 63 : 64 716786 : return criterion_met ? _subdomain_id : _complement_subdomain_id; 65 : }