https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
11#include "Conversion.h"
12#include "FEProblem.h"
13#include "MooseEnum.h"
14
15registerMooseAction("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");
32 "custom_orders",
34 "list of quadrature orders for the blocks specified in `custom_blocks`");
36 "custom_types",
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 params.addParam<bool>(
41 "allow_negative_qweights", true, "Whether or not allow negative quadrature weights");
42
43 return params;
44}
45
47 : Action(parameters),
48 _type(Moose::stringToEnum<libMesh::QuadratureType>(getParam<MooseEnum>("type"))),
49 _order(Moose::stringToEnum<Order>(getParam<MooseEnum>("order"))),
50 _element_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("element_order"))),
51 _side_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("side_order"))),
52 _custom_block_orders(getParam<SubdomainID, MooseEnumItem>("custom_blocks", "custom_orders")),
53 _allow_negative_qweights(getParam<bool>("allow_negative_qweights"))
54{
55 for (const auto & t : getParam<MultiMooseEnum>("custom_types"))
57
58 if (!_custom_block_types.empty() && _custom_block_types.size() != _custom_block_orders.size())
59 paramError("custom_types",
60 "Must have the same number of entries as 'custom_blocks' (got ",
62 " types for ",
64 " blocks)");
65}
66
67void
69{
70 if (_problem.get() == nullptr)
71 return;
72
73 // add default/global quadrature rules
74 _problem->createQRules(
76
77 // add custom block-specific quadrature rules
78 for (const auto i : index_range(_custom_block_orders))
79 {
80 const auto & [block, order] = _custom_block_orders[i];
81 const auto qtype = (i < _custom_block_types.size()) ? _custom_block_types[i] : _type;
82 _problem->createQRules(qtype,
83 _order,
86 block,
88 }
89}
registerMooseAction("MooseApp", SetupQuadratureAction, "setup_quadrature")
Base class for actions.
Definition Action.h:38
static InputParameters validParams()
Definition Action.C:26
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition Action.h:178
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:457
Class for containing MooseEnum item information.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type.
static MultiMooseEnum getQuadratureOrdersMultiEnum()
A MultiMooseEnum for selecting multiple quadrature orders.
static InputParameters validParams()
libMesh::QuadratureType _type
const std::vector< std::pair< SubdomainID, MooseEnumItem > > _custom_block_orders
static MooseEnum getQuadratureOrderEnum()
Return the potential selections for the order of the quadrature, with an 'auto' default.
static MultiMooseEnum getQuadratureTypesMultiEnum()
A MultiMooseEnum for selecting multiple quadrature types (one per custom block)
std::vector< libMesh::QuadratureType > _custom_block_types
Per-block quadrature types, parallel to _custom_block_orders. Falls back to _type if empty.
SetupQuadratureAction(const InputParameters &parameters)
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
static MooseEnum getQuadratureTypesEnum()
Return the possible selections for the type of the quadrature.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
const SubdomainID ANY_BLOCK_ID
Definition MooseTypes.C:19
libMesh::QuadratureType stringToEnum< libMesh::QuadratureType >(const std::string &s)
Order stringToEnum< Order >(const std::string &s)
Definition Conversion.C:175
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...