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 "SetupQuadratureAction.h" 11 : #include "Conversion.h" 12 : #include "FEProblem.h" 13 : #include "MooseEnum.h" 14 : 15 : registerMooseAction("MooseApp", SetupQuadratureAction, "setup_quadrature"); 16 : 17 : InputParameters 18 66436 : SetupQuadratureAction::validParams() 19 : { 20 66436 : InputParameters params = Action::validParams(); 21 132872 : params.addClassDescription("Sets the quadrature type for the simulation."); 22 265744 : params.addParam<MooseEnum>("type", getQuadratureTypesEnum(), "Type of the quadrature rule"); 23 265744 : params.addParam<MooseEnum>("order", getQuadratureOrderEnum(), "Order of the quadrature"); 24 199308 : params.addParam<MooseEnum>( 25 132872 : "element_order", getQuadratureOrderEnum(), "Order of the quadrature for elements"); 26 199308 : params.addParam<MooseEnum>( 27 132872 : "side_order", getQuadratureOrderEnum(), "Order of the quadrature for sides"); 28 199308 : params.addParam<std::vector<SubdomainID>>("custom_blocks", 29 132872 : std::vector<SubdomainID>{}, 30 : "list of blocks to specify custom quadrature order"); 31 199308 : params.addParam<MultiMooseEnum>( 32 : "custom_orders", 33 132872 : getQuadratureOrdersMultiEnum(), 34 : "list of quadrature orders for the blocks specified in `custom_blocks`"); 35 199308 : params.addParam<MultiMooseEnum>( 36 : "custom_types", 37 132872 : getQuadratureTypesMultiEnum(), 38 : "list of quadrature types for the blocks specified in `custom_blocks` " 39 : "(must match length of custom_blocks; omit to use global type for all custom blocks)"); 40 132872 : params.addParam<bool>( 41 132872 : "allow_negative_qweights", true, "Whether or not allow negative quadrature weights"); 42 : 43 66436 : return params; 44 0 : } 45 : 46 66394 : SetupQuadratureAction::SetupQuadratureAction(const InputParameters & parameters) 47 : : Action(parameters), 48 66394 : _type(Moose::stringToEnum<libMesh::QuadratureType>(getParam<MooseEnum>("type"))), 49 132788 : _order(Moose::stringToEnum<Order>(getParam<MooseEnum>("order"))), 50 132788 : _element_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("element_order"))), 51 132788 : _side_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("side_order"))), 52 265573 : _custom_block_orders(getParam<SubdomainID, MooseEnumItem>("custom_blocks", "custom_orders")), 53 199176 : _allow_negative_qweights(getParam<bool>("allow_negative_qweights")) 54 : { 55 199200 : for (const auto & t : getParam<MultiMooseEnum>("custom_types")) 56 27 : _custom_block_types.push_back(Moose::stringToEnum<libMesh::QuadratureType>(std::string(t))); 57 : 58 66391 : if (!_custom_block_types.empty() && _custom_block_types.size() != _custom_block_orders.size()) 59 6 : paramError("custom_types", 60 : "Must have the same number of entries as 'custom_blocks' (got ", 61 : _custom_block_types.size(), 62 : " types for ", 63 : _custom_block_orders.size(), 64 : " blocks)"); 65 66388 : } 66 : 67 : void 68 61467 : SetupQuadratureAction::act() 69 : { 70 61467 : if (_problem.get() == nullptr) 71 0 : return; 72 : 73 : // add default/global quadrature rules 74 61467 : _problem->createQRules( 75 61467 : _type, _order, _element_order, _side_order, Moose::ANY_BLOCK_ID, _allow_negative_qweights); 76 : 77 : // add custom block-specific quadrature rules 78 61515 : for (const auto i : index_range(_custom_block_orders)) 79 : { 80 48 : const auto & [block, order] = _custom_block_orders[i]; 81 48 : const auto qtype = (i < _custom_block_types.size()) ? _custom_block_types[i] : _type; 82 96 : _problem->createQRules(qtype, 83 : _order, 84 : Moose::stringToEnum<Order>(order), 85 : Moose::stringToEnum<Order>(order), 86 48 : block, 87 48 : _allow_negative_qweights); 88 : } 89 : }