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 65990 : SetupQuadratureAction::validParams() 19 : { 20 65990 : InputParameters params = Action::validParams(); 21 131980 : params.addClassDescription("Sets the quadrature type for the simulation."); 22 263960 : params.addParam<MooseEnum>("type", getQuadratureTypesEnum(), "Type of the quadrature rule"); 23 263960 : params.addParam<MooseEnum>("order", getQuadratureOrderEnum(), "Order of the quadrature"); 24 197970 : params.addParam<MooseEnum>( 25 131980 : "element_order", getQuadratureOrderEnum(), "Order of the quadrature for elements"); 26 197970 : params.addParam<MooseEnum>( 27 131980 : "side_order", getQuadratureOrderEnum(), "Order of the quadrature for sides"); 28 197970 : params.addParam<std::vector<SubdomainID>>("custom_blocks", 29 131980 : std::vector<SubdomainID>{}, 30 : "list of blocks to specify custom quadrature order"); 31 197970 : params.addParam<MultiMooseEnum>( 32 : "custom_orders", 33 131980 : getQuadratureOrdersMultiEnum(), 34 : "list of quadrature orders for the blocks specified in `custom_blocks`"); 35 197970 : params.addParam<MultiMooseEnum>( 36 : "custom_types", 37 131980 : 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 131980 : params.addParam<bool>( 41 131980 : "allow_negative_qweights", true, "Whether or not allow negative quadrature weights"); 42 : 43 65990 : return params; 44 0 : } 45 : 46 65948 : SetupQuadratureAction::SetupQuadratureAction(const InputParameters & parameters) 47 : : Action(parameters), 48 65948 : _type(Moose::stringToEnum<libMesh::QuadratureType>(getParam<MooseEnum>("type"))), 49 131896 : _order(Moose::stringToEnum<Order>(getParam<MooseEnum>("order"))), 50 131896 : _element_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("element_order"))), 51 131896 : _side_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("side_order"))), 52 263789 : _custom_block_orders(getParam<SubdomainID, MooseEnumItem>("custom_blocks", "custom_orders")), 53 197838 : _allow_negative_qweights(getParam<bool>("allow_negative_qweights")) 54 : { 55 197862 : for (const auto & t : getParam<MultiMooseEnum>("custom_types")) 56 27 : _custom_block_types.push_back(Moose::stringToEnum<libMesh::QuadratureType>(std::string(t))); 57 : 58 65945 : 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 65942 : } 66 : 67 : void 68 61028 : SetupQuadratureAction::act() 69 : { 70 61028 : if (_problem.get() == nullptr) 71 0 : return; 72 : 73 : // add default/global quadrature rules 74 61028 : _problem->createQRules( 75 61028 : _type, _order, _element_order, _side_order, Moose::ANY_BLOCK_ID, _allow_negative_qweights); 76 : 77 : // add custom block-specific quadrature rules 78 61076 : 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 : }