38 const int &localEdgeId,
41#ifndef TTK_ENABLE_KAMIKAZE
54#ifndef TTK_ENABLE_KAMIKAZE
61 template <std::
size_t N>
64 std::vector<std::vector<SimplexId>> &vec) {
65 for(
size_t i = 0; i < table.size(); ++i) {
66 vec[i] = {table[i].begin(), table[i].end()};
70 inline const std::vector<std::vector<SimplexId>> *
79 const int &localNeighborId,
82 neighborId = cellNeighborData_[cellId][localNeighborId];
88 return cellNeighborData_.
size(cellId);
91 inline const std::vector<std::vector<SimplexId>> *
98 const int &localTriangleId,
101#ifndef TTK_ENABLE_KAMIKAZE
104 if((localTriangleId < 0)
116#ifndef TTK_ENABLE_KAMIKAZE
124 inline const std::vector<std::vector<SimplexId>> *
133 const int &localVertexId,
135#ifndef TTK_ENABLE_KAMIKAZE
136 if((!cellArray_) || (!cellNumber_))
139 vertexId = cellArray_->getCellVertex(cellId, localVertexId);
144 const SimplexId &cellId)
const override {
145#ifndef TTK_ENABLE_KAMIKAZE
146 if((!cellArray_) || (!cellNumber_))
149 return cellArray_->getCellVertexNumber(cellId);
156 inline const std::vector<std::array<SimplexId, 2>> *
163 const int &localLinkId,
166 linkId = edgeLinkData_[edgeId][localLinkId];
171 const SimplexId &edgeId)
const override {
172 return edgeLinkData_.
size(edgeId);
175 inline const std::vector<std::vector<SimplexId>> *
183 const int &localStarId,
186 starId = edgeStarData_[edgeId][localStarId];
191 const SimplexId &edgeId)
const override {
192 return edgeStarData_.
size(edgeId);
195 inline const std::vector<std::vector<SimplexId>> *
202 const int &localTriangleId,
204 triangleId = edgeTriangleData_[edgeId][localTriangleId];
210 return edgeTriangleData_.
size(edgeId);
213 inline const std::vector<std::vector<SimplexId>> *
220 const int &localVertexId,
222#ifndef TTK_ENABLE_KAMIKAZE
225 if((localVertexId != 0) && (localVertexId != 1))
250 return vertexNumber_;
253 inline const std::vector<std::array<SimplexId, 3>> *
259 const int &localEdgeId,
262#ifndef TTK_ENABLE_KAMIKAZE
266 if((localEdgeId < 0) || (localEdgeId > 2))
276 const SimplexId &triangleId)
const override {
278#ifndef TTK_ENABLE_KAMIKAZE
287 inline const std::vector<std::vector<SimplexId>> *
296 const int &localLinkId,
299 linkId = triangleLinkData_[triangleId][localLinkId];
304 const SimplexId &triangleId)
const override {
305 return triangleLinkData_[triangleId].
size();
308 inline const std::vector<std::vector<SimplexId>> *
316 const int &localStarId,
318 starId = triangleStarData_[triangleId][localStarId];
323 const SimplexId &triangleId)
const override {
324 return triangleStarData_[triangleId].
size();
327 inline const std::vector<std::vector<SimplexId>> *
334 const int &localVertexId,
336#ifndef TTK_ENABLE_KAMIKAZE
339 if((localVertexId < 0)
348 const int &localEdgeId,
350 edgeId = vertexEdgeData_[vertexId][localEdgeId];
356 return vertexEdgeData_[vertexId].
size();
359 inline const std::vector<std::vector<SimplexId>> *
367 const int &localLinkId,
370 linkId = vertexLinkData_[vertexId][localLinkId];
375 const SimplexId &vertexId)
const override {
376 return vertexLinkData_[vertexId].
size();
379 inline const std::vector<std::vector<SimplexId>> *
387 const int &localNeighborId,
390 neighborId = vertexNeighborData_[vertexId][localNeighborId];
395 const SimplexId &vertexId)
const override {
396 return vertexNeighborData_[vertexId].
size();
399 inline const std::vector<std::vector<SimplexId>> *
406 const SimplexId &vertexId,
float &x,
float &y,
float &z)
const override {
407#ifndef TTK_ENABLE_KAMIKAZE
408 if((vertexId < 0) || (vertexId >= vertexNumber_))
412 if(doublePrecision_) {
413 x = ((
const double *)pointSet_)[3 * vertexId];
414 y = ((
const double *)pointSet_)[3 * vertexId + 1];
415 z = ((
const double *)pointSet_)[3 * vertexId + 2];
417 x = ((
const float *)pointSet_)[3 * vertexId];
418 y = ((
const float *)pointSet_)[3 * vertexId + 1];
419 z = ((
const float *)pointSet_)[3 * vertexId + 2];
427 const int &localStarId,
429 starId = vertexStarData_[vertexId][localStarId];
434 const SimplexId &vertexId)
const override {
435 return vertexStarData_[vertexId].
size();
438 inline const std::vector<std::vector<SimplexId>> *
445 const int &localTriangleId,
447 triangleId = vertexTriangleData_[vertexId][localTriangleId];
452 const SimplexId &vertexId)
const override {
453 return vertexTriangleData_[vertexId].
size();
456 inline const std::vector<std::vector<SimplexId>> *
463 const SimplexId &edgeId)
const override {
464#ifndef TTK_ENABLE_KAMIKAZE
472 return !vertexNumber_;
476 const SimplexId &triangleId)
const override {
477#ifndef TTK_ENABLE_KAMIKAZE
486 const SimplexId &vertexId)
const override {
487#ifndef TTK_ENABLE_KAMIKAZE
520#ifdef TTK_CELL_ARRAY_NEW
529 const auto &cellDimension = offset[1] - offset[0] - 1;
531 if(cellDimension < 0 || cellDimension > 3) {
532 this->
printErr(
"Unable to create triangulation for cells of "
533 "dimension 4 or higher ("
534 + std::to_string(cellDimension) +
").");
540#ifdef TTK_ENABLE_OPENMP
541#pragma omp parallel for num_threads(this->threadNumber_)
543 for(
SimplexId i = 0; i < cellNumber; i++) {
544 if(offset[i + 1] - offset[i] - 1 != cellDimension) {
545#ifdef TTK_ENABLE_OPENMP
546#pragma omp atomic write
553 this->
printErr(
"Unable to create triangulation for "
554 "inhomogeneous\ncell dimensions.");
563 cellNumber_ = cellNumber;
566 = std::make_shared<CellArray>(connectivity, offset, cellNumber);
570 maxCellDim_ = cellArray_->getCellVertexNumber(0) - 1;
581 cellNumber_ = cellNumber;
585 cellArray_ = std::make_shared<CellArray>(
586 cellArray, cellNumber, cellArray[0] - 1);
587 maxCellDim_ = cellArray[0] - 1;
594 const void *pointSet,
595 const bool &doublePrecision =
false) {
600 vertexNumber_ = pointNumber;
601 pointSet_ = pointSet;
602 doublePrecision_ = doublePrecision;
625 inline void setCellsGlobalIds(
const LongSimplexId *
const cellGid) {
626 this->cellGid_ = cellGid;
629 this->vertGid_ = array;
633 getVertexGlobalIdInternal(
const SimplexId lvid)
const override {
634 return this->vertGid_[lvid];
638 getVertexLocalIdInternal(
const SimplexId gvid)
const override {
639 const auto it{this->vertexGidToLid_.find(gvid)};
640 if(it == this->vertexGidToLid_.end()) {
647 getCellGlobalIdInternal(
const SimplexId lcid)
const override {
648 return this->cellGid_[lcid];
652 getCellLocalIdInternal(
const SimplexId gcid)
const override {
653 const auto it{this->cellGidToLid_.find(gcid)};
654#ifndef TTK_ENABLE_KAMIKAZE
655 if(it == this->cellGidToLid_.end()) {
663 getEdgeGlobalIdInternal(
const SimplexId leid)
const override {
664 return this->edgeLidToGid_[leid];
668 getEdgeLocalIdInternal(
const SimplexId geid)
const override {
669 const auto it = this->edgeGidToLid_.find(geid);
670#ifndef TTK_ENABLE_KAMIKAZE
671 if(it == this->edgeGidToLid_.end()) {
679 getTriangleGlobalIdInternal(
const SimplexId ltid)
const override {
680 return this->triangleLidToGid_[ltid];
684 getTriangleLocalIdInternal(
const SimplexId gtid)
const override {
685 const auto it = this->triangleGidToLid_.find(gtid);
686#ifndef TTK_ENABLE_KAMIKAZE
687 if(it == this->triangleGidToLid_.end()) {
694 inline int setVertexRankArray(
const int *rankArray)
override {
695 vertexRankArray_.resize(vertexNumber_);
696 std::copy(rankArray, rankArray + vertexNumber_, vertexRankArray_.begin());
700 inline int setCellRankArray(
const int *rankArray)
override {
701 cellRankArray_.resize(cellNumber_);
702 std::copy(rankArray, rankArray + cellNumber_, cellRankArray_.begin());
706 inline int getVertexRankInternal(
const SimplexId lvid)
const override {
707 return this->vertexRankArray_[lvid];
710 inline std::unordered_map<SimplexId, SimplexId> &getVertexGlobalIdMap() {
711 return this->vertexGidToLid_;
715 template <
typename Func0,
typename Func1,
typename Func2>
716 int exchangeDistributedInternal(
const Func0 &getGlobalSimplexId,
717 const Func1 &storeGlobalSimplexId,
718 const Func2 &iterCond,
719 const int nSimplicesPerCell);
721 int preconditionDistributedCellRanges();
723 computeCellRangeOffsets(std::vector<size_t> &nSimplicesPerRange)
const;
725 int preconditionDistributedCells()
override;
726 int preconditionExchangeGhostCells()
override;
727 int preconditionDistributedEdges()
override;
728 int preconditionDistributedVertices()
override;
729 int preconditionExchangeGhostVertices()
override;
730 int preconditionDistributedTriangles()
override;
731 int preconditionVertexRankArray();
732 int preconditionCellRankArray();
733 int preconditionEdgeRankArray()
override;
734 int preconditionTriangleRankArray()
override;
748 static inline MPI_Datatype getMPIType() {
750 const auto cellRangeSize =
sizeof(CellRange) /
sizeof(
size_t);
751 MPI_Type_contiguous(cellRangeSize, ttk::getMPIType(
size_t{}), &res);
756 std::vector<CellRange> localCellRanges_{};
758 std::vector<CellRange> gatheredCellRanges_{};
760 std::vector<int> nRangesPerRank_{};
768 std::unordered_map<SimplexId, SimplexId> vertexGidToLid_{};
770 std::unordered_map<SimplexId, SimplexId> cellGidToLid_{};
772 std::vector<SimplexId> edgeLidToGid_{};
773 std::unordered_map<SimplexId, SimplexId> edgeGidToLid_{};
774 std::vector<SimplexId> triangleLidToGid_{};
775 std::unordered_map<SimplexId, SimplexId> triangleGidToLid_{};
777 std::vector<int> vertexRankArray_{};
778 std::vector<int> cellRankArray_{};
779 std::vector<int> edgeRankArray_{};
780 std::vector<int> triangleRankArray_{};
785 bool doublePrecision_;
787 const void *pointSet_;
789 std::shared_ptr<CellArray> cellArray_;
791 FlatJaggedArray vertexNeighborData_{};
792 FlatJaggedArray cellNeighborData_{};
793 FlatJaggedArray vertexEdgeData_{};
794 FlatJaggedArray vertexTriangleData_{};
795 FlatJaggedArray edgeTriangleData_{};
796 FlatJaggedArray vertexStarData_{};
797 FlatJaggedArray edgeStarData_{};
798 FlatJaggedArray triangleStarData_{};
799 FlatJaggedArray vertexLinkData_{};
800 FlatJaggedArray edgeLinkData_{};
801 FlatJaggedArray triangleLinkData_{};
804 static const char *magicBytes_;
807 static const unsigned long formatVersion_;
#define TTK_TRIANGULATION_INTERNAL(NAME)
AbstractTriangulation is an interface class that defines an interface for efficient traversal methods...
std::vector< std::vector< SimplexId > > vertexStarList_
std::vector< std::array< SimplexId, 3 > > triangleList_
std::vector< bool > boundaryEdges_
std::vector< bool > boundaryTriangles_
std::vector< std::array< SimplexId, 4 > > tetraTriangleList_
std::vector< std::vector< SimplexId > > triangleLinkList_
std::vector< std::vector< SimplexId > > vertexNeighborList_
std::vector< std::vector< SimplexId > > vertexLinkList_
std::vector< std::vector< SimplexId > > edgeLinkList_
std::vector< bool > boundaryVertices_
std::vector< std::vector< SimplexId > > vertexEdgeList_
std::vector< std::vector< SimplexId > > triangleEdgeVector_
std::vector< std::vector< SimplexId > > triangleStarList_
std::vector< std::vector< SimplexId > > cellNeighborList_
std::vector< std::array< SimplexId, 2 > > edgeList_
std::vector< std::array< SimplexId, 6 > > tetraEdgeList_
std::vector< std::vector< SimplexId > > edgeStarList_
std::vector< std::vector< SimplexId > > vertexTriangleList_
std::vector< std::vector< SimplexId > > cellEdgeVector_
std::vector< std::vector< SimplexId > > cellTriangleVector_
std::vector< std::array< SimplexId, 3 > > triangleEdgeList_
std::vector< std::vector< SimplexId > > edgeTriangleList_
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
ExplicitTriangulation is a class that provides time efficient traversal methods on triangulations of ...
SimplexId getTriangleEdgeNumberInternal(const SimplexId &triangleId) const override
SimplexId TTK_TRIANGULATION_INTERNAL() getVertexNeighborNumber(const SimplexId &vertexId) const override
int preconditionEdgeStarsInternal() override
int getVertexTriangleInternal(const SimplexId &vertexId, const int &localTriangleId, SimplexId &triangleId) const override
size_t footprint(size_t size=0) const
const std::vector< std::vector< SimplexId > > * getTriangleEdgesInternal() override
int TTK_TRIANGULATION_INTERNAL() getVertexPoint(const SimplexId &vertexId, float &x, float &y, float &z) const override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getVertexStars() override
int TTK_TRIANGULATION_INTERNAL() getVertexNeighbor(const SimplexId &vertexId, const int &localNeighborId, SimplexId &neighborId) const override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getEdgeStars() override
int TTK_TRIANGULATION_INTERNAL() getVertexStar(const SimplexId &vertexId, const int &localStarId, SimplexId &starId) const override
int preconditionTriangleStarsInternal() override
int TTK_TRIANGULATION_INTERNAL() getCellVertex(const SimplexId &cellId, const int &localVertexId, SimplexId &vertexId) const override
int getVertexEdgeInternal(const SimplexId &vertexId, const int &localEdgeId, SimplexId &edgeId) const override
SimplexId TTK_TRIANGULATION_INTERNAL() getTriangleLinkNumber(const SimplexId &triangleId) const override
int preconditionTrianglesInternal() override
SimplexId getNumberOfTrianglesInternal() const override
SimplexId getCellEdgeNumberInternal(const SimplexId &cellId) const override
int writeToFile(std::ofstream &stream) const
Write internal state to disk.
int preconditionBoundaryTrianglesInternal() override
const std::vector< std::vector< SimplexId > > * getVertexTrianglesInternal() override
int setInputCells(const SimplexId &cellNumber, const LongSimplexId *cellArray)
int preconditionEdgesInternal() override
SimplexId TTK_TRIANGULATION_INTERNAL() getVertexLinkNumber(const SimplexId &vertexId) const override
int preconditionCellTrianglesInternal() override
int preconditionVertexNeighborsInternal() override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getTriangleStars() override
SimplexId TTK_TRIANGULATION_INTERNAL() getNumberOfCells() const override
int TTK_TRIANGULATION_INTERNAL() getTriangleStar(const SimplexId &triangleId, const int &localStarId, SimplexId &starId) const override
int preconditionCellEdgesInternal() override
int preconditionVertexLinksInternal() override
SimplexId TTK_TRIANGULATION_INTERNAL() getTriangleStarNumber(const SimplexId &triangleId) const override
bool TTK_TRIANGULATION_INTERNAL() isVertexOnBoundary(const SimplexId &vertexId) const override
const std::vector< std::array< SimplexId, 3 > > *TTK_TRIANGULATION_INTERNAL() getTriangles() override
int preconditionTriangleLinksInternal() override
int getTriangleVertexInternal(const SimplexId &triangleId, const int &localVertexId, SimplexId &vertexId) const override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getVertexLinks() override
int preconditionManifoldInternal() override
ExplicitTriangulation & operator=(ExplicitTriangulation &&)=default
~ExplicitTriangulation() override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getEdgeLinks() override
SimplexId getVertexTriangleNumberInternal(const SimplexId &vertexId) const override
int preconditionEdgeLinksInternal() override
ExplicitTriangulation & operator=(const ExplicitTriangulation &)=default
const std::vector< std::array< SimplexId, 2 > > *TTK_TRIANGULATION_INTERNAL() getEdges() override
int preconditionVertexStarsInternal() override
SimplexId TTK_TRIANGULATION_INTERNAL() getCellNeighborNumber(const SimplexId &cellId) const override
int preconditionVertexEdgesInternal() override
bool TTK_TRIANGULATION_INTERNAL() isTriangleOnBoundary(const SimplexId &triangleId) const override
int getEdgeVertexInternal(const SimplexId &edgeId, const int &localVertexId, SimplexId &vertexId) const override
const std::vector< std::vector< SimplexId > > * getCellEdgesInternal() override
int setInputPoints(const SimplexId &pointNumber, const void *pointSet, const bool &doublePrecision=false)
int preconditionBoundaryEdgesInternal() override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getCellNeighbors() override
void convertToVector(const std::vector< std::array< SimplexId, N > > &table, std::vector< std::vector< SimplexId > > &vec)
int preconditionEdgeTrianglesInternal() override
int getCellEdgeInternal(const SimplexId &cellId, const int &localEdgeId, SimplexId &edgeId) const override
int preconditionBoundaryVerticesInternal() override
SimplexId getNumberOfEdgesInternal() const override
const std::vector< std::vector< SimplexId > > * getCellTrianglesInternal() override
int preconditionTriangleEdgesInternal() override
ExplicitTriangulation(const ExplicitTriangulation &)=default
SimplexId TTK_TRIANGULATION_INTERNAL() getEdgeStarNumber(const SimplexId &edgeId) const override
int TTK_TRIANGULATION_INTERNAL() getDimensionality() const override
const std::vector< std::vector< SimplexId > > * getEdgeTrianglesInternal() override
int TTK_TRIANGULATION_INTERNAL() getEdgeStar(const SimplexId &edgeId, const int &localStarId, SimplexId &starId) const override
int TTK_TRIANGULATION_INTERNAL() getEdgeLink(const SimplexId &edgeId, const int &localLinkId, SimplexId &linkId) const override
ExplicitTriangulation(ExplicitTriangulation &&)=default
int preconditionCellNeighborsInternal() override
const std::vector< std::vector< SimplexId > > * getVertexEdgesInternal() override
int getEdgeTriangleInternal(const SimplexId &edgeId, const int &localTriangleId, SimplexId &triangleId) const override
int TTK_TRIANGULATION_INTERNAL() getCellNeighbor(const SimplexId &cellId, const int &localNeighborId, SimplexId &neighborId) const override
bool TTK_TRIANGULATION_INTERNAL() isEdgeOnBoundary(const SimplexId &edgeId) const override
int writeToFileASCII(std::ofstream &stream) const
Write internal state to disk using an ASCII format.
SimplexId getEdgeTriangleNumberInternal(const SimplexId &edgeId) const override
SimplexId getCellTriangleNumberInternal(const SimplexId &cellId) const override
SimplexId getVertexEdgeNumberInternal(const SimplexId &vertexId) const override
SimplexId TTK_TRIANGULATION_INTERNAL() getNumberOfVertices() const override
SimplexId TTK_TRIANGULATION_INTERNAL() getEdgeLinkNumber(const SimplexId &edgeId) const override
int getTriangleEdgeInternal(const SimplexId &triangleId, const int &localEdgeId, SimplexId &edgeId) const override
SimplexId TTK_TRIANGULATION_INTERNAL() getVertexStarNumber(const SimplexId &vertexId) const override
SimplexId TTK_TRIANGULATION_INTERNAL() getCellVertexNumber(const SimplexId &cellId) const override
int getCellTriangleInternal(const SimplexId &cellId, const int &localTriangleId, SimplexId &triangleId) const override
int TTK_TRIANGULATION_INTERNAL() getVertexLink(const SimplexId &vertexId, const int &localLinkId, SimplexId &linkId) const override
bool isEmpty() const override
int preconditionVertexTrianglesInternal() override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getVertexNeighbors() override
int readFromFile(std::ifstream &stream)
Read from disk into internal state.
int TTK_TRIANGULATION_INTERNAL() getTriangleLink(const SimplexId &triangleId, const int &localLinkId, SimplexId &linkId) const override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL() getTriangleLinks() override
void copyTo(std::vector< std::vector< SimplexId > > &dst, int threadNumber=1) const
Copy buffers to a std::vector<std::vector<SimplexId>>
SimplexId size(SimplexId id) const
Get the size of a particular sub-vector.
long long int LongSimplexId
Identifier type for simplices of any dimension.
int SimplexId
Identifier type for simplices of any dimension.
T end(std::pair< T, T > &p)
T begin(std::pair< T, T > &p)