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