diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
index 3698b2e95..f490f220d 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
@@ -27,13 +27,13 @@ Application
Description
Legacy VTK file format writer.
- - handles volScalar, volVector, pointScalar, pointVector, surfaceScalar
+ - Handles volFields, pointFields, surfaceScalarField, surfaceVectorField
fields.
- - mesh topo changes.
- - both ascii and binary.
- - single time step writing.
- - write subset only.
- - automatic decomposition of cells; polygons on boundary undecomposed since
+ - Mesh topo changes.
+ - Both ascii and binary.
+ - Single time step writing.
+ - Write subset only.
+ - Automatic decomposition of cells; polygons on boundary undecomposed since
handled by vtk.
Usage
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files
index 9dee50c90..c0df3f199 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files
@@ -9,4 +9,7 @@ writeSurfFields.C
vtkMesh.C
vtkTopo.C
+writeVTK/writeVTK.C
+writeVTK/writeVTKFunctionObject.C
+
LIB = $(FOAM_LIBBIN)/libfoamToVTK
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/IOwriteVTK.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/IOwriteVTK.H
new file mode 100644
index 000000000..71851a258
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/IOwriteVTK.H
@@ -0,0 +1,49 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+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 .
+
+Typedef
+ Foam::IOwriteVTK
+
+Description
+ Instance of the generic IOOutputFilter for writeVTK.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef IOwriteVTK_H
+#define IOwriteVTK_H
+
+#include "writeVTK.H"
+#include "IOOutputFilter.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+ typedef IOOutputFilter IOwriteVTK;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/controlDict b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/controlDict
new file mode 100644
index 000000000..fdb8d149c
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/controlDict
@@ -0,0 +1,81 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| ========= | |
+| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
+| \\ / O peration | Version: dev |
+| \\ / A nd | Web: www.OpenFOAM.org |
+| \\/ M anipulation | |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+ version 2.0;
+ format ascii;
+ class dictionary;
+ object controlDict;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+// So we get a decent warning if we have multiple functionObject entries
+// with the same name.
+#inputMode error;
+
+application icoFoam;
+
+startFrom startTime;
+
+startTime 0;
+
+stopAt endTime;
+
+endTime 0.5;
+
+deltaT 0.005;
+
+writeControl timeStep;
+
+writeInterval 20;
+
+purgeWrite 0;
+
+writeFormat ascii;
+
+writePrecision 6;
+
+writeCompression uncompressed;
+
+timeFormat general;
+
+timePrecision 6;
+
+runTimeModifiable yes;
+
+functions
+{
+ writeVTK
+ {
+ type writeVTK;
+
+ // Where to load it from
+ functionObjectLibs ("libfoamToVTK.so");
+
+ // When to write:
+ // timeStep (with optional outputInterval)
+ // outputTime (with optional outputInterval)
+ // adjustableTime
+ // runTime
+ // clockTime
+ // cpuTime
+ outputControl outputTime;
+
+ // Write every writeInterval (only valid for timeStemp, outputTime)
+ outputInterval 1;
+
+ // Interval of time (valid for adjustableTime, runTime, clockTime,
+ // cpuTime)
+ writeInterval 1;
+
+ // Objects to write
+ objectNames ();
+ }
+}
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.C
new file mode 100644
index 000000000..8e9e3bcdf
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.C
@@ -0,0 +1,175 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+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 "writeVTK.H"
+#include "dictionary.H"
+#include "Time.H"
+#include "vtkMesh.H"
+#include "internalWriter.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace functionObjects
+{
+ defineTypeNameAndDebug(writeVTK, 0);
+}
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::functionObjects::writeVTK::writeVTK
+(
+ const word& name,
+ const objectRegistry& obr,
+ const dictionary& dict,
+ const bool loadFromFiles
+)
+:
+ name_(name),
+ obr_(obr),
+ objectNames_()
+{
+ read(dict);
+}
+
+
+bool Foam::functionObjects::writeVTK::viable
+(
+ const word& name,
+ const objectRegistry& obr,
+ const dictionary& dict,
+ const bool loadFromFiles
+)
+{
+ // Construction is viable if the available mesh is an fvMesh
+ return isA(obr);
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::functionObjects::writeVTK::~writeVTK()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+void Foam::functionObjects::writeVTK::read(const dictionary& dict)
+{
+ dict.lookup("objectNames") >> objectNames_;
+}
+
+
+void Foam::functionObjects::writeVTK::execute()
+{}
+
+
+void Foam::functionObjects::writeVTK::end()
+{}
+
+
+void Foam::functionObjects::writeVTK::timeSet()
+{}
+
+
+void Foam::functionObjects::writeVTK::write()
+{
+ Info<< type() << " " << name_ << " output:" << nl;
+
+ fvMesh& mesh = const_cast(refCast(obr_));
+
+ const Time& runTime = mesh.time();
+
+ Info<< "Time: " << runTime.timeName() << endl;
+
+ word timeDesc = runTime.timeName();
+
+ // VTK/ directory in the case
+ fileName fvPath(runTime.path()/"VTK");
+
+ mkDir(fvPath);
+
+ string vtkName = runTime.caseName();
+
+ if (Pstream::parRun())
+ {
+ // Strip off leading casename, leaving just processor_DDD ending.
+ string::size_type i = vtkName.rfind("processor");
+
+ if (i != string::npos)
+ {
+ vtkName = vtkName.substr(i);
+ }
+ }
+
+ // Create file and write header
+ fileName vtkFileName
+ (
+ fvPath/vtkName
+ + "_"
+ + timeDesc
+ + ".vtk"
+ );
+
+ Info<< " Internal : " << vtkFileName << endl;
+
+ vtkMesh vMesh(mesh);
+
+ // Write mesh
+ internalWriter writer(vMesh, false, vtkFileName);
+
+ UPtrList vsf(lookupFields());
+ UPtrList vvf(lookupFields());
+ UPtrList vsptf
+ (
+ lookupFields()
+ );
+ UPtrList vstf(lookupFields());
+ UPtrList vtf(lookupFields());
+
+ // Write header for cellID and volFields
+ writeFuns::writeCellDataHeader
+ (
+ writer.os(),
+ vMesh.nFieldCells(),
+ 1 + vsf.size() + vvf.size() + vsptf.size() + vstf.size() + vtf.size()
+ );
+
+ // Write cellID field
+ writer.writeCellIDs();
+
+ // Write volFields
+ writer.write(vsf);
+ writer.write(vvf);
+ writer.write(vsptf);
+ writer.write(vstf);
+ writer.write(vtf);
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.H
new file mode 100644
index 000000000..dad936a9e
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.H
@@ -0,0 +1,197 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+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 .
+
+Class
+ Foam::functionObjects::writeVTK
+
+Group
+ grpUtilitiesFunctionObjects
+
+Description
+ This functionObject writes objects registered to the database in VTK format
+ using the foamToVTK library.
+
+ Currently only the writing of the cell-values of volFields is supported but
+ support for other field types, patch fields, Lagrangian data etc. will be
+ added.
+
+ Example of function object specification:
+ \verbatim
+ writeVTK1
+ {
+ type writeVTK;
+ functionObjectLibs ("libIOFunctionObjects.so");
+ ...
+ objectNames (obj1 obj2);
+ }
+ \endverbatim
+
+ \heading Function object usage
+ \table
+ Property | Description | Required | Default value
+ type | type name: writeVTK | yes |
+ objectNames | objects to write | yes |
+ \endtable
+
+SeeAlso
+ Foam::functionObject
+ Foam::OutputFilterFunctionObject
+
+SourceFiles
+ writeVTK.C
+ IOwriteVTK.H
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef functionObjects_writeVTK_H
+#define functionObjects_writeVTK_H
+
+#include "wordReList.H"
+#include "runTimeSelectionTables.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Forward declaration of classes
+class objectRegistry;
+class dictionary;
+class polyMesh;
+class mapPolyMesh;
+
+namespace functionObjects
+{
+
+/*---------------------------------------------------------------------------*\
+ Class writeVTK Declaration
+\*---------------------------------------------------------------------------*/
+
+class writeVTK
+{
+ // Private data
+
+ //- Name of this set of writeVTK
+ word name_;
+
+ //- Refererence to Db
+ const objectRegistry& obr_;
+
+ //- Names of objects
+ wordReList objectNames_;
+
+
+ // Private Member Functions
+
+ template
+ UPtrList lookupFields() const;
+
+ //- Disallow default bitwise copy construct
+ writeVTK(const writeVTK&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const writeVTK&);
+
+
+public:
+
+ //- Runtime type information
+ TypeName("writeVTK");
+
+
+ // Constructors
+
+ //- Construct for given objectRegistry and dictionary.
+ // Allow the possibility to load fields from files
+ writeVTK
+ (
+ const word& name,
+ const objectRegistry&,
+ const dictionary&,
+ const bool loadFromFiles = false
+ );
+
+ //- Return true if the construction of this functionObject is viable
+ // i.e. the prerequisites for construction are available
+ static bool viable
+ (
+ const word& name,
+ const objectRegistry&,
+ const dictionary&,
+ const bool loadFromFiles = false
+ );
+
+
+ //- Destructor
+ virtual ~writeVTK();
+
+
+ // Member Functions
+
+ //- Return name of the writeVTK
+ virtual const word& name() const
+ {
+ return name_;
+ }
+
+ //- Read the writeVTK data
+ virtual void read(const dictionary&);
+
+ //- Execute, currently does nothing
+ virtual void execute();
+
+ //- Execute at the final time-loop, currently does nothing
+ virtual void end();
+
+ //- Called when time was set at the end of the Time::operator++
+ virtual void timeSet();
+
+ //- Write the writeVTK
+ virtual void write();
+
+ //- Update for changes of mesh
+ virtual void updateMesh(const mapPolyMesh&)
+ {}
+
+ //- Update for changes of mesh
+ virtual void movePoints(const polyMesh&)
+ {}
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace functionObjects
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+ #include "writeVTKTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.C
new file mode 100644
index 000000000..804d7156b
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.C
@@ -0,0 +1,46 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+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 "writeVTKFunctionObject.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+ defineNamedTemplateTypeNameAndDebug
+ (
+ writeVTKFunctionObject,
+ 0
+ );
+
+ addToRunTimeSelectionTable
+ (
+ functionObject,
+ writeVTKFunctionObject,
+ dictionary
+ );
+}
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.H
new file mode 100644
index 000000000..7033928cc
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.H
@@ -0,0 +1,54 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+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 .
+
+Typedef
+ Foam::writeVTKFunctionObject
+
+Description
+ FunctionObject wrapper around writeVTK to allow them to be
+ created via the functions entry within controlDict.
+
+SourceFiles
+ writeVTKFunctionObject.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef writeVTKFunctionObject_H
+#define writeVTKFunctionObject_H
+
+#include "writeVTK.H"
+#include "OutputFilterFunctionObject.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+ typedef OutputFilterFunctionObject
+ writeVTKFunctionObject;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKTemplates.C
new file mode 100644
index 000000000..e46f0333d
--- /dev/null
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKTemplates.C
@@ -0,0 +1,61 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+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 "writeVTK.H"
+#include "objectRegistry.H"
+#include "DynamicList.H"
+
+// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+
+template
+Foam::UPtrList
+Foam::functionObjects::writeVTK::lookupFields() const
+{
+ DynamicList allNames(obr_.toc().size());
+ forAll(objectNames_, i)
+ {
+ wordList names(obr_.names(objectNames_[i]));
+
+ if (names.size())
+ {
+ allNames.append(names);
+ }
+ }
+
+ UPtrList fields(allNames.size());
+
+ forAll(allNames, i)
+ {
+ const GeoField& field = obr_.lookupObject(allNames[i]);
+ Info<< " Writing " << GeoField::typeName
+ << " field " << field.name() << endl;
+ fields.set(i, &field);
+ }
+
+ return fields;
+}
+
+
+// ************************************************************************* //