ENH: enable vtkPolyhedron support when detected

This commit is contained in:
Mark Olesen
2010-04-30 12:36:49 +02:00
parent 1075587fc1
commit 4ea1f8f98a
26 changed files with 121 additions and 88 deletions

View File

@ -39,7 +39,7 @@ License
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkStringArray.h"
// Foam includes
// OpenFOAM includes
#include "vtkPV3Foam.H"
#undef EXPERIMENTAL_TIME_CACHING
@ -413,7 +413,7 @@ int vtkPV3FoamReader::RequestData
#endif
// Do any cleanup on the Foam side
// Do any cleanup on the OpenFOAM side
foamData_->CleanUp();
return 1;

View File

@ -47,7 +47,7 @@ SourceFiles
class vtkDataArraySelection;
class vtkCallbackCommand;
// Foam forward declarations
// OpenFOAM forward declarations
namespace Foam
{
class vtkPV3Foam;
@ -78,16 +78,16 @@ public:
vtkGetStringMacro(FileName);
// Description:
// FOAM mesh caching control
// OpenFOAM mesh caching control
vtkSetMacro(CacheMesh, int);
vtkGetMacro(CacheMesh, int);
// Description:
// FOAM refresh times/fields
// OpenFOAM refresh times/fields
virtual void SetRefresh(int);
// Description:
// FOAM Skip/include the 0/ time directory
// OpenFOAM skip/include the 0/ time directory
vtkSetMacro(SkipZeroTime, int);
vtkGetMacro(SkipZeroTime, int);
@ -97,27 +97,27 @@ public:
vtkGetMacro(UpdateGUI, int);
// Description:
// FOAM extrapolate internal values onto the patches
// OpenFOAM extrapolate internal values onto the patches
vtkSetMacro(ExtrapolatePatches, int);
vtkGetMacro(ExtrapolatePatches, int);
// Description:
// FOAM use vtkPolyhedron instead of decomposing polyhedra
// OpenFOAM use vtkPolyhedron instead of decomposing polyhedra
vtkSetMacro(UseVTKPolyhedron, int);
vtkGetMacro(UseVTKPolyhedron, int);
// Description:
// FOAM read sets control
// OpenFOAM read sets control
virtual void SetIncludeSets(int);
vtkGetMacro(IncludeSets, int);
// Description:
// FOAM read zones control
// OpenFOAM read zones control
virtual void SetIncludeZones(int);
vtkGetMacro(IncludeZones, int);
// Description:
// FOAM display patch names control
// OpenFOAM display patch names control
virtual void SetShowPatchNames(int);
vtkGetMacro(ShowPatchNames, int);

View File

@ -1,10 +1,18 @@
/* Note: enable vtkPolyhedron when available */
PARAVIEW_INC=$(ParaView_DIR)/include/paraview-$(ParaView_MAJOR)
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(ParaView_DIR)/include/paraview-$(ParaView_MAJOR) \
-I../../vtkPV3Readers/lnInclude \
-I../PV3FoamReader
-I../PV3FoamReader \
-I$(PARAVIEW_INC) \
$(shell \
test -f $(PARAVIEW_INC)/vtkPolyhedron.h && \
echo "-DHAS_VTK_POLYHEDRON" || echo "-UHAS_VTK_POLYHEDRON" \
)
LIB_LIBS = \
-lvtkPV3Readers \

View File

@ -56,7 +56,7 @@ inline void vtkSetOpenFOAMPoint
}
// Convert Foam mesh vertices to VTK
// Convert OpenFOAM mesh vertices to VTK
inline vtkPoints* vtkSetOpenFOAMPoints(const Foam::pointField& points)
{
vtkPoints *vtkpoints = vtkPoints::New();

View File

@ -26,7 +26,7 @@ License
#include "vtkPV3Foam.H"
#include "vtkPV3FoamReader.h"
// Foam includes
// OpenFOAM includes
#include "fvMesh.H"
#include "Time.H"
#include "patchZones.H"
@ -426,12 +426,12 @@ void Foam::vtkPV3Foam::updateFoamMesh()
meshPtr_ = NULL;
}
// Check to see if the FOAM mesh has been created
// Check to see if the OpenFOAM mesh has been created
if (!meshPtr_)
{
if (debug)
{
Info<< "Creating Foam mesh for region " << meshRegion_
Info<< "Creating OpenFOAM mesh for region " << meshRegion_
<< " at time=" << dbPtr_().timeName()
<< endl;
@ -454,7 +454,7 @@ void Foam::vtkPV3Foam::updateFoamMesh()
{
if (debug)
{
Info<< "Using existing Foam mesh" << endl;
Info<< "Using existing OpenFOAM mesh" << endl;
}
}
@ -488,7 +488,7 @@ void Foam::vtkPV3Foam::Update
reader_->UpdateProgress(0.15);
// Update the Foam mesh
// Update the OpenFOAM mesh
updateFoamMesh();
reader_->UpdateProgress(0.4);
@ -527,6 +527,10 @@ void Foam::vtkPV3Foam::Update
convertVolFields(output);
convertPointFields(output);
convertLagrangianFields(lagrangianOutput);
if (debug)
{
Info<< "done reader part" << endl;
}
reader_->UpdateProgress(0.95);
meshChanged_ = fieldsChanged_ = false;

View File

@ -89,7 +89,7 @@ class vtkIndent;
namespace Foam
{
// Foam class forward declarations
// OpenFOAM class forward declarations
class argList;
class Time;
class fvMesh;
@ -249,10 +249,10 @@ class vtkPV3Foam
//- Access to the controlling vtkPV3FoamReader
vtkPV3FoamReader* reader_;
//- Foam time control
//- OpenFOAM time control
autoPtr<Time> dbPtr_;
//- Foam mesh
//- OpenFOAM mesh
fvMesh* meshPtr_;
//- The mesh region
@ -384,7 +384,7 @@ class vtkPV3Foam
// Update helper functions
//- Foam mesh
//- OpenFOAM mesh
void updateFoamMesh();
//- Reduce memory footprint after conversion
@ -496,7 +496,7 @@ class vtkPV3Foam
);
// Convert Foam fields
// Convert OpenFOAM fields
//- Volume fields - all types
template<class Type>

View File

@ -26,7 +26,7 @@ License
#ifndef vtkPV3FoamAddToSelection_H
#define vtkPV3FoamAddToSelection_H
// FOAM includes
// OpenFOAM includes
#include "IOobjectList.H"
#include "SortableList.H"

View File

@ -25,7 +25,7 @@ License
#include "vtkPV3Foam.H"
// Foam includes
// OpenFOAM includes
#include "IOobjectList.H"
#include "vtkPV3FoamReader.h"
@ -94,7 +94,7 @@ void Foam::vtkPV3Foam::convertVolFields
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertVolFields" << nl
<< "converting Foam volume fields" << endl;
<< "converting OpenFOAM volume fields" << endl;
forAllConstIter(IOobjectList, objects, iter)
{
Info<< " " << iter()->name()
@ -163,6 +163,10 @@ void Foam::vtkPV3Foam::convertPointFields
if (selectedFields.empty())
{
if (debug)
{
Info<< "no point fields selected" << endl;
}
return;
}
@ -179,7 +183,7 @@ void Foam::vtkPV3Foam::convertPointFields
if (debug)
{
Info<< "<beg> Foam::vtkPV3Foam::convertPointFields" << nl
<< "converting Foam volume fields" << endl;
<< "converting OpenFOAM volume fields -> point fields" << endl;
forAllConstIter(IOobjectList, objects, iter)
{
Info<< " " << iter()->name()
@ -274,7 +278,7 @@ void Foam::vtkPV3Foam::convertLagrangianFields
if (debug)
{
Info<< "converting Foam lagrangian fields" << nl;
Info<< "converting OpenFOAM lagrangian fields" << nl;
forAllConstIter(IOobjectList, objects, iter)
{
Info<< " " << iter()->name()

View File

@ -25,7 +25,7 @@ License
#include "vtkPV3Foam.H"
// Foam includes
// OpenFOAM includes
#include "cellSet.H"
#include "faceSet.H"
#include "pointSet.H"

View File

@ -25,7 +25,7 @@ License
#include "vtkPV3Foam.H"
// Foam includes
// OpenFOAM includes
#include "Cloud.H"
#include "fvMesh.H"
#include "IOobjectList.H"

View File

@ -25,7 +25,7 @@ License
#include "vtkPV3Foam.H"
// Foam includes
// OpenFOAM includes
#include "polyPatch.H"
#include "primitivePatch.H"
#include "vtkOpenFOAMPoints.H"
@ -47,7 +47,7 @@ vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh(const polyPatch& p)
printMemory();
}
// Convert Foam mesh vertices to VTK
// Convert OpenFOAM mesh vertices to VTK
const Foam::pointField& points = p.localPoints();
vtkPoints* vtkpoints = vtkPoints::New();

View File

@ -25,7 +25,7 @@ License
#include "vtkPV3Foam.H"
// Foam includes
// OpenFOAM includes
#include "faceSet.H"
#include "pointSet.H"
#include "vtkOpenFOAMPoints.H"
@ -65,7 +65,7 @@ vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh
// The balance of this routine should be identical to patchVTKMesh
// Convert Foam mesh vertices to VTK
// Convert OpenFOAM mesh vertices to VTK
const pointField& points = p.localPoints();
vtkPoints* vtkpoints = vtkPoints::New();

View File

@ -26,7 +26,7 @@ License
#include "vtkPV3Foam.H"
#include "vtkPV3FoamReader.h"
// Foam includes
// OpenFOAM includes
#include "fvMesh.H"
#include "cellModeller.H"
#include "vtkOpenFOAMPoints.H"
@ -74,15 +74,15 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
labelList& superCells = decompInfo.superCells();
labelList& addPointCellLabels = decompInfo.addPointCellLabels();
if (debug)
{
Info<< "... scanning" << endl;
}
// Scan for cells which need to be decomposed and count additional points
// and cells
if (!reader_->GetUseVTKPolyhedron())
{
if (debug)
{
Info<< "... scanning for polyhedra" << endl;
}
forAll(cellShapes, cellI)
{
const cellModel& model = cellShapes[cellI].model();
@ -138,7 +138,7 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
Info<< "... converting points" << endl;
}
// Convert Foam mesh vertices to VTK
// Convert OpenFOAM mesh vertices to VTK
vtkPoints* vtkpoints = vtkPoints::New();
vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
@ -164,6 +164,17 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
// data types - max 'order' = hex = 8 points
vtkIdType nodeIds[8];
// hash to establish unique node ids for a polyhedral cell
HashSet<vtkIdType, Hash<label> > hashUniqId(2*256);
// unique node ids for a polyhedral cell
DynamicList<vtkIdType> uniqueNodeIds(256);
// face-stream for a polyhedral cell
// [numFace0Pts, id1, id2, id3, numFace1Pts, id1, id2, id3, ...]
DynamicList<vtkIdType> faceStream(256);
forAll(cellShapes, cellI)
{
const cellShape& cellShape = cellShapes[cellI];
@ -272,7 +283,6 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
const labelList& cFaces = mesh.cells()[cellI];
vtkIdType nFaces = cFaces.size();
vtkIdType nodeCount = 0;
vtkIdType nLabels = nFaces;
// count size for face stream
@ -282,46 +292,51 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
nLabels += f.size();
}
// hash to establish unique node ids for a polyhedral cell
hashUniqId.clear();
// unique node ids - approximately equal to the number of point ids
DynamicList<vtkIdType> uniqueNodeIds(nLabels-nFaces);
uniqueNodeIds.clear();
uniqueNodeIds.reserve(nLabels-nFaces);
// zero-based index into uniqueNodeIds
DynamicList<vtkIdType> faceLabels(nLabels);
// build face-stream
// [numFace0Pts, id1, id2, id3, numFace1Pts, id1, id2, id3, ...]
// point Ids are global
faceStream.clear();
faceStream.reserve(nLabels + nFaces);
// localized point id within the cell
Map<label> mapLocalId(2*nLabels);
// establish the unique point ids,
// record the local mapping ids,
// create new face list
forAll(cFaces, cFaceI)
{
const face& f = mesh.faces()[cFaces[cFaceI]];
const bool isOwner = (owner[cFaces[cFaceI]] == cellI);
const label nFacePoints = f.size();
// number of labels for this face
faceLabels.append(nFacePoints);
faceStream.append(nFacePoints);
forAll(f, fp)
if (isOwner)
{
const label nodeId = f[fp];
if (mapLocalId.insert(nodeId, nodeCount))
forAll(f, fp)
{
// insertion was successful (node Id was unique)
uniqueNodeIds.append(nodeId);
// map orig vertex id -> localized point label
faceLabels.append(nodeCount);
++nodeCount;
hashUniqId.insert(f[fp]);
faceStream.append(f[fp]);
}
else
}
else
{
// fairly immaterial if we reverse the list
// or use face::reverseFace()
forAllReverse(f, fp)
{
// map orig vertex id -> localized point label
faceLabels.append(mapLocalId[nodeId]);
hashUniqId.insert(f[fp]);
faceStream.append(f[fp]);
}
}
}
uniqueNodeIds.append(hashUniqId.sortedToc());
vtkIdType nodeCount = uniqueNodeIds.size();
#ifdef HAS_VTK_POLYHEDRON
vtkmesh->InsertNextCell
(
@ -329,9 +344,11 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh
nodeCount,
uniqueNodeIds.data(),
nFaces,
faceLabels.data()
faceStream.data()
);
#else
// this is a horrible substitute
// but avoids crashes when there is no vtkPolyhedron support
vtkmesh->InsertNextCell
(
VTK_CONVEX_POINT_SET,

View File

@ -25,7 +25,7 @@ License
#include "vtkPV3Foam.H"
// Foam includes
// OpenFOAM includes
#include "vtkOpenFOAMPoints.H"
// VTK includes
@ -62,7 +62,7 @@ vtkPolyData* Foam::vtkPV3Foam::faceZoneVTKMesh
// The balance of this routine should be identical to patchVTKMesh
// Convert Foam mesh vertices to VTK
// Convert OpenFOAM mesh vertices to VTK
const pointField& points = p.localPoints();
vtkPoints* vtkpoints = vtkPoints::New();

View File

@ -29,7 +29,7 @@ InClass
#ifndef vtkPV3FoamPointFields_H
#define vtkPV3FoamPointFields_H
// Foam includes
// OpenFOAM includes
#include "interpolatePointToCell.H"
#include "vtkOpenFOAMTupleRemap.H"

View File

@ -25,7 +25,7 @@ License
#include "vtkPV3Foam.H"
// Foam includes
// OpenFOAM includes
#include "cellSet.H"
#include "faceSet.H"
#include "pointSet.H"

View File

@ -29,7 +29,7 @@ Description
#include "vtkPV3Foam.H"
#include "vtkPV3FoamReader.h"
// Foam includes
// OpenFOAM includes
#include "fvMesh.H"
#include "Time.H"
#include "IFstream.H"

View File

@ -29,7 +29,7 @@ InClass
#ifndef vtkPV3FoamVolFields_H
#define vtkPV3FoamVolFields_H
// Foam includes
// OpenFOAM includes
#include "emptyFvPatchField.H"
#include "wallPolyPatch.H"
#include "faceSet.H"

View File

@ -39,7 +39,7 @@ License
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkStringArray.h"
// Foam includes
// OpenFOAM includes
#include "vtkPV3blockMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -226,7 +226,7 @@ int vtkPV3blockMeshReader::RequestData
foamData_->Update(output);
updatePointNumbersView(ShowPointNumbers);
// Do any cleanup on the Foam side
// Do any cleanup on the OpenFOAM side
foamData_->CleanUp();
return 1;

View File

@ -26,7 +26,7 @@ License
#include "vtkPV3blockMesh.H"
#include "vtkPV3blockMeshReader.h"
// Foam includes
// OpenFOAM includes
#include "blockMesh.H"
#include "Time.H"
#include "patchZones.H"
@ -298,7 +298,7 @@ void Foam::vtkPV3blockMesh::updateFoamMesh()
Info<< "<beg> Foam::vtkPV3blockMesh::updateFoamMesh" << endl;
}
// Check to see if the FOAM mesh has been created
// Check to see if the OpenFOAM mesh has been created
if (!meshPtr_)
{
if (debug)
@ -347,7 +347,7 @@ void Foam::vtkPV3blockMesh::Update
reader_->UpdateProgress(0.2);
// Update the Foam mesh
// Update the OpenFOAM mesh
updateFoamMesh();
reader_->UpdateProgress(0.5);

View File

@ -71,7 +71,7 @@ class vtkIndent;
namespace Foam
{
// Foam class forward declarations
// OpenFOAM class forward declarations
class argList;
class Time;
class blockMesh;
@ -167,10 +167,10 @@ class vtkPV3blockMesh
//- Access to the controlling vtkPV3blockMeshReader
vtkPV3blockMeshReader* reader_;
//- Foam time control
//- OpenFOAM time control
autoPtr<Time> dbPtr_;
//- Foam mesh
//- OpenFOAM mesh
blockMesh* meshPtr_;
//- Selected geometrical parts
@ -242,7 +242,7 @@ class vtkPV3blockMesh
// Update helper functions
//- Foam mesh
//- OpenFOAM mesh
void updateFoamMesh();
// Mesh conversion functions

View File

@ -26,7 +26,7 @@ License
#include "vtkPV3blockMesh.H"
#include "vtkPV3blockMeshReader.h"
// Foam includes
// OpenFOAM includes
#include "blockMesh.H"
#include "Time.H"
@ -81,7 +81,7 @@ void Foam::vtkPV3blockMesh::convertMeshBlocks
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
// Convert Foam mesh vertices to VTK
// Convert OpenFOAM mesh vertices to VTK
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate( blockDef.nPoints() );
const labelList& blockLabels = blockDef.blockShape();

View File

@ -28,7 +28,7 @@ Description
#include "vtkPV3Readers.H"
// Foam includes
// OpenFOAM includes
#include "IFstream.H"
// VTK includes

View File

@ -73,7 +73,7 @@ extern "C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// slightly changed with 2.0 from 1.0
// (to handle complex variables - not used by FOAM anyway)
// (to handle complex variables - not used by OpenFOAM anyway)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "USERD_get_constant_val.H"

View File

@ -117,7 +117,7 @@ void register_functions()
//
// Storage for all Foam state (mainly database & mesh)
// Storage for all OpenFOAM state (mainly database & mesh)
//
static readerDatabase db_;
@ -521,7 +521,7 @@ void user_query_file_function
(
"Could not find system/ and constant/ directory in\n"
+ rootAndCase
+ "\nPlease select a Foam case directory."
+ "\nPlease select an OpenFOAM case directory."
);
*iret = 1;

View File

@ -25,7 +25,7 @@ Class
Foam::readerDatabase
Description
Singleton caching Foam database and mesh and various. Used in Fv reader
Singleton caching OpenFOAM database and mesh and various. Used in Fv reader
to keep track of data inbetween callbacks.
SourceFiles