/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2025 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 "foamVtkOutput.H" #include "foamVtkFormatter.H" #include "foamVtkAsciiFormatter.H" #include "foamVtkBase64Formatter.H" #include "foamVtkAppendBase64Formatter.H" #include "foamVtkAppendRawFormatter.H" #include "foamVtkLegacyAsciiFormatter.H" #include "foamVtkLegacyRawFormatter.H" #include "foamVersion.H" #include "typeInfo.H" #include "globalIndex.H" #include "instant.H" #include "Fstream.H" #include "Pstream.H" #include "OSspecific.H" // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // Foam::autoPtr Foam::vtk::newFormatter(std::ostream& os, unsigned prec) { return autoPtr::NewFrom(os, prec); } Foam::autoPtr Foam::vtk::newFormatter ( std::ostream& os, const enum formatType fmtType, unsigned prec ) { autoPtr fmt; switch (fmtType) { case formatType::INLINE_ASCII: fmt.reset(new vtk::asciiFormatter(os, prec)); break; case formatType::INLINE_BASE64: fmt.reset(new vtk::base64Formatter(os)); break; case formatType::APPEND_BASE64: fmt.reset(new vtk::appendBase64Formatter(os)); break; case formatType::APPEND_BINARY: fmt.reset(new vtk::appendRawFormatter(os)); break; case formatType::LEGACY_ASCII: fmt.reset(new vtk::legacyAsciiFormatter(os, prec)); break; case formatType::LEGACY_BINARY: fmt.reset(new vtk::legacyRawFormatter(os)); break; } return fmt; } void Foam::vtk::writeIdentity ( vtk::formatter& fmt, const label len, label start ) { // No nComponents for label, can use fmt.write() directly for (label i=0; i < len; ++i) { fmt.write(start); ++start; } } void Foam::vtk::writeList ( vtk::formatter& fmt, const UList& values ) { // No nComponents for char, can use fmt.write() directly for (const uint8_t val : values) { fmt.write(val); } } void Foam::vtk::writeListParallel ( vtk::formatter& fmt, const labelUList& values, const globalIndex& procOffset ) { // Gather sizes (offsets irrelevant) const globalIndex procAddr(globalIndex::gatherOnly{}, values.size()); if (Pstream::master()) { // Write master data - with value offset const label offsetId = procOffset.localStart(0); for (const label val : values) { vtk::write(fmt, val + offsetId); } // Receive and write DynamicList