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 "ParsedSubdomainMeshGenerator.h" 11 : 12 : registerMooseObject("MooseApp", ParsedSubdomainMeshGenerator); 13 : 14 : InputParameters 15 18683 : ParsedSubdomainMeshGenerator::validParams() 16 : { 17 18683 : InputParameters params = ParsedSubdomainGeneratorBase::validParams(); 18 : 19 18683 : params.renameParam("expression", 20 : "combinatorial_geometry", 21 : "Function expression encoding a combinatorial geometry"); 22 18683 : params.addRequiredParam<subdomain_id_type>("block_id", 23 : "Subdomain id to set for inside of the combinatorial"); 24 18683 : params.addParam<SubdomainName>("block_name", 25 : "Subdomain name to set for inside of the combinatorial"); 26 18683 : params.addClassDescription( 27 : "Uses a parsed expression (`combinatorial_geometry`) to determine if an " 28 : "element (via its centroid) is inside the region defined by the expression and " 29 : "assigns a new block ID."); 30 : 31 18683 : return params; 32 0 : } 33 : 34 2209 : ParsedSubdomainMeshGenerator::ParsedSubdomainMeshGenerator(const InputParameters & parameters) 35 : : ParsedSubdomainGeneratorBase(parameters), 36 2209 : _block_id(parameters.get<subdomain_id_type>("block_id")) 37 : { 38 2209 : } 39 : 40 : void 41 771962 : ParsedSubdomainMeshGenerator::assignElemSubdomainID(Elem * elem) 42 : { 43 771962 : _func_params[0] = elem->vertex_average()(0); 44 771962 : _func_params[1] = elem->vertex_average()(1); 45 771962 : _func_params[2] = elem->vertex_average()(2); 46 772120 : for (const auto i : index_range(_eeid_indices)) 47 158 : _func_params[3 + i] = elem->get_extra_integer(_eeid_indices[i]); 48 771962 : bool contains = evaluate(_func_F); 49 : 50 812864 : if (contains && std::find(_excluded_ids.begin(), _excluded_ids.end(), elem->subdomain_id()) == 51 812864 : _excluded_ids.end()) 52 40811 : elem->subdomain_id() = _block_id; 53 771962 : } 54 : 55 : void 56 2160 : ParsedSubdomainMeshGenerator::setBlockName(std::unique_ptr<MeshBase> & mesh) 57 : { 58 2160 : if (isParamValid("block_name")) 59 278 : mesh->subdomain_name(getParam<subdomain_id_type>("block_id")) = 60 417 : getParam<SubdomainName>("block_name"); 61 2160 : }