Commit f8b27463 authored by Mark Olesen's avatar Mark Olesen
Browse files

PV3FoamReader reorganization

  - vtkPV3Foam get PrintSelf (reduces number of methods)
  - move output data member from vtkPV3Foam -> PV3FoamReader
    in preparation for rewriting output method
  - roughed in code to track mesh/field changes in preparation for rewriting
    output method
  - progress bar with arbitrary values to give the user something to watch
parent e2d12e73
......@@ -47,6 +47,8 @@ vtkPV3FoamReader::vtkPV3FoamReader()
FileName = NULL;
foamData_ = NULL;
output1_ = NULL;
TimeStep = 0;
TimeStepRange[0] = 0;
TimeStepRange[1] = 0;
......@@ -61,7 +63,6 @@ vtkPV3FoamReader::vtkPV3FoamReader()
UpdateGUI = 1;
UpdateGUIOld = 1;
RegionSelection = vtkDataArraySelection::New();
VolFieldSelection = vtkDataArraySelection::New();
PointFieldSelection = vtkDataArraySelection::New();
......@@ -148,38 +149,6 @@ int vtkPV3FoamReader::RequestInformation
return 0;
}
if (Foam::vtkPV3Foam::debug)
{
vtkInformation* outputInfo = this->GetOutputPortInformation(0);
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
(
outputInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
);
outputInfo->Print(cout);
if (output)
{
output->Print(cout);
}
else
{
cout<< "no output\n";
}
this->GetExecutive()->GetOutputInformation(0)->Print(cout);
int nInfo = outputVector->GetNumberOfInformationObjects();
cout<< "requestInfo with " << nInfo << " items:\n";
for (int i = 0; i < nInfo; ++i)
{
vtkInformation *info = outputVector->GetInformationObject(i);
info->Print(cout);
}
}
vtkInformation *outInfo = outputVector->GetInformationObject(0);
if (!foamData_)
......@@ -189,17 +158,22 @@ int vtkPV3FoamReader::RequestInformation
(
outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
);
foamData_ = new Foam::vtkPV3Foam(FileName, this, output);
foamData_->UpdateInformation();
if (Foam::vtkPV3Foam::debug)
{
cout<< "constructed vtkPV3Foam with output: ";
output->Print(cout);
}
foamData_ = new Foam::vtkPV3Foam(FileName, this);
}
else
{
vtkDebugMacro("RequestInformation: updating information");
foamData_->UpdateInformation();
}
int nTimeSteps = 0;
double* timeSteps = foamData_->timeSteps(nTimeSteps);
double* timeSteps = foamData_->findTimes(nTimeSteps);
outInfo->Set
(
......@@ -402,27 +376,20 @@ void vtkPV3FoamReader::removePatchNamesFromView()
}
void vtkPV3FoamReader::PrintSelf
(
ostream& os,
vtkIndent indent
)
void vtkPV3FoamReader::PrintSelf(ostream& os, vtkIndent indent)
{
vtkDebugMacro(<<"PrintSelf");
this->Superclass::PrintSelf(os,indent);
os<< indent << "File name: "
<< (this->FileName ? this->FileName : "(none)") << "\n";
os<< indent << "Number of meshes: " << foamData_->numberOfMeshes() << "\n";
os<< indent << "Number of nodes: " << foamData_->numberOfPoints() << "\n";
os<< indent << "Number of cells: " << foamData_->numberOfCells() << "\n";
os<< indent << "Number of available time steps: " << foamData_->numberOfAvailableTimes()
<< endl;
foamData_->PrintSelf(os, indent);
os<< indent << "Time step range: "
<< this->TimeStepRange[0] << " - " << this->TimeStepRange[1]
<< endl;
<< "\n";
os<< indent << "Time step: " << this->TimeStep << endl;
return;
}
......@@ -478,7 +445,6 @@ void vtkPV3FoamReader::SetRegionArrayStatus(const char* name, int status)
vtkDataArraySelection* vtkPV3FoamReader::GetVolFieldSelection()
{
vtkDebugMacro(<<"GetVolFieldSelection");
return VolFieldSelection;
}
......@@ -486,7 +452,6 @@ vtkDataArraySelection* vtkPV3FoamReader::GetVolFieldSelection()
int vtkPV3FoamReader::GetNumberOfVolFieldArrays()
{
vtkDebugMacro(<<"GetNumberOfVolFieldArrays");
return VolFieldSelection->GetNumberOfArrays();
}
......@@ -494,7 +459,6 @@ int vtkPV3FoamReader::GetNumberOfVolFieldArrays()
const char* vtkPV3FoamReader::GetVolFieldArrayName(int index)
{
vtkDebugMacro(<<"GetVolFieldArrayName");
return VolFieldSelection->GetArrayName(index);
}
......@@ -502,7 +466,6 @@ const char* vtkPV3FoamReader::GetVolFieldArrayName(int index)
int vtkPV3FoamReader::GetVolFieldArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetVolFieldArrayStatus");
return VolFieldSelection->ArrayIsEnabled(name);
}
......@@ -510,7 +473,6 @@ int vtkPV3FoamReader::GetVolFieldArrayStatus(const char* name)
void vtkPV3FoamReader::SetVolFieldArrayStatus(const char* name, int status)
{
vtkDebugMacro(<<"SetVolFieldArrayStatus");
if (status)
{
VolFieldSelection->EnableArray(name);
......@@ -528,7 +490,6 @@ void vtkPV3FoamReader::SetVolFieldArrayStatus(const char* name, int status)
vtkDataArraySelection* vtkPV3FoamReader::GetPointFieldSelection()
{
vtkDebugMacro(<<"GetPointFieldSelection");
return PointFieldSelection;
}
......@@ -536,7 +497,6 @@ vtkDataArraySelection* vtkPV3FoamReader::GetPointFieldSelection()
int vtkPV3FoamReader::GetNumberOfPointFieldArrays()
{
vtkDebugMacro(<<"GetNumberOfPointFieldArrays");
return PointFieldSelection->GetNumberOfArrays();
}
......@@ -544,7 +504,6 @@ int vtkPV3FoamReader::GetNumberOfPointFieldArrays()
const char* vtkPV3FoamReader::GetPointFieldArrayName(int index)
{
vtkDebugMacro(<<"GetPointFieldArrayName");
return PointFieldSelection->GetArrayName(index);
}
......@@ -552,7 +511,6 @@ const char* vtkPV3FoamReader::GetPointFieldArrayName(int index)
int vtkPV3FoamReader::GetPointFieldArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetPointFieldArrayStatus");
return PointFieldSelection->ArrayIsEnabled(name);
}
......@@ -560,7 +518,6 @@ int vtkPV3FoamReader::GetPointFieldArrayStatus(const char* name)
void vtkPV3FoamReader::SetPointFieldArrayStatus(const char* name, int status)
{
vtkDebugMacro(<<"SetPointFieldArrayStatus");
if (status)
{
PointFieldSelection->EnableArray(name);
......@@ -578,7 +535,6 @@ void vtkPV3FoamReader::SetPointFieldArrayStatus(const char* name, int status)
vtkDataArraySelection* vtkPV3FoamReader::GetLagrangianFieldSelection()
{
vtkDebugMacro(<<"GetLagrangianFieldSelection");
return LagrangianFieldSelection;
}
......@@ -586,7 +542,6 @@ vtkDataArraySelection* vtkPV3FoamReader::GetLagrangianFieldSelection()
int vtkPV3FoamReader::GetNumberOfLagrangianFieldArrays()
{
vtkDebugMacro(<<"GetNumberOfLagrangianFieldArrays");
return LagrangianFieldSelection->GetNumberOfArrays();
}
......@@ -594,7 +549,6 @@ int vtkPV3FoamReader::GetNumberOfLagrangianFieldArrays()
const char* vtkPV3FoamReader::GetLagrangianFieldArrayName(int index)
{
vtkDebugMacro(<<"GetLagrangianFieldArrayName");
return LagrangianFieldSelection->GetArrayName(index);
}
......@@ -602,7 +556,6 @@ const char* vtkPV3FoamReader::GetLagrangianFieldArrayName(int index)
int vtkPV3FoamReader::GetLagrangianFieldArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetLagrangianFieldArrayStatus");
return LagrangianFieldSelection->ArrayIsEnabled(name);
}
......@@ -614,7 +567,6 @@ void vtkPV3FoamReader::SetLagrangianFieldArrayStatus
)
{
vtkDebugMacro(<<"SetLagrangianFieldArrayStatus");
if (status)
{
LagrangianFieldSelection->EnableArray(name);
......@@ -642,7 +594,6 @@ void vtkPV3FoamReader::SelectionModifiedCallback
void vtkPV3FoamReader::SelectionModified()
{
vtkDebugMacro(<<"SelectionModified");
Modified();
}
......
......@@ -191,6 +191,9 @@ private:
vtkDataArraySelection* PointFieldSelection;
vtkDataArraySelection* LagrangianFieldSelection;
//- Access to the output port1
vtkMultiBlockDataSet* output1_;
//BTX
Foam::vtkPV3Foam* foamData_;
//ETX
......
......@@ -198,12 +198,34 @@ bool Foam::vtkPV3Foam::setTime(const double& requestedTime)
found = true;
}
runTime.setTime(Times[nearestIndex], nearestIndex);
// see what has changed
if (timeIndex_ != nearestIndex)
{
timeIndex_ = nearestIndex;
runTime.setTime(Times[nearestIndex], nearestIndex);
// the fields change each time
fieldsChanged_ = true;
if (meshPtr_)
{
if (meshPtr_->readUpdate() != polyMesh::UNCHANGED)
{
meshChanged_ = true;
}
}
else
{
meshChanged_ = true;
}
}
if (debug)
{
Info<< "<end> Foam::vtkPV3Foam::setTime() - selected time "
<< Times[nearestIndex].name() << endl;
<< Times[nearestIndex].name() << " index=" << nearestIndex
<< " meshChanged=" << meshChanged_
<< " fieldsChanged=" << fieldsChanged_ << endl;
}
return found;
......@@ -221,13 +243,26 @@ void Foam::vtkPV3Foam::updateSelectedRegions()
const label nSelect = arraySelection->GetNumberOfArrays();
selectedRegions_.setSize(nSelect);
if (selectedRegions_.size() != nSelect)
{
selectedRegions_.setSize(nSelect);
selectedRegions_ = 0;
meshChanged_ = true;
}
selectedRegionDatasetIds_.setSize(nSelect);
// Read the selected patches and add to the region list
// Read the selected cell regions, zones, patches and add to region list
forAll (selectedRegions_, regionId)
{
selectedRegions_[regionId] = arraySelection->GetArraySetting(regionId);
int setting = arraySelection->GetArraySetting(regionId);
if (selectedRegions_[regionId] != setting)
{
selectedRegions_[regionId] = setting;
meshChanged_ = true;
}
selectedRegionDatasetIds_[regionId] = -1;
if (debug)
......@@ -421,12 +456,10 @@ void Foam::vtkPV3Foam::setSelectedArrayEntries
Foam::vtkPV3Foam::vtkPV3Foam
(
const char* const FileName,
vtkPV3FoamReader* reader,
vtkMultiBlockDataSet* output
vtkPV3FoamReader* reader
)
:
reader_(reader),
output_(output),
dbPtr_(NULL),
meshPtr_(NULL),
selectInfoVolume_(VOLUME, "unzoned"),
......@@ -439,7 +472,10 @@ Foam::vtkPV3Foam::vtkPV3Foam
selectInfoFaceSets_(FACESET, "faceSet"),
selectInfoPointSets_(POINTSET, "pointSet"),
patchTextActorsPtrs_(0),
nMesh_(0)
nMesh_(0),
timeIndex_(-1),
meshChanged_(true),
fieldsChanged_(true)
{
if (debug)
{
......@@ -487,17 +523,11 @@ Foam::vtkPV3Foam::vtkPV3Foam
dbPtr_().functionObjects().off();
if (debug)
{
cout<< "constructed with output: ";
output_->Print(cout);
}
resetCounters();
// Set initial cloud name
// TODO - TEMPORARY MEASURE UNTIL CAN PROCESS MULTIPLE CLOUDS
cloudName_ = "";
UpdateInformation();
}
......@@ -574,6 +604,11 @@ void Foam::vtkPV3Foam::UpdateInformation()
selectedEntries
);
if (meshChanged_)
{
fieldsChanged_ = true;
}
// Update volField array
updateInformationFields<fvPatchField, volMesh>
(
......@@ -609,22 +644,23 @@ void Foam::vtkPV3Foam::Update
output->Print(cout);
cout<<"Internally:\n";
output_->Print(cout);
output->Print(cout);
cout<< " has " << output_->GetNumberOfBlocks() << " blocks\n";
cout<< " has " << output->GetNumberOfBlocks() << " blocks\n";
}
// Set up region selection(s)
updateSelectedRegions();
// Update the Foam mesh
updateFoamMesh();
reader_->UpdateProgress(0.2);
// Convert meshes
convertMeshVolume(output);
convertMeshLagrangian(output);
convertMeshPatches(output);
reader_->UpdateProgress(0.4);
if (reader_->GetIncludeZones())
{
......@@ -639,11 +675,13 @@ void Foam::vtkPV3Foam::Update
convertMeshFaceSets(output);
convertMeshPointSets(output);
}
reader_->UpdateProgress(0.8);
// Update fields
updateVolFields(output);
updatePointFields(output);
updateLagrangianFields(output);
reader_->UpdateProgress(1.0);
if (debug)
{
......@@ -670,16 +708,18 @@ void Foam::vtkPV3Foam::Update
// traverse blocks:
cout<< "nBlocks = " << output->GetNumberOfBlocks() << "\n";
cout<< "done Update\n";
output_->Print(cout);
cout<< " has " << output_->GetNumberOfBlocks() << " blocks\n";
output_->GetInformation()->Print(cout);
output->Print(cout);
cout<< " has " << output->GetNumberOfBlocks() << " blocks\n";
output->GetInformation()->Print(cout);
cout<<"ShouldIReleaseData :" << output_->ShouldIReleaseData() << "\n";
cout<<"ShouldIReleaseData :" << output->ShouldIReleaseData() << "\n";
}
meshChanged_ = fieldsChanged_ = false;
}
double* Foam::vtkPV3Foam::timeSteps(int& nTimeSteps)
double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps)
{
int nTimes = 0;
double* tsteps = NULL;
......@@ -687,10 +727,10 @@ double* Foam::vtkPV3Foam::timeSteps(int& nTimeSteps)
if (dbPtr_.valid())
{
Time& runTime = dbPtr_();
instantList times = runTime.times();
instantList timeLst = runTime.times();
// always skip "constant" time, unless there are no other times
nTimes = times.size();
nTimes = timeLst.size();
label timeI = 0;
if (nTimes > 1)
......@@ -704,7 +744,7 @@ double* Foam::vtkPV3Foam::timeSteps(int& nTimeSteps)
tsteps = new double[nTimes];
for (label stepI = 0; stepI < nTimes; ++stepI, ++timeI)
{
tsteps[stepI] = times[timeI].value();
tsteps[stepI] = timeLst[timeI].value();
}
}
}
......@@ -924,48 +964,17 @@ void Foam::vtkPV3Foam::removePatchNames(vtkRenderer* renderer)
}
int Foam::vtkPV3Foam::numberOfAvailableTimes() const
void Foam::vtkPV3Foam::PrintSelf(ostream& os, vtkIndent indent) const
{
if (dbPtr_.valid())
{
return dbPtr_().times().size();
}
else
{
return 0;
}
os << indent << "Number of meshes: " << nMesh_ << "\n";
os << indent << "Number of nodes: "
<< (meshPtr_ ? meshPtr_->nPoints() : 0) << "\n";
os << indent << "Number of cells: "
<< (meshPtr_ ? meshPtr_->nCells() : 0) << "\n";
os << indent << "Number of available time steps: "
<< (dbPtr_.valid() ? dbPtr_().times().size() : 0) << endl;
}
int Foam::vtkPV3Foam::numberOfPoints()
{
if (meshPtr_)
{
return meshPtr_->nPoints();
}
else
{
return 0;
}
}
int Foam::vtkPV3Foam::numberOfCells()
{
if (meshPtr_)
{
return meshPtr_->nCells();
}
{
return 0;
}
}
int Foam::vtkPV3Foam::numberOfMeshes() const
{
return nMesh_;
}
// ************************************************************************* //
......@@ -69,13 +69,14 @@ SourceFiles
class vtkDataArraySelection;
class vtkDataSet;
class vtkMultiBlockDataSet;
class vtkPoints;
class vtkPV3FoamReader;
class vtkRenderer;
class vtkTextActor;
class vtkMultiBlockDataSet;
class vtkPolyData;
class vtkUnstructuredGrid;
class vtkIndent;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -195,9 +196,6 @@ private:
//- Access to the controlling vtkPV3FoamReader
vtkPV3FoamReader* reader_;
//- Access to the output block
vtkMultiBlockDataSet* output_;
//- Foam time control
autoPtr<Time> dbPtr_;
......@@ -231,12 +229,12 @@ private:
labelList superCells_;
//- Label of original cell for decomposed cells
// - cell zone meshes
List<labelList> superCellZonesCells_;
// - cellZone meshes
List<labelList> zoneSuperCells_;
//- Label of original cell for decomposed cells
// - cell set meshes
List<labelList> superCellSetCells_;
// - cellSet meshes
List<labelList> csetSuperCells_;
//- List of patch names
List<vtkTextActor*> patchTextActorsPtrs_;
......@@ -252,6 +250,15 @@ private:
// TODO - currently only set up to process ONE cloud
word cloudName_;
//- The time index
int timeIndex_;
//- Track changes in mesh geometry
bool meshChanged_;
//- Track changes in fields
bool fieldsChanged_;
// Private Member Functions
......@@ -610,8 +617,7 @@ public:
vtkPV3Foam
(
const char* const FileName,
vtkPV3FoamReader* reader,
vtkMultiBlockDataSet* output
vtkPV3FoamReader* reader
);
......@@ -622,13 +628,14 @@ public:
// Member Functions
//- Update
void UpdateInformation();
void Update(vtkMultiBlockDataSet* output);
//- allocate and return a list of selected times
//- Allocate and return a list of selected times
// returns the count via the parameter
double* timeSteps(int& nTimeSteps);
double* findTimes(int& nTimeSteps);
//- Add patch names to the display