/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2016-2022 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 "steadyParticleTracksTemplates.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template Foam::tmp> Foam::readParticleField ( const word& fieldName, const IOobjectList& cloudObjects ) { const IOobject* io = cloudObjects.cfindObject>(fieldName); if (io) { return tmp>::New(*io); } FatalErrorInFunction << "Cloud field name " << fieldName << " not found or the incorrect type" << abort(FatalError); return nullptr; } template void Foam::writeVTK(OFstream& os, const Type& value) { os << component(value, 0); for (label d=1; d < pTraits::nComponents; ++d) { os << ' ' << component(value, d); } } template void Foam::writeVTKField ( OFstream& os, const IOField& field, const List& addr ) { const label step = max(1, floor(8/pTraits::nComponents)); Info<< " writing field " << field.name() << endl; os << nl << field.name() << ' ' << int(pTraits::nComponents) << ' ' << field.size() << " float" << nl; ///label offset = 0; for (const labelList& ids : addr) { List data(UIndirectList(field, ids)); label nData = data.size() - 1; forAll(data, i) { writeVTK(os, data[i]); if (((i + 1) % step == 0) || (i == nData)) { os << nl; } else { os << ' '; } } /// offset += ids.size(); } } template void Foam::processFields ( OFstream& os, const List& addr, const IOobjectList& cloudObjects ) { for (const word& fldName : cloudObjects.sortedNames>()) { const IOobject* io = cloudObjects.cfindObject>(fldName); if (!io) { FatalErrorInFunction << "Could not read field:" << fldName << " type:" << IOField::typeName << abort(FatalError); } else { Info<< " reading field " << fldName << endl; IOField field(*io); writeVTKField(os, field, addr); } } } // ************************************************************************* //