/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 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 . InNamespace Foam Description Read volume fields from disk and write with vtk::internalWriter and vtk::patchWriter SourceFiles writeVolFields.H \*---------------------------------------------------------------------------*/ #ifndef writeVolFields_H #define writeVolFields_H #include "readFields.H" #include "foamVtkInternalWriter.H" #include "foamVtkPatchWriter.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { template bool writeVolField ( autoPtr& internalWriter, UPtrList& patchWriters, const tmp& tfield ) { if (!tfield.valid()) { return false; } const auto& field = tfield(); // Internal if (internalWriter.valid()) { internalWriter->write(field); } // Boundary for (vtk::patchWriter& writer : patchWriters) { writer.write(field); } tfield.clear(); return true; } template bool writeVolField ( autoPtr& internalWriter, const autoPtr& pInterp, UPtrList& patchWriters, const UPtrList>& patchInterps, const tmp& tfield ) { if (!tfield.valid()) { return false; } const auto& field = tfield(); // Internal if (internalWriter.valid() && pInterp.valid()) { internalWriter->write(field, *pInterp); } // Boundary label writeri = 0; for (vtk::patchWriter& writer : patchWriters) { if (writeri < patchInterps.size() && patchInterps.set(writeri)) { writer.write(field, patchInterps[writeri]); } ++writeri; } tfield.clear(); return true; } template label writeVolFields ( autoPtr& internalWriter, UPtrList& patchWriters, const fvMeshSubsetProxy& proxy, const IOobjectList& objects, const bool syncPar ) { label count = 0; for (const word& fieldName : objects.sortedNames()) { if ( writeVolField ( internalWriter, patchWriters, getField(proxy, objects, fieldName, syncPar) ) ) { ++count; } } return count; } template label writeVolFields ( autoPtr& internalWriter, const autoPtr& pInterp, UPtrList& patchWriters, const UPtrList>& patchInterps, const fvMeshSubsetProxy& proxy, const IOobjectList& objects, const bool syncPar ) { label count = 0; for (const word& fieldName : objects.sortedNames()) { if ( writeVolField ( internalWriter, pInterp, patchWriters, patchInterps, getField(proxy, objects, fieldName, syncPar) ) ) { ++count; } } return count; } label writeAllVolFields ( autoPtr& internalWriter, UPtrList& patchWriters, const fvMeshSubsetProxy& proxy, const IOobjectList& objects, const bool syncPar ) { #undef foamToVtk_WRITE_FIELD #define foamToVtk_WRITE_FIELD(FieldType) \ writeVolFields \ ( \ internalWriter, \ patchWriters, \ proxy, \ objects, \ syncPar \ ) label count = 0; count += foamToVtk_WRITE_FIELD(volScalarField); count += foamToVtk_WRITE_FIELD(volVectorField); count += foamToVtk_WRITE_FIELD(volSphericalTensorField); count += foamToVtk_WRITE_FIELD(volSymmTensorField); count += foamToVtk_WRITE_FIELD(volTensorField); #undef foamToVTK_WRITE_FIELD return count; } label writeAllVolFields ( autoPtr& internalWriter, const autoPtr& pInterp, UPtrList& patchWriters, const UPtrList>& patchInterps, const fvMeshSubsetProxy& proxy, const IOobjectList& objects, const bool syncPar ) { #undef foamToVtk_WRITE_FIELD #define foamToVtk_WRITE_FIELD(FieldType) \ writeVolFields \ ( \ internalWriter, pInterp, \ patchWriters, patchInterps, \ proxy, \ objects, \ syncPar \ ) label count = 0; count += foamToVtk_WRITE_FIELD(volScalarField); count += foamToVtk_WRITE_FIELD(volVectorField); count += foamToVtk_WRITE_FIELD(volSphericalTensorField); count += foamToVtk_WRITE_FIELD(volSymmTensorField); count += foamToVtk_WRITE_FIELD(volTensorField); #undef foamToVtk_WRITE_FIELD return count; } } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* //