TTK
Loading...
Searching...
No Matches
HelloWorld.h
Go to the documentation of this file.
1
17
18#pragma once
19
20// ttk common includes
21#include <Debug.h>
22#include <Triangulation.h>
23
24namespace ttk {
25
30 class HelloWorld : virtual public Debug {
31
32 public:
33 HelloWorld();
34
44 ttk::AbstractTriangulation *triangulation) const {
45 return triangulation->preconditionVertexNeighbors();
46 }
47
55 template <class dataType,
56 class triangulationType = ttk::AbstractTriangulation>
57 int computeAverages(dataType *outputData,
58 const dataType *inputData,
59 const triangulationType *triangulation) const {
60 // start global timer
61 ttk::Timer globalTimer;
62
63 // print horizontal separator
64 this->printMsg(ttk::debug::Separator::L1); // L1 is the '=' separator
65
66 // print input parameters in table format
67 this->printMsg({
68 {"#Threads", std::to_string(this->threadNumber_)},
69 {"#Vertices", std::to_string(triangulation->getNumberOfVertices())},
70 });
72
73 // -----------------------------------------------------------------------
74 // Compute Vertex Averages
75 // -----------------------------------------------------------------------
76 {
77 // start a local timer for this subprocedure
78 ttk::Timer localTimer;
79
80 // print the progress of the current subprocedure (currently 0%)
81 this->printMsg("Computing Averages",
82 0, // progress form 0-1
83 0, // elapsed time so far
85
86 // compute the average of each vertex in parallel
87 size_t const nVertices = triangulation->getNumberOfVertices();
88#ifdef TTK_ENABLE_OPENMP
89#pragma omp parallel for num_threads(this->threadNumber_)
90#endif
91 for(size_t i = 0; i < nVertices; i++) {
92 // initialize average
93 outputData[i] = inputData[i];
94
95 // add neighbor values to average
96 size_t const nNeighbors = triangulation->getVertexNeighborNumber(i);
97 ttk::SimplexId neighborId{-1};
98 for(size_t j = 0; j < nNeighbors; j++) {
99 triangulation->getVertexNeighbor(i, j, neighborId);
100 outputData[i] += inputData[neighborId];
101 }
102
103 // divide by neighbor number
104 outputData[i] /= (nNeighbors + 1);
105 }
106
107 // print the progress of the current subprocedure with elapsed time
108 this->printMsg("Computing Averages",
109 1, // progress
110 localTimer.getElapsedTime(), this->threadNumber_);
111 }
112
113 // ---------------------------------------------------------------------
114 // print global performance
115 // ---------------------------------------------------------------------
116 {
117 this->printMsg(ttk::debug::Separator::L2); // horizontal '-' separator
118 this->printMsg(
119 "Complete", 1, globalTimer.getElapsedTime() // global progress, time
120 );
121 this->printMsg(ttk::debug::Separator::L1); // horizontal '=' separator
122 }
123
124 return 1; // return success
125 }
126
127 }; // HelloWorld class
128
129} // namespace ttk
AbstractTriangulation is an interface class that defines an interface for efficient traversal methods...
Minimalist debugging class.
Definition Debug.h:88
int preconditionTriangulation(ttk::AbstractTriangulation *triangulation) const
Definition HelloWorld.h:43
int computeAverages(dataType *outputData, const dataType *inputData, const triangulationType *triangulation) const
Definition HelloWorld.h:57
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)