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