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 int getEdgeRankInternal(
const SimplexId lvid)
const override {
711 return this->edgeRankArray_[lvid];
714 inline int getTriangleRankInternal(
const SimplexId lvid)
const override {
715 return this->triangleRankArray_[lvid];
718 inline std::unordered_map<SimplexId, SimplexId> &getVertexGlobalIdMap() {
719 return this->vertexGidToLid_;
723 template <
typename Func0,
typename Func1,
typename Func2>
724 int exchangeDistributedInternal(
const Func0 &getGlobalSimplexId,
725 const Func1 &storeGlobalSimplexId,
726 const Func2 &iterCond,
727 const int nSimplicesPerCell);
729 int preconditionDistributedCellRanges();
731 computeCellRangeOffsets(std::vector<size_t> &nSimplicesPerRange)
const;
733 int preconditionDistributedCells()
override;
734 int preconditionExchangeGhostCells()
override;
735 int preconditionDistributedEdges()
override;
736 int preconditionDistributedVertices()
override;
737 int preconditionExchangeGhostVertices()
override;
738 int preconditionDistributedTriangles()
override;
739 int preconditionVertexRankArray();
740 int preconditionCellRankArray();
741 int preconditionEdgeRankArray()
override;
742 int preconditionTriangleRankArray()
override;
756 static inline MPI_Datatype getMPIType() {
758 const auto cellRangeSize =
sizeof(CellRange) /
sizeof(
size_t);
759 MPI_Type_contiguous(cellRangeSize, ttk::getMPIType(
size_t{}), &res);
764 std::vector<CellRange> localCellRanges_{};
766 std::vector<CellRange> gatheredCellRanges_{};
768 std::vector<int> nRangesPerRank_{};
776 std::unordered_map<SimplexId, SimplexId> vertexGidToLid_{};
778 std::unordered_map<SimplexId, SimplexId> cellGidToLid_{};
780 std::vector<SimplexId> edgeLidToGid_{};
781 std::unordered_map<SimplexId, SimplexId> edgeGidToLid_{};
782 std::vector<SimplexId> triangleLidToGid_{};
783 std::unordered_map<SimplexId, SimplexId> triangleGidToLid_{};
785 std::vector<int> vertexRankArray_{};
786 std::vector<int> cellRankArray_{};
787 std::vector<int> edgeRankArray_{};
788 std::vector<int> triangleRankArray_{};
793 bool doublePrecision_;
795 const void *pointSet_;
797 std::shared_ptr<CellArray> cellArray_;
799 FlatJaggedArray vertexNeighborData_{};
800 FlatJaggedArray cellNeighborData_{};
801 FlatJaggedArray vertexEdgeData_{};
802 FlatJaggedArray vertexTriangleData_{};
803 FlatJaggedArray edgeTriangleData_{};
804 FlatJaggedArray vertexStarData_{};
805 FlatJaggedArray edgeStarData_{};
806 FlatJaggedArray triangleStarData_{};
807 FlatJaggedArray vertexLinkData_{};
808 FlatJaggedArray edgeLinkData_{};
809 FlatJaggedArray triangleLinkData_{};
812 static const char *magicBytes_;
815 static const unsigned long formatVersion_;
#define TTK_TRIANGULATION_INTERNAL(NAME)
int SimplexId
Identifier type for simplices of any dimension.
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
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL getTriangleStars() override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL getVertexLinks() override
SimplexId getTriangleEdgeNumberInternal(const SimplexId &triangleId) const override
int preconditionEdgeStarsInternal() override
SimplexId TTK_TRIANGULATION_INTERNAL getVertexLinkNumber(const SimplexId &vertexId) const override
int getVertexTriangleInternal(const SimplexId &vertexId, const int &localTriangleId, SimplexId &triangleId) const override
size_t footprint(size_t size=0) const
bool TTK_TRIANGULATION_INTERNAL isTriangleOnBoundary(const SimplexId &triangleId) const override
const std::vector< std::vector< SimplexId > > * getTriangleEdgesInternal() override
int TTK_TRIANGULATION_INTERNAL getVertexLink(const SimplexId &vertexId, const int &localLinkId, SimplexId &linkId) const override
SimplexId TTK_TRIANGULATION_INTERNAL getCellNeighborNumber(const SimplexId &cellId) const override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL getCellNeighbors() override
SimplexId TTK_TRIANGULATION_INTERNAL getNumberOfCells() const override
int preconditionTriangleStarsInternal() override
SimplexId TTK_TRIANGULATION_INTERNAL getVertexNeighborNumber(const SimplexId &vertexId) const override
int getVertexEdgeInternal(const SimplexId &vertexId, const int &localEdgeId, SimplexId &edgeId) const override
int preconditionTrianglesInternal() override
bool TTK_TRIANGULATION_INTERNAL isEdgeOnBoundary(const SimplexId &edgeId) const 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
int preconditionCellTrianglesInternal() override
int TTK_TRIANGULATION_INTERNAL getTriangleLink(const SimplexId &triangleId, const int &localLinkId, SimplexId &linkId) const override
int TTK_TRIANGULATION_INTERNAL getEdgeLink(const SimplexId &edgeId, const int &localLinkId, SimplexId &linkId) const override
int preconditionVertexNeighborsInternal() override
int preconditionCellEdgesInternal() override
int TTK_TRIANGULATION_INTERNAL getVertexPoint(const SimplexId &vertexId, float &x, float &y, float &z) const override
int preconditionVertexLinksInternal() override
int TTK_TRIANGULATION_INTERNAL getVertexStar(const SimplexId &vertexId, const int &localStarId, SimplexId &starId) const override
const std::vector< std::array< SimplexId, 2 > > *TTK_TRIANGULATION_INTERNAL getEdges() override
SimplexId TTK_TRIANGULATION_INTERNAL getEdgeLinkNumber(const SimplexId &edgeId) const override
int preconditionTriangleLinksInternal() override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL getEdgeLinks() override
int getTriangleVertexInternal(const SimplexId &triangleId, const int &localVertexId, SimplexId &vertexId) const override
int preconditionManifoldInternal() override
int TTK_TRIANGULATION_INTERNAL getDimensionality() const override
ExplicitTriangulation & operator=(ExplicitTriangulation &&)=default
~ExplicitTriangulation() override
SimplexId getVertexTriangleNumberInternal(const SimplexId &vertexId) const override
SimplexId TTK_TRIANGULATION_INTERNAL getTriangleLinkNumber(const SimplexId &triangleId) const override
SimplexId TTK_TRIANGULATION_INTERNAL getTriangleStarNumber(const SimplexId &triangleId) const override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL getVertexNeighbors() override
int preconditionEdgeLinksInternal() override
int TTK_TRIANGULATION_INTERNAL getCellVertex(const SimplexId &cellId, const int &localVertexId, SimplexId &vertexId) const override
ExplicitTriangulation & operator=(const ExplicitTriangulation &)=default
int preconditionVertexStarsInternal() override
int preconditionVertexEdgesInternal() 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)
SimplexId TTK_TRIANGULATION_INTERNAL getNumberOfVertices() const override
int TTK_TRIANGULATION_INTERNAL getTriangleStar(const SimplexId &triangleId, const int &localStarId, SimplexId &starId) const override
int preconditionBoundaryEdgesInternal() override
void convertToVector(const std::vector< std::array< SimplexId, N > > &table, std::vector< std::vector< SimplexId > > &vec)
const std::vector< std::array< SimplexId, 3 > > *TTK_TRIANGULATION_INTERNAL getTriangles() override
int preconditionEdgeTrianglesInternal() override
int getCellEdgeInternal(const SimplexId &cellId, const int &localEdgeId, SimplexId &edgeId) const override
SimplexId TTK_TRIANGULATION_INTERNAL getEdgeStarNumber(const 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 getVertexStarNumber(const SimplexId &vertexId) const override
int TTK_TRIANGULATION_INTERNAL getVertexNeighbor(const SimplexId &vertexId, const int &localNeighborId, SimplexId &neighborId) const override
int TTK_TRIANGULATION_INTERNAL getEdgeStar(const SimplexId &edgeId, const int &localStarId, SimplexId &starId) const override
const std::vector< std::vector< SimplexId > > * getEdgeTrianglesInternal() override
ExplicitTriangulation(ExplicitTriangulation &&)=default
int preconditionCellNeighborsInternal() override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL getTriangleLinks() override
const std::vector< std::vector< SimplexId > > * getVertexEdgesInternal() override
int getEdgeTriangleInternal(const SimplexId &edgeId, const int &localTriangleId, SimplexId &triangleId) const override
int writeToFileASCII(std::ofstream &stream) const
Write internal state to disk using an ASCII format.
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL getEdgeStars() override
SimplexId getEdgeTriangleNumberInternal(const SimplexId &edgeId) const override
int TTK_TRIANGULATION_INTERNAL getCellNeighbor(const SimplexId &cellId, const int &localNeighborId, SimplexId &neighborId) const override
SimplexId getCellTriangleNumberInternal(const SimplexId &cellId) const override
SimplexId TTK_TRIANGULATION_INTERNAL getCellVertexNumber(const SimplexId &cellId) const override
SimplexId getVertexEdgeNumberInternal(const SimplexId &vertexId) const override
const std::vector< std::vector< SimplexId > > *TTK_TRIANGULATION_INTERNAL getVertexStars() override
int getTriangleEdgeInternal(const SimplexId &triangleId, const int &localEdgeId, SimplexId &edgeId) const override
int getCellTriangleInternal(const SimplexId &cellId, const int &localTriangleId, SimplexId &triangleId) const override
bool isEmpty() const override
int preconditionVertexTrianglesInternal() override
bool TTK_TRIANGULATION_INTERNAL isVertexOnBoundary(const SimplexId &vertexId) const override
int readFromFile(std::ifstream &stream)
Read from disk into internal state.
TTK base package defining the standard types.
int SimplexId
Identifier type for simplices of any dimension.
long long int LongSimplexId
Identifier type for simplices of any dimension.
T end(std::pair< T, T > &p)
T begin(std::pair< T, T > &p)