From 89615f708e38be26f1062f9de48a855304edf6c7 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 4 Mar 2010 11:20:20 +0100 Subject: [PATCH] ENH: respect face orientation when decomposing polyhedra. ENH: use face::trianglesQuads() method for PV3FoamReader as well. - this avoids missing faces (and weird cells) in the decomposed polyhedra. --- .../dataConversion/foamToVTK/foamToVTK.C | 44 ++----- .../dataConversion/foamToVTK/internalWriter.C | 2 +- .../dataConversion/foamToVTK/internalWriter.H | 2 +- .../foamToVTK/internalWriterTemplates.C | 2 +- .../foamToVTK/lagrangianWriter.C | 2 +- .../foamToVTK/lagrangianWriter.H | 2 +- .../foamToVTK/lagrangianWriterTemplates.C | 2 +- .../dataConversion/foamToVTK/patchWriter.C | 2 +- .../dataConversion/foamToVTK/patchWriter.H | 2 +- .../foamToVTK/patchWriterTemplates.C | 2 +- .../dataConversion/foamToVTK/readFields.C | 2 +- .../dataConversion/foamToVTK/readFields.H | 2 +- .../dataConversion/foamToVTK/vtkMesh.C | 2 +- .../dataConversion/foamToVTK/vtkMesh.H | 2 +- .../dataConversion/foamToVTK/vtkTopo.C | 119 ++++++++++-------- .../dataConversion/foamToVTK/vtkTopo.H | 9 +- .../dataConversion/foamToVTK/writeFaceSet.C | 2 +- .../dataConversion/foamToVTK/writeFaceSet.H | 2 +- .../dataConversion/foamToVTK/writeFuns.C | 2 +- .../dataConversion/foamToVTK/writeFuns.H | 2 +- .../foamToVTK/writeFunsTemplates.C | 2 +- .../dataConversion/foamToVTK/writePatchGeom.C | 2 +- .../dataConversion/foamToVTK/writePatchGeom.H | 2 +- .../dataConversion/foamToVTK/writePointSet.C | 2 +- .../dataConversion/foamToVTK/writePointSet.H | 2 +- .../foamToVTK/writeSurfFields.C | 2 +- .../foamToVTK/writeSurfFields.H | 2 +- .../PV3FoamReader/PV3FoamReader_SM.xml | 3 +- .../PV3FoamReader/pqPV3FoamReaderPanel.cxx | 2 +- .../PV3FoamReader/pqPV3FoamReaderPanel.h | 2 +- .../vtkPV3Foam/vtkPV3FoamMeshVolume.C | 118 ++++++++++------- 31 files changed, 188 insertions(+), 157 deletions(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 6855685414..872f639510 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -159,13 +159,6 @@ Note // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -static const label VTK_TETRA = 10; -static const label VTK_PYRAMID = 14; -static const label VTK_WEDGE = 13; -static const label VTK_HEXAHEDRON = 12; - - template void print(const char* msg, Ostream& os, const PtrList& flds) { @@ -229,10 +222,7 @@ labelList getSelectedPatches } - - - - +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: int main(int argc, char *argv[]) @@ -285,11 +275,11 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" - bool doWriteInternal = !args.optionFound("noInternal"); - bool doFaceZones = !args.optionFound("noFaceZones"); - bool doLinks = !args.optionFound("noLinks"); - bool binary = !args.optionFound("ascii"); - bool useTimeName = args.optionFound("useTimeName"); + const bool doWriteInternal = !args.optionFound("noInternal"); + const bool doFaceZones = !args.optionFound("noFaceZones"); + const bool doLinks = !args.optionFound("noLinks"); + const bool binary = !args.optionFound("ascii"); + const bool useTimeName = args.optionFound("useTimeName"); if (binary && (sizeof(floatScalar) != 4 || sizeof(label) != 4)) { @@ -299,7 +289,7 @@ int main(int argc, char *argv[]) << exit(FatalError); } - bool nearCellValue = args.optionFound("nearCellValue"); + const bool nearCellValue = args.optionFound("nearCellValue"); if (nearCellValue) { @@ -308,7 +298,7 @@ int main(int argc, char *argv[]) << nl << endl; } - bool noPointValues = args.optionFound("noPointValues"); + const bool noPointValues = args.optionFound("noPointValues"); if (noPointValues) { @@ -316,7 +306,7 @@ int main(int argc, char *argv[]) << "Outputting cell values only" << nl << endl; } - bool allPatches = args.optionFound("allPatches"); + const bool allPatches = args.optionFound("allPatches"); List excludePatches; if (args.optionFound("excludePatches")) @@ -392,15 +382,8 @@ int main(int argc, char *argv[]) Info<< "Time: " << runTime.timeName() << endl; - word timeDesc = ""; - if (useTimeName) - { - timeDesc = runTime.timeName(); - } - else - { - timeDesc = name(runTime.timeIndex()); - } + word timeDesc = + useTimeName ? runTime.timeName() : Foam::name(runTime.timeIndex()); // Check for new polyMesh/ and update mesh, fvMeshSubset and cell // decomposition. @@ -470,10 +453,7 @@ int main(int argc, char *argv[]) IOobjectList objects(mesh, runTime.timeName()); HashSet selectedFields; - if (args.optionFound("fields")) - { - args.optionLookup("fields")() >> selectedFields; - } + args.optionReadIfPresent("fields", selectedFields); // Construct the vol fields (on the original mesh if subsetted) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C index e44dec894c..ac0c7420be 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.H index 64c53721c8..0a7446d178 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriterTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriterTemplates.C index 3a0843771d..5f772eb05d 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriterTemplates.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriterTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C index 7ea7629bd4..75733f3340 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.H index 8c4f23a2e5..292228a98b 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriterTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriterTemplates.C index 0407a58841..a08217fbab 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriterTemplates.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriterTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.C index b012e4baf6..9b332d8636 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.H index 410be952b8..d824fc5e60 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriterTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriterTemplates.C index 2d1fba9883..ad811071bc 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriterTemplates.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriterTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C index 838d5e2971..100ce05519 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.H index ad847dc358..5ef4f6ce8f 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/readFields.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C index e5e607d677..bd80793291 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.H index d2b1e9f0e3..5070dc3d20 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.C index d403aca363..42f2335847 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,10 +33,10 @@ Description #include "polyMesh.H" #include "cellShape.H" #include "cellModeller.H" +#include "Swap.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::vtkTopo::vtkTopo(const polyMesh& mesh) : mesh_(mesh), @@ -61,6 +61,9 @@ Foam::vtkTopo::vtkTopo(const polyMesh& mesh) // Number of additional cells generated by the decomposition of polyhedra label nAddCells = 0; + // face owner is needed to determine the face orientation + const labelList& owner = mesh.faceOwner(); + // Scan for cells which need to be decomposed and count additional points // and cells @@ -71,7 +74,7 @@ Foam::vtkTopo::vtkTopo(const polyMesh& mesh) if ( model != hex -// && model != wedge // See above. + // && model != wedge // See above. && model != prism && model != pyr && model != tet @@ -111,7 +114,7 @@ Foam::vtkTopo::vtkTopo(const polyMesh& mesh) cellTypes_.setSize(cellShapes.size() + nAddCells); // Set counters for additional points and additional cells - label api = 0, aci = 0; + label addPointI = 0, addCellI = 0; forAll(cellShapes, cellI) { @@ -134,15 +137,13 @@ Foam::vtkTopo::vtkTopo(const polyMesh& mesh) } else if (cellModel == prism) { - vtkVerts.setSize(6); - vtkVerts[0] = cellShape[0]; - vtkVerts[1] = cellShape[2]; - vtkVerts[2] = cellShape[1]; - vtkVerts[3] = cellShape[3]; - vtkVerts[4] = cellShape[5]; - vtkVerts[5] = cellShape[4]; + // VTK has a different node order for VTK_WEDGE + // their triangles point outwards! + vtkVerts = cellShape; + + Foam::Swap(vtkVerts[1], vtkVerts[2]); + Foam::Swap(vtkVerts[4], vtkVerts[5]); - // VTK calls this a wedge. cellTypes_[cellI] = VTK_WEDGE; } else if (cellModel == tetWedge) @@ -175,34 +176,28 @@ Foam::vtkTopo::vtkTopo(const polyMesh& mesh) // } else if (cellModel == hex) { - vtkVerts.setSize(8); - vtkVerts[0] = cellShape[0]; - vtkVerts[1] = cellShape[1]; - vtkVerts[2] = cellShape[2]; - vtkVerts[3] = cellShape[3]; - vtkVerts[4] = cellShape[4]; - vtkVerts[5] = cellShape[5]; - vtkVerts[6] = cellShape[6]; - vtkVerts[7] = cellShape[7]; + vtkVerts = cellShape; cellTypes_[cellI] = VTK_HEXAHEDRON; } else { // Polyhedral cell. Decompose into tets + prisms. - // (see dxFoamExec/createDxConnections.C) // Mapping from additional point to cell - addPointCellLabels_[api] = cellI; + addPointCellLabels_[addPointI] = cellI; + + // The new vertex from the cell-centre + const label newVertexLabel = mesh_.nPoints() + addPointI; // Whether to insert cell in place of original or not. bool substituteCell = true; const labelList& cFaces = mesh_.cells()[cellI]; - forAll(cFaces, cFaceI) { const face& f = mesh_.faces()[cFaces[cFaceI]]; + const bool isOwner = (owner[cFaces[cFaceI]] == cellI); // Number of triangles and quads in decomposition label nTris = 0; @@ -216,75 +211,95 @@ Foam::vtkTopo::vtkTopo(const polyMesh& mesh) label quadi = 0; f.trianglesQuads(mesh_.points(), trii, quadi, triFcs, quadFcs); - forAll(quadFcs, quadi) + forAll(quadFcs, quadI) { - label thisCellI = -1; + label thisCellI; if (substituteCell) { thisCellI = cellI; - substituteCell = false; } else { - thisCellI = mesh_.nCells() + aci; - - superCells_[aci] = cellI; - - aci++; + thisCellI = mesh_.nCells() + addCellI; + superCells_[addCellI++] = cellI; } labelList& addVtkVerts = vertLabels_[thisCellI]; addVtkVerts.setSize(5); - const face& quad = quadFcs[quadi]; + const face& quad = quadFcs[quadI]; - addVtkVerts[0] = quad[0]; - addVtkVerts[1] = quad[1]; - addVtkVerts[2] = quad[2]; - addVtkVerts[3] = quad[3]; - addVtkVerts[4] = mesh_.nPoints() + api; + // Ensure we have the correct orientation for the + // base of the primitive cell shape. + // If the cell is face owner, the orientation needs to be + // flipped. + // At the moment, VTK doesn't actually seem to care if + // negative cells are defined, but we'll do it anyhow + // (for safety). + if (isOwner) + { + addVtkVerts[0] = quad[3]; + addVtkVerts[1] = quad[2]; + addVtkVerts[2] = quad[1]; + addVtkVerts[3] = quad[0]; + } + else + { + addVtkVerts[0] = quad[0]; + addVtkVerts[1] = quad[1]; + addVtkVerts[2] = quad[2]; + addVtkVerts[3] = quad[3]; + } + addVtkVerts[4] = newVertexLabel; cellTypes_[thisCellI] = VTK_PYRAMID; } - forAll(triFcs, trii) + forAll(triFcs, triI) { - label thisCellI = -1; + label thisCellI; if (substituteCell) { thisCellI = cellI; - substituteCell = false; } else { - thisCellI = mesh_.nCells() + aci; - - superCells_[aci] = cellI; - - aci++; + thisCellI = mesh_.nCells() + addCellI; + superCells_[addCellI++] = cellI; } labelList& addVtkVerts = vertLabels_[thisCellI]; - const face& tri = triFcs[trii]; + const face& tri = triFcs[triI]; addVtkVerts.setSize(4); - addVtkVerts[0] = tri[0]; - addVtkVerts[1] = tri[1]; - addVtkVerts[2] = tri[2]; - addVtkVerts[3] = mesh_.nPoints() + api; + + // See note above about the orientation. + if (isOwner) + { + addVtkVerts[0] = tri[2]; + addVtkVerts[1] = tri[1]; + addVtkVerts[2] = tri[0]; + } + else + { + addVtkVerts[0] = tri[0]; + addVtkVerts[1] = tri[1]; + addVtkVerts[2] = tri[2]; + } + addVtkVerts[3] = newVertexLabel; cellTypes_[thisCellI] = VTK_TETRA; } } - api++; + addPointI++; } } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.H index bc11ef4071..8d5c5c66eb 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,7 +80,7 @@ public: // Public static data - // this must be consistent with the enumeration in "vtkCell.H" + //- equivalent to enumeration in "vtkCellType.h" enum vtkTypes { VTK_TRIANGLE = 5, @@ -88,9 +88,10 @@ public: VTK_QUAD = 9, VTK_TETRA = 10, - VTK_PYRAMID = 14, - VTK_WEDGE = 13, VTK_HEXAHEDRON = 12, + VTK_WEDGE = 13, + VTK_PYRAMID = 14, + VTK_POLYHEDRON = 42 }; // Constructors diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFaceSet.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFaceSet.C index 4d6afaadad..6bc43cbc00 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFaceSet.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFaceSet.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFaceSet.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFaceSet.H index 2df3632e67..aa2ef52111 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFaceSet.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFaceSet.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C index 82a8df0cca..6fc82f6201 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.H index c38bbda669..4dff5df591 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFunsTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFunsTemplates.C index e9202450bb..ca11a055cf 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFunsTemplates.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFunsTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C index e420148275..ce4ab7746f 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.H index 9cbae04b6c..058b625e9a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C index 904b96c5c6..5310efbb29 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.H index d464f56c21..b3a366b908 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.C index ceb4725b78..8c422f56d7 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.H index b496a6ea05..e2dae1c043 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml index 41aa21e674..6e7a78ffe2 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml @@ -91,7 +91,8 @@ animateable="0"> - Use vtkPolyhedron instead of decomposing polyhedra + Use vtkPolyhedron instead of decomposing polyhedra. + !!Actually uses vtkConvexPointSet until this is properly supported in VTK!! diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx index 7755a75d0f..d05c998aed 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2010-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h index 71f9faafdd..a311cef43f 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2010-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshVolume.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshVolume.C index 8cba50347a..1336da5082 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshVolume.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshVolume.C @@ -31,6 +31,7 @@ License #include "fvMesh.H" #include "cellModeller.H" #include "vtkOpenFOAMPoints.H" +#include "Swap.H" // VTK includes #include "vtkCellArray.h" @@ -45,6 +46,13 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh polyDecomp& decompInfo ) { + const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& pyr = *(cellModeller::lookup("pyr")); + const cellModel& prism = *(cellModeller::lookup("prism")); + const cellModel& wedge = *(cellModeller::lookup("wedge")); + const cellModel& tetWedge = *(cellModeller::lookup("tetWedge")); + const cellModel& hex = *(cellModeller::lookup("hex")); + vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New(); if (debug) @@ -53,36 +61,27 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh printMemory(); } + const cellShapeList& cellShapes = mesh.cellShapes(); + // Number of additional points needed by the decomposition of polyhedra label nAddPoints = 0; // Number of additional cells generated by the decomposition of polyhedra label nAddCells = 0; + // face owner is needed to determine the face orientation + const labelList& owner = mesh.faceOwner(); + labelList& superCells = decompInfo.superCells(); labelList& addPointCellLabels = decompInfo.addPointCellLabels(); - const cellModel& tet = *(cellModeller::lookup("tet")); - const cellModel& pyr = *(cellModeller::lookup("pyr")); - const cellModel& prism = *(cellModeller::lookup("prism")); - const cellModel& wedge = *(cellModeller::lookup("wedge")); - const cellModel& tetWedge = *(cellModeller::lookup("tetWedge")); - const cellModel& hex = *(cellModeller::lookup("hex")); - - // Scan for cells which need to be decomposed and count additional points - // and cells - if (debug) - { - Info<< "... building cell-shapes" << endl; - } - const cellShapeList& cellShapes = mesh.cellShapes(); - if (debug) { Info<< "... scanning" << endl; } - // count number of cells to decompose + // Scan for cells which need to be decomposed and count additional points + // and cells if (!reader_->GetUseVTKPolyhedron()) { forAll(cellShapes, cellI) @@ -105,10 +104,10 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh { const face& f = mesh.faces()[cFaces[cFaceI]]; - label nFacePoints = f.size(); + label nQuads = 0; + label nTris = 0; + f.nTrianglesQuads(mesh.points(), nTris, nQuads); - label nQuads = (nFacePoints - 2)/2; - label nTris = (nFacePoints - 2)%2; nAddCells += nQuads + nTris; } @@ -201,8 +200,8 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh } else if (cellModel == prism) { - // VTK has a different node order - their triangles point outwards! - + // VTK has a different node order for VTK_WEDGE + // their triangles point outwards! nodeIds[0] = cellShape[0]; nodeIds[1] = cellShape[2]; nodeIds[2] = cellShape[1]; @@ -349,29 +348,34 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh // Mapping from additional point to cell addPointCellLabels[addPointI] = cellI; - // Insert the new vertex from the cell-centre - label newVertexLabel = mesh.nPoints() + addPointI; + // The new vertex from the cell-centre + const label newVertexLabel = mesh.nPoints() + addPointI; vtkInsertNextOpenFOAMPoint(vtkpoints, mesh.C()[cellI]); // Whether to insert cell in place of original or not. bool substituteCell = true; const labelList& cFaces = mesh.cells()[cellI]; - forAll(cFaces, cFaceI) { const face& f = mesh.faces()[cFaces[cFaceI]]; + const bool isOwner = (owner[cFaces[cFaceI]] == cellI); - label nFacePoints = f.size(); + // Number of triangles and quads in decomposition + label nTris = 0; + label nQuads = 0; + f.nTrianglesQuads(mesh.points(), nTris, nQuads); - label nQuads = (nFacePoints - 2)/2; - label nTris = (nFacePoints - 2)%2; + // Do actual decomposition into triFcs and quadFcs. + faceList triFcs(nTris); + faceList quadFcs(nQuads); + label trii = 0; + label quadi = 0; + f.trianglesQuads(mesh.points(), trii, quadi, triFcs, quadFcs); - label qpi = 0; - - for (label quadi=0; quadiInsertNextCell ( @@ -395,13 +418,11 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh 5, nodeIds ); - - qpi += 2; } - if (nTris) + forAll(triFcs, triI) { - label thisCellI = -1; + label thisCellI; if (substituteCell) { @@ -414,10 +435,23 @@ vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh superCells[addCellI++] = cellI; } - nodeIds[0] = f[0]; - nodeIds[1] = f[qpi + 1]; - nodeIds[2] = f[qpi + 2]; + const face& tri = triFcs[triI]; + + // See note above about the orientation. + if (isOwner) + { + nodeIds[0] = tri[2]; + nodeIds[1] = tri[1]; + nodeIds[2] = tri[0]; + } + else + { + nodeIds[0] = tri[0]; + nodeIds[1] = tri[1]; + nodeIds[2] = tri[2]; + } nodeIds[3] = newVertexLabel; + vtkmesh->InsertNextCell ( VTK_TETRA,