https://mooseframework.inl.gov
Loading...
Searching...
No Matches
QuadraturePointsPositions.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 "libmesh/quadrature_gauss.h"
13
15
18{
20 params.addClassDescription("Positions of element quadrature points.");
22
23 params.addParam<MooseEnum>("quadrature_type",
25 "Type of the quadrature rule");
26 params.addParam<MooseEnum>("quadrature_order",
28 "Order of the volumetric quadrature. If unspecified, defaults to the "
29 "local element default order. This is not the problem default, which "
30 "is based on the order of the variables in the system.");
31
32 // Element centroids could be sorted by XYZ or by id. Default to not sorting
33 params.set<bool>("auto_sort") = false;
34 // Gathered locally, should be broadcast on every process
35 params.set<bool>("auto_broadcast") = true;
36
37 return params;
38}
39
41 : Positions(parameters),
43 _mesh(_subproblem.mesh()),
44 _q_type(Moose::stringToEnum<QuadratureType>(getParam<MooseEnum>("quadrature_type"))),
45 _q_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("quadrature_order")))
46{
47 // Mesh is ready at construction
48 initialize();
49 // Trigger synchronization as the initialization is distributed
50 finalize();
51}
52
53void
55{
57
58 // By default, initialize should be called on meshChanged()
59 // Gathering of positions is local, reporter system makes sure to make it global
60 if (blockRestricted())
61 {
62 _positions_2d.resize(numBlocks());
63 unsigned int b_index = 0;
64 for (const auto & sub_id : blockIDs())
65 {
66 for (const auto & elem : _mesh.getMesh().active_local_subdomain_elements_ptr_range(sub_id))
67 {
68 // Get a quadrature going of the requested type and order
69 const FEFamily mapping_family = FEMap::map_fe_type(*elem);
70 const FEType fe_type(elem->default_order(), mapping_family);
71 std::unique_ptr<FEBase> fe = FEBase::build(elem->dim(), fe_type);
72 const auto q_order =
73 (_q_order == INVALID_ORDER) ? fe_type.default_quadrature_order() : _q_order;
74 auto qrule = QBase::build(_q_type, elem->dim(), q_order);
75 fe->attach_quadrature_rule(qrule.get());
76 const auto & q_points = fe->get_xyz();
77 fe->reinit(elem);
78
79 for (const auto & q : q_points)
80 {
81 _positions.emplace_back(q);
82 _positions_2d[b_index].emplace_back(q);
83 }
84 }
85 b_index += 1;
86 }
87 }
88 else
89 {
90 _positions.resize(_mesh.getMesh().n_active_local_elem());
91 for (const auto & elem : _mesh.getMesh().active_local_element_ptr_range())
92 {
93 // Get a quadrature going on the element
94 const FEFamily mapping_family = FEMap::map_fe_type(*elem);
95 const FEType fe_type(elem->default_order(), mapping_family);
96 std::unique_ptr<FEBase> fe = FEBase::build(elem->dim(), fe_type);
97 const auto q_order =
98 (_q_order == INVALID_ORDER) ? fe_type.default_quadrature_order() : _q_order;
99 auto qrule = QBase::build(_q_type, elem->dim(), q_order);
100 fe->attach_quadrature_rule(qrule.get());
101 const auto & q_points = fe->get_xyz();
102 fe->reinit(elem);
103
104 for (const auto & q : q_points)
105 _positions.emplace_back(q);
106 }
107 }
108 _initialized = true;
109}
registerMooseObject("MooseApp", QuadraturePointsPositions)
An interface that restricts an object to subdomains via the 'blocks' input parameter.
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted,...
unsigned int numBlocks() const
Return the number of blocks for this object.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
static InputParameters validParams()
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.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3557
Positions objects are under the hood Reporters.
Definition Positions.h:21
std::vector< std::vector< Point > > _positions_2d
2D storage for all the positions
Definition Positions.h:95
void clearPositions()
Clear all positions vectors.
Definition Positions.C:154
std::vector< Point > & _positions
For now, only the 1D vector will be shared across all ranks.
Definition Positions.h:92
static InputParameters validParams()
Definition Positions.C:15
virtual void finalize() override
In charge of reduction across all ranks & sorting for consistent output.
Definition Positions.C:220
bool _initialized
Whether the positions object has been initialized. This must be set by derived objects.
Definition Positions.h:116
Positions of all the quadrature points.
libMesh::QuadratureType _q_type
Type of the quadrature.
static InputParameters validParams()
const MooseMesh & _mesh
Reference to the mesh.
virtual void initialize() override
In charge of computing / loading the positions.
QuadraturePointsPositions(const InputParameters &parameters)
libMesh::Order _q_order
Order of the quadrature.
static MooseEnum getQuadratureOrderEnum()
Return the potential selections for the order of the quadrature, with an 'auto' default.
static MooseEnum getQuadratureTypesEnum()
Return the possible selections for the type of the quadrature.
MeshBase & mesh
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...