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