Bug fixed for post-processing meshes with topological changes

This commit is contained in:
Hrvoje Jasak 2011-03-21 20:24:36 +00:00
parent 655aac8fc6
commit 0810741b91
2 changed files with 57 additions and 14 deletions

View file

@ -53,6 +53,7 @@ void Foam::vtkPV3Foam::convertFaceField
{
const label nComp = pTraits<Type>::nComponents;
const label nInternalFaces = mesh.nInternalFaces();
const label nFaces = mesh.nFaces();
const labelList& faceOwner = mesh.faceOwner();
const labelList& faceNeigh = mesh.faceNeighbour();
@ -77,7 +78,9 @@ void Foam::vtkPV3Foam::convertFaceField
// for boundary faces: owner
forAll(faceLabels, faceI)
{
// Bug fix: filter inactive faces. HJ, 21/Mar/2011
const label faceNo = faceLabels[faceI];
if (faceNo < nInternalFaces)
{
Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
@ -87,7 +90,7 @@ void Foam::vtkPV3Foam::convertFaceField
vec[d] = component(t, d);
}
}
else
else if (faceNo < nFaces)
{
const Type& t = tf[faceOwner[faceNo]];
for (direction d = 0; d < nComp; d++)
@ -95,6 +98,13 @@ void Foam::vtkPV3Foam::convertFaceField
vec[d] = component(t, d);
}
}
else
{
for (direction d = 0; d < nComp; d++)
{
vec[d] = 0;
}
}
vtkOpenFOAMTupleRemap<Type>(vec);
cellData->InsertTuple(faceI, vec);
@ -124,6 +134,7 @@ void Foam::vtkPV3Foam::convertFaceField
{
const label nComp = pTraits<Type>::nComponents;
const label nInternalFaces = mesh.nInternalFaces();
const label nFaces = mesh.nFaces();
const labelList& faceOwner = mesh.faceOwner();
const labelList& faceNeigh = mesh.faceNeighbour();
@ -151,6 +162,7 @@ void Foam::vtkPV3Foam::convertFaceField
{
const label faceNo = iter.key();
// Bug fix: filter inactive faces. HJ, 21/Mar/2011
if (faceNo < nInternalFaces)
{
Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
@ -160,7 +172,7 @@ void Foam::vtkPV3Foam::convertFaceField
vec[d] = component(t, d);
}
}
else
else if (faceNo < nFaces)
{
const Type& t = tf[faceOwner[faceNo]];
for (direction d = 0; d < nComp; d++)
@ -168,6 +180,13 @@ void Foam::vtkPV3Foam::convertFaceField
vec[d] = component(t, d);
}
}
else
{
for (direction d = 0; d < nComp; d++)
{
vec[d] = 0;
}
}
vtkOpenFOAMTupleRemap<Type>(vec);
cellData->InsertTuple(faceI, vec);

View file

@ -54,12 +54,22 @@ vtkPolyData* Foam::vtkPV3Foam::faceZoneVTKMesh
// Construct primitivePatch of faces in faceZone
const faceList& meshFaces = mesh.faces();
const faceList& meshFaces = mesh.allFaces();
faceList patchFaces(faceLabels.size());
label npf = 0;
// Filter faces that are not in live mesh
// Bug fix. HJ, 21/Mar/2011
forAll(faceLabels, faceI)
{
patchFaces[faceI] = meshFaces[faceLabels[faceI]];
if (faceLabels[faceI] < mesh.nFaces())
{
patchFaces[npf] = meshFaces[faceLabels[faceI]];
npf++;
}
}
patchFaces.setSize(npf);
primitiveFacePatch p(patchFaces, mesh.points());
@ -124,14 +134,28 @@ vtkPolyData* Foam::vtkPV3Foam::pointZoneVTKMesh
printMemory();
}
const pointField& meshPoints = mesh.points();
const pointField& meshPoints = mesh.allPoints();
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate( pointLabels.size() );
// Filter point labels to include only live points
labelList pl(pointLabels.size());
label npl = 0;
forAll (pointLabels, pointI)
{
vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[pointLabels[pointI]]);
if (pointLabels[pointI] < mesh.nPoints())
{
pl[npl] = pointLabels[pointI];
npl++;
}
}
pl.setSize(npl);
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate( pl.size());
forAll(pointLabels, pointI)
{
vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[pl[pointI]]);
}
vtkmesh->SetPoints(vtkpoints);