www.mooseframework.org
VerifyNodalUniqueID.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 // MOOSE includes
11 #include "VerifyNodalUniqueID.h"
12 #include "SubProblem.h"
13 #include "MooseMesh.h"
14 
16 
19 {
21  params.addClassDescription("Verifies that all node ids are unique.");
22  return params;
23 }
24 
26  : NodalUserObject(parameters)
27 {
28 }
29 
30 // This object can't test every possible scenario. For instance, it can't detect recycled ids
31 // It's only designed to make sure that all ids are unique in the mesh at any specified execution
32 void
34 {
35  _all_ids.clear();
36  _all_ids.reserve(_subproblem.mesh().getMesh().n_local_nodes());
37 }
38 
39 void
41 {
42 #ifdef LIBMESH_ENABLE_UNIQUE_ID
43  _all_ids.push_back(_current_node->unique_id());
44 #else
45  _all_ids.push_back(0);
46 #endif
47 }
48 
49 void
51 {
52  const auto & uo = static_cast<const VerifyNodalUniqueID &>(y);
53 
54  _all_ids.insert(_all_ids.end(), uo._all_ids.begin(), uo._all_ids.end());
55 }
56 
57 void
59 {
60  // On Parallel Mesh we have to look at all the ids over all the processors
63 
64  std::sort(_all_ids.begin(), _all_ids.end());
65  std::vector<dof_id_type>::iterator it_end = std::unique(_all_ids.begin(), _all_ids.end());
66  if (it_end != _all_ids.end())
67  mooseError("Duplicate unique_ids found!");
68 }
virtual MooseMesh & mesh()=0
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
bool isDistributedMesh() const
Returns the final Mesh distribution type.
Definition: MooseMesh.h:984
registerMooseObject("MooseApp", VerifyNodalUniqueID)
const Node *const & _current_node
Reference to current node pointer.
static InputParameters validParams()
virtual void finalize() override
Finalize.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
static InputParameters validParams()
const Parallel::Communicator & _communicator
virtual void execute() override
Execute method.
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:207
A user object that runs over all the nodes and does an aggregation step to compute a single value...
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3198
virtual void threadJoin(const UserObject &y) override
Must override.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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::vector< dof_id_type > _all_ids
Base class for user-specific data.
Definition: UserObject.h:39
VerifyNodalUniqueID(const InputParameters &parameters)