general clean-up, and renamed filename extension to avoid conflict with internal reader

This commit is contained in:
andy
2008-07-03 14:35:00 +01:00
parent 79a425236b
commit d23666042f
14 changed files with 177 additions and 546 deletions

View File

@ -0,0 +1,7 @@
#!/bin/sh
set -x
rm -r PV3FoamReader/Make
wclean libso vtkPV3Foam

View File

@ -54,7 +54,7 @@ vtkPV3FoamReader::vtkPV3FoamReader()
{
Debug = 0;
vtkDebugMacro(<<"Constructor");
SetNumberOfInputPorts(0);
FileName = NULL;
@ -115,7 +115,6 @@ vtkPV3FoamReader::vtkPV3FoamReader()
vtkPV3FoamReader::~vtkPV3FoamReader()
{
vtkDebugMacro(<<"Deconstructor");
cout << "Destroy ~vtkPV3FoamReader\n";
if (foamData_)
{
@ -152,23 +151,30 @@ int vtkPV3FoamReader::RequestInformation
)
{
vtkDebugMacro(<<"RequestInformation");
cout<<"REQUEST_INFORMATION\n";
if (Foam::vtkPV3Foam::debug)
{
cout<<"REQUEST_INFORMATION\n";
}
if (!FileName)
{
vtkErrorMacro("FileName has to be specified!");
return 0;
}
if (Foam::vtkPV3Foam::debug)
{
vtkInformation* outputInfo = this->GetOutputPortInformation(0);
outputInfo->Print(cout);
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
(
outputInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
);
if (output)
outputInfo->Print(cout);
if (output)
{
output->Print(cout);
}
@ -177,21 +183,19 @@ int vtkPV3FoamReader::RequestInformation
cout << "no output\n";
}
cout << "GetExecutive:\n";
this->GetExecutive()->GetOutputInformation(0)->Print(cout);
}
{
int nInfo = outputVector->GetNumberOfInformationObjects();
cout<<"requestInfo with " << nInfo << " items\n";
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_)
@ -207,15 +211,12 @@ int vtkPV3FoamReader::RequestInformation
else
{
vtkDebugMacro("RequestInformation: updating information");
foamData_->UpdateInformation();
}
int nTimeSteps = 0;
double* timeSteps = foamData_->timeSteps(nTimeSteps);
cout<<"Have nTimeSteps: " << nTimeSteps << "\n";
outInfo->Set
(
vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
@ -229,13 +230,16 @@ int vtkPV3FoamReader::RequestInformation
timeRange[0] = timeSteps[0];
timeRange[1] = timeSteps[nTimeSteps-1];
cout<<"nTimeSteps " << nTimeSteps << "\n";
cout<<"timeRange " << timeRange[0] << " -> " << timeRange[1] << "\n";
if (Foam::vtkPV3Foam::debug)
{
cout<<"nTimeSteps " << nTimeSteps << "\n";
cout<<"timeRange " << timeRange[0] << " to " << timeRange[1] << "\n";
// for (int i = 0; i < nTimeSteps; ++i)
// {
// cout<<"step[" << i << "] = " << timeSteps[i] << "\n";
// }
for (int i = 0; i < nTimeSteps; ++i)
{
cout<< "step[" << i << "] = " << timeSteps[i] << "\n";
}
}
outInfo->Set
(
@ -247,7 +251,6 @@ int vtkPV3FoamReader::RequestInformation
delete timeSteps;
cout<<"done RequestInformation\n";
return 1;
}
@ -261,21 +264,27 @@ int vtkPV3FoamReader::RequestData
)
{
vtkDebugMacro(<<"RequestData");
cout<<"REQUEST_DATA\n";
if (!FileName)
{
vtkErrorMacro("FileName has to be specified!");
return 0;
}
{
int nInfo = outputVector->GetNumberOfInformationObjects();
cout<<"requestData with " << nInfo << " items\n";
if (Foam::vtkPV3Foam::debug)
{
cout<<"requestData with " << nInfo << " items\n";
}
for (int i=0; i<nInfo; i++)
{
vtkInformation *info = outputVector->GetInformationObject(i);
info->Print(cout);
if (Foam::vtkPV3Foam::debug)
{
info->Print(cout);
}
}
}
@ -284,38 +293,38 @@ int vtkPV3FoamReader::RequestData
(
outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
);
#if 1
if (Foam::vtkPV3Foam::debug)
{
vtkInformation* outputInfo = this->GetOutputPortInformation(0);
outputInfo->Print(cout);
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
(
outputInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
);
if (output)
if (output)
{
output->Print(cout);
}
else
{
cout << "no output\n";
cout<< "no output\n";
}
vtkInformation* execInfo = this->GetExecutive()->GetOutputInformation(0);
execInfo->Print(cout);
outInfo->Print(cout);
vtkMultiBlockDataSet* dobj = vtkMultiBlockDataSet::SafeDownCast
(
outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT())
);
if (dobj)
if (dobj)
{
dobj->Print(cout);
vtkInformation* dobjInfo = dobj->GetInformation();
dobjInfo->Print(cout);
}
@ -323,16 +332,16 @@ int vtkPV3FoamReader::RequestData
{
cout << "no data_object\n";
}
}
#endif
if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()))
{
cout<<"Has UPDATE_TIME_STEPS\n";
cout<<"output->GetNumberOfBlocks() " << output->GetNumberOfBlocks() <<
"\n";
if (Foam::vtkPV3Foam::debug)
{
cout<<"Has UPDATE_TIME_STEPS\n";
cout<<"output->GetNumberOfBlocks() = "
<< output->GetNumberOfBlocks() << "\n";
}
// Get the requested time step.
// We only supprt requests of a single time step
@ -370,10 +379,6 @@ int vtkPV3FoamReader::RequestData
}
UpdateGUIOld = GetUpdateGUI();
cout<<"done RequestData\n";
cout<<"done output->GetNumberOfBlocks() "
<< output->GetNumberOfBlocks() << "\n";
return 1;
}

View File

@ -84,13 +84,15 @@ void Foam::vtkPV3Foam::AddToBlock
output->SetBlock(blockNo, block);
block->Delete();
}
if (block)
else
{
Info<< "block[" << blockNo << "] has "
<< block->GetNumberOfBlocks()
<< " datasets prior to adding set " << datasetNo
<< " with name: " << blockName << endl;
if (debug)
{
Info<< "block[" << blockNo << "] has "
<< block->GetNumberOfBlocks()
<< " datasets prior to adding set " << datasetNo
<< " with name: " << blockName << endl;
}
// when assigning dataset 0, also name the parent block
if (!datasetNo && selector.name())
@ -481,8 +483,11 @@ Foam::vtkPV3Foam::vtkPV3Foam
dbPtr_().functionObjects().off();
cout<<"constructed with output: ";
output_->Print(cout),
if (debug)
{
cout<< "constructed with output: ";
output_->Print(cout);
}
resetCounters();
@ -579,8 +584,8 @@ void Foam::vtkPV3Foam::Update
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::Update" << endl;
cout<<"Update\n";
cout<< "entered Foam::vtkPV3Foam::Update" << nl
<<"Update\n";
output->Print(cout);
cout<<"Internally:\n";

View File

@ -172,6 +172,7 @@ public:
}
};
private:
// Private data
@ -645,85 +646,6 @@ public:
};
// * * * * * * * * * * * * * Template Specialisations * * * * * * * * * * * //
template<>
void vtkPV3Foam::convertVolField
(
const GeometricField<scalar, fvPatchField, volMesh>& sf,
vtkMultiBlockDataSet* output,
const selectionInfo&,
const label datasetNo,
labelList& superCells
);
template<>
void vtkPV3Foam::convertPatchFaceField
(
const word& name,
const Field<scalar>&,
vtkMultiBlockDataSet* output,
const selectionInfo&,
const label datasetNo
);
template<>
void vtkPV3Foam::convertFaceField
(
const GeometricField<scalar, fvPatchField, volMesh>&,
vtkMultiBlockDataSet* output,
const selectionInfo&,
const label datasetNo,
const fvMesh&,
const labelList& faceLabels
);
template<>
void vtkPV3Foam::convertFaceField
(
const GeometricField<scalar, fvPatchField, volMesh>&,
vtkMultiBlockDataSet* output,
const selectionInfo&,
const label datasetNo,
const fvMesh&,
const faceSet&
);
template<>
void vtkPV3Foam::convertPointField
(
const GeometricField<scalar, pointPatchField, pointMesh>&,
const GeometricField<scalar, fvPatchField, volMesh>&,
vtkMultiBlockDataSet* output,
const selectionInfo&,
const label datasetNo
);
template<>
void vtkPV3Foam::convertPatchPointField
(
const word& name,
const Field<scalar>&,
vtkMultiBlockDataSet* output,
const selectionInfo&,
const label datasetNo
);
template<>
void vtkPV3Foam::convertLagrangianField
(
const IOField<scalar>&,
vtkMultiBlockDataSet* output,
const selectionInfo&,
const label datasetNo
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -48,6 +48,8 @@ void Foam::vtkPV3Foam::convertFaceField
const labelList& faceLabels
)
{
const label nComp = pTraits<Type>::nComponents;
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
@ -59,33 +61,30 @@ void Foam::vtkPV3Foam::convertFaceField
vtkFloatArray *cellData = vtkFloatArray::New();
cellData->SetNumberOfTuples(faceLabels.size());
cellData->SetNumberOfComponents(Type::nComponents);
cellData->Allocate(Type::nComponents*faceLabels.size());
cellData->SetNumberOfComponents(nComp);
cellData->Allocate(nComp*faceLabels.size());
cellData->SetName(tf.name().c_str());
float vec[Type::nComponents];
float vec[nComp];
forAll(faceLabels, faceI)
{
const label faceNo = faceLabels[faceI];
if (faceNo < nInternalFaces)
{
Type t = 0.5 *
(
tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]
);
Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
for (direction d=0; d<Type::nComponents; d++)
for (direction d=0; d<nComp; d++)
{
vec[d] = t[d];
vec[d] = component(t, d);
}
}
else
{
const Type& t = tf[faceOwner[faceNo]];
for (direction d=0; d<Type::nComponents; d++)
for (direction d=0; d<nComp; d++)
{
vec[d] = t[d];
vec[d] = component(t, d);
}
}
@ -108,6 +107,8 @@ void Foam::vtkPV3Foam::convertFaceField
const faceSet& fSet
)
{
const label nComp = pTraits<Type>::nComponents;
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
@ -119,11 +120,11 @@ void Foam::vtkPV3Foam::convertFaceField
vtkFloatArray *cellData = vtkFloatArray::New();
cellData->SetNumberOfTuples(fSet.size());
cellData->SetNumberOfComponents(Type::nComponents);
cellData->Allocate(Type::nComponents*fSet.size());
cellData->SetNumberOfComponents(nComp);
cellData->Allocate(nComp*fSet.size());
cellData->SetName(tf.name().c_str());
float vec[Type::nComponents];
float vec[nComp];
label faceI = 0;
forAllConstIter(faceSet, fSet, iter)
@ -132,22 +133,19 @@ void Foam::vtkPV3Foam::convertFaceField
if (faceNo < nInternalFaces)
{
Type t = 0.5 *
(
tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]
);
Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
for (direction d=0; d<Type::nComponents; d++)
for (direction d=0; d<nComp; d++)
{
vec[d] = t[d];
vec[d] = component(t, d);
}
}
else
{
const Type& t = tf[faceOwner[faceNo]];
for (direction d=0; d<Type::nComponents; d++)
for (direction d=0; d<nComp; d++)
{
vec[d] = t[d];
vec[d] = component(t, d);
}
}
@ -160,125 +158,6 @@ void Foam::vtkPV3Foam::convertFaceField
}
template<>
void Foam::vtkPV3Foam::convertFaceField
(
const GeometricField<scalar, fvPatchField, volMesh>& tf,
vtkMultiBlockDataSet* output,
const selectionInfo& selector,
const label datasetNo,
const fvMesh& mesh,
const labelList& faceLabels
)
{
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
);
const label nInternalFaces = mesh.nInternalFaces();
const labelList& faceOwner = mesh.faceOwner();
const labelList& faceNeigh = mesh.faceNeighbour();
vtkFloatArray *cellData = vtkFloatArray::New();
cellData->SetNumberOfTuples(faceLabels.size());
cellData->SetNumberOfComponents(1);
cellData->Allocate(faceLabels.size());
cellData->SetName(tf.name().c_str());
forAll(faceLabels, faceI)
{
const label faceNo = faceLabels[faceI];
if (faceNo < nInternalFaces)
{
cellData->InsertComponent
(
faceI,
0,
0.5 * (tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]])
);
}
else
{
cellData->InsertComponent
(
faceI, 0, tf[faceOwner[faceNo]]
);
}
}
vtkmesh->GetCellData()->AddArray(cellData);
if (!vtkmesh->GetCellData()->GetScalars())
{
vtkmesh->GetCellData()->SetScalars(cellData);
}
cellData->Delete();
}
template<>
void Foam::vtkPV3Foam::convertFaceField
(
const GeometricField<scalar, fvPatchField, volMesh>& tf,
vtkMultiBlockDataSet* output,
const selectionInfo& selector,
const label datasetNo,
const fvMesh& mesh,
const faceSet& fSet
)
{
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
);
const label nInternalFaces = mesh.nInternalFaces();
const labelList& faceOwner = mesh.faceOwner();
const labelList& faceNeigh = mesh.faceNeighbour();
vtkFloatArray *cellData = vtkFloatArray::New();
cellData->SetNumberOfTuples(fSet.size());
cellData->SetNumberOfComponents(1);
cellData->Allocate(fSet.size());
cellData->SetName(tf.name().c_str());
label faceI = 0;
forAllConstIter(faceSet, fSet, iter)
{
const label faceNo = iter.key();
if (faceNo < nInternalFaces)
{
cellData->InsertComponent
(
faceI,
0,
0.5 * (tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]])
);
}
else
{
cellData->InsertComponent
(
faceI, 0, tf[faceOwner[faceNo]]
);
}
++faceI;
}
vtkmesh->GetCellData()->AddArray(cellData);
if (!vtkmesh->GetCellData()->GetScalars())
{
vtkmesh->GetCellData()->SetScalars(cellData);
}
cellData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -95,6 +95,8 @@ void Foam::vtkPV3Foam::convertLagrangianField
const label datasetNo
)
{
const label nComp = pTraits<Type>::nComponents;
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
@ -102,24 +104,24 @@ void Foam::vtkPV3Foam::convertLagrangianField
vtkFloatArray *pointData = vtkFloatArray::New();
pointData->SetNumberOfTuples(tf.size());
pointData->SetNumberOfComponents(Type::nComponents);
pointData->Allocate(Type::nComponents*tf.size());
pointData->SetNumberOfComponents(nComp);
pointData->Allocate(nComp*tf.size());
pointData->SetName(tf.name().c_str());
if (debug)
{
Info<< "converting Lagrangian <Type>Field: " << tf.name() << nl
<< "tf.size() = " << tf.size() << nl
<< "nComps = " << Type::nComponents << endl;
<< "nComp = " << nComp << endl;
}
float vec[Type::nComponents];
float vec[nComp];
forAll(tf, i)
{
for (direction d=0; d<Type::nComponents; d++)
for (direction d=0; d<nComp; d++)
{
vec[d] = tf[i][d];
vec[d] = component(tf[i], d);
}
pointData->InsertTuple(i, vec);
@ -130,48 +132,6 @@ void Foam::vtkPV3Foam::convertLagrangianField
}
template<>
void Foam::vtkPV3Foam::convertLagrangianField
(
const IOField<scalar>& sf,
vtkMultiBlockDataSet* output,
const selectionInfo& selector,
const label datasetNo
)
{
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
);
vtkFloatArray *pointData = vtkFloatArray::New();
pointData->SetNumberOfTuples(sf.size());
pointData->SetNumberOfComponents(1);
pointData->Allocate(sf.size());
pointData->SetName(sf.name().c_str());
if (debug)
{
Info<< "converting Lagrangian scalarField: " << sf.name() << nl
<< "sf.size() = " << sf.size() << nl
<< "nComps = 1" << endl;
}
for (int i=0; i<sf.size(); i++)
{
pointData->InsertComponent(i, 0, sf[i]);
}
vtkmesh->GetPointData()->AddArray(pointData);
if (!vtkmesh->GetPointData()->GetScalars())
{
vtkmesh->GetPointData()->SetScalars(pointData);
}
pointData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -48,6 +48,8 @@ void Foam::vtkPV3Foam::convertPatchFaceField
const label datasetNo
)
{
const label nComp = pTraits<Type>::nComponents;
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
@ -55,18 +57,18 @@ void Foam::vtkPV3Foam::convertPatchFaceField
vtkFloatArray *cellData = vtkFloatArray::New();
cellData->SetNumberOfTuples(ptf.size());
cellData->SetNumberOfComponents(Type::nComponents);
cellData->Allocate(Type::nComponents*ptf.size());
cellData->SetNumberOfComponents(nComp);
cellData->Allocate(nComp*ptf.size());
cellData->SetName(name.c_str());
float vec[Type::nComponents];
float vec[nComp];
forAll(ptf, i)
{
const Type& t = ptf[i];
for (direction d=0; d<Type::nComponents; d++)
for (direction d=0; d<nComp; d++)
{
vec[d] = t[d];
vec[d] = component(t, d);
}
cellData->InsertTuple(i, vec);
@ -77,43 +79,6 @@ void Foam::vtkPV3Foam::convertPatchFaceField
}
template<>
void Foam::vtkPV3Foam::convertPatchFaceField
(
const word& name,
const Field<scalar>& psf,
vtkMultiBlockDataSet* output,
const selectionInfo& selector,
const label datasetNo
)
{
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
);
vtkFloatArray *cellData = vtkFloatArray::New();
cellData->SetNumberOfTuples(psf.size());
cellData->SetNumberOfComponents(1);
cellData->Allocate(psf.size());
cellData->SetName(name.c_str());
forAll(psf, i)
{
cellData->InsertComponent(i, 0, psf[i]);
}
vtkmesh->GetCellData()->AddArray(cellData);
if (!vtkmesh->GetCellData()->GetScalars())
{
vtkmesh->GetCellData()->SetScalars(cellData);
}
cellData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -45,6 +45,8 @@ void Foam::vtkPV3Foam::convertPatchPointField
const label datasetNo
)
{
const label nComp = pTraits<Type>::nComponents;
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
@ -52,17 +54,17 @@ void Foam::vtkPV3Foam::convertPatchPointField
vtkFloatArray *pointData = vtkFloatArray::New();
pointData->SetNumberOfTuples(pptf.size());
pointData->SetNumberOfComponents(Type::nComponents);
pointData->Allocate(Type::nComponents*pptf.size());
pointData->SetNumberOfComponents(nComp);
pointData->Allocate(nComp*pptf.size());
pointData->SetName(name.c_str());
float vec[Type::nComponents];
float vec[nComp];
forAll(pptf, i)
{
for (direction d=0; d<Type::nComponents; d++)
for (direction d=0; d<nComp; d++)
{
vec[d] = pptf[i][d];
vec[d] = component(pptf[i], d);
}
pointData->InsertTuple(i, vec);
@ -73,42 +75,6 @@ void Foam::vtkPV3Foam::convertPatchPointField
}
template<>
void Foam::vtkPV3Foam::convertPatchPointField
(
const word& name,
const Field<scalar>& ppsf,
vtkMultiBlockDataSet* output,
const selectionInfo& selector,
const label datasetNo
)
{
vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
);
vtkFloatArray *pointData = vtkFloatArray::New();
pointData->SetNumberOfTuples(ppsf.size());
pointData->SetNumberOfComponents(1);
pointData->Allocate(ppsf.size());
pointData->SetName(name.c_str());
for (int i=0; i<ppsf.size(); i++)
{
pointData->InsertComponent(i, 0, ppsf[i]);
}
vtkmesh->GetPointData()->AddArray(pointData);
if (!vtkmesh->GetPointData()->GetScalars())
{
vtkmesh->GetPointData()->SetScalars(pointData);
}
pointData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -33,8 +33,6 @@ InClass
// Foam includes
#include "interpolatePointToCell.H"
// VTK includes
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
@ -145,6 +143,8 @@ void Foam::vtkPV3Foam::convertPointField
const label datasetNo
)
{
const label nComp = pTraits<Type>::nComponents;
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
@ -152,17 +152,17 @@ void Foam::vtkPV3Foam::convertPointField
vtkFloatArray *pointData = vtkFloatArray::New();
pointData->SetNumberOfTuples(ptf.size() + addPointCellLabels_.size());
pointData->SetNumberOfComponents(Type::nComponents);
pointData->Allocate(Type::nComponents*ptf.size());
pointData->SetNumberOfComponents(nComp);
pointData->Allocate(nComp*ptf.size());
pointData->SetName(tf.name().c_str());
float vec[Type::nComponents];
float vec[nComp];
forAll(ptf, i)
{
for (direction d=0; d<Type::nComponents; d++)
for (direction d=0; d<nComp; d++)
{
vec[d] = ptf[i][d];
vec[d] = component(ptf[i], d);
}
pointData->InsertTuple(i, vec);
@ -176,9 +176,9 @@ void Foam::vtkPV3Foam::convertPointField
{
Type t = tf[addPointCellLabels_[api]];
for (direction d=0; d<Type::nComponents; d++)
for (direction d=0; d<nComp; d++)
{
vec[d] = t[d];
vec[d] = component(t, d);
}
pointData->InsertTuple(i++, vec);
@ -190,9 +190,9 @@ void Foam::vtkPV3Foam::convertPointField
{
Type t = interpolatePointToCell(ptf, addPointCellLabels_[api]);
for (direction d=0; d<Type::nComponents; d++)
for (direction d=0; d<nComp; d++)
{
vec[d] = t[d];
vec[d] = component(t, d);
}
pointData->InsertTuple(i++, vec);
@ -204,69 +204,6 @@ void Foam::vtkPV3Foam::convertPointField
}
template<>
void Foam::vtkPV3Foam::convertPointField
(
const GeometricField<scalar, pointPatchField, pointMesh>& psf,
const GeometricField<scalar, fvPatchField, volMesh>& sf,
vtkMultiBlockDataSet* output,
const selectionInfo& selector,
const label datasetNo
)
{
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
);
vtkFloatArray *pointData = vtkFloatArray::New();
pointData->SetNumberOfTuples(psf.size() + addPointCellLabels_.size());
pointData->SetNumberOfComponents(1);
pointData->Allocate(psf.size());
pointData->SetName(sf.name().c_str());
for (int i=0; i<psf.size(); i++)
{
pointData->InsertComponent(i, 0, psf[i]);
}
label i = psf.size();
if (&sf != &GeometricField<scalar, fvPatchField, volMesh>::null())
{
forAll(addPointCellLabels_, api)
{
pointData->InsertComponent
(
i++,
0,
sf[addPointCellLabels_[api]]
);
}
}
else
{
forAll(addPointCellLabels_, api)
{
pointData->InsertComponent
(
i++,
0,
interpolatePointToCell(psf, addPointCellLabels_[api])
);
}
}
internalMesh->GetPointData()->AddArray(pointData);
if (!internalMesh->GetPointData()->GetScalars())
{
internalMesh->GetPointData()->SetScalars(pointData);
}
pointData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -372,6 +372,8 @@ void Foam::vtkPV3Foam::convertVolField
labelList& superCells
)
{
const label nComp = pTraits<Type>::nComponents;
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
@ -379,8 +381,8 @@ void Foam::vtkPV3Foam::convertVolField
vtkFloatArray* celldata = vtkFloatArray::New();
celldata->SetNumberOfTuples(superCells.size());
celldata->SetNumberOfComponents(Type::nComponents);
celldata->Allocate(Type::nComponents*superCells.size());
celldata->SetNumberOfComponents(nComp);
celldata->Allocate(nComp*superCells.size());
celldata->SetName(tf.name().c_str());
if (debug)
@ -388,17 +390,17 @@ void Foam::vtkPV3Foam::convertVolField
Info<< "converting vol<Type>Field: " << tf.name() << nl
<< "field size = " << tf.size() << nl
<< "nTuples = " << superCells.size() << nl
<< "nComps = " << Type::nComponents << endl;
<< "nComp = " << nComp << endl;
}
float vec[Type::nComponents];
float vec[nComp];
forAll(superCells, scI)
{
const Type& t = tf[superCells[scI]];
for (direction d=0; d<Type::nComponents; d++)
for (direction d=0; d<nComp; d++)
{
vec[d] = t[d];
vec[d] = component(t, d);
}
celldata->InsertTuple(scI, vec);
@ -409,50 +411,6 @@ void Foam::vtkPV3Foam::convertVolField
}
template<>
void Foam::vtkPV3Foam::convertVolField
(
const GeometricField<scalar, fvPatchField, volMesh>& sf,
vtkMultiBlockDataSet* output,
const selectionInfo& selector,
const label datasetNo,
labelList& superCells
)
{
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::SafeDownCast
(
GetDataSetFromBlock(output, selector, datasetNo)
);
vtkFloatArray *cellData = vtkFloatArray::New();
cellData->SetNumberOfTuples(superCells.size());
cellData->SetNumberOfComponents(1);
cellData->Allocate(superCells.size());
cellData->SetName(sf.name().c_str());
if (debug)
{
Info<< "converting volScalarField: " << sf.name() << nl
<< "field size = " << sf.size() << nl
<< "nTuples = " << superCells.size() << nl
<< "nComps = 1" << endl;
}
forAll(superCells, scI)
{
cellData->InsertComponent(scI, 0, sf[superCells[scI]]);
}
vtkmesh->GetCellData()->AddArray(cellData);
if (!vtkmesh->GetCellData()->GetScalars())
{
vtkmesh->GetCellData()->SetScalars(cellData);
}
cellData->Delete();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -114,6 +114,12 @@ void Foam::vtkPV3Foam::updateVolFields
}
volPointInterpolation pInterp(mesh, pMesh);
/*
convertVolFields<Foam::label>
(
mesh, pInterp, objects, arraySelection, output
);
*/
convertVolFields<Foam::scalar>
(
mesh, pInterp, objects, arraySelection, output
@ -159,7 +165,12 @@ void Foam::vtkPV3Foam::updatePointFields
{
Info<< "converting Foam point fields" << endl;
}
/*
convertPointFields<Foam::label>
(
mesh, objects, arraySelection, output
);
*/
convertPointFields<Foam::scalar>
(
mesh, objects, arraySelection, output
@ -213,6 +224,11 @@ void Foam::vtkPV3Foam::updateLagrangianFields
Info<< "converting Foam Lagrangian fields" << endl;
}
convertLagrangianFields<Foam::label>
(
mesh, objects, arraySelection, output
);
convertLagrangianFields<Foam::scalar>
(
mesh, objects, arraySelection, output

View File

@ -108,15 +108,13 @@ void Foam::vtkPV3Foam::updateInformationLagrangian()
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::updateInformationLagrangian at timePath "
<< dbPtr_->timePath()/"lagrangian" << endl;
Info<< "entered Foam::vtkPV3Foam::updateInformationLagrangian "
<< "at timePath " << dbPtr_->timePath()/"lagrangian" << endl;
}
vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();
// Search for list of lagrangian objects for this time
// IOobjectList lagrangianObjects(dbPtr(), dbPtr_().timeName(), "lagrangian");
fileNameList cloudDirs
(
readDir(dbPtr_->timePath()/"lagrangian", fileName::DIRECTORY)
@ -144,7 +142,8 @@ void Foam::vtkPV3Foam::updateInformationLagrangian()
}
else
{
Info<<"no cloudDirs @ " << dbPtr_->timePath()/"lagrangian" << endl;
Info<<"no clouds identified in "
<< dbPtr_->timePath()/"lagrangian" << endl;
}
}
@ -159,7 +158,7 @@ void Foam::vtkPV3Foam::updateInformationPatches()
vtkDataArraySelection *arraySelection = reader_->GetRegionSelection();
//- Read patches
// Read patches
polyBoundaryMeshEntries patchEntries
(
IOobject
@ -182,7 +181,7 @@ void Foam::vtkPV3Foam::updateInformationPatches()
{
label nFaces(readLabel(patchEntries[entryI].dict().lookup("nFaces")));
//- Valid patch if nFace > 0
// Valid patch if nFace > 0
if (nFaces)
{
// Add patch to GUI region list
@ -208,7 +207,7 @@ void Foam::vtkPV3Foam::updateInformationZones()
vtkDataArraySelection *arraySelection = reader_->GetRegionSelection();
//- Read cell zone information
// Read cell zone information
{
zonesEntries zones
(
@ -240,7 +239,7 @@ void Foam::vtkPV3Foam::updateInformationZones()
superCellZonesCells_.setSize(selectInfoCellZones_.size());
}
//- Read face zone information
// Read face zone information
{
zonesEntries zones
(
@ -270,7 +269,7 @@ void Foam::vtkPV3Foam::updateInformationZones()
}
}
//- Read point zone information
// Read point zone information
{
zonesEntries zones
(
@ -373,6 +372,11 @@ void Foam::vtkPV3Foam::updateInformationLagrangianFields()
"lagrangian"/cloudName_
);
addFields<IOField<label> >
(
arraySelection,
objects
);
addFields<IOField<scalar> >
(
arraySelection,

View File

@ -55,6 +55,13 @@ void Foam::vtkPV3Foam::updateInformationFields
// Populate the GUI volume/point field arrays
//- Add volume fields to GUI
/*
addFields<GeometricField<label, patchType, meshType> >
(
arraySelection,
objects
);
*/
addFields<GeometricField<scalar, patchType, meshType> >
(
arraySelection,