Loading...
Searching...
No Matches
cell.hpp
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#ifndef __BITPIT_CELL_HPP__
26#define __BITPIT_CELL_HPP__
27
28#include <memory>
29
30#include "bitpit_containers.hpp"
31
32#include "element.hpp"
33
34namespace bitpit {
35
36class Cell;
37class PatchKernel;
38
39IBinaryStream & operator>>(IBinaryStream &buf, Cell& cell);
40OBinaryStream & operator<<(OBinaryStream &buf, const Cell& cell);
41
42class Cell : public Element {
43
44friend class PatchKernel;
45
46friend OBinaryStream& (operator<<) (OBinaryStream& buf, const Cell& cell);
47friend IBinaryStream& (operator>>) (IBinaryStream& buf, Cell& cell);
48
49public:
50 Cell();
51 BITPIT_DEPRECATED(Cell(long id, ElementType type, bool interior, bool storeNeighbourhood));
52 BITPIT_DEPRECATED(Cell(long id, ElementType type, int connectSize, bool interior, bool storeNeighbourhood));
53 BITPIT_DEPRECATED(Cell(long id, ElementType type, std::unique_ptr<long[]> &&connectStorage, bool interior, bool storeNeighbourhood));
54 Cell(long id, ElementType type, bool interior = true, bool storeInterfaces = true, bool storeAjacencies = true);
55 Cell(long id, ElementType type, int connectSize, bool interior = true, bool storeInterfaces = true, bool storeAjacencies = true);
56 Cell(long id, ElementType type, std::unique_ptr<long[]> &&connectStorage, bool interior = true, bool storeInterfaces = true, bool storeAjacencies = true);
57
58 void swap(Cell &other) noexcept;
59
60 BITPIT_DEPRECATED(void initialize(long id, ElementType type, bool interior, bool storeNeighbourhood ));
61 BITPIT_DEPRECATED(void initialize(long id, ElementType type, int connectSize, bool interior, bool storeNeighbourhood));
62 BITPIT_DEPRECATED(void initialize(long id, ElementType type, std::unique_ptr<long[]> &&connectStorage, bool interior, bool storeNeighbourhood));
63 void initialize(long id, ElementType type, bool interior, bool storeInterfaces = true, bool storeAjacencies = true);
64 void initialize(long id, ElementType type, int connectSize, bool interior, bool storeInterfaces = true, bool storeAjacencies = true);
65 void initialize(long id, ElementType type, std::unique_ptr<long[]> &&connectStorage, bool interior, bool storeInterfaces = true, bool storeAjacencies = true);
66
67 bool isInterior() const;
68
69 void deleteInterfaces();
70 void resetInterfaces(bool storeInterfaces = true);
71 void setInterfaces(const std::vector<std::vector<long>> &interfaces);
72 void setInterfaces(FlatVector2D<long> &&interfaces);
73 void setInterface(int face, int index, long interface);
74 bool pushInterface(int face, long interface);
75 void deleteInterface(int face, int i);
76 int getInterfaceCount() const;
77 int getInterfaceCount(int face) const;
78 long getInterface(int face, int index = 0) const;
79 const long * getInterfaces() const;
80 long * getInterfaces();
81 const long * getInterfaces(int face) const;
82 long * getInterfaces(int face);
83 int findInterface(int face, int interface);
84 int findInterface(int interface);
85
86 void deleteAdjacencies();
87 void resetAdjacencies(bool storeAdjacencies = true);
88 void setAdjacencies(const std::vector<std::vector<long>> &adjacencies);
89 void setAdjacencies(FlatVector2D<long> &&adjacencies);
90 void setAdjacency(int face, int index, long adjacencies);
91 bool pushAdjacency(int face, long adjacency);
92 void deleteAdjacency(int face, int i);
93 int getAdjacencyCount() const;
94 int getAdjacencyCount(int face) const;
95 long getAdjacency(int face, int index = 0) const;
96 const long * getAdjacencies() const;
97 long * getAdjacencies();
98 const long * getAdjacencies(int face) const;
99 long * getAdjacencies(int face);
100 int findAdjacency(int face, int adjacency);
101 int findAdjacency(int adjacency);
102
103 bool isFaceBorder(int face) const;
104
105 void display(std::ostream &out, unsigned short int indent) const;
106
107 unsigned int getBinarySize() const;
108
109protected:
110 void setInterior(bool interior);
111
112private:
113 bitpit::FlatVector2D<long> m_interfaces;
114 bitpit::FlatVector2D<long> m_adjacencies;
115
116 bool m_interior;
117
118 bitpit::FlatVector2D<long> createNeighbourhoodStorage(bool storeNeighbourhood);
119
120 void _initialize(bool interior, bool initializeInterfaces, bool storeInterfaces, bool initializeAdjacency, bool storeAdjacencies);
121
122};
123
124template<typename QualifiedCell>
125class QualifiedCellHalfEdge : public ElementHalfEdge<QualifiedCell> {
126
127public:
128 typedef typename ElementHalfEdge<QualifiedCell>::Winding Winding;
129
130 QualifiedCellHalfEdge(QualifiedCell &cell, int edge, Winding winding = Winding::WINDING_NATURAL);
131
132 QualifiedCell & getCell() const;
133
134};
135
136template<typename QualifiedCell>
137class QualifiedCellHalfFace : public ElementHalfFace<QualifiedCell> {
138
139public:
140 typedef typename ElementHalfFace<QualifiedCell>::Winding Winding;
141
142 QualifiedCellHalfFace(QualifiedCell &cell, int face, Winding winding = Winding::WINDING_NATURAL);
143
144 QualifiedCell & getCell() const;
145
146};
147
148extern template class PiercedVector<Cell>;
149
150extern template class QualifiedCellHalfEdge<Cell>;
151extern template class QualifiedCellHalfEdge<const Cell>;
152
153extern template class QualifiedCellHalfFace<Cell>;
154extern template class QualifiedCellHalfFace<const Cell>;
155
158
161
162}
163
164// Include template implementations
165#include "cell.tpp"
166
167#endif
The Cell class defines the cells.
Definition cell.hpp:42
bool isInterior() const
Definition cell.cpp:396
void swap(Cell &other) noexcept
Definition cell.cpp:238
bool isFaceBorder(int face) const
Definition cell.cpp:946
void initialize(long id, ElementType type, bool interior, bool storeNeighbourhood)
Definition cell.cpp:257
bool pushAdjacency(int face, long adjacency)
Definition cell.cpp:771
void setInterior(bool interior)
Definition cell.cpp:385
void deleteInterface(int face, int i)
Definition cell.cpp:522
void setInterfaces(const std::vector< std::vector< long > > &interfaces)
Definition cell.cpp:450
void deleteAdjacencies()
Definition cell.cpp:674
int findInterface(int face, int interface)
Definition cell.cpp:635
int getInterfaceCount() const
Definition cell.cpp:535
void deleteInterfaces()
Definition cell.cpp:404
int findAdjacency(int face, int adjacency)
Definition cell.cpp:905
void resetInterfaces(bool storeInterfaces=true)
Definition cell.cpp:425
unsigned int getBinarySize() const
Definition cell.cpp:1061
void resetAdjacencies(bool storeAdjacencies=true)
Definition cell.cpp:695
long getAdjacency(int face, int index=0) const
Definition cell.cpp:831
const long * getAdjacencies() const
Definition cell.cpp:841
void setInterface(int face, int index, long interface)
Definition cell.cpp:484
void setAdjacency(int face, int index, long adjacencies)
Definition cell.cpp:754
const long * getInterfaces() const
Definition cell.cpp:571
void display(std::ostream &out, unsigned short int indent) const
Definition cell.cpp:958
void deleteAdjacency(int face, int i)
Definition cell.cpp:792
int getAdjacencyCount() const
Definition cell.cpp:805
long getInterface(int face, int index=0) const
Definition cell.cpp:561
void setAdjacencies(const std::vector< std::vector< long > > &adjacencies)
Definition cell.cpp:720
bool pushInterface(int face, long interface)
Definition cell.cpp:501
The ElementHalfEdge class defines element half-edge items.
Definition element.hpp:257
The ElementHalfFace class defines element half-faces.
Definition element.hpp:272
The Element class provides an interface for defining elements.
Definition element.hpp:46
Metafunction for generation of a flattened vector of vectors.
Output binary stream.
Output binary stream.
The PatchKernel class provides an interface for defining patches.
Metafunction for generating a pierced vector.
QualifiedCellHalfEdge(QualifiedCell &cell, int edge, Winding winding=Winding::WINDING_NATURAL)
Definition cell.tpp:47
QualifiedCell & getCell() const
Definition cell.tpp:58
The QualifiedCellHalfFace class defines cell half-faces.
Definition cell.hpp:137
QualifiedCellHalfFace(QualifiedCell &cell, int face, Winding winding=Winding::WINDING_NATURAL)
Definition cell.tpp:83
QualifiedCell & getCell() const
Definition cell.tpp:94
std::ostream & operator<<(std::ostream &, const std::vector< T > &)
#define BITPIT_DEPRECATED(func)
Definition compiler.hpp:87
--- layout: doxygen_footer ---