27#include "bitpit_common.hpp"
42IBinaryStream& operator>>(IBinaryStream &buffer, Cell &cell)
45 Element &element(cell);
49 buffer >> cell.m_interfaces;
52 buffer >> cell.m_adjacencies;
65OBinaryStream&
operator<<(OBinaryStream &buffer,
const Cell &cell)
68 const Element &element(cell);
72 buffer << cell.m_interfaces;
75 buffer << cell.m_adjacencies;
102 if (!storeNeighbourhood || type == ElementType::UNDEFINED) {
119 m_interfaces(createNeighbourhoodStorage(false)),
120 m_adjacencies(createNeighbourhoodStorage(false)),
136 :
Cell(id, type, interior, storeNeighbourhood, storeNeighbourhood)
152 :
Cell(id, type, connectSize, interior, storeNeighbourhood, storeNeighbourhood)
167Cell::Cell(
long id,
ElementType type, std::unique_ptr<
long[]> &&connectStorage,
bool interior,
bool storeNeighbourhood)
168 :
Cell(id, type, std::move(connectStorage), interior, storeNeighbourhood, storeNeighbourhood)
185 m_interfaces(createNeighbourhoodStorage(storeInterfaces)),
186 m_adjacencies(createNeighbourhoodStorage(storeAdjacencies))
188 _initialize(interior,
false,
false,
false,
false);
205 :
Element(id, type, connectSize),
206 m_interfaces(createNeighbourhoodStorage(storeInterfaces)),
207 m_adjacencies(createNeighbourhoodStorage(storeAdjacencies))
209 _initialize(interior,
false,
false,
false,
false);
225Cell::Cell(
long id,
ElementType type, std::unique_ptr<
long[]> &&connectStorage,
bool interior,
bool storeInterfaces,
bool storeAdjacencies)
226 :
Element(id, type, std::move(connectStorage)),
227 m_interfaces(createNeighbourhoodStorage(storeInterfaces)),
228 m_adjacencies(createNeighbourhoodStorage(storeAdjacencies))
230 _initialize(interior,
false,
false,
false,
false);
242 std::swap(other.m_interior, m_interior);
244 other.m_interfaces.swap(m_interfaces);
245 other.m_adjacencies.swap(m_adjacencies);
259 initialize(
id, type, interior, storeNeighbourhood, storeNeighbourhood);
275 initialize(
id, type, connectSize, interior, storeNeighbourhood, storeNeighbourhood);
291 initialize(
id, type, std::move(connectStorage), interior, storeNeighbourhood, storeNeighbourhood);
309 _initialize(interior,
true, storeInterfaces,
true, storeAdjacencies);
329 _initialize(interior,
true, storeInterfaces,
true, storeAdjacencies);
345void Cell::initialize(
long id,
ElementType type, std::unique_ptr<
long[]> &&connectStorage,
bool interior,
bool storeInterfaces,
bool storeAdjacencies)
349 _initialize(interior,
true, storeInterfaces,
true, storeAdjacencies);
365void Cell::_initialize(
bool interior,
bool initializeInterfaces,
bool storeInterfaces,
bool initializeAdjacency,
bool storeAdjacencies)
370 if (initializeInterfaces) {
375 if (initializeAdjacency) {
387 m_interior = interior;
429 if (!storeInterfaces || type == ElementType::UNDEFINED) {
452 if (
getType() == ElementType::UNDEFINED) {
468 if (
getType() == ElementType::UNDEFINED) {
474 m_interfaces.
swap(interfaces);
486 m_interfaces.
setItem(face, index, interface);
563 return m_interfaces.
getItem(face, index);
573 if (m_interfaces.
empty()) {
577 return m_interfaces.
get(0);
588 if (m_interfaces.
empty()) {
592 return m_interfaces.
get(face);
602 if (m_interfaces.
empty()) {
606 return m_interfaces.
get(0);
617 if (m_interfaces.
empty()) {
621 return m_interfaces.
get(face);
639 for (
int i = 0; i < nFaceInterfaces; i++) {
640 if (faceInterfaces[i] == interface) {
662 for (
int i = 0; i < nCellInterfaces; i++) {
663 if (interfaces[i] == interface) {
699 if (!storeAdjacencies || type == ElementType::UNDEFINED) {
722 if (
getType() == ElementType::UNDEFINED) {
738 if (
getType() == ElementType::UNDEFINED) {
744 m_adjacencies.
swap(adjacencies);
756 m_adjacencies.
setItem(face, index, adjacency);
833 return m_adjacencies.
getItem(face, index);
843 if (m_adjacencies.
empty()) {
847 return m_adjacencies.
get(0);
858 if (m_adjacencies.
empty()) {
862 return m_adjacencies.
get(face);
872 if (m_adjacencies.
empty()) {
876 return m_adjacencies.
get(0);
887 if (m_adjacencies.
empty()) {
891 return m_adjacencies.
get(face);
909 for (
int i = 0; i < nFaceAdjacencies; i++) {
910 if (faceAdjacencies[i] == adjacency) {
932 for (
int i = 0; i < nCellAdjacencies; i++) {
933 if (adjacencies[i] == adjacency) {
965 std::string t_s(indent,
' ');
974 if (
getType() == ElementType::UNDEFINED) {
975 out << t_s <<
"cell type: (unknown)" << std::endl;
986 out << t_s <<
"cell type: " <<
getType() << std::endl;
987 out << t_s <<
"ID: " <<
getId() << std::endl;
988 out << t_s <<
"is ghost: ";
989 if (m_interior) { out <<
"(false)"; }
990 else { out <<
"(true)"; }
994 out << t_s <<
"connectivity: [ ";
995 for (i = 0; i < nv-1; ++i) {
996 if (cellVertexIds[i] == Vertex::NULL_ID) out <<
"n.a. ";
997 else out << cellVertexIds[i] <<
", ";
999 if (cellVertexIds[nv-1] == Vertex::NULL_ID) out <<
"n.a. ";
1000 else out << cellVertexIds[nv-1] <<
" ]" << std::endl;
1003 if (m_adjacencies.
size() > 0) {
1004 out << t_s <<
"neighbors: [ ";
1005 for (i = 0; i < nf; ++i) {
1011 for (j = 0; j < nn; ++j) {
1013 if (j != (nn - 1)) {
1020 if (i != (nf - 1)) {
1025 out <<
"]" << std::endl;
1029 if (m_interfaces.
size() > 0) {
1030 out << t_s <<
"interfaces: [ ";
1031 for (i = 0; i < nf; ++i) {
1037 for (j = 0; j < nn; ++j) {
1039 if (j != (nn - 1)) {
1046 if (i != (nf - 1)) {
1051 out <<
"]" << std::endl;
The Cell class defines the cells.
void swap(Cell &other) noexcept
bool isFaceBorder(int face) const
void initialize(long id, ElementType type, bool interior, bool storeNeighbourhood)
bool pushAdjacency(int face, long adjacency)
void setInterior(bool interior)
void deleteInterface(int face, int i)
void setInterfaces(const std::vector< std::vector< long > > &interfaces)
int findInterface(int face, int interface)
int getInterfaceCount() const
int findAdjacency(int face, int adjacency)
void resetInterfaces(bool storeInterfaces=true)
unsigned int getBinarySize() const
void resetAdjacencies(bool storeAdjacencies=true)
long getAdjacency(int face, int index=0) const
const long * getAdjacencies() const
void setInterface(int face, int index, long interface)
void setAdjacency(int face, int index, long adjacencies)
const long * getInterfaces() const
void display(std::ostream &out, unsigned short int indent) const
void deleteAdjacency(int face, int i)
int getAdjacencyCount() const
long getInterface(int face, int index=0) const
void setAdjacencies(const std::vector< std::vector< long > > &adjacencies)
bool pushInterface(int face, long interface)
The Element class provides an interface for defining elements.
ElementType getType() const
void swap(Element &other) noexcept
unsigned int getBinarySize() const
ConstProxyVector< long > getVertexIds() const
void initialize(long id, ElementType type, int connectSize=0)
int getVertexCount() const
Metafunction for generation of a flattened vector of vectors.
T & getItem(std::size_t i, std::size_t j)
void swap(FlatVector2D &other) noexcept
std::size_t getItemCount() const
void initialize(const std::vector< std::size_t > &sizes, const T &value=T())
void eraseItem(std::size_t i, std::size_t j)
const T * get(std::size_t i) const
std::size_t getBinarySize() const
void setItem(std::size_t i, std::size_t j, const T &value)
void pushBackItem(const T &value)
Metafunction for generating a pierced vector.
Metafunction for generating a list of elements that can be either stored in an external vectror or,...
The QualifiedCellHalfFace class defines cell half-faces.
Logger & operator<<(Logger &logger, LoggerManipulator< T > &&m)