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