diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 0c9dcf6d0784d4b159210d615ed66db16529ed8c..7c205e610a92ec870482abce398abdeadb9e91a2 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -40,7 +40,6 @@ Usage - foamToVTK [OPTION] - @param -ascii \n Write VTK data in ASCII format instead of binary. @@ -78,6 +77,9 @@ Usage @param -noLinks \n (in parallel) do not link processor files to master + @param poly \n + write polyhedral cells without tet/pyramid decomposition + @param -allPatches \n Combine all patches into a single file @@ -95,7 +97,7 @@ Usage Note mesh subset is handled by vtkMesh. Slight inconsistency in - interpolation: on the internal field it interpolates the whole volfield + interpolation: on the internal field it interpolates the whole volField to the whole-mesh pointField and then selects only those values it needs for the subMesh (using the fvMeshSubset cellMap(), pointMap() functions). For the patches however it uses the @@ -262,14 +264,11 @@ int main(int argc, char *argv[]) "ascii", "write in ASCII format instead of binary" ); -/* argList::addBoolOption ( - "noDecompose", - "do not decompose polyhedral cells into tets/prism cells" - "- NOT YET IMPLEMENTED" + "poly", + "write polyhedral cells without tet/pyramid decomposition" ); - */ argList::addBoolOption ( "surfaceFields", @@ -326,9 +325,8 @@ int main(int argc, char *argv[]) const bool binary = !args.optionFound("ascii"); const bool useTimeName = args.optionFound("useTimeName"); - // decomposition of polyhedral cells into tets/prism cells - // vtkTopo::decomposePoly = !args.optionFound("noDecompose"); - + // decomposition of polyhedral cells into tets/pyramids cells + vtkTopo::decomposePoly = !args.optionFound("poly"); if (binary && (sizeof(floatScalar) != 4 || sizeof(label) != 4)) { diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C index 0c008935545dac4af6467e3e69930632d1302506..fa4ad21a5b87b6c3e0fcad9887d0e6212ca4b5a8 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C @@ -28,7 +28,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::internalWriter::internalWriter ( const vtkMesh& vMesh, @@ -58,8 +57,7 @@ Foam::internalWriter::internalWriter const labelList& addPointCellLabels = topo.addPointCellLabels(); const label nTotPoints = mesh.nPoints() + addPointCellLabels.size(); - os_ << "POINTS " << nTotPoints - << " float" << std::endl; + os_ << "POINTS " << nTotPoints << " float" << std::endl; DynamicList<floatScalar> ptField(3*nTotPoints); @@ -87,9 +85,7 @@ Foam::internalWriter::internalWriter nFaceVerts += vtkVertLabels[cellI].size() + 1; } - os_ << "CELLS " << vtkVertLabels.size() << ' ' << nFaceVerts - << std::endl; - + os_ << "CELLS " << vtkVertLabels.size() << ' ' << nFaceVerts << std::endl; DynamicList<label> vertLabels(nFaceVerts); @@ -104,7 +100,6 @@ Foam::internalWriter::internalWriter writeFuns::write(os_, binary_, vertLabels); - const labelList& vtkCellTypes = topo.cellTypes(); os_ << "CELL_TYPES " << vtkCellTypes.size() << std::endl; @@ -128,8 +123,7 @@ void Foam::internalWriter::writeCellIDs() const labelList& superCells = topo.superCells(); // Cell ids first - os_ << "cellID 1 " << vtkCellTypes.size() << " int" - << std::endl; + os_ << "cellID 1 " << vtkCellTypes.size() << " int" << std::endl; labelList cellId(vtkCellTypes.size()); label labelI = 0; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C index 7f1354c4c41dfa7703ee4fc6c9af0f50218273ac..439857dc79fa9b5a4f7ce66998f13a906a0ce808 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C @@ -30,7 +30,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::lagrangianWriter::lagrangianWriter ( const vtkMesh& vMesh, diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.C index 69bbac95754903473abd619901e9728b98a7d908..31fdd5fc130014277836b5c455ff1182f3eee0bf 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/patchWriter.C @@ -26,11 +26,8 @@ License #include "patchWriter.H" #include "writeFuns.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::patchWriter::patchWriter ( const vtkMesh& vMesh, @@ -91,8 +88,7 @@ Foam::patchWriter::patchWriter } writeFuns::write(os_, binary_, ptField); - os_ << "CELLS " << nFaces_ << ' ' << nFaceVerts - << std::endl; + os_ << "CELLS " << nFaces_ << ' ' << nFaceVerts << std::endl; DynamicList<label> vertLabels(nFaceVerts); DynamicList<label> faceTypes(nFaceVerts); @@ -130,7 +126,6 @@ Foam::patchWriter::patchWriter writeFuns::write(os_, binary_, vertLabels); os_ << "CELL_TYPES " << nFaces_ << std::endl; - writeFuns::write(os_, binary_, faceTypes); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C index ae11ffbf38f728c3e8c6bee7cb4bb1b1cf3b2e1b..c006a05ba3f7c6f7d51ae4c092ee76ca8fb0010e 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkMesh.C @@ -28,12 +28,8 @@ License #include "Time.H" #include "cellSet.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::vtkMesh::vtkMesh ( fvMesh& baseMesh, @@ -63,8 +59,8 @@ Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate() if (meshState != polyMesh::UNCHANGED) { - // Note: since fvMeshSubset has no movePoints() functionality reconstruct - // the subset even if only movement. + // Note: since fvMeshSubset has no movePoints() functionality, + // reconstruct the subset even if only movement. topoPtr_.clear(); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.C index 560f757e7749367a76ebc2a7a63c61bd87c2a8b8..c8d32ef33d240c75521c0401a3e561b255b5d422 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/vtkTopo.C @@ -102,10 +102,6 @@ Foam::vtkTopo::vtkTopo(const polyMesh& mesh) } } } - else - { - notImplemented("vtkTopo: non-decomposed polyhedron"); - } // Set size of additional point addressing array @@ -191,7 +187,7 @@ Foam::vtkTopo::vtkTopo(const polyMesh& mesh) } else if (decomposePoly) { - // Polyhedral cell. Decompose into tets + prisms. + // Polyhedral cell. Decompose into tets + pyramids. // Mapping from additional point to cell addPointCellLabels_[addPointI] = cellI; @@ -314,6 +310,50 @@ Foam::vtkTopo::vtkTopo(const polyMesh& mesh) { // Polyhedral cell - not decomposed cellTypes_[cellI] = VTK_POLYHEDRON; + + const labelList& cFaces = mesh_.cells()[cellI]; + + // space for the number of faces and size of each face + label nData = 1 + cFaces.size(); + + // count total number of face points + forAll(cFaces, cFaceI) + { + const face& f = mesh.faces()[cFaces[cFaceI]]; + nData += f.size(); // space for the face labels + } + + vtkVerts.setSize(nData); + + nData = 0; + vtkVerts[nData++] = cFaces.size(); + + // build face stream + forAll(cFaces, cFaceI) + { + const face& f = mesh.faces()[cFaces[cFaceI]]; + const bool isOwner = (owner[cFaces[cFaceI]] == cellI); + + // number of labels for this face + vtkVerts[nData++] = f.size(); + + if (isOwner) + { + forAll(f, fp) + { + vtkVerts[nData++] = f[fp]; + } + } + else + { + // fairly immaterial if we reverse the list + // or use face::reverseFace() + forAllReverse(f, fp) + { + vtkVerts[nData++] = f[fp]; + } + } + } } } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C index 905d89c56a801fab0063eed3f1625f362a93f71f..6c5f7c4bdbda6896dcb845739207b8add873c61a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C @@ -227,62 +227,59 @@ void Foam::writeFuns::writePointDataHeader } -void Foam::writeFuns::insert(const scalar pt, DynamicList<floatScalar>& dest) +void Foam::writeFuns::insert(const scalar src, DynamicList<floatScalar>& dest) { - dest.append(float(pt)); + dest.append(float(src)); } -void Foam::writeFuns::insert(const vector& pt, DynamicList<floatScalar>& dest) +void Foam::writeFuns::insert(const vector& src, DynamicList<floatScalar>& dest) { - for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++) + for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt) { - dest.append(float(pt[cmpt])); + dest.append(float(src[cmpt])); } } void Foam::writeFuns::insert ( - const sphericalTensor& pt, + const sphericalTensor& src, DynamicList<floatScalar>& dest ) { - for (direction cmpt = 0; cmpt < sphericalTensor::nComponents; cmpt++) + for (direction cmpt = 0; cmpt < sphericalTensor::nComponents; ++cmpt) { - dest.append(float(pt[cmpt])); + dest.append(float(src[cmpt])); } } void Foam::writeFuns::insert ( - const symmTensor& pt, + const symmTensor& src, DynamicList<floatScalar>& dest ) { - for (direction cmpt = 0; cmpt < symmTensor::nComponents; cmpt++) + for (direction cmpt = 0; cmpt < symmTensor::nComponents; ++cmpt) { - dest.append(float(pt[cmpt])); + dest.append(float(src[cmpt])); } } -void Foam::writeFuns::insert(const tensor& pt, DynamicList<floatScalar>& dest) +void Foam::writeFuns::insert(const tensor& src, DynamicList<floatScalar>& dest) { - for (direction cmpt = 0; cmpt < tensor::nComponents; cmpt++) + for (direction cmpt = 0; cmpt < tensor::nComponents; ++cmpt) { - dest.append(float(pt[cmpt])); + dest.append(float(src[cmpt])); } } -void Foam::writeFuns::insert(const labelList& source, DynamicList<label>& dest) +void Foam::writeFuns::insert(const labelList& src, DynamicList<label>& dest) { - forAll(source, i) - { - dest.append(source[i]); - } + dest.append(src); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.H index b4055d98da49971f97ea28a7e37746f832deb627..18af5fa8b9b075c962ea0cd37e83ab4929b5f22c 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfFields.H @@ -44,7 +44,7 @@ SourceFiles namespace Foam { -// Write lagrangian fields. +// Write surface vector fields void writeSurfFields ( const bool binary,