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 18779 : ParsedSubdomainMeshGenerator::validParams() 16 : { 17 18779 : InputParameters params = ParsedSubdomainGeneratorBase::validParams(); 18 : 19 112674 : params.renameParam("expression", 20 : "combinatorial_geometry", 21 : "Function expression encoding a combinatorial geometry"); 22 75116 : params.addRequiredParam<subdomain_id_type>("block_id", 23 : "Subdomain id to set for inside of the combinatorial"); 24 75116 : params.addParam<SubdomainName>("block_name", 25 : "Subdomain name to set for inside of the combinatorial"); 26 18779 : 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 18779 : return params; 32 0 : } 33 : 34 2257 : ParsedSubdomainMeshGenerator::ParsedSubdomainMeshGenerator(const InputParameters & parameters) 35 : : ParsedSubdomainGeneratorBase(parameters), 36 2257 : _block_id(parameters.get<subdomain_id_type>("block_id")) 37 : { 38 2257 : } 39 : 40 : void 41 775743 : ParsedSubdomainMeshGenerator::assignElemSubdomainID(Elem * elem) 42 : { 43 775743 : _func_params[0] = elem->vertex_average()(0); 44 775743 : _func_params[1] = elem->vertex_average()(1); 45 775743 : _func_params[2] = elem->vertex_average()(2); 46 775901 : for (const auto i : index_range(_eeid_indices)) 47 158 : _func_params[3 + i] = elem->get_extra_integer(_eeid_indices[i]); 48 1551486 : bool contains = evaluate(_func_F); 49 : 50 818496 : if (contains && std::find(_excluded_ids.begin(), _excluded_ids.end(), elem->subdomain_id()) == 51 818496 : _excluded_ids.end()) 52 42662 : elem->subdomain_id() = _block_id; 53 775743 : } 54 : 55 : void 56 2207 : ParsedSubdomainMeshGenerator::setBlockName(std::unique_ptr<MeshBase> & mesh) 57 : { 58 6621 : if (isParamValid("block_name")) 59 453 : mesh->subdomain_name(getParam<subdomain_id_type>("block_id")) = 60 755 : getParam<SubdomainName>("block_name"); 61 2207 : }