KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
find_global_nodal_neighbours_for_entities_process.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Riccardo Rossi
11 // Suneth Warnakulasuriya
12 //
13 
14 #if !defined(KRATOS_FIND_NODAL_NEIGHBOURS_FOR_ENTITIES_PROCESS_H_INCLUDED)
15 #define KRATOS_FIND_NODAL_NEIGHBOURS_FOR_ENTITIES_PROCESS_H_INCLUDED
16 
17 // System includes
18 #include <iostream>
19 #include <string>
20 #include <unordered_map>
21 
22 // External includes
23 
24 // Project includes
27 #include "includes/define.h"
28 #include "includes/model_part.h"
29 #include "processes/process.h"
30 
31 namespace Kratos
32 {
35 
37 
39 template <class TContainerType>
40 class KRATOS_API(KRATOS_CORE) FindNodalNeighboursForEntitiesProcess : public Process
41 {
42 public:
45 
48 
51 
55 
58  ModelPart& rModelPart,
59  const Variable<GlobalPointersVector<NodeType>>& rOutputVariable)
60  : mrModelPart(rModelPart),
61  mrDataCommunicator(rModelPart.GetCommunicator().GetDataCommunicator()),
62  mrOutputVariable(rOutputVariable)
63  {
64  }
65 
66  KRATOS_DEPRECATED_MESSAGE("Use of DataCommunicator is deprecated. Please use constructor without it.")
68  const DataCommunicator& rDataCommunicator,
69  ModelPart& rModelPart,
70  const Variable<GlobalPointersVector<NodeType>>& rOutputVariable)
71  : FindNodalNeighboursForEntitiesProcess(rModelPart, rOutputVariable)
72  {
73  }
74 
77 
80  FindNodalNeighboursForEntitiesProcess const& rOther) = delete;
81 
85 
86  void operator()()
87  {
88  Execute();
89  }
90 
94 
95  void Execute() override;
96 
97  void ClearNeighbours();
98 
99  std::unordered_map<int, std::vector<int>> GetNeighbourIds(
100  NodesContainerType& rNodes) const
101  {
103  rNodes, this->mrDataCommunicator, this->mrOutputVariable);
104  }
105 
106  static std::unordered_map<int, std::vector<int>> GetNodalNeighbourIdsMap(
107  NodesContainerType& rNodes,
108  const DataCommunicator& rDataCommunicator,
109  const Variable<GlobalPointersVector<NodeType>>& rNodalGlobalPointerVariable);
110 
114 
116  std::string Info() const override
117  {
118  return "FindNodalNeighboursForEntitiesProcess";
119  }
120 
122  void PrintInfo(std::ostream& rOStream) const override
123  {
124  rOStream << "FindNodalNeighboursForEntitiesProcess";
125  }
126 
128  void PrintData(std::ostream& rOStream) const override
129  {
130  }
131 
133 
134 private:
137 
138  ModelPart& mrModelPart;
139  const DataCommunicator& mrDataCommunicator;
140  const Variable<GlobalPointersVector<NodeType>>& mrOutputVariable;
141 
145 
146  TContainerType& GetContainer();
147 
148  void AddHangingNodeIds(
149  std::unordered_map<int, std::unordered_map<int, std::vector<int>>>& rNeighbourIds) const;
150 
151  void AddUnique(
152  std::vector<int>& rContainer,
153  const int Item) const;
154 
155  template <class TDataType>
156  void AddUniqueGlobalPointer(
158  const GlobalPointer<TDataType>& rCandidate) const
159  {
160  bool found = false;
161  for (const auto& gp : rGPVector.GetContainer()) {
162  if (&(*gp) == &(*rCandidate) && gp.GetRank() == rCandidate.GetRank()) {
163  found = true;
164  break;
165  }
166  }
167  if (!found) {
168  rGPVector.push_back(rCandidate);
169  }
170  }
171 
173 }; // Class FindNodalNeighboursForEntitiesProcess
174 
178 
180 template <class TContainerType>
181 inline std::istream& operator>>(
182  std::istream& rIStream,
184 
186 template <class TContainerType>
187 inline std::ostream& operator<<(
188  std::ostream& rOStream,
190 {
191  rThis.PrintInfo(rOStream);
192  rOStream << std::endl;
193  rThis.PrintData(rOStream);
194 
195  return rOStream;
196 }
198 
199 } // namespace Kratos.
200 
201 #endif // KRATOS_FIND_NODAL_NEIGHBOURS_FOR_ENTITIES_PROCESS_H_INCLUDED defined
Serial (do-nothing) version of a wrapper class for MPI communication.
Definition: data_communicator.h:318
Short class definition.
Definition: find_global_nodal_neighbours_for_entities_process.h:41
FindNodalNeighboursForEntitiesProcess & operator=(FindNodalNeighboursForEntitiesProcess const &rOther)=delete
Assignment operator.
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: find_global_nodal_neighbours_for_entities_process.h:128
std::unordered_map< int, std::vector< int > > GetNeighbourIds(NodesContainerType &rNodes) const
Definition: find_global_nodal_neighbours_for_entities_process.h:99
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: find_global_nodal_neighbours_for_entities_process.h:122
std::string Info() const override
Turn back information as a string.
Definition: find_global_nodal_neighbours_for_entities_process.h:116
FindNodalNeighboursForEntitiesProcess(ModelPart &rModelPart, const Variable< GlobalPointersVector< NodeType >> &rOutputVariable)
Constructor.
Definition: find_global_nodal_neighbours_for_entities_process.h:57
static std::unordered_map< int, std::vector< int > > GetNodalNeighbourIdsMap(NodesContainerType &rNodes, const DataCommunicator &rDataCommunicator, const Variable< GlobalPointersVector< NodeType >> &rNodalGlobalPointerVariable)
Definition: find_global_nodal_neighbours_for_entities_process.cpp:252
KRATOS_CLASS_POINTER_DEFINITION(FindNodalNeighboursForEntitiesProcess)
Pointer definition of FindNodalNeighboursForEntitiesProcess.
~FindNodalNeighboursForEntitiesProcess() override=default
Destructor.
void operator()()
Definition: find_global_nodal_neighbours_for_entities_process.h:86
This class is a wrapper for a pointer to a data that is located in a different rank.
Definition: global_pointer.h:44
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
void push_back(TPointerType x)
Definition: global_pointers_vector.h:322
TContainerType & GetContainer()
Definition: global_pointers_vector.h:419
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Node NodeType
Definition: model_part.h:117
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
This class defines the node.
Definition: node.h:65
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
The base class for all processes in Kratos.
Definition: process.h:49
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
int GetRank() const
Returns the rank of the global pointer.
Definition: global_pointer.h:262
TContainerType & GetContainer(ModelPart::MeshType &rMesh)
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
ModelPart::NodesContainerType NodesContainerType
Definition: find_conditions_neighbours_process.h:44
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
namespace KRATOS_DEPRECATED_MESSAGE("Please use std::filesystem directly") filesystem
Definition: kratos_filesystem.h:33
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
tuple const
Definition: ode_solve.py:403