cleanup and better check for valid seeds.

This commit is contained in:
Dave Pugmire 2023-04-14 14:19:50 -04:00
parent fe35202de8
commit d257108236
3 changed files with 13 additions and 64 deletions

@ -10,9 +10,12 @@
#include <vtkm/Particle.h>
#include <vtkm/cont/EnvironmentTracker.h>
#include <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/filter/flow/FilterParticleAdvection.h>
#include <vtkm/thirdparty/diy/diy.h>
namespace vtkm
{
namespace filter
@ -33,7 +36,15 @@ VTKM_CONT void FilterParticleAdvection::ValidateOptions() const
{
if (this->GetUseCoordinateSystemAsField())
throw vtkm::cont::ErrorFilterExecution("Coordinate system as field not supported");
if (this->Seeds.GetNumberOfValues() == 0)
vtkm::Id numSeeds = this->Seeds.GetNumberOfValues();
#ifdef VTKM_ENABLE_MPI
vtkmdiy::mpi::communicator comm = vtkm::cont::EnvironmentTracker::GetCommunicator();
vtkm::Id totalNumSeeds = 0;
vtkmdiy::mpi::all_reduce(comm, numSeeds, totalNumSeeds, std::plus<vtkm::Id>{});
numSeeds = totalNumSeeds;
#endif
if (numSeeds == 0)
throw vtkm::cont::ErrorFilterExecution("No seeds provided.");
if (!this->Seeds.IsBaseComponentType<vtkm::Particle>() &&
!this->Seeds.IsBaseComponentType<vtkm::ChargedParticle>())

@ -80,8 +80,7 @@ public:
const ParticleType p = portal.Get(i);
std::vector<vtkm::Id> ids = this->BoundsMap.FindBlocks(p.GetPosition());
//DRP
//Note: For duplicate blocks, this will give the seeds to the rank that first in the list.
//Note: For duplicate blocks, this will give the seeds to the rank that are first in the list.
if (!ids.empty())
{
auto ranks = this->BoundsMap.FindRank(ids[0]);

@ -31,20 +31,6 @@
#include <set>
#include <vector>
template <typename T>
void printVec(const std::vector<T>& v)
{
std::cout << "[";
int n = v.size();
if (n > 0)
{
for (int i = 0; i < n - 1; i++)
std::cout << v[i] << " ";
std::cout << v[n - 1];
}
std::cout << "]";
}
namespace vtkm
{
namespace filter
@ -84,11 +70,6 @@ public:
std::vector<int> FindRank(vtkm::Id blockId) const
{
auto it = this->BlockToRankMap.find(blockId);
/*
std::cout<<"FindRank("<<blockId<<") --> ";
printVec(it->second); std::cout<<std::endl;
*/
if (it == this->BlockToRankMap.end())
return {};
@ -134,7 +115,6 @@ private:
this->LocalNumBlocks = dataSets.size();
vtkmdiy::mpi::communicator comm = vtkm::cont::EnvironmentTracker::GetCommunicator();
//if (comm.rank() == 0) std::cout<<"Init: "<<blockIds.size()<<std::endl;
//1. Get the min/max blockId
vtkm::Id locMinId = 0, locMaxId = 0;
@ -206,40 +186,10 @@ private:
this->BlockToRankMap[bid].push_back(rank);
}
}
/*
if (comm.rank() == 0)
{
std::cout << "Rank --> BlockIds" << std::endl;
for (int i = 0; i < comm.size(); i++)
{
std::cout << i << ": ";
printVec(rankToBlockIds[i]);
std::cout << std::endl;
}
std::cout << "BlockIds --> Ranks" << std::endl;
for (const auto& it : this->BlockToRankMap)
{
std::cout << it.first << " : ";
printVec(it.second);
std::cout << std::endl;
}
}
*/
this->Build(dataSets);
//ensure dataSets.size() == blockIds.size()
//find min/max block id.
//count number of copies of each block. It better be >= 1 for each.
//find blocks per rank for all ranks.
//exchange who has what blocks.
//exchange ranks for each block
//building block tree will be the same: duplicates wont mess up the min/max
//
}
void Init(const std::vector<vtkm::cont::DataSet>& dataSets)
{
this->LocalNumBlocks = dataSets.size();
@ -312,17 +262,6 @@ private:
this->GlobalBounds.Include(block);
idx += 3;
}
/*
#ifdef VTKM_ENABLE_MPI
if (comm.rank() == 0)
#endif
{
std::cout << "BlockBounds: " << this->GlobalBounds << std::endl;
for (const auto& block : this->BlockBounds)
std::cout << " " << block << std::endl;
}
*/
}
vtkm::Id LocalNumBlocks = 0;