Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BooleanOperators.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: MeshElements.cpp
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Mesh manipulation objects.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43 namespace NekMeshUtils
44 {
45 
46 bool operator==(ElmtConfig const &c1, ElmtConfig const &c2)
47 {
48  return (c1.m_e == c2.m_e && c1.m_order == c2.m_order);
49 }
50 
51 /**
52  * @brief Compares two %HOSurf objects referred to as shared pointers.
53  *
54  * Two %HOSurf objects are defined to be equal if they contain identical
55  * vertex ids contained in HOSurf::vertId.
56  */
57 bool operator==(HOSurfSharedPtr const &p1, HOSurfSharedPtr const &p2)
58 {
59  if (p1->vertId.size() != p2->vertId.size())
60  {
61  return false;
62  }
63 
64  vector<int> ids1 = p1->vertId;
65  vector<int> ids2 = p2->vertId;
66  sort(ids1.begin(), ids1.end());
67  sort(ids2.begin(), ids2.end());
68 
69  for (int i = 0; i < ids1.size(); ++i)
70  {
71  if (ids1[i] != ids2[i])
72  return false;
73  }
74 
75  return true;
76 }
77 
78 /**
79  * @brief Test equality of two conditions - i.e. compare types, fields
80  * and values but _not_ composite ids.
81  */
83 {
84  int i, n = c1->type.size();
85 
86  if (n != c2->type.size())
87  {
88  return false;
89  }
90 
91  for (i = 0; i < n; ++i)
92  {
93  if (c1->type[i] != c2->type[i])
94  {
95  return false;
96  }
97 
98  if (c1->field[i] != c2->field[i] || c1->value[i] != c2->value[i])
99  {
100  return false;
101  }
102  }
103 
104  return true;
105 }
106 
107 /**
108  * @brief Defines equality between two #NodeSharedPtr objects.
109  */
110 bool operator==(NodeSharedPtr const &p1, NodeSharedPtr const &p2)
111 {
112  return *p1 == *p2;
113 }
114 
115 bool operator!=(NodeSharedPtr const &p1, NodeSharedPtr const &p2)
116 {
117  if(p1->m_id != p2->m_id)
118  {
119  return true;
120  }
121  else
122  {
123  return false;
124  }
125 }
126 
127 /**
128  * @brief Defines ordering between two #NodeSharedPtr objects.
129  */
130 bool operator< (NodeSharedPtr const &p1, NodeSharedPtr const &p2)
131 {
132  return *p1 < *p2;
133 }
134 
135 std::ostream &operator<<(std::ostream &os, const NodeSharedPtr &n)
136 {
137  os << n->m_x << " " << n->m_y << " " << n->m_z;
138  return os;
139 }
140 
141 /**
142  * @brief Defines equality of two edges (equal if IDs of end nodes
143  * match in either ordering).
144  */
145 bool operator==(EdgeSharedPtr const &p1, EdgeSharedPtr const &p2)
146 {
147  return ( ((*(p1->m_n1) == *(p2->m_n1)) && (*(p1->m_n2) == *(p2->m_n2)))
148  || ((*(p1->m_n2) == *(p2->m_n1)) && (*(p1->m_n1) == *(p2->m_n2))));
149 }
150 
151 /**
152  * @brief Defines ordering between two edges (based on ID of edges).
153  */
154 bool operator< (EdgeSharedPtr const &p1, EdgeSharedPtr const &p2)
155 {
156  return p1->m_id < p2->m_id;
157 }
158 
159 /**
160  * @brief Defines equality of two faces (equal if IDs of vertices are
161  * the same.)
162  */
163 bool operator==(FaceSharedPtr const &p1, FaceSharedPtr const &p2)
164 {
166  for (it1 = p1->m_vertexList.begin(); it1 != p1->m_vertexList.end(); ++it1)
167  {
168  if (find(p2->m_vertexList.begin(), p2->m_vertexList.end(), *it1)
169  == p2->m_vertexList.end())
170  {
171  return false;
172  }
173  }
174  return true;
175 }
176 
177 /**
178  * @brief Defines ordering between two faces (depending on ID of
179  * faces).
180  */
181 bool operator< (FaceSharedPtr const &p1, FaceSharedPtr const &p2)
182 {
183  return p1->m_id < p2->m_id;
184 }
185 
186 }
187 }
Basic information about an element.
Definition: Element.h:58
boost::shared_ptr< HOSurf > HOSurfSharedPtr
Definition: Triangle.h:216
STL namespace.
bool operator<(FaceSharedPtr const &p1, FaceSharedPtr const &p2)
Defines ordering between two faces (depending on ID of faces).
unsigned int m_order
Order of the element.
Definition: Element.h:96
bool operator!=(NodeSharedPtr const &p1, NodeSharedPtr const &p2)
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
boost::shared_ptr< Condition > ConditionSharedPtr
Definition: Mesh.h:78
std::ostream & operator<<(std::ostream &os, const NodeSharedPtr &n)
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:196
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:315
boost::shared_ptr< Face > FaceSharedPtr
Shared pointer to a face.
Definition: Face.h:378
bool operator==(const VertexSharedPtr &v1, const VertexSharedPtr &v2)
Define comparison operator for the vertex struct.
Definition: VtkToFld.cpp:51
LibUtilities::ShapeType m_e
Element type (e.g. triangle, quad, etc).
Definition: Element.h:85