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
14using namespace libMesh;
15
17
20{
22 params.addClassDescription("Positions of element quadrature points.");
24
25 params.addParam<MooseEnum>("quadrature_type",
27 "Type of the quadrature rule");
28 params.addParam<MooseEnum>("quadrature_order",
30 "Order of the volumetric quadrature. If unspecified, defaults to the "
31 "local element default order. This is not the problem default, which "
32 "is based on the order of the variables in the system.");
33
34 // Element centroids could be sorted by XYZ or by id. Default to not sorting
35 params.set<bool>("auto_sort") = false;
36 // Gathered locally, should be broadcast on every process
37 params.set<bool>("auto_broadcast") = true;
38
39 return params;
40}
41
43 : Positions(parameters),
45 _mesh(_subproblem.mesh()),
46 _q_type(Moose::stringToEnum<QuadratureType>(getParam<MooseEnum>("quadrature_type"))),
47 _q_order(Moose::stringToEnum<Order>(getParam<MooseEnum>("quadrature_order")))
48{
49 // Mesh is ready at construction
50 initialize();
51 // Trigger synchronization as the initialization is distributed
52 finalize();
53}
54
55void
57{
59
60 // By default, initialize should be called on meshChanged()
61 // Gathering of positions is local, reporter system makes sure to make it global
62 if (blockRestricted())
63 {
64 _positions_2d.resize(numBlocks());
65 unsigned int b_index = 0;
66 for (const auto & sub_id : blockIDs())
67 {
68 for (const auto & elem : _mesh.getMesh().active_local_subdomain_elements_ptr_range(sub_id))
69 {
70 // Get a quadrature going of the requested type and order
71 const FEFamily mapping_family = FEMap::map_fe_type(*elem);
72 const FEType fe_type(elem->default_order(), mapping_family);
73 std::unique_ptr<FEBase> fe = FEBase::build(elem->dim(), fe_type);
74 const auto q_order =
76 auto qrule = QBase::build(_q_type, elem->dim(), q_order);
77 fe->attach_quadrature_rule(qrule.get());
78 const auto & q_points = fe->get_xyz();
79 fe->reinit(elem);
80
81 for (const auto & q : q_points)
82 {
83 _positions.emplace_back(q);
84 _positions_2d[b_index].emplace_back(q);
85 }
86 }
87 b_index += 1;
88 }
89 }
90 else
91 {
93 for (const auto & elem : _mesh.getMesh().active_local_element_ptr_range())
94 {
95 // Get a quadrature going on the element
96 const FEFamily mapping_family = FEMap::map_fe_type(*elem);
97 const FEType fe_type(elem->default_order(), mapping_family);
98 std::unique_ptr<FEBase> fe = FEBase::build(elem->dim(), fe_type);
99 const auto q_order =
101 auto qrule = QBase::build(_q_type, elem->dim(), q_order);
102 fe->attach_quadrature_rule(qrule.get());
103 const auto & q_points = fe->get_xyz();
104 fe->reinit(elem);
105
106 for (const auto & q : q_points)
107 _positions.emplace_back(q);
108 }
109 }
110 _initialized = true;
111}
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:3549
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.
std::unique_ptr< FEGenericBase< Real > > build(const unsigned int dim, const FEType &fet)
static FEFamily map_fe_type(const Elem &elem)
Order default_quadrature_order() const
virtual SimpleRange< element_iterator > active_local_subdomain_elements_ptr_range(subdomain_id_type sid)=0
dof_id_type n_active_local_elem() const
static std::unique_ptr< QBase > build(std::string_view name, const unsigned int dim, const Order order=INVALID_ORDER)
MeshBase & mesh
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...