/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "foamVtkLagrangianWriter.H" #include "Cloud.H" #include "passiveParticle.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::vtk::lagrangianWriter::beginPiece() { if (!legacy_) { if (useVerts_) { format() .openTag(vtk::fileTag::PIECE) .xmlAttr(fileAttr::NUMBER_OF_POINTS, nParcels_) .xmlAttr(fileAttr::NUMBER_OF_VERTS, nParcels_) .closeTag(); } else { format() .openTag(vtk::fileTag::PIECE) .xmlAttr(fileAttr::NUMBER_OF_POINTS, nParcels_) .closeTag(); } } } void Foam::vtk::lagrangianWriter::writePoints() { Cloud parcels(mesh_, cloudName_, false); nParcels_ = parcels.size(); const uint64_t payLoad = (nParcels_ * 3 * sizeof(float)); if (legacy_) { legacy::beginPoints(os_, nParcels_); } else { beginPiece(); // Tricky - hide begin piece in here if (!nParcels_) return; // No parcels? ... skip everything else format().tag(vtk::fileTag::POINTS) .openDataArray(vtk::dataArrayAttr::POINTS) .closeTag(); } format().writeSize(payLoad); forAllConstIters(parcels, iter) { const point pt(iter().position()); vtk::write(format(), pt); } format().flush(); if (!legacy_) { format() .endDataArray() .endTag(vtk::fileTag::POINTS); } } void Foam::vtk::lagrangianWriter::writeVertsLegacy() { os_ << "VERTICES " << nParcels_ << ' ' << 2*nParcels_ << nl; // legacy has cells + connectivity together // count the number of vertices referenced for (label i=0; i < nParcels_; ++i) { format().write(label(1)); // Number of vertices for this cell (==1) format().write(i); } format().flush(); } void Foam::vtk::lagrangianWriter::writeVerts() { format().tag(vtk::fileTag::VERTS); // Same payload throughout const uint64_t payLoad = (nParcels_ * sizeof(label)); // // 'connectivity' // = linear mapping onto points // { format().openDataArray