MCPcopy Create free account
hub / github.com/Kitware/VTK / Initialize

Method Initialize

Filters/ParallelFlowPaths/vtkPStreamTracer.cxx:1003–1057  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1001 }
1002
1003 void Initialize(bool hasData, const PStreamTracerPointArray& seeds, int MaxId)
1004 {
1005 AssertGe(MaxId, 0);
1006 int numSeeds = static_cast<int>(seeds.size());
1007 this->HasData.resize(this->NumProcs);
1008 std::fill(this->HasData.begin(), this->HasData.end(), 0);
1009 {
1010 const int self_hasdata = hasData ? 1 : 0;
1011 this->Controller->AllGather(&self_hasdata, this->HasData.data(), 1);
1012 }
1013
1014 for (int i = 0; i < NumProcs; i++)
1015 {
1016 if (this->HasData[i])
1017 {
1018 this->Leader = i;
1019 break;
1020 }
1021 }
1022
1023 std::vector<int> processMap0(MaxId + 1, -1);
1024 for (int i = 0; i < numSeeds; i++)
1025 {
1026 int rank = seeds[i]->GetRank();
1027 int id = seeds[i]->GetId();
1028 if (rank < 0 && this->Locator)
1029 {
1030 rank = this->Locator->InCurrentProcess(seeds[i]->GetSeed()) ? this->Rank : -1;
1031 }
1032 processMap0[id] = rank;
1033 }
1034
1035 std::vector<int> processMap(MaxId + 1);
1036 this->Controller->AllReduce(
1037 processMap0.data(), processMap.data(), MaxId + 1, vtkCommunicator::MAX_OP);
1038
1039 int totalNumTasks = std::accumulate(processMap.begin(), processMap.end(), 0,
1040 [](int accumlatedSum, int b) { return accumlatedSum + (b >= 0 ? 1 : 0); });
1041
1042 this->TotalNumTasks = Rank == this->Leader
1043 ? totalNumTasks
1044 : INT_MAX; // only the master process knows how many are left
1045
1046 for (int i = 0; i < numSeeds; i++)
1047 {
1048 int id = seeds[i]->GetId();
1049 if (processMap[id] == Rank)
1050 {
1051 vtkNew<Task> task;
1052 task->Point = seeds[i];
1053 NTasks.emplace_back(task);
1054 }
1055 }
1056 ALLPRINT(NTasks.size() << " initial seeds out of " << totalNumTasks);
1057 }
1058
1059 Task* NextTask()
1060 {

Callers 7

InitializeMethod · 0.45
RequestDataMethod · 0.45
TestPStreamFunction · 0.45
TestPStreamAMRFunction · 0.45
TestPParticleTracersFunction · 0.45
TestPStreamGeometryFunction · 0.45

Calls 13

InCurrentProcessMethod · 0.80
fillFunction · 0.50
sizeMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
AllGatherMethod · 0.45
dataMethod · 0.45
GetRankMethod · 0.45
GetIdMethod · 0.45
GetSeedMethod · 0.45
AllReduceMethod · 0.45

Tested by 5

TestPStreamFunction · 0.36
TestPStreamAMRFunction · 0.36
TestPParticleTracersFunction · 0.36
TestPStreamGeometryFunction · 0.36