Loading...
Searching...
No Matches
volume_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 "volume_kernel.hpp"
26
27namespace bitpit {
28
38
39#if BITPIT_ENABLE_MPI==1
43 If a null comunicator is provided, a serial patch will be created, this
44 means that each processor will be unaware of the existence of the other
45 processes.
46
47 \param communicator is the communicator to be used for exchanging data
48 among the processes. If a null comunicator is provided, a serial patch
49 will be created
50 \param haloSize is the size, expressed in number of layers, of the ghost
51 cells halo
52 \param adaptionMode is the adaption mode that will be used for the patch
53 \param partitioningMode is the partitioning mode that will be used for the
54 patch
55*/
56VolumeKernel::VolumeKernel(MPI_Comm communicator, std::size_t haloSize,
57 AdaptionMode adaptionMode, PartitioningMode partitioningMode)
58 : PatchKernel(communicator, haloSize, adaptionMode, partitioningMode)
59#else
66 : PatchKernel(adaptionMode)
67#endif
68{
69}
70
71#if BITPIT_ENABLE_MPI==1
89VolumeKernel::VolumeKernel(int dimension, MPI_Comm communicator, std::size_t haloSize,
90 AdaptionMode adaptionMode, PartitioningMode partitioningMode)
91 : PatchKernel(dimension, communicator, haloSize, adaptionMode, partitioningMode)
92#else
99VolumeKernel::VolumeKernel(int dimension, AdaptionMode adaptionMode)
100 : PatchKernel(dimension, adaptionMode)
101#endif
102{
103}
104
105#if BITPIT_ENABLE_MPI==1
124VolumeKernel::VolumeKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize,
125 AdaptionMode adaptionMode, PartitioningMode partitioningMode)
126 : PatchKernel(id, dimension, communicator, haloSize, adaptionMode, partitioningMode)
127#else
135VolumeKernel::VolumeKernel(int id, int dimension, AdaptionMode adaptionMode)
136 : PatchKernel(id, dimension, adaptionMode)
137#endif
138{
139}
140
147{
148 return 0;
149}
150
157{
158 return -1;
159}
160
167{
168 return -2;
169}
170
177{
178 return -3;
179}
180
190{
192}
193
202bool VolumeKernel::isPointInside(double x, double y, double z) const
203{
204 return isPointInside({{x, y, z}});
205}
206
216bool VolumeKernel::isPointInside(long id, double x, double y, double z) const
217{
218 return isPointInside(id, {{x, y, z}});
219}
220
228ConstProxyVector<long> VolumeKernel::getFaceOrderedVertexIds(const Cell &cell, int face) const
229{
230 ConstProxyVector<long> faceVertexIds = cell.getFaceVertexIds(face);
231 if (areFaceVerticesOrdered(cell, face)) {
232 return faceVertexIds;
233 }
234
235 std::size_t nFaceVertices = faceVertexIds.size();
236 ConstProxyVector<long> orderedFaceVertexIds(ConstProxyVector<long>::INTERNAL_STORAGE, nFaceVertices);
237 ConstProxyVector<long>::storage_pointer orderedFaceVertexIdsStorage = orderedFaceVertexIds.storedData();
238 for (std::size_t k = 0; k < nFaceVertices; ++k) {
239 int vertex = getFaceOrderedLocalVertex(cell, face, k);
240 orderedFaceVertexIdsStorage[k] = faceVertexIds[vertex];
241 }
242
243 return orderedFaceVertexIds;
244}
245
254bool VolumeKernel::areFaceVerticesOrdered(const Cell &cell, int face) const
255{
256 // Early return for low-dimension elements
257 if (getDimension() <= 2) {
258 return true;
259 }
260
261 // Check if vertices are ordered
262 ElementType faceType = cell.getFaceType(face);
263 switch (faceType) {
264
265 case (ElementType::POLYGON):
266 {
267 return true;
268 }
269
270 default:
271 {
272 assert(faceType != ElementType::UNDEFINED);
273 const Reference2DElementInfo &faceInfo = static_cast<const Reference2DElementInfo &>(ReferenceElementInfo::getInfo(faceType));
274 return faceInfo.areVerticesCCWOrdered();
275 }
276
277 }
278}
279
290int VolumeKernel::getFaceOrderedLocalVertex(const Cell &cell, int face, std::size_t n) const
291{
292 // Early return for low-dimension elements
293 if (getDimension() <= 2) {
294 return n;
295 }
296
297 // Get the request index
298 ElementType faceType = cell.getFaceType(face);
299 switch (faceType) {
300
301 case (ElementType::POLYGON):
302 {
303 return n;
304 }
305
306 default:
307 {
308 assert(faceType != ElementType::UNDEFINED);
309 const Reference2DElementInfo &faceInfo = static_cast<const Reference2DElementInfo &>(ReferenceElementInfo::getInfo(faceType));
310 return faceInfo.getCCWOrderedVertex(n);
311 }
312
313 }
314}
315
316}
The Cell class defines the cells.
Definition cell.hpp:42
ConstProxyVector< long > getFaceVertexIds(int face) const
Definition element.cpp:1320
ElementType getFaceType(int face) const
Definition element.cpp:701
PatchKernel(PatchKernel &&other)
void extractEnvelope(PatchKernel &envelope) const
static constexpr __PXV_POINTER__ INTERNAL_STORAGE
std::size_t size() const
__PXV_STORAGE_POINTER__ storedData() noexcept
The Reference2DElementInfo class allows to define information about reference two-dimensional element...
virtual int getCCWOrderedVertex(int n) const
virtual bool areVerticesCCWOrdered() const
static BITPIT_PUBLIC_API const ReferenceElementInfo & getInfo(ElementType type)
The SurfaceKernel class provides an interface for defining surface patches.
int getFaceOrderedLocalVertex(const Cell &cell, int face, std::size_t n) const
void extractEnvelope(SurfaceKernel &envelope) const
int getSurfaceCodimension() const override
int getPointCodimension() const override
int getLineCodimension() const override
int getVolumeCodimension() const override
bool isPointInside(double x, double y, double z) const
bool areFaceVerticesOrdered(const Cell &cell, int face) const
ConstProxyVector< long > getFaceOrderedVertexIds(const Cell &cell, int face) const
VolumeKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode)