Nektar++
Loading...
Searching...
No Matches
PointGeom.cpp
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////////////
2//
3// File: PointGeom.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// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Point geometry information
32//
33////////////////////////////////////////////////////////////////////////////////
34
35#include <fstream>
36
41
43{
44
51
52PointGeom::PointGeom(const int coordim, const int vid, NekDouble x, NekDouble y,
53 NekDouble z)
54 : NekPoint<NekDouble>(x, y, z)
55{
57 m_coordim = coordim;
58 m_globalID = vid;
59}
60
61// copy constructor
68
70{
71 switch (m_coordim)
72 {
73 case 3:
74 z = (*this)(2);
75 /* Falls through. */
76 case 2:
77 y = (*this)(1);
78 /* Falls through. */
79 case 1:
80 x = (*this)(0);
81 break;
82 }
83}
84
86{
87 switch (m_coordim)
88 {
89 case 3:
90 coords[2] = (*this)(2);
91 /* Falls through. */
92 case 2:
93 coords[1] = (*this)(1);
94 /* Falls through. */
95 case 1:
96 coords[0] = (*this)(0);
97 break;
98 }
99}
100
102{
103 (*this)(0) = x;
104 (*this)(1) = y;
105 (*this)(2) = z;
106}
107
108// _this = a + b
110{
111 (*this)(0) = a[0] + b[0];
112 (*this)(1) = a[1] + b[1];
113 (*this)(2) = a[2] + b[2];
114 m_coordim = std::max(a.GetCoordim(), b.GetCoordim());
115}
116
117// _this = a + b
119{
120 (*this)(0) = a[0] - b[0];
121 (*this)(1) = a[1] - b[1];
122 (*this)(2) = a[2] - b[2];
123 m_coordim = std::max(a.GetCoordim(), b.GetCoordim());
124}
125
126/// \brief _this = a x b
128{
129 (*this)(0) = a[1] * b[2] - a[2] * b[1];
130 (*this)(1) = a[2] * b[0] - a[0] * b[2];
131 (*this)(2) = a[0] * b[1] - a[1] * b[0];
132 m_coordim = 3;
133}
134
135/// \brief _this = rotation of a by angle 'angle' around axis dir
136void PointGeom::Rotate(PointGeom &a, int dir, NekDouble angle)
137{
138 switch (dir)
139 {
140 case 0:
141 {
142 NekDouble yrot = cos(angle) * a.y() - sin(angle) * a.z();
143 NekDouble zrot = sin(angle) * a.y() + cos(angle) * a.z();
144
145 (*this)(0) = a.x();
146 (*this)(1) = yrot;
147 (*this)(2) = zrot;
148 }
149 break;
150 case 1:
151 {
152 NekDouble zrot = cos(angle) * a.z() - sin(angle) * a.x();
153 NekDouble xrot = sin(angle) * a.z() + cos(angle) * a.x();
154
155 (*this)(0) = xrot;
156 (*this)(1) = a.y();
157 (*this)(2) = zrot;
158 }
159 break;
160 case 2:
161 {
162 NekDouble xrot = cos(angle) * a.x() - sin(angle) * a.y();
163 NekDouble yrot = sin(angle) * a.x() + cos(angle) * a.y();
164
165 (*this)(0) = xrot;
166 (*this)(1) = yrot;
167 (*this)(2) = a.z();
168 }
169 break;
170 }
171}
172
173/// \brief return distance between this and input a
175{
176 return sqrt((x() - a.x()) * (x() - a.x()) + (y() - a.y()) * (y() - a.y()) +
177 (z() - a.z()) * (z() - a.z()));
178}
179
180/// \brief retun the dot product between this and input a
182{
183 return (x() * a.x() + y() * a.y() + z() * a.z());
184}
185
186/// Determine equivalence by the ids. No matter what the position,
187/// if the ids are the same, then they are equivalent, and vice versa.
188bool operator==(const PointGeom &x, const PointGeom &y)
189{
190 return (x.m_globalID == y.m_globalID);
191}
192
193bool operator==(const PointGeom &x, const PointGeom *y)
194{
195 return (x.m_globalID == y->m_globalID);
196}
197
198bool operator==(const PointGeom *x, const PointGeom &y)
199{
200 return (x->m_globalID == y.m_globalID);
201}
202
203bool operator!=(const PointGeom &x, const PointGeom &y)
204{
205 return (x.m_globalID != y.m_globalID);
206}
207
208bool operator!=(const PointGeom &x, const PointGeom *y)
209{
210 return (x.m_globalID != y->m_globalID);
211}
212
213bool operator!=(const PointGeom *x, const PointGeom &y)
214{
215 return (x->m_globalID != y.m_globalID);
216}
217
235
236} // namespace Nektar::SpatialDomains
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
boost::call_traits< DataType >::const_reference x() const
Definition NekPoint.hpp:160
boost::call_traits< DataType >::const_reference a() const
Definition NekPoint.hpp:178
boost::call_traits< DataType >::const_reference z() const
Definition NekPoint.hpp:172
boost::call_traits< DataType >::const_reference b() const
Definition NekPoint.hpp:184
boost::call_traits< DataType >::const_reference y() const
Definition NekPoint.hpp:166
1D geometry information
Definition Geometry0D.h:47
bool m_setupState
Wether or not the setup routines have been run.
Definition Geometry.h:193
void SetUpCoeffs(const int nCoeffs)
Initialise the Geometry::m_coeffs array.
Definition Geometry.h:704
LibUtilities::ShapeType m_shapeType
Type of shape.
Definition Geometry.h:197
Array< OneD, Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
Definition Geometry.h:201
GeomState m_geomFactorsState
State of the geometric factors.
Definition Geometry.h:187
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition Geometry.h:189
GeomFactorsSharedPtr m_geomFactors
Geometric factors.
Definition Geometry.h:185
int m_coordim
Coordinate dimension of this geometry object.
Definition Geometry.h:183
void Sub(PointGeom &a, PointGeom &b)
void GetCoords(NekDouble &x, NekDouble &y, NekDouble &z)
Definition PointGeom.cpp:69
void Mult(PointGeom &a, PointGeom &b)
_this = a x b
void Rotate(PointGeom &a, int dir, NekDouble angle)
_this = rotation of a by angle 'angle' around axis dir
NekDouble dot(PointGeom &a)
retun the dot product between this and input a
void Add(PointGeom &a, PointGeom &b)
void UpdatePosition(NekDouble x, NekDouble y, NekDouble z)
NekDouble dist(PointGeom &a)
return distance between this and input a
bool operator==(const GeomFactors &lhs, const GeomFactors &rhs)
Equivalence test for GeomFactors objects.
bool operator!=(const PointGeom &x, const PointGeom &y)
GeomType
Indicates the type of element geometry.
@ eRegular
Geometry is straight-sided with constant geometric factors.
@ ePtsFilled
Geometric information has been generated.
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:290