Loading...
Searching...
No Matches
point_kernel.cpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#include "point_kernel.hpp"
26
27namespace bitpit {
28
29#if BITPIT_ENABLE_MPI==1
42PointKernel::PointKernel(MPI_Comm communicator,
43 AdaptionMode adaptionMode, PartitioningMode partitioningMode)
44 : PatchKernel(communicator, 0, adaptionMode, partitioningMode)
45#else
52 : PatchKernel(adaptionMode)
53#endif
54{
55 initialize();
56}
57
58#if BITPIT_ENABLE_MPI==1
74PointKernel::PointKernel(int dimension, MPI_Comm communicator,
75 AdaptionMode adaptionMode, PartitioningMode partitioningMode)
76 : PatchKernel(dimension, communicator, 0, adaptionMode, partitioningMode)
77#else
86PointKernel::PointKernel(int dimension, AdaptionMode adaptionMode)
87 : PatchKernel(dimension, adaptionMode)
88#endif
89{
90 initialize();
91}
92
93#if BITPIT_ENABLE_MPI==1
110PointKernel::PointKernel(int id, int dimension, MPI_Comm communicator,
111 AdaptionMode adaptionMode, PartitioningMode partitioningMode)
112 : PatchKernel(id, dimension, communicator, 0, adaptionMode, partitioningMode)
113#else
121PointKernel::PointKernel(int id, int dimension, AdaptionMode adaptionMode)
122 : PatchKernel(id, dimension, adaptionMode)
123#endif
124{
125}
126
130void PointKernel::initialize()
131{
132 // Nothing to do
133}
134
141{
142 return 3;
143}
144
151{
152 return 2;
153}
154
161{
162 return 1;
163}
164
171{
172 return 0;
173}
174
181double PointKernel::evalCellSize(long id) const
182{
183 BITPIT_UNUSED(id);
184
185 return 0.;
186}
187
195double PointKernel::evalPointsDistance(long id1, long id2) const
196{
197 const Cell &cell1 = m_cells[id1];
198 const Cell &cell2 = m_cells[id2];
199
200 ConstProxyVector<long> cellVertexIds1 = cell1.getVertexIds();
201 const Vertex &vertex1 = getVertex(cellVertexIds1[0]);
202
203 ConstProxyVector<long> cellVertexIds2 = cell2.getVertexIds();
204 const Vertex &vertex2 = getVertex(cellVertexIds2[0]);
205
206 double distance = norm2(vertex2.getCoords() - vertex1.getCoords());
207
208 return distance;
209}
210
218std::array<double, 3> PointKernel::evalPointsDirection(long id1, long id2) const
219{
220 const Cell &cell1 = m_cells[id1];
221 const Cell &cell2 = m_cells[id2];
222
223 ConstProxyVector<long> cellVertexIds1 = cell1.getVertexIds();
224 const Vertex &vertex1 = getVertex(cellVertexIds1[0]);
225
226 ConstProxyVector<long> cellVertexIds2 = cell2.getVertexIds();
227 const Vertex &vertex2 = getVertex(cellVertexIds2[0]);
228
229 std::array<double, 3> direction = vertex2.getCoords() - vertex1.getCoords();
230
231 double distance = norm2(direction);
232 if (!utils::DoubleFloatingEqual()(distance, 0., getTol())) {
233 direction /= distance;
234 }
235
236 return direction;
237}
238
239}
The Cell class defines the cells.
Definition cell.hpp:42
static ConstProxyVector< long > getVertexIds(ElementType type, const long *connectivity)
Definition element.cpp:1193
The PatchKernel class provides an interface for defining patches.
Vertex & getVertex(long id)
double getTol() const
double evalCellSize(long id) const override
int getVolumeCodimension() const override
int getSurfaceCodimension() const override
PointKernel(MPI_Comm communicator, AdaptionMode adaptionMode, PartitioningMode partitioningMode)
virtual std::array< double, 3 > evalPointsDirection(long id1, long id2) const
int getLineCodimension() const override
virtual double evalPointsDistance(long id1, long id2) const
int getPointCodimension() const override
Metafunction for generating a list of elements that can be either stored in an external vectror or,...
The Vertex class defines the vertexs.
Definition vertex.hpp:42
std::array< double, 3 > & getCoords()
Definition vertex.cpp:246
double norm2(const std::array< T, d > &x)
#define BITPIT_UNUSED(variable)
Definition compiler.hpp:63
--- layout: doxygen_footer ---