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

Fixing flow paths correct injection time and ability to add extra arrays.

The injection time was getting incremented once when it shouldn't
have been and didn't give any information on the actual time
step that particles were injected at (instead it was just a counter
telling how many times before particles were injected). Also, there
wasn't any good mechanism to figure out the actual simulation time
for ParticlePaths so I added in functionality in the base class to
add in extra arrays specific to a concrete flow path algorithm. This
was then used to add in Simulation Time for particle paths.

Change-Id: Idaaff28439ff2b4c966ec02b871243c1e04e24b3
parent ab8ae4f1
......@@ -13,16 +13,18 @@ PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkParticlePathFilter.h"
#include "vtkObjectFactory.h"
#include "vtkSetGet.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkCell.h"
#include "vtkCellArray.h"
#include "vtkPointData.h"
#include "vtkDoubleArray.h"
#include "vtkFloatArray.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkIntArray.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkSetGet.h"
#include "vtkSmartPointer.h"
#include "vtkFloatArray.h"
#include <vector>
......@@ -126,6 +128,16 @@ void ParticlePathFilterInternal::Finalize()
vtkParticlePathFilter::vtkParticlePathFilter()
{
this->It.Initialize(this);
this->SimulationTime = NULL;
}
vtkParticlePathFilter::~vtkParticlePathFilter()
{
if(this->SimulationTime)
{
this->SimulationTime->Delete();
this->SimulationTime = NULL;
}
}
void vtkParticlePathFilter::ResetCache()
......@@ -144,6 +156,26 @@ int vtkParticlePathFilter::OutputParticles(vtkPolyData* particles)
return this->It.OutputParticles(particles);
}
void vtkParticlePathFilter::InitializeExtraPointDataArrays(vtkPointData* outputPD)
{
if(this->SimulationTime == NULL)
{
this->SimulationTime = vtkDoubleArray::New();
this->SimulationTime->SetName("SimulationTime");
}
if(outputPD->GetArray("SimulationTime"))
{
outputPD->RemoveArray("SimulationTime");
}
this->SimulationTime->SetNumberOfTuples(0);
outputPD->AddArray(this->SimulationTime);
}
void vtkParticlePathFilter::AppendToExtraPointDataArrays()
{
this->SimulationTime->InsertNextValue(this->GetCurrentTime());
}
void vtkParticlePathFilter::Finalize()
{
this->It.Finalize();
......
......@@ -31,7 +31,7 @@
class VTKFILTERSFLOWPATHS_EXPORT ParticlePathFilterInternal
{
public:
public:
ParticlePathFilterInternal():Filter(NULL){}
void Initialize(vtkParticleTracerBase* filter);
virtual ~ParticlePathFilterInternal(){}
......@@ -46,23 +46,29 @@ private:
class VTKFILTERSFLOWPATHS_EXPORT vtkParticlePathFilter: public vtkParticleTracerBase
{
public:
public:
vtkTypeMacro(vtkParticlePathFilter,vtkParticleTracerBase)
void PrintSelf(ostream& os, vtkIndent indent);
static vtkParticlePathFilter *New();
protected:
protected:
vtkParticlePathFilter();
~vtkParticlePathFilter(){}
~vtkParticlePathFilter();
vtkParticlePathFilter(const vtkParticlePathFilter&); // Not implemented.
void operator=(const vtkParticlePathFilter&); // Not implemented.
virtual void ResetCache();
virtual int OutputParticles(vtkPolyData* poly);
virtual void InitializeExtraPointDataArrays(vtkPointData* outputPD);
virtual void AppendToExtraPointDataArrays();
void Finalize();
ParticlePathFilterInternal It;
private:
vtkDoubleArray* SimulationTime;
};
......
......@@ -793,13 +793,12 @@ vtkPolyData* vtkParticleTracerBase::Execute(vtkInformationVector** inputVector)
this->ParticleRotation->SetName("Rotation");
this->ParticleAngularVel->SetName("AngularVelocity");
}
this->InitializeExtraPointDataArrays(output->GetPointData());
output->SetPoints(this->OutputCoordinates);
output->SetVerts(this->ParticleCells);
vtkDebugMacro(<< "Finished allocating point arrays ");
///
// How many Seed point sources are connected?
// Copy the sources into a vector for later use
......@@ -848,7 +847,7 @@ vtkPolyData* vtkParticleTracerBase::Execute(vtkInformationVector** inputVector)
// Now update our main list with the ones we are keeping
vtkDebugMacro(<< "Reinjection about to update candidates (" << this->LocalSeeds.size() << " particles)");
this->UpdateParticleList(this->LocalSeeds);
this->ReinjectionCounter += 1;
//this->ReinjectionCounter += this->ForceReinjectionEveryNSteps;
}
if(this->CurrentTimeStep==this->StartTimeStep) //just add all the particles
......@@ -931,7 +930,7 @@ vtkPolyData* vtkParticleTracerBase::Execute(vtkInformationVector** inputVector)
if(injectionFlag) //reinject again in the last step
{
this->ReinjectionCounter += 1;
this->ReinjectionCounter += this->ForceReinjectionEveryNSteps;
ParticleListIterator lastParticle = this->ParticleHistories.end();
if (!this->ParticleHistories.empty())
......@@ -1529,6 +1528,7 @@ void vtkParticleTracerBase::AddParticle(
this->InjectedStepIds->InsertNextValue(info.InjectedStepId);
this->ErrorCode->InsertNextValue(info.ErrorCode);
this->ParticleAge->InsertNextValue(info.age);
this->AppendToExtraPointDataArrays();
info.PointId = tempId;
//
......
......@@ -224,8 +224,6 @@ public:
vtkParticleTracerBaseNamespace::ParticleDataList ParticleHistories;
vtkSmartPointer<vtkPointData> ParticlePointData; //the current particle point data consistent
//with particle history
int ReinjectionCounter;
//Everything related to time
int IgnorePipelineTime; //whether to use the pipeline time for termination
int DisableResetCache; //whether to enable ResetCache() method
......@@ -370,12 +368,9 @@ public:
vtkFloatArray* GetParticleRotation(vtkPointData*);
vtkFloatArray* GetParticleAngularVel(vtkPointData*);
// utility function we use to test if a point is inside any of our local datasets
bool InsideBounds(double point[]);
void CalculateVorticity( vtkGenericCell* cell, double pcoords[3],
vtkDoubleArray* cellVectors, double vorticity[3] );
......@@ -396,6 +391,15 @@ public:
bool IsPointDataValid(vtkCompositeDataSet* input, std::vector<std::string>& arrayNames);
void GetPointDataArrayNames(vtkDataSet* input, std::vector<std::string>& names);
vtkGetMacro(ReinjectionCounter, int);
vtkGetMacro(CurrentTime, double);
// Description:
// Methods to append values to existing point data arrays that may
// only be desired on specific concrete derived classes.
virtual void InitializeExtraPointDataArrays(vtkPointData* vtkNotUsed(outputPD)) {}
virtual void AppendToExtraPointDataArrays() {}
private:
// Description:
// Hide this because we require a new interpolator type
......@@ -422,6 +426,9 @@ private:
double RotationScale;
double TerminalSpeed;
// A counter to keep track of how many times we reinjected
int ReinjectionCounter;
// Important for Caching of Cells/Ids/Weights etc
int AllFixedGeometry;
int StaticMesh;
......
......@@ -16,8 +16,9 @@ PURPOSE. See the above copyright notice for more information.
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkCellArray.h"
#include "vtkDataArray.h"
#include "vtkCharArray.h"
#include "vtkDataArray.h"
#include "vtkDoubleArray.h"
#include "vtkFloatArray.h"
#include "vtkNew.h"
#include <cassert>
......@@ -27,6 +28,16 @@ vtkStandardNewMacro(vtkPParticlePathFilter);
vtkPParticlePathFilter::vtkPParticlePathFilter()
{
this->It.Initialize(this);
this->SimulationTime = NULL;
}
vtkPParticlePathFilter::~vtkPParticlePathFilter()
{
if(this->SimulationTime)
{
this->SimulationTime->Delete();
this->SimulationTime = NULL;
}
}
void vtkPParticlePathFilter::ResetCache()
......@@ -70,6 +81,7 @@ int vtkPParticlePathFilter::OutputParticles(vtkPolyData* particles)
this->GetInjectedStepIds(tailPD)->InsertValue(tempId, info.InjectedStepId);
this->GetErrorCodeArr(tailPD)->InsertValue(tempId, info.ErrorCode);
this->GetParticleAge(tailPD)->InsertValue(tempId, info.age);
this->SimulationTime->InsertValue(tempId, this->GetCurrentTime());
if(this->GetComputeVorticity())
{
......@@ -83,6 +95,26 @@ int vtkPParticlePathFilter::OutputParticles(vtkPolyData* particles)
return this->It.OutputParticles(particles);
}
void vtkPParticlePathFilter::InitializeExtraPointDataArrays(vtkPointData* outputPD)
{
if(this->SimulationTime == NULL)
{
this->SimulationTime = vtkDoubleArray::New();
this->SimulationTime->SetName("SimulationTime");
}
if(outputPD->GetArray("SimulationTime"))
{
outputPD->RemoveArray("SimulationTime");
}
this->SimulationTime->SetNumberOfTuples(0);
outputPD->AddArray(this->SimulationTime);
}
void vtkPParticlePathFilter::AppendToExtraPointDataArrays()
{
this->SimulationTime->InsertNextValue(this->GetCurrentTime());
}
void vtkPParticlePathFilter::Finalize()
{
this->It.Finalize();
......
......@@ -25,31 +25,34 @@
#define __vtkPParticlePathFilter_h
#include "vtkSmartPointer.h" // For protected ivars.
#include "vtkPParticleTracerBase.h"
#include "vtkParticlePathFilter.h" //for utility
#include "vtkFiltersParallelFlowPathsModule.h" // For export macro
class VTKFILTERSPARALLELFLOWPATHS_EXPORT vtkPParticlePathFilter: public vtkPParticleTracerBase
{
public:
public:
vtkTypeMacro(vtkPParticlePathFilter,vtkPParticleTracerBase)
void PrintSelf(ostream& os, vtkIndent indent);
static vtkPParticlePathFilter *New();
protected:
protected:
vtkPParticlePathFilter();
~vtkPParticlePathFilter(){}
~vtkPParticlePathFilter();
virtual void ResetCache();
virtual int OutputParticles(vtkPolyData* poly);
virtual void InitializeExtraPointDataArrays(vtkPointData* outputPD);
virtual void AppendToExtraPointDataArrays();
void Finalize();
ParticlePathFilterInternal It;
private:
vtkPParticlePathFilter(const vtkPParticlePathFilter&); // Not implemented.
void operator=(const vtkPParticlePathFilter&); // Not implemented
vtkDoubleArray* SimulationTime;
};
......
......@@ -127,7 +127,7 @@ void vtkPParticleTracerBase::AssignSeedsToProcessors(
info.CachedDataSetId[1] = 0;
info.SourceID = sourceID;
info.InjectedPointId = i+ptId;
info.InjectedStepId = this->ReinjectionCounter;
info.InjectedStepId = this->GetReinjectionCounter();
info.TimeStepAge = 0;
info.UniqueParticleId =-1;
info.rotation = 0.0;
......
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