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 // start a local timer for this subprocedure
72 ttk::Timer localTimer;
73
74#ifndef TTK_ENABLE_KAMIKAZE
75 if(!triangulation)
76 return -1;
77#endif
78
79 SimplexId vertexNumber = triangulation->getNumberOfVertices();
80 SimplexId cellNumber = triangulation->getNumberOfCells();
81
82 // create the octree
83 Octree preOctree(triangulation, argument);
84 for(SimplexId i = 0; i < vertexNumber; i++) {
85 preOctree.insertVertex(i);
86 }
87
88 for(SimplexId i = 0; i < cellNumber; i++) {
89 preOctree.insertCell(i);
90 }
91
92 if(preOctree.verifyTree(vertexNumber)) {
93 this->printErr("The construction of the tree failed!");
94 return -1;
95 }
96
97 preOctree.reindex(this->vertices, this->nodes, this->cells);
98 this->printMsg({
99 {"Size of vertex vector", std::to_string(this->vertices.size())},
100 {"Size of cell vector", std::to_string(this->cells.size())},
101 });
102 }
103
104 // ---------------------------------------------------------------------
105 // print global performance
106 // ---------------------------------------------------------------------
107 {
108 this->printMsg(ttk::debug::Separator::L2); // horizontal '-' separator
109 this->printMsg(
110 "Complete", 1, globalTimer.getElapsedTime() // global progress, time
111 );
112 this->printMsg(ttk::debug::Separator::L1); // horizontal '=' separator
113 }
114
115 return 1; // return success
116 }
117
118 void clear() {
119 this->vertices.clear();
120 this->nodes.clear();
121 this->cells.clear();
122 }
123
124 const std::vector<SimplexId> &getVertices() const {
125 return this->vertices;
126 }
127 const std::vector<SimplexId> &getNodes() const {
128 return this->nodes;
129 }
130 const std::vector<SimplexId> &getCells() const {
131 return this->cells;
132 }
133
134 protected:
135 mutable std::vector<SimplexId> vertices, nodes, cells;
136
137 }; // CompactTriangulationPreconditioning class
138
139} // 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
int threadNumber_
Definition: BaseClass.h:95
TTK processing package for mesh preprocessing before using TopoCluster.
const std::vector< SimplexId > & getVertices() const
const std::vector< SimplexId > & getNodes() const
const std::vector< SimplexId > & getCells() 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 printMsg(const std::string &msg, const debug::Priority &priority=debug::Priority::INFO, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
Definition: Debug.h:118
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
The Topology ToolKit.
int SimplexId
Identifier type for simplices of any dimension.
Definition: DataTypes.h:22