TTK
Loading...
Searching...
No Matches
CompactTriangulationPreconditioning.h
Go to the documentation of this file.
1
25
26#pragma once
27
28// ttk common includes
29#include <Debug.h>
30#include <Octree.h>
31#include <Triangulation.h>
32
33namespace ttk {
34
40
41 public:
44 "CompactTriangulationPreconditioning"); // inherited from Debug: prefix
45 // will be printed at the
46 // beginning of every msg
47 };
49 ;
50
51 template <class triangulationType = ttk::AbstractTriangulation>
52 int execute(const triangulationType *triangulation,
53 const int &argument) const {
54 // start global timer
55 ttk::Timer globalTimer;
56
57 // print horizontal separator
58 this->printMsg(ttk::debug::Separator::L1); // L1 is the '=' separator
59
60 // print input parameters in table format
61 this->printMsg({
62 {"#Threads", std::to_string(this->threadNumber_)},
63 {"#Vertices", std::to_string(triangulation->getNumberOfVertices())},
64 });
66
67 // -----------------------------------------------------------------------
68 // Compute Octree
69 // -----------------------------------------------------------------------
70 {
71#ifndef TTK_ENABLE_KAMIKAZE
72 if(!triangulation)
73 return -1;
74#endif
75
76 SimplexId vertexNumber = triangulation->getNumberOfVertices();
77 SimplexId const cellNumber = triangulation->getNumberOfCells();
78
79 // create the octree
80 Octree preOctree(triangulation, argument);
81 for(SimplexId i = 0; i < vertexNumber; i++) {
82 preOctree.insertVertex(i);
83 }
84
85 for(SimplexId i = 0; i < cellNumber; i++) {
86 preOctree.insertCell(i);
87 }
88
89 if(preOctree.verifyTree(vertexNumber)) {
90 this->printErr("The construction of the tree failed!");
91 return -1;
92 }
93
94 preOctree.reindex(this->vertices, this->nodes, this->cells);
95 this->printMsg({
96 {"Size of vertex vector", std::to_string(this->vertices.size())},
97 {"Size of cell vector", std::to_string(this->cells.size())},
98 });
99 }
100
101 // ---------------------------------------------------------------------
102 // print global performance
103 // ---------------------------------------------------------------------
104 {
105 this->printMsg(ttk::debug::Separator::L2); // horizontal '-' separator
106 this->printMsg(
107 "Complete", 1, globalTimer.getElapsedTime() // global progress, time
108 );
109 this->printMsg(ttk::debug::Separator::L1); // horizontal '=' separator
110 }
111
112 return 1; // return success
113 }
114
115 void clear() {
116 this->vertices.clear();
117 this->nodes.clear();
118 this->cells.clear();
119 }
120
121 const std::vector<SimplexId> &getVertices() const {
122 return this->vertices;
123 }
124 const std::vector<SimplexId> &getNodes() const {
125 return this->nodes;
126 }
127 const std::vector<SimplexId> &getCells() const {
128 return this->cells;
129 }
130
131 protected:
132 mutable std::vector<SimplexId> vertices, nodes, cells;
133
134 }; // CompactTriangulationPreconditioning class
135
136} // namespace ttk
Implementation of the point region (PR) octree.
Definition Octree.h:52
int insertVertex(ttk::SimplexId &vertexId)
Definition Octree.cpp:123
int insertCell(ttk::SimplexId &cellId)
Definition Octree.cpp:158
void reindex(std::vector< ttk::SimplexId > &vertices, std::vector< ttk::SimplexId > &nodes, std::vector< ttk::SimplexId > &cells)
Definition Octree.cpp:197
int verifyTree(ttk::SimplexId &vertexNum)
Definition Octree.cpp:96
TTK processing package for mesh preprocessing before using TopoCluster.
const std::vector< SimplexId > & getVertices() const
~CompactTriangulationPreconditioning() override=default
int execute(const triangulationType *triangulation, const int &argument) const
Minimalist debugging class.
Definition Debug.h:88
void setDebugMsgPrefix(const std::string &prefix)
Definition Debug.h:364
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Definition Debug.h:149
double getElapsedTime()
Definition Timer.h:15
std::string to_string(__int128)
Definition ripserpy.cpp:99
The Topology ToolKit.
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)