Commit eab902ac authored by Andrew Bauer's avatar Andrew Bauer
Browse files

Adding in warning if the input vtkPointData structures is different.

These filters use vtkDataSetAttributes to interpolate input
point data to the output polydata so we need to make sure
that the point data structures match on all processes and
data sets. If they don't, the filters now return an error
and fail.

Change-Id: I639964871d8cf9fdd398e821560050bedd937143
parent a3fff3e5
......@@ -111,7 +111,6 @@ namespace
//---------------------------------------------------------------------------
vtkParticleTracerBase::vtkParticleTracerBase()
{
this->SetNumberOfInputPorts(2);
// by default process active point vectors
......@@ -1027,6 +1026,13 @@ int vtkParticleTracerBase::RequestData(
if(this->FirstIteration)
{
vtkDataObject* input = inInfo->Get(vtkDataObject::DATA_OBJECT());
// first check if the point data is consistent on all blocks of a multiblock
// and over all processes.
if(this->IsPointDataValid(input) == false)
{
vtkErrorMacro("Point data arrays are not consistent across all data sets. Cannot do flow paths.");
return 0;
}
this->CreateProtoPD(input);
}
......@@ -1568,6 +1574,56 @@ void vtkParticleTracerBase::AddParticle( vtkParticleTracerBaseNamespace::Particl
}
bool vtkParticleTracerBase::IsPointDataValid(vtkDataObject* input)
{
if(vtkCompositeDataSet* cdInput = vtkCompositeDataSet::SafeDownCast(input))
{
std::vector<std::string> arrayNames;
return this->IsPointDataValid(cdInput, arrayNames);
}
// a single data set on a single process will always have consistent point data
return true;
}
bool vtkParticleTracerBase::IsPointDataValid(vtkCompositeDataSet* input,
std::vector<std::string>& arrayNames)
{
arrayNames.clear();
vtkCompositeDataIterator* iter = input->NewIterator();
iter->SkipEmptyNodesOn();
iter->GoToFirstItem();
this->GetPointDataArrayNames(vtkDataSet::SafeDownCast(iter->GetCurrentDataObject()),
arrayNames);
for(iter->GoToNextItem();!iter->IsDoneWithTraversal();iter->GoToNextItem())
{
std::vector<std::string> tempNames;
this->GetPointDataArrayNames(vtkDataSet::SafeDownCast(iter->GetCurrentDataObject()),
tempNames);
if(std::equal(tempNames.begin(), tempNames.end(), arrayNames.begin()) == false)
{
iter->Delete();
return false;
}
}
iter->Delete();
return true;
}
void vtkParticleTracerBase::GetPointDataArrayNames(
vtkDataSet* input, std::vector<std::string>& names)
{
if(input == NULL)
{
names.clear();
return;
}
names.resize(input->GetPointData()->GetNumberOfArrays());
for(vtkIdType i=0;i<input->GetPointData()->GetNumberOfArrays();i++)
{
names[i] = input->GetPointData()->GetArrayName(i);
}
}
vtkFloatArray* vtkParticleTracerBase::GetParticleAge(vtkPointData* pd)
{
return vtkFloatArray::SafeDownCast(pd->GetArray("ParticleAge"));
......
......@@ -12,10 +12,11 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkParticleTracerBase - A Parallel Particle tracer for unsteady vector fields
// .NAME vtkParticleTracerBase - A particle tracer for vector fields
// .SECTION Description
// vtkParticleTracerBase is the base class for filters that advect particles
// in a time varying vector field
// in a vector field. Note that the input vtkPointData structure must
// be identical on all datasets.
//
// .SECTION See Also
// vtkRibbonFilter vtkRuledSurfaceFilter vtkInitialValueProblemSolver
......@@ -32,26 +33,24 @@
#include <list> // STL Header
//ETX
class vtkMultiProcessController;
class vtkMultiBlockDataSet;
class vtkDataArray;
class vtkDoubleArray;
class vtkGenericCell;
class vtkIntArray;
class vtkTemporalInterpolatedVelocityField;
class vtkPoints;
class vtkAbstractInterpolatedVelocityField;
class vtkAbstractParticleWriter;
class vtkCellArray;
class vtkDoubleArray;
class vtkFloatArray;
class vtkIntArray;
class vtkCharArray;
class vtkAbstractParticleWriter;
class vtkCompositeDataSet;
class vtkDataArray;
class vtkDataSet;
class vtkDoubleArray;
class vtkFloatArray;
class vtkGenericCell;
class vtkInitialValueProblemSolver;
class vtkIntArray;
class vtkMultiBlockDataSet;
class vtkMultiProcessController;
class vtkPointData;
class vtkAbstractInterpolatedVelocityField;
class vtkPoints;
class vtkPolyData;
class vtkTemporalInterpolatedVelocityField;
//BTX
namespace vtkParticleTracerBaseNamespace
......@@ -348,8 +347,9 @@ public:
return true;
}
// Description : This is an old routine kept for possible future use.
// In dnamic meshes, particles might leave the domain and need to be extrapolated across
// Description:
// This is an old routine kept for possible future use.
// In dynamic meshes, particles might leave the domain and need to be extrapolated across
// a gap between the meshes before they re-renter another domain
// dodgy rotating meshes need special care....
bool ComputeDomainExitLocation(
......@@ -389,6 +389,14 @@ public:
virtual void ResetCache();
void AddParticle(vtkParticleTracerBaseNamespace::ParticleInformation &info, double* velocity);
// Description:
// Methods that check that the input arrays are ordered the
// same on all data sets. This needs to be true for all
// blocks in a composite data set as well as across all processes.
virtual bool IsPointDataValid(vtkDataObject* input);
bool IsPointDataValid(vtkCompositeDataSet* input, std::vector<std::string>& arrayNames);
void GetPointDataArrayNames(vtkDataSet* input, std::vector<std::string>& names);
private:
// Description:
// Hide this because we require a new interpolator type
......@@ -402,8 +410,6 @@ private:
bool RetryWithPush(
vtkParticleTracerBaseNamespace::ParticleInformation &info, double* point1,double delT, int subSteps);
private:
//Parameters of tracing
vtkInitialValueProblemSolver* Integrator;
double IntegrationStep;
......
......@@ -33,6 +33,7 @@ PURPOSE. See the above copyright notice for more information.
#include "vtkMath.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkMultiProcessController.h"
#include "vtkMultiProcessStream.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkPointSet.h"
......@@ -50,6 +51,8 @@ PURPOSE. See the above copyright notice for more information.
#include "vtkMPIController.h"
#include "vtkMultiProcessController.h"
#include <algorithm>
using namespace vtkParticleTracerBaseNamespace;
vtkPParticleTracerBase::vtkPParticleTracerBase()
......@@ -420,6 +423,80 @@ void vtkPParticleTracerBase::UpdateParticleListFromOtherProcesses()
}
bool vtkPParticleTracerBase::IsPointDataValid(vtkDataObject* input)
{
if(this->Controller->GetNumberOfProcesses() == 1)
{
return this->Superclass::IsPointDataValid(input);
}
int retVal = 1;
vtkMultiProcessStream stream;
if(this->Controller->GetLocalProcessId() == 0)
{
std::vector<std::string> arrayNames;
if(vtkCompositeDataSet* cdInput = vtkCompositeDataSet::SafeDownCast(input))
{
retVal = (int) this->Superclass::IsPointDataValid(cdInput, arrayNames);
}
else
{
this->GetPointDataArrayNames(vtkDataSet::SafeDownCast(input), arrayNames);
}
stream << retVal;
// only need to send the array names to check if proc 0 has valid point data
if(retVal == 1)
{
stream << (int)arrayNames.size();
for(std::vector<std::string>::iterator it=arrayNames.begin();
it!=arrayNames.end();it++)
{
stream << *it;
}
}
}
this->Controller->Broadcast(stream, 0);
if(this->Controller->GetLocalProcessId() != 0)
{
stream >> retVal;
if(retVal == 0)
{
return false;
}
int numArrays;
stream >> numArrays;
std::vector<std::string> arrayNames(numArrays);
for(int i=0;i<numArrays;i++)
{
stream >> arrayNames[i];
}
std::vector<std::string> tempNames;
if(vtkCompositeDataSet* cdInput = vtkCompositeDataSet::SafeDownCast(input))
{
retVal = (int) this->Superclass::IsPointDataValid(cdInput, tempNames);
if(retVal)
{
retVal = (std::equal(tempNames.begin(), tempNames.end(), arrayNames.begin()) == true ?
1 : 0);
}
}
else
{
this->GetPointDataArrayNames(vtkDataSet::SafeDownCast(input), tempNames);
retVal = (std::equal(tempNames.begin(), tempNames.end(), arrayNames.begin()) == true ?
1 : 0);
}
}
else if(retVal == 0)
{
return false;
}
int tmp = retVal;
cerr << retVal << " is my retval\n";
this->Controller->AllReduce(&tmp, &retVal, 1, vtkMPICommunicator::MIN_OP);
return (retVal != 0);
}
//---------------------------------------------------------------------------
vtkCxxSetObjectMacro(vtkPParticleTracerBase, Controller, vtkMultiProcessController);
......
......@@ -12,11 +12,11 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkParticleTracerBase - A Parallel Particle tracer for unsteady vector fields
// .NAME vtkParticleTracerBase - A parallel particle tracer for vector fields
// .SECTION Description
// vtkParticleTracerBase is a filter that integrates a vector field to generate
//
//
// vtkPParticleTracerBase is the base class for parallel filters that advect particles
// in a vector field. Note that the input vtkPointData structure must
// be identical on all datasets.
// .SECTION See Also
// vtkRibbonFilter vtkRuledSurfaceFilter vtkInitialValueProblemSolver
// vtkRungeKutta2 vtkRungeKutta4 vtkRungeKutta45 vtkStreamTracer
......@@ -32,23 +32,6 @@
#include <list> // STL Header
//ETX
class vtkMultiProcessController;
class vtkMultiBlockDataSet;
class vtkDataArray;
class vtkDoubleArray;
class vtkGenericCell;
class vtkIntArray;
class vtkTemporalInterpolatedVelocityField;
class vtkPoints;
class vtkCellArray;
class vtkDoubleArray;
class vtkFloatArray;
class vtkIntArray;
class vtkCharArray;
class vtkAbstractParticleWriter;
class vtkPolyData;
#include "vtkFiltersParallelFlowPathsModule.h" // For export macro
class VTKFILTERSPARALLELFLOWPATHS_EXPORT vtkPParticleTracerBase : public vtkParticleTracerBase
......@@ -121,6 +104,13 @@ public:
void UpdateParticleListFromOtherProcesses();
// Description:
// Method that checks that the input arrays are ordered the
// same on all data sets. This needs to be true for all
// blocks in a composite data set as well as across all processes.
virtual bool IsPointDataValid(vtkDataObject* input);
//
//ETX
//
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment