https://mooseframework.inl.gov
Loading...
Searching...
No Matches
VerifyNodalUniqueID.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// 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
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
32void
34{
35 _all_ids.clear();
36 _all_ids.reserve(_subproblem.mesh().getMesh().n_local_nodes());
37}
38
39void
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
49void
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
57void
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}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObject("MooseApp", VerifyNodalUniqueID)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3549
virtual bool isDistributedMesh() const
Returns the final Mesh distribution type.
Definition MooseMesh.h:1143
A user object that runs over all the nodes and does an aggregation step to compute a single value.
const Node *const & _current_node
Reference to current node pointer.
static InputParameters validParams()
virtual MooseMesh & mesh()=0
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Base class for user-specific data.
Definition UserObject.h:20
static InputParameters validParams()
virtual void finalize() override
Finalize.
VerifyNodalUniqueID(const InputParameters &parameters)
virtual void execute() override
Execute method.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
std::vector< dof_id_type > _all_ids
virtual void threadJoin(const UserObject &y) override
Must override.
const Parallel::Communicator & _communicator