OGS 6.2.0-244-g47b8a9a9d
Node.h
Go to the documentation of this file.
1 
15 #pragma once
16 
17 #include <cstdlib>
18 #include <limits>
19 #include <vector>
20 
21 #include "MathLib/Point3dWithID.h"
22 #include "MathLib/Vector3.h"
23 
24 namespace ApplicationUtils
25 {
26  class NodeWiseMeshPartitioner;
27 }
28 
29 namespace MeshLib {
30 
31 class Element;
32 
37 {
38  /* friend classes: */
39  friend class Mesh;
40  friend class NodePartitionedMesh;
41  friend class MeshRevision;
42  friend class MeshLayerMapper;
44 
45 public:
47  explicit Node(const double coords[3],
48  std::size_t id = std::numeric_limits<std::size_t>::max());
49 
51  explicit Node(std::array<double, 3> const& coords,
52  std::size_t id = std::numeric_limits<std::size_t>::max());
53 
55  Node(double x, double y, double z, std::size_t id = std::numeric_limits<std::size_t>::max());
56 
58  Node(const Node &node);
59 
61  const std::vector<MeshLib::Node*>& getConnectedNodes() const { return _connected_nodes; }
62 
64  const Element* getElement(std::size_t idx) const { return _elements[idx]; }
65 
67  const std::vector<Element*>& getElements() const { return _elements; }
68 
70  std::size_t getNumberOfElements() const { return _elements.size(); }
71 
74  {
75  return Node(_x[0]-v[0], _x[1]-v[1], _x[2]-v[2]);
76  }
77 
78 protected:
81  void updateCoordinates(double x, double y, double z);
82 
87  void addElement(Element* elem) { _elements.push_back(elem); }
88 
90  void clearElements() { _elements.clear(); }
91 
95  void setConnectedNodes(std::vector<Node*> &connected_nodes)
96  {
97  _connected_nodes = connected_nodes;
98  }
99 
101  void setID(std::size_t id) { _id = id; }
102 
103  std::vector<Node*> _connected_nodes;
104  std::vector<Element*> _elements;
105 }; /* class */
106 
109 bool isBaseNode(Node const& node);
110 
111 } // namespace MeshLib
Node operator-(MathLib::Vector3 const &v) const
Shift the node according to the displacement vector v.
Definition: Node.h:73
const std::vector< Element * > & getElements() const
Get all elements the node is part of.
Definition: Node.h:67
void setConnectedNodes(std::vector< Node *> &connected_nodes)
Definition: Node.h:95
const Element * getElement(std::size_t idx) const
Get an element the node is part of.
Definition: Node.h:64
bool isBaseNode(Node const &node)
Definition: Node.cpp:54
std::size_t getNumberOfElements() const
Get number of elements the node is part of.
Definition: Node.h:70
Manipulating and adding prism element layers to an existing 2D mesh.
Definition of the Point3d class.
void clearElements()
clear stored elements connecting to this node
Definition: Node.h:90
void addElement(Element *elem)
Definition: Node.h:87
Interface for heuristic search length strategy.
Definition: ProjectData.h:29
void setID(std::size_t id)
Sets the ID of a node to the given value.
Definition: Node.h:101
const std::vector< MeshLib::Node * > & getConnectedNodes() const
Return all the nodes connected to this one.
Definition: Node.h:61
Definition of the Vector3 class. From: http://www.strout.net/info/coding/classlib/intro.html with modifications to derive from TemplatePoint.
std::vector< Node * > _connected_nodes
Definition: Node.h:103
std::vector< Element * > _elements
Definition: Node.h:104