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 69289 : SetupQuadratureAction::validParams() 19 : { 20 69289 : InputParameters params = Action::validParams(); 21 138578 : params.addClassDescription("Sets the quadrature type for the simulation."); 22 277156 : params.addParam<MooseEnum>("type", getQuadratureTypesEnum(), "Type of the quadrature rule"); 23 277156 : params.addParam<MooseEnum>("order", getQuadratureOrderEnum(), "Order of the quadrature"); 24 207867 : params.addParam<MooseEnum>( 25 138578 : "element_order", getQuadratureOrderEnum(), "Order of the quadrature for elements"); 26 207867 : params.addParam<MooseEnum>( 27 138578 : "side_order", getQuadratureOrderEnum(), "Order of the quadrature for sides"); 28 207867 : params.addParam<std::vector<SubdomainID>>("custom_blocks", 29 138578 : std::vector<SubdomainID>{}, 30 : "list of blocks to specify custom quadrature order"); 31 207867 : params.addParam<MultiMooseEnum>( 32 : "custom_orders", 33 138578 : getQuadratureOrdersMultiEnum(), 34 : "list of quadrature orders for the blocks specified in `custom_blocks`"); 35 138578 : params.addParam<bool>( 36 138578 : "allow_negative_qweights", true, "Whether or not allow negative quadrature weights"); 37 : 38 69289 : return params; 39 0 : } 40 : 41 69086 : SetupQuadratureAction::SetupQuadratureAction(const InputParameters & parameters) 42 : : Action(parameters), 43 69086 : _type(Moose::stringToEnum<libMesh::QuadratureType>(getParam<MooseEnum>("type"))), 44 138172 : _order(Moose::stringToEnum<Order>(getParam<MooseEnum>("order"))), 45 138172 : _element_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("element_order"))), 46 138172 : _side_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("side_order"))), 47 276340 : _custom_block_orders(getParam<SubdomainID, MooseEnumItem>("custom_blocks", "custom_orders")), 48 207250 : _allow_negative_qweights(getParam<bool>("allow_negative_qweights")) 49 : { 50 69082 : } 51 : 52 : void 53 64214 : SetupQuadratureAction::act() 54 : { 55 64214 : if (_problem.get() == nullptr) 56 0 : return; 57 : 58 : // add default/global quadrature rules 59 64214 : _problem->createQRules( 60 64214 : _type, _order, _element_order, _side_order, Moose::ANY_BLOCK_ID, _allow_negative_qweights); 61 : 62 : // add custom block-specific quadrature rules 63 64240 : for (const auto & [block, order] : _custom_block_orders) 64 52 : _problem->createQRules(_type, 65 : _order, 66 : Moose::stringToEnum<Order>(order), 67 : Moose::stringToEnum<Order>(order), 68 26 : block, 69 26 : _allow_negative_qweights); 70 : }