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 "ParsedSubdomainIDsGenerator.h" 11 : 12 : registerMooseObject("MooseApp", ParsedSubdomainIDsGenerator); 13 : 14 : InputParameters 15 14333 : ParsedSubdomainIDsGenerator::validParams() 16 : { 17 14333 : InputParameters params = ParsedSubdomainGeneratorBase::validParams(); 18 : 19 14333 : params.addClassDescription( 20 : "Uses a parsed expression to determine the subdomain ids of included elements."); 21 : 22 14333 : return params; 23 0 : } 24 : 25 34 : ParsedSubdomainIDsGenerator::ParsedSubdomainIDsGenerator(const InputParameters & parameters) 26 34 : : ParsedSubdomainGeneratorBase(parameters) 27 : { 28 34 : } 29 : 30 : void 31 128 : ParsedSubdomainIDsGenerator::assignElemSubdomainID(Elem * elem) 32 : { 33 128 : _func_params[0] = elem->vertex_average()(0); 34 128 : _func_params[1] = elem->vertex_average()(1); 35 128 : _func_params[2] = elem->vertex_average()(2); 36 168 : for (const auto i : index_range(_eeid_indices)) 37 40 : _func_params[3 + i] = elem->get_extra_integer(_eeid_indices[i]); 38 : 39 128 : if (std::find(_excluded_ids.begin(), _excluded_ids.end(), elem->subdomain_id()) == 40 256 : _excluded_ids.end()) 41 : { 42 128 : const Real func_val = evaluate(_func_F); 43 128 : if (func_val < 0.0) 44 4 : paramError("expression", 45 4 : "the value of the function is negative at the element with ID " + 46 8 : std::to_string(elem->id()) + 47 : ". The function must be non-negative. Consider using the absolute value of " 48 : "the function."); 49 124 : elem->subdomain_id() = std::round(func_val); 50 : } 51 124 : }