https://mooseframework.inl.gov
SetupQuadratureAction.C
Go to the documentation of this file.
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 
19 {
21  params.addClassDescription("Sets the quadrature type for the simulation.");
22  params.addParam<MooseEnum>("type", getQuadratureTypesEnum(), "Type of the quadrature rule");
23  params.addParam<MooseEnum>("order", getQuadratureOrderEnum(), "Order of the quadrature");
24  params.addParam<MooseEnum>(
25  "element_order", getQuadratureOrderEnum(), "Order of the quadrature for elements");
26  params.addParam<MooseEnum>(
27  "side_order", getQuadratureOrderEnum(), "Order of the quadrature for sides");
28  params.addParam<std::vector<SubdomainID>>("custom_blocks",
29  std::vector<SubdomainID>{},
30  "list of blocks to specify custom quadrature order");
31  params.addParam<MultiMooseEnum>(
32  "custom_orders",
34  "list of quadrature orders for the blocks specified in `custom_blocks`");
35  params.addParam<bool>(
36  "allow_negative_qweights", true, "Whether or not allow negative quadrature weights");
37 
38  return params;
39 }
40 
42  : Action(parameters),
43  _type(Moose::stringToEnum<libMesh::QuadratureType>(getParam<MooseEnum>("type"))),
44  _order(Moose::stringToEnum<Order>(getParam<MooseEnum>("order"))),
45  _element_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("element_order"))),
46  _side_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("side_order"))),
47  _custom_block_orders(getParam<SubdomainID, MooseEnumItem>("custom_blocks", "custom_orders")),
48  _allow_negative_qweights(getParam<bool>("allow_negative_qweights"))
49 {
50 }
51 
52 void
54 {
55  if (_problem.get() == nullptr)
56  return;
57 
58  // add default/global quadrature rules
59  _problem->createQRules(
61 
62  // add custom block-specific quadrature rules
63  for (const auto & [block, order] : _custom_block_orders)
64  _problem->createQRules(_type,
65  _order,
68  block,
70 }
Sets the quadrature.
static MooseEnum getQuadratureOrderEnum()
Return the potential selections for the order of the quadrature, with an &#39;auto&#39; default.
Order
static MultiMooseEnum getQuadratureOrdersMultiEnum()
A MultiMooseEnum for selecting multiple quadrature orders.
T stringToEnum(const std::string &s)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const std::vector< std::pair< SubdomainID, MooseEnumItem > > _custom_block_orders
QuadratureType
registerMooseAction("MooseApp", SetupQuadratureAction, "setup_quadrature")
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Order stringToEnum< Order >(const std::string &s)
Definition: Conversion.C:175
Base class for actions.
Definition: Action.h:33
static MooseEnum getQuadratureTypesEnum()
Return the possible selections for the type of the quadrature.
libMesh::QuadratureType _type
static InputParameters validParams()
Definition: Action.C:24
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
static InputParameters validParams()
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.C:19
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
SetupQuadratureAction(const InputParameters &parameters)
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:168
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...