Flow123d  release_3.0.0-1157-gd246670
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 <armadillo>
23 
24 
25 
26 
27 /**
28  * Class of node.
29  * First approach in turning to class.
30  */
31 class Node {
32 private:
33  /// Node point in 3D space.
35 
36 public:
37  /**
38  * Default constructor.
39  */
40  Node()
41  //: element(NULL)
42  {coordinates.zeros();}
43 
44  /**
45  * Construct form given coordinates.
46  *
47  * Possibly there could be also constructor from a vector.
48  */
49  Node(double x, double y, double z)
50  //: element(NULL)
51  {coordinates(0)=x; coordinates(1)=y; coordinates(2)=z;}
52 
53  /**
54  * Old getter methods. OBSOLETE.
55  */
56  inline double getX() const
57  { return coordinates[0];}
58  inline double getY() const
59  {return coordinates[1];}
60  inline double getZ() const
61  {return coordinates[2];}
62 
63 
64  /**
65  * Getter method for nodal point. Can be used also for modification.
66  */
67  inline arma::vec3 &point()
68  { return coordinates; }
69 
70  inline const arma::vec3 &point() const
71  { return coordinates; }
72 
73  /**
74  * Difference of two nodes is a vector.
75  */
76  inline arma::vec3 operator-(const Node &n2) const
77  {
78  return ( this->point() - n2.point() );
79  }
80 
81 
82  /**
83  * Distance of two nodes.
84  */
85  inline double distance(const Node &n2) const
86  {
87  return norm(*this - n2, 2);
88  }
89 
90 };
91 
92 #endif
93 //-----------------------------------------------------------------------------
94 // vim: set cindent:
double getY() const
Definition: nodes.hh:58
Definition: nodes.hh:31
Node()
Definition: nodes.hh:40
arma::vec3 operator-(const Node &n2) const
Definition: nodes.hh:76
double distance(const Node &n2) const
Definition: nodes.hh:85
Node(double x, double y, double z)
Definition: nodes.hh:49
arma::vec3 coordinates
Node point in 3D space.
Definition: nodes.hh:34
double getZ() const
Definition: nodes.hh:60
Global macros to enhance readability and debugging, general constants.
double getX() const
Definition: nodes.hh:56
const arma::vec3 & point() const
Definition: nodes.hh:70
arma::vec3 & point()
Definition: nodes.hh:67