diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/files b/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/files index 23c2c6738c..2c10cfe303 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/files +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/files @@ -1,9 +1,10 @@ +surfaceMeshWriter.C + foamToVTK.C internalWriter.C lagrangianWriter.C patchWriter.C writeFuns.C -writePatchGeom.C writeFaceSet.C writePointSet.C writeSurfFields.C diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 2b82a234ba..272307588a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -157,7 +157,7 @@ Note #include "writeFaceSet.H" #include "writePointSet.H" -#include "writePatchGeom.H" +#include "surfaceMeshWriter.H" #include "writeSurfFields.H" @@ -963,20 +963,42 @@ int main(int argc, char *argv[]) if (doFaceZones) { + PtrList ssf; + readFields + ( + vMesh, + vMesh.baseMesh(), + objects, + selectedFields, + ssf + ); + print(" surfScalarFields :", Info, ssf); + + PtrList svf; + readFields + ( + vMesh, + vMesh.baseMesh(), + objects, + selectedFields, + svf + ); + print(" surfVectorFields :", Info, svf); + const faceZoneMesh& zones = mesh.faceZones(); forAll(zones, zoneI) { - const faceZone& pp = zones[zoneI]; + const faceZone& fz = zones[zoneI]; - mkDir(fvPath/pp.name()); + mkDir(fvPath/fz.name()); fileName patchFileName; if (vMesh.useSubMesh()) { patchFileName = - fvPath/pp.name()/cellSetName + fvPath/fz.name()/cellSetName + "_" + timeDesc + ".vtk"; @@ -984,7 +1006,7 @@ int main(int argc, char *argv[]) else { patchFileName = - fvPath/pp.name()/pp.name() + fvPath/fz.name()/fz.name() + "_" + timeDesc + ".vtk"; @@ -992,18 +1014,31 @@ int main(int argc, char *argv[]) Info<< " FaceZone : " << patchFileName << endl; - std::ofstream ostr(patchFileName.c_str()); - - writeFuns::writeHeader(ostr, binary, pp.name()); - ostr<< "DATASET POLYDATA" << std::endl; - - writePatchGeom + indirectPrimitivePatch pp ( - binary, - pp().localFaces(), - pp().localPoints(), - ostr + IndirectList(mesh.faces(), fz), + mesh.points() ); + + surfaceMeshWriter writer + ( + vMesh, + binary, + pp, + fz.name(), + patchFileName + ); + + // Number of fields + writeFuns::writeCellDataHeader + ( + writer.os(), + pp.size(), + ssf.size()+svf.size() + ); + + writer.write(ssf); + writer.write(svf); } } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/surfaceMeshWriter.C similarity index 59% rename from applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C rename to applications/utilities/postProcessing/dataConversion/foamToVTK/surfaceMeshWriter.C index 0dd2bd9200..d947eb3de3 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/surfaceMeshWriter.C @@ -23,60 +23,63 @@ License \*---------------------------------------------------------------------------*/ -#include "writePatchGeom.H" -#include "OFstream.H" -#include "floatScalar.H" +#include "surfaceMeshWriter.H" #include "writeFuns.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // - -void writePatchGeom +Foam::surfaceMeshWriter::surfaceMeshWriter ( + const vtkMesh& vMesh, const bool binary, - const faceList& faces, - const pointField& points, - std::ofstream& ostr + const indirectPrimitivePatch& pp, + const word& name, + const fileName& fName ) +: + vMesh_(vMesh), + binary_(binary), + pp_(pp), + fName_(fName), + os_(fName.c_str()) { - ostr<< "POINTS " << points.size() << " float" << std::endl; - - DynamicList ptField(3*points.size()); - - writeFuns::insert(points, ptField); - - writeFuns::write(ostr, binary, ptField); + // Write header + writeFuns::writeHeader(os_, binary_, name); + os_ << "DATASET POLYDATA" << std::endl; + // Write topology label nFaceVerts = 0; - forAll(faces, faceI) + forAll(pp, faceI) { - nFaceVerts += faces[faceI].size() + 1; + nFaceVerts += pp[faceI].size() + 1; } - ostr<< "POLYGONS " << faces.size() << ' ' << nFaceVerts << std::endl; + os_ << "POINTS " << pp.nPoints() << " float" << std::endl; + + DynamicList ptField(3*pp.nPoints()); + writeFuns::insert(pp.localPoints(), ptField); + writeFuns::write(os_, binary, ptField); + + + os_ << "POLYGONS " << pp.size() << ' ' << nFaceVerts << std::endl; DynamicList