Flow123d  release_2.2.0-37-g336ee74
nodes.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file nodes.hh
15  * @brief Nodes of a mesh.
16  */
17 
18 #ifndef NODE_H
19 #define NODE_H
20 
21 #include "system/global_defs.h"
22 #include "mesh/mesh_types.hh"
23 #include <armadillo>
24 
25 
26 
27 
28 /**
29  * Class of node.
30  * First approach in turning to class.
31  */
32 class Node {
33 private:
34  /// Node point in 3D space.
36 
37 public:
38  /**
39  * Default constructor.
40  */
41  Node()
42  //: element(NULL)
43  {coordinates.zeros();}
44 
45  /**
46  * Construct form given coordinates.
47  *
48  * Possibly there could be also constructor from a vector.
49  */
50  Node(double x, double y, double z)
51  //: element(NULL)
52  {coordinates(0)=x; coordinates(1)=y; coordinates(2)=z;}
53 
54  /**
55  * Old getter methods. OBSOLETE.
56  */
57  inline double getX() const
58  { return coordinates[0];}
59  inline double getY() const
60  {return coordinates[1];}
61  inline double getZ() const
62  {return coordinates[2];}
63 
64 
65  /**
66  * Getter method for nodal point. Can be used also for modification.
67  */
68  inline arma::vec3 &point()
69  { return coordinates; }
70 
71  inline const arma::vec3 &point() const
72  { return coordinates; }
73 
74  /**
75  * Difference of two nodes is a vector.
76  */
77  inline arma::vec3 operator-(const Node &n2) const
78  {
79  return ( this->point() - n2.point() );
80  }
81 
82 
83  /**
84  * Distance of two nodes.
85  */
86  inline double distance(const Node &n2) const
87  {
88  return norm(*this - n2, 2);
89  }
90 
91 
92  // Misc
93  int aux; // Auxiliary flag
94 };
95 
96 #endif
97 //-----------------------------------------------------------------------------
98 // vim: set cindent:
double getY() const
Definition: nodes.hh:59
Definition: nodes.hh:32
Node()
Definition: nodes.hh:41
arma::vec3 operator-(const Node &n2) const
Definition: nodes.hh:77
double distance(const Node &n2) const
Definition: nodes.hh:86
Node(double x, double y, double z)
Definition: nodes.hh:50
arma::vec3 coordinates
Node point in 3D space.
Definition: nodes.hh:35
double getZ() const
Definition: nodes.hh:61
Global macros to enhance readability and debugging, general constants.
double getX() const
Definition: nodes.hh:57
int aux
Definition: nodes.hh:93
const arma::vec3 & point() const
Definition: nodes.hh:71
arma::vec3 & point()
Definition: nodes.hh:68