TTK
Loading...
Searching...
No Matches
BaseClass.cpp
Go to the documentation of this file.
1#include <BaseClass.h>
2
3#ifdef TTK_ENABLE_OPENMP
4COMMON_EXPORTS int ttk::globalThreadNumber_ = omp_get_max_threads();
5#else
7#endif
8
11#ifdef TTK_ENABLE_MPI
12COMMON_EXPORTS MPI_Comm ttk::MPIcomm_;
13#endif
14
15using namespace ttk;
16
17BaseClass::BaseClass() : lastObject_{false}, wrapper_{nullptr} {
19
20#ifdef TTK_ENABLE_MPI
21 if(ttk::MPIrank_ == -1) {
22 int flag;
23 MPI_Initialized(&flag);
24 if(flag) {
25 MPI_Comm_rank(MPI_COMM_WORLD, &ttk::MPIrank_);
26 MPI_Comm_size(MPI_COMM_WORLD, &ttk::MPIsize_);
27 MPI_Comm_dup(MPI_COMM_WORLD, &ttk::MPIcomm_);
28 } else {
29 ttk::MPIrank_ = 0;
30 ttk::MPIsize_ = 0;
31 }
32 }
33#endif // TTK_ENABLE_MPI
34}
35
36int BaseClass::setWrapper(const Wrapper *wrapper) {
37 wrapper_ = const_cast<Wrapper *>(wrapper);
38
39 // dynamic_cast is impossible because the Wrapper class is incomplete
40 setThreadNumber(reinterpret_cast<BaseClass *>(wrapper_)->threadNumber_);
41 return 0;
42}
#define COMMON_EXPORTS
Definition: BaseClass.h:31
TTK base package.
Definition: BaseClass.h:70
virtual int setWrapper(const Wrapper *wrapper)
Definition: BaseClass.cpp:36
int threadNumber_
Definition: BaseClass.h:95
virtual int setThreadNumber(const int threadNumber)
Definition: BaseClass.h:80
Wrapper * wrapper_
Definition: BaseClass.h:96
Wrapper class to wrap ttk code.
Definition: Wrapper.h:14
The Topology ToolKit.
COMMON_EXPORTS int MPIsize_
Definition: BaseClass.cpp:10
COMMON_EXPORTS int globalThreadNumber_
Definition: BaseClass.cpp:6
COMMON_EXPORTS int MPIrank_
Definition: BaseClass.cpp:9