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.
neighbours.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: Pooyan Dadvand
11 // Riccardo Rossi
12 //
13 //
14 
15 
16 #if !defined(KRATOS_NEIGHBOURS_H_INCLUDED )
17 #define KRATOS_NEIGHBOURS_H_INCLUDED
18 
19 
20 
21 // System includes
22 #include <string>
23 #include <iostream>
24 #include <sstream>
25 #include <cstddef>
26 
27 
28 // External includes
29 
30 
31 // Project includes
32 #include "includes/define.h"
34 
35 
36 namespace Kratos
37 {
38 
41 
45 
49 
53 
57 
59 
61 template<class TNodeType, class TElementType>
63 {
64 public:
67 
70 
71  typedef std::size_t IndexType;
72 
74 
76 
79 
82 
86 
89 
91  Neighbours(const Neighbours& rOther)
92  : mIndex(rOther.mIndex)
93  , mpNeighbourElements(rOther.mpNeighbourElements)
94  , mpNeighbourNodes(rOther.mpNeighbourNodes)
95  {
96  }
97 
99  typename NeighbourElementsArrayType::Pointer pNewNeighbourElements,
100  typename NeighbourNodesArrayType::Pointer pNewNeighbourNodes)
101  : mIndex(NewIndex)
102  , mpNeighbourElements(pNewNeighbourElements)
103  , mpNeighbourNodes(pNewNeighbourNodes)
104  {
105  }
106 
108  : mIndex(NewIndex)
109  {
110  }
111 
113  virtual ~Neighbours() {}
114 
115 
119 
122  {
123  mIndex = rOther.mIndex;
124  mpNeighbourElements = rOther.mpNeighbourElements;
125  mpNeighbourNodes = rOther.mpNeighbourNodes;
126 
127  return *this;
128  }
129 
130 
134 
136  {
137  typename NeighbourElementsArrayType::Pointer p_neighbour_elements(new NeighbourElementsArrayType(*mpNeighbourElements));
138  typename NeighbourNodesArrayType::Pointer p_neighbour_nodes(new NeighbourNodesArrayType(*mpNeighbourNodes));
139 
140  return Neighbours(mIndex, p_neighbour_elements, p_neighbour_nodes);
141  }
142 
143 
147 
149  {
150  return mIndex;
151  }
152 
153 
154  const typename NeighbourElementsArrayType::Pointer pNeighbourElements() const
155  {
156  return mpNeighbourElements;
157  }
158 
159  typename NeighbourElementsArrayType::Pointer pNeighbourElements()
160  {
161  return mpNeighbourElements;
162  }
163 
165  {
166  return *mpNeighbourElements;
167  }
168 
170  {
171  return *mpNeighbourElements;
172  }
173 
174  const typename NeighbourNodesArrayType::Pointer pNeighbourNodes() const
175  {
176  return mpNeighbourNodes;
177  }
178 
179  typename NeighbourNodesArrayType::Pointer pNeighbourNodes()
180  {
181  return mpNeighbourNodes;
182  }
183 
185  {
186  return *mpNeighbourNodes;
187  }
188 
190  {
191  return *mpNeighbourNodes;
192  }
193 
197 
198 
202 
204  virtual std::string Info() const
205  {
206  return "Neighbours";
207  }
208 
210  virtual void PrintInfo(std::ostream& rOStream) const
211  {
212  rOStream << Info();
213  }
214 
216  virtual void PrintData(std::ostream& rOStream) const
217  {
218  rOStream << "Number of neighbour nodes : " << mpNeighbourNodes->size() << std::endl;
219  rOStream << "Number of neighbour elements : " << mpNeighbourElements->size() << std::endl;
220 // rOStream << "Neighbour nodes : " <<;
221 // for(
222 // rOStream << "Neighbour elements : " << mpNeighbourElements->size() << std::endl;
223 
224  }
225 
226 
230 
231 
233 
234 protected:
237 
238 
242 
243 
247 
248 
252 
253 
257 
258 
262 
263 
267 
268 
270 
271 private:
274 
275 
279 
280  IndexType mIndex;
281 
282  typename NeighbourElementsArrayType::Pointer mpNeighbourElements;
283 
284  typename NeighbourNodesArrayType::Pointer mpNeighbourNodes;
285 
286 
290 
291 
295 
296 
300 
301 
305 
306 
310 
312 
313 }; // Class Neighbours
314 
316 
319 
320 
324 
325 
327 template<class TNodeType, class TElementType>
328 inline std::istream& operator >> (std::istream& rIStream,
330 
332 template<class TNodeType, class TElementType>
333 inline std::ostream& operator << (std::ostream& rOStream,
335 {
336  rThis.PrintInfo(rOStream);
337  rOStream << std::endl;
338  rThis.PrintData(rOStream);
339 
340  return rOStream;
341 }
343 
344 
345 } // namespace Kratos.
346 
347 #endif // KRATOS_NEIGHBOURS_H_INCLUDED defined
348 
349 
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
Short class definition.
Definition: neighbours.h:63
KRATOS_CLASS_POINTER_DEFINITION(Neighbours)
Pointer definition of Neighbours.
IndexType Index()
Definition: neighbours.h:148
virtual ~Neighbours()
Destructor.
Definition: neighbours.h:113
Neighbours Clone()
Definition: neighbours.h:135
Kratos::weak_ptr< TElementType > ElementWeakPointer
Definition: neighbours.h:75
std::size_t IndexType
Definition: neighbours.h:71
const NeighbourElementsArrayType::Pointer pNeighbourElements() const
Definition: neighbours.h:154
Neighbours(IndexType NewIndex, typename NeighbourElementsArrayType::Pointer pNewNeighbourElements, typename NeighbourNodesArrayType::Pointer pNewNeighbourNodes)
Definition: neighbours.h:98
GlobalPointersVector< TNodeType > NeighbourNodesArrayType
Definition: neighbours.h:81
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: neighbours.h:210
const NeighbourNodesArrayType::Pointer pNeighbourNodes() const
Definition: neighbours.h:174
NeighbourElementsArrayType::Pointer pNeighbourElements()
Definition: neighbours.h:159
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: neighbours.h:216
Neighbours(IndexType NewIndex)
Definition: neighbours.h:107
NeighbourNodesArrayType::Pointer pNeighbourNodes()
Definition: neighbours.h:179
Neighbours()
Default constructor.
Definition: neighbours.h:88
Neighbours & operator=(const Neighbours &rOther)
Assignment operator.
Definition: neighbours.h:121
Kratos::weak_ptr< TNodeType > NodeWeakPointer
Definition: neighbours.h:73
NeighbourNodesArrayType const & NeighbourNodes() const
Definition: neighbours.h:184
GlobalPointersVector< TElementType > NeighbourElementsArrayType
Definition: neighbours.h:78
NeighbourNodesArrayType & NeighbourNodes()
Definition: neighbours.h:189
NeighbourElementsArrayType const & NeighbourElements() const
Definition: neighbours.h:164
Neighbours(const Neighbours &rOther)
Copy constructor.
Definition: neighbours.h:91
NeighbourElementsArrayType & NeighbourElements()
Definition: neighbours.h:169
virtual std::string Info() const
Turn back information as a string.
Definition: neighbours.h:204
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::weak_ptr< T > weak_ptr
Definition: smart_pointers.h:30
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432