ENH: replace foamToVTK routines with library-level equivalents

This commit is contained in:
Mark Olesen
2017-05-22 16:13:53 +02:00
parent 8a66ec9975
commit 2495fcb42e
42 changed files with 1381 additions and 2760 deletions

View File

@ -1,10 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
wmake $targetType foamToVTK
wmake $targetType
#------------------------------------------------------------------------------

View File

@ -1,3 +1,4 @@
foamVtkLagrangianWriter.C
foamToVTK.C
EXE = $(FOAM_APPBIN)/foamToVTK

View File

@ -1,12 +1,13 @@
EXE_INC = \
-IfoamToVTK/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfoamToVTK \
-lconversion \
-ldynamicMesh \
-llagrangian \
-lgenericPatchFields

View File

@ -1,13 +0,0 @@
surfaceMeshWriter.C
internalWriter.C
lagrangianWriter.C
patchWriter.C
writeFuns.C
writeFaceSet.C
writePointSet.C
writeSurfFields.C
vtkTopo.C
writeVTK/writeVTK.C
LIB = $(FOAM_LIBBIN)/libfoamToVTK

View File

@ -1,10 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-ldynamicMesh \
-llagrangian \
-lgenericPatchFields

View File

@ -1,165 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "internalWriter.H"
#include "writeFuns.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::internalWriter::internalWriter
(
const vtkMesh& vMesh,
const bool binary,
const fileName& fName
)
:
vMesh_(vMesh),
binary_(binary),
fName_(fName),
os_(fName.c_str())
{
const fvMesh& mesh = vMesh_.mesh();
const vtkTopo& topo = vMesh_.topo();
// Write header
writeFuns::writeHeader(os_, binary_, mesh.time().caseName());
os_ << "DATASET UNSTRUCTURED_GRID" << std::endl;
//------------------------------------------------------------------
//
// Write topology
//
//------------------------------------------------------------------
const labelList& addPointCellLabels = topo.addPointCellLabels();
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
os_ << "POINTS " << nTotPoints << " float" << std::endl;
DynamicList<floatScalar> ptField(3*nTotPoints);
writeFuns::insert(mesh.points(), ptField);
const pointField& ctrs = mesh.cellCentres();
forAll(addPointCellLabels, api)
{
writeFuns::insert(ctrs[addPointCellLabels[api]], ptField);
}
writeFuns::write(os_, binary_, ptField);
//
// Write cells
//
const labelListList& vtkVertLabels = topo.vertLabels();
// Count total number of vertices referenced.
label nFaceVerts = 0;
forAll(vtkVertLabels, celli)
{
nFaceVerts += vtkVertLabels[celli].size() + 1;
}
os_ << "CELLS " << vtkVertLabels.size() << ' ' << nFaceVerts << std::endl;
DynamicList<label> vertLabels(nFaceVerts);
forAll(vtkVertLabels, celli)
{
const labelList& vtkVerts = vtkVertLabels[celli];
vertLabels.append(vtkVerts.size());
writeFuns::insert(vtkVerts, vertLabels);
}
writeFuns::write(os_, binary_, vertLabels);
const labelList& vtkCellTypes = topo.cellTypes();
os_ << "CELL_TYPES " << vtkCellTypes.size() << std::endl;
// Make copy since writing might swap stuff.
DynamicList<label> cellTypes(vtkCellTypes.size());
writeFuns::insert(vtkCellTypes, cellTypes);
writeFuns::write(os_, binary_, cellTypes);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::internalWriter::writeCellIDs()
{
const fvMesh& mesh = vMesh_.mesh();
const vtkTopo& topo = vMesh_.topo();
const labelList& vtkCellTypes = topo.cellTypes();
const labelList& superCells = topo.superCells();
// Cell ids first
os_ << "cellID 1 " << vtkCellTypes.size() << " int" << std::endl;
labelList cellId(vtkCellTypes.size());
label labelI = 0;
if (vMesh_.useSubMesh())
{
const labelList& cMap = vMesh_.subsetter().cellMap();
forAll(mesh.cells(), celli)
{
cellId[labelI++] = cMap[celli];
}
forAll(superCells, superCelli)
{
label origCelli = cMap[superCells[superCelli]];
cellId[labelI++] = origCelli;
}
}
else
{
forAll(mesh.cells(), celli)
{
cellId[labelI++] = celli;
}
forAll(superCells, superCelli)
{
label origCelli = superCells[superCelli];
cellId[labelI++] = origCelli;
}
}
writeFuns::write(os_, binary_, cellId);
}
// ************************************************************************* //

View File

@ -1,135 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
Class
Foam::internalWriter
Description
Write fields (internal).
SourceFiles
internalWriter.C
internalWriterTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef internalWriter_H
#define internalWriter_H
#include "OFstream.H"
#include "volFields.H"
#include "pointFields.H"
#include "vtkMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class volPointInterpolation;
/*---------------------------------------------------------------------------*\
Class internalWriter Declaration
\*---------------------------------------------------------------------------*/
class internalWriter
{
const vtkMesh& vMesh_;
const bool binary_;
const fileName fName_;
std::ofstream os_;
public:
// Constructors
//- Construct from components
internalWriter
(
const vtkMesh&,
const bool binary,
const fileName&
);
// Member Functions
std::ofstream& os()
{
return os_;
}
//- Write cellIDs
void writeCellIDs();
//- Write generic GeometricFields
template<class Type, template<class> class PatchField, class GeoMesh>
void write
(
const UPtrList<const GeometricField<Type, PatchField, GeoMesh>>&
);
//- Write generic internal fields
template<class Type, class GeoMesh>
void write
(
const PtrList<const DimensionedField<Type, volMesh>>& flds
);
//- Interpolate and write volFields
template<class Type>
void write
(
const volPointInterpolation&,
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>&
);
//- Interpolate and internal fields
template<class Type, class GeoMesh>
void write
(
const volPointInterpolation&,
const PtrList<const DimensionedField<Type, volMesh>>&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "internalWriterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,99 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "internalWriter.H"
#include "writeFuns.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::internalWriter::write
(
const UPtrList<const GeometricField<Type, PatchField, GeoMesh>>& flds
)
{
forAll(flds, i)
{
writeFuns::write(os_, binary_, flds[i], vMesh_);
}
}
template<class Type, class GeoMesh>
void Foam::internalWriter::write
(
const PtrList<const DimensionedField<Type, volMesh>>& flds
)
{
forAll(flds, i)
{
writeFuns::write(os_, binary_, flds[i], vMesh_);
}
}
template<class Type>
void Foam::internalWriter::write
(
const volPointInterpolation& pInterp,
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
)
{
forAll(flds, i)
{
writeFuns::write
(
os_,
binary_,
flds[i],
pInterp.interpolate(flds[i])(),
vMesh_
);
}
}
template<class Type, class GeoMesh>
void Foam::internalWriter::write
(
const volPointInterpolation& pInterp,
const PtrList<const DimensionedField<Type, volMesh>>& flds
)
{
forAll(flds, i)
{
writeFuns::write
(
os_,
binary_,
flds[i],
pInterp.interpolate(flds[i])(),
vMesh_
);
}
}
// ************************************************************************* //

View File

@ -1,137 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
Class
Foam::vtkMesh
Description
Encapsulation of VTK mesh data. Holds mesh or meshsubset and
polyhedral-cell decomposition on it.
SourceFiles
vtkMesh.C
\*---------------------------------------------------------------------------*/
#ifndef vtkMesh_H
#define vtkMesh_H
#include "meshSubsetHelper.H"
#include "vtkTopo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class vtkMesh Declaration
\*---------------------------------------------------------------------------*/
class vtkMesh
:
public meshSubsetHelper
{
// Private data
//- Current decomposition of topology
mutable autoPtr<vtkTopo> topoPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
vtkMesh(const vtkMesh&) = delete;
//- Disallow default bitwise assignment
void operator=(const vtkMesh&) = delete;
public:
// Constructors
//- Construct from components
vtkMesh(fvMesh& baseMesh, const word& setName = word::null)
:
meshSubsetHelper(baseMesh, meshSubsetHelper::SET, setName)
{}
// Member Functions
// Access
//- Topology
const vtkTopo& topo() const
{
if (topoPtr_.empty())
{
topoPtr_.reset(new vtkTopo(mesh()));
}
return topoPtr_();
}
//- Number of field cells
label nFieldCells() const
{
return topo().cellTypes().size();
}
//- Number of field points
label nFieldPoints() const
{
return mesh().nPoints() + topo().addPointCellLabels().size();
}
// Edit
//- Read mesh, forcing topo update if necessary
polyMesh::readUpdateState readUpdate()
{
polyMesh::readUpdateState meshState
= meshSubsetHelper::readUpdate();
if (meshState != polyMesh::UNCHANGED)
{
topoPtr_.clear();
}
return meshState;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,373 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
Description
Note: bug in vtk displaying wedges? Seems to display ok if we decompose
them. Should be thoroughly tested!
(they appear rarely in polyhedral meshes, do appear in some cut meshes)
\*---------------------------------------------------------------------------*/
#include "vtkTopo.H"
#include "polyMesh.H"
#include "cellShape.H"
#include "cellModeller.H"
#include "Swap.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
bool Foam::vtkTopo::decomposePoly = true;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::vtkTopo::vtkTopo(const polyMesh& mesh)
:
mesh_(mesh),
vertLabels_(),
cellTypes_(),
addPointCellLabels_(),
superCells_()
{
const cellModel& tet = *(cellModeller::lookup("tet"));
const cellModel& pyr = *(cellModeller::lookup("pyr"));
const cellModel& prism = *(cellModeller::lookup("prism"));
const cellModel& wedge = *(cellModeller::lookup("wedge"));
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
const cellModel& hex = *(cellModeller::lookup("hex"));
const cellShapeList& cellShapes = mesh_.cellShapes();
// Number of additional points needed by the decomposition of polyhedra
label nAddPoints = 0;
// Number of additional cells generated by the decomposition of polyhedra
label nAddCells = 0;
// face owner is needed to determine the face orientation
const labelList& owner = mesh.faceOwner();
// Scan for cells which need to be decomposed and count additional points
// and cells
if (decomposePoly)
{
forAll(cellShapes, celli)
{
const cellModel& model = cellShapes[celli].model();
if
(
model != hex
&& model != wedge // See above.
&& model != prism
&& model != pyr
&& model != tet
&& model != tetWedge
)
{
const cell& cFaces = mesh_.cells()[celli];
forAll(cFaces, cFacei)
{
const face& f = mesh_.faces()[cFaces[cFacei]];
label nQuads = 0;
label nTris = 0;
f.nTrianglesQuads(mesh_.points(), nTris, nQuads);
nAddCells += nQuads + nTris;
}
nAddCells--;
nAddPoints++;
}
}
}
// Set size of additional point addressing array
// (from added point to original cell)
addPointCellLabels_.setSize(nAddPoints);
// Set size of additional cells mapping array
// (from added cell to original cell)
superCells_.setSize(nAddCells);
// List of vertex labels in VTK ordering
vertLabels_.setSize(cellShapes.size() + nAddCells);
// Label of vtk type
cellTypes_.setSize(cellShapes.size() + nAddCells);
// Set counters for additional points and additional cells
label addPointi = 0, addCelli = 0;
forAll(cellShapes, celli)
{
const cellShape& cellShape = cellShapes[celli];
const cellModel& cellModel = cellShape.model();
labelList& vtkVerts = vertLabels_[celli];
if (cellModel == tet)
{
vtkVerts = cellShape;
cellTypes_[celli] = VTK_TETRA;
}
else if (cellModel == pyr)
{
vtkVerts = cellShape;
cellTypes_[celli] = VTK_PYRAMID;
}
else if (cellModel == prism)
{
// VTK has a different node order for VTK_WEDGE
// their triangles point outwards!
vtkVerts = cellShape;
Foam::Swap(vtkVerts[1], vtkVerts[2]);
Foam::Swap(vtkVerts[4], vtkVerts[5]);
cellTypes_[celli] = VTK_WEDGE;
}
else if (cellModel == tetWedge && decomposePoly)
{
// Treat as squeezed prism (VTK_WEDGE)
vtkVerts.setSize(6);
vtkVerts[0] = cellShape[0];
vtkVerts[1] = cellShape[2];
vtkVerts[2] = cellShape[1];
vtkVerts[3] = cellShape[3];
vtkVerts[4] = cellShape[4];
vtkVerts[5] = cellShape[3];
cellTypes_[celli] = VTK_WEDGE;
}
else if (cellModel == wedge)
{
// Treat as squeezed hex
vtkVerts.setSize(8);
vtkVerts[0] = cellShape[0];
vtkVerts[1] = cellShape[1];
vtkVerts[2] = cellShape[2];
vtkVerts[3] = cellShape[2];
vtkVerts[4] = cellShape[3];
vtkVerts[5] = cellShape[4];
vtkVerts[6] = cellShape[5];
vtkVerts[7] = cellShape[6];
cellTypes_[celli] = VTK_HEXAHEDRON;
}
else if (cellModel == hex)
{
vtkVerts = cellShape;
cellTypes_[celli] = VTK_HEXAHEDRON;
}
else if (decomposePoly)
{
// Polyhedral cell. Decompose into tets + pyramids.
// Mapping from additional point to cell
addPointCellLabels_[addPointi] = celli;
// The new vertex from the cell-centre
const label newVertexLabel = mesh_.nPoints() + addPointi;
// Whether to insert cell in place of original or not.
bool substituteCell = true;
const labelList& cFaces = mesh_.cells()[celli];
forAll(cFaces, cFacei)
{
const face& f = mesh_.faces()[cFaces[cFacei]];
const bool isOwner = (owner[cFaces[cFacei]] == celli);
// Number of triangles and quads in decomposition
label nTris = 0;
label nQuads = 0;
f.nTrianglesQuads(mesh_.points(), nTris, nQuads);
// Do actual decomposition into triFcs and quadFcs.
faceList triFcs(nTris);
faceList quadFcs(nQuads);
label trii = 0;
label quadi = 0;
f.trianglesQuads(mesh_.points(), trii, quadi, triFcs, quadFcs);
forAll(quadFcs, quadI)
{
label thisCelli;
if (substituteCell)
{
thisCelli = celli;
substituteCell = false;
}
else
{
thisCelli = mesh_.nCells() + addCelli;
superCells_[addCelli++] = celli;
}
labelList& addVtkVerts = vertLabels_[thisCelli];
addVtkVerts.setSize(5);
const face& quad = quadFcs[quadI];
// Ensure we have the correct orientation for the
// base of the primitive cell shape.
// If the cell is face owner, the orientation needs to be
// flipped.
// At the moment, VTK doesn't actually seem to care if
// negative cells are defined, but we'll do it anyhow
// (for safety).
if (isOwner)
{
addVtkVerts[0] = quad[3];
addVtkVerts[1] = quad[2];
addVtkVerts[2] = quad[1];
addVtkVerts[3] = quad[0];
}
else
{
addVtkVerts[0] = quad[0];
addVtkVerts[1] = quad[1];
addVtkVerts[2] = quad[2];
addVtkVerts[3] = quad[3];
}
addVtkVerts[4] = newVertexLabel;
cellTypes_[thisCelli] = VTK_PYRAMID;
}
forAll(triFcs, triI)
{
label thisCelli;
if (substituteCell)
{
thisCelli = celli;
substituteCell = false;
}
else
{
thisCelli = mesh_.nCells() + addCelli;
superCells_[addCelli++] = celli;
}
labelList& addVtkVerts = vertLabels_[thisCelli];
const face& tri = triFcs[triI];
addVtkVerts.setSize(4);
// See note above about the orientation.
if (isOwner)
{
addVtkVerts[0] = tri[2];
addVtkVerts[1] = tri[1];
addVtkVerts[2] = tri[0];
}
else
{
addVtkVerts[0] = tri[0];
addVtkVerts[1] = tri[1];
addVtkVerts[2] = tri[2];
}
addVtkVerts[3] = newVertexLabel;
cellTypes_[thisCelli] = VTK_TETRA;
}
}
addPointi++;
}
else
{
// Polyhedral cell - not decomposed
cellTypes_[celli] = VTK_POLYHEDRON;
const labelList& cFaces = mesh_.cells()[celli];
// space for the number of faces and size of each face
label nData = 1 + cFaces.size();
// count total number of face points
forAll(cFaces, cFacei)
{
const face& f = mesh.faces()[cFaces[cFacei]];
nData += f.size(); // space for the face labels
}
vtkVerts.setSize(nData);
nData = 0;
vtkVerts[nData++] = cFaces.size();
// build face stream
forAll(cFaces, cFacei)
{
const face& f = mesh.faces()[cFaces[cFacei]];
const bool isOwner = (owner[cFaces[cFacei]] == celli);
// number of labels for this face
vtkVerts[nData++] = f.size();
if (isOwner)
{
forAll(f, fp)
{
vtkVerts[nData++] = f[fp];
}
}
else
{
// fairly immaterial if we reverse the list
// or use face::reverseFace()
forAllReverse(f, fp)
{
vtkVerts[nData++] = f[fp];
}
}
}
}
}
if (decomposePoly)
{
Pout<< " Original cells:" << mesh_.nCells()
<< " points:" << mesh_.nPoints()
<< " Additional cells:" << superCells_.size()
<< " additional points:" << addPointCellLabels_.size()
<< nl << endl;
}
}
// ************************************************************************* //

View File

@ -1,139 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
Class
Foam::vtkTopo
Description
Polyhedral cell decomposition for VTK.
SourceFiles
vtkTopo.C
\*---------------------------------------------------------------------------*/
#ifndef vtkTopo_H
#define vtkTopo_H
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class polyMesh;
/*---------------------------------------------------------------------------*\
Class vtkTopo Declaration
\*---------------------------------------------------------------------------*/
class vtkTopo
{
// Private data
const polyMesh& mesh_;
//- Vertices per cell (including added cells) in vtk ordering
labelListList vertLabels_;
//- Cell types (including added cells) in vtk numbering
labelList cellTypes_;
labelList addPointCellLabels_;
labelList superCells_;
// Private Member Functions
//- Disallow default bitwise copy construct
vtkTopo(const vtkTopo&);
//- Disallow default bitwise assignment
void operator=(const vtkTopo&);
public:
// Public static data
//- Equivalent to enumeration in "vtkCellType.h"
enum vtkTypes
{
VTK_TRIANGLE = 5,
VTK_POLYGON = 7,
VTK_QUAD = 9,
VTK_TETRA = 10,
VTK_HEXAHEDRON = 12,
VTK_WEDGE = 13,
VTK_PYRAMID = 14,
VTK_POLYHEDRON = 42
};
//- Enable/disable polyhedron decomposition. Default = true
static bool decomposePoly;
// Constructors
//- Construct from components
vtkTopo(const polyMesh&);
// Member Functions
// Access
const labelListList& vertLabels() const
{
return vertLabels_;
}
const labelList& cellTypes() const
{
return cellTypes_;
}
const labelList& addPointCellLabels() const
{
return addPointCellLabels_;
}
const labelList& superCells() const
{
return superCells_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,127 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "writeFaceSet.H"
#include "OFstream.H"
#include "writeFuns.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::writeFaceSet
(
const bool binary,
const fvMesh& mesh,
const faceSet& set,
const fileName& fileName
)
{
const faceList& faces = mesh.faces();
std::ofstream ostr(fileName.c_str());
writeFuns::writeHeader
(
ostr,
binary,
set.name()
);
ostr<< "DATASET POLYDATA" << std::endl;
//------------------------------------------------------------------
//
// Write topology
//
//------------------------------------------------------------------
// Construct primitivePatch of faces in faceSet.
faceList setFaces(set.size());
labelList setFaceLabels(set.size());
label setFacei = 0;
forAllConstIter(faceSet, set, iter)
{
setFaceLabels[setFacei] = iter.key();
setFaces[setFacei] = faces[iter.key()];
setFacei++;
}
primitiveFacePatch fp(setFaces, mesh.points());
// Write points and faces as polygons
ostr<< "POINTS " << fp.nPoints() << " float" << std::endl;
DynamicList<floatScalar> ptField(3*fp.nPoints());
writeFuns::insert(fp.localPoints(), ptField);
writeFuns::write(ostr, binary, ptField);
label nFaceVerts = 0;
forAll(fp.localFaces(), facei)
{
nFaceVerts += fp.localFaces()[facei].size() + 1;
}
ostr<< "POLYGONS " << fp.size() << ' ' << nFaceVerts << std::endl;
DynamicList<label> vertLabels(nFaceVerts);
forAll(fp.localFaces(), facei)
{
const face& f = fp.localFaces()[facei];
vertLabels.append(f.size());
writeFuns::insert(f, vertLabels);
}
writeFuns::write(ostr, binary, vertLabels);
//-----------------------------------------------------------------
//
// Write data
//
//-----------------------------------------------------------------
// Write faceID
ostr
<< "CELL_DATA " << fp.size() << std::endl
<< "FIELD attributes 1" << std::endl;
// Cell ids first
ostr<< "faceID 1 " << fp.size() << " int" << std::endl;
writeFuns::write(ostr, binary, setFaceLabels);
}
// ************************************************************************* //

View File

@ -1,63 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
InClass
Foam::writeFaceSet
Description
Write faceSet to vtk polydata file. Only one data which is original
faceID.
SourceFiles
writeFaceSet.C
\*---------------------------------------------------------------------------*/
#ifndef writeFaceSet_H
#define writeFaceSet_H
#include "fvMesh.H"
#include "faceSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Write lagrangian fields.
void writeFaceSet
(
const bool binary,
const fvMesh&,
const faceSet& set,
const fileName& fileName
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,264 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "writeFuns.H"
#include "vtkTopo.H"
#include "endian.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::writeFuns::swapWord(label& word32)
{
char* mem = reinterpret_cast<char*>(&word32);
char a = mem[0];
mem[0] = mem[3];
mem[3] = a;
a = mem[1];
mem[1] = mem[2];
mem[2] = a;
}
void Foam::writeFuns::swapWords(const label nWords, label* words32)
{
for (label i = 0; i < nWords; i++)
{
swapWord(words32[i]);
}
}
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
List<floatScalar>& fField
)
{
if (binary)
{
#ifdef WM_LITTLE_ENDIAN
swapWords(fField.size(), reinterpret_cast<label*>(fField.begin()));
#endif
os.write
(
reinterpret_cast<char*>(fField.begin()),
fField.size()*sizeof(float)
);
os << std::endl;
}
else
{
forAll(fField, i)
{
os << fField[i];
if (i > 0 && (i % 10) == 0)
{
os << std::endl;
}
else
{
os << ' ';
}
}
os << std::endl;
}
}
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
DynamicList<floatScalar>& fField
)
{
List<floatScalar>& fld = fField.shrink();
write(os, binary, fld);
}
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
labelList& elems
)
{
if (binary)
{
#ifdef WM_LITTLE_ENDIAN
swapWords(elems.size(), reinterpret_cast<label*>(elems.begin()));
#endif
os.write
(
reinterpret_cast<char*>(elems.begin()),
elems.size()*sizeof(label)
);
os << std::endl;
}
else
{
forAll(elems, i)
{
os << elems[i];
if (i > 0 && (i % 10) == 0)
{
os << std::endl;
}
else
{
os << ' ';
}
}
os << std::endl;
}
}
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
DynamicList<label>& elems
)
{
labelList& fld = elems.shrink();
write(os, binary, fld);
}
void Foam::writeFuns::writeHeader
(
std::ostream& os,
const bool binary,
const std::string& title
)
{
os << "# vtk DataFile Version 2.0" << std::endl
<< title << std::endl;
if (binary)
{
os << "BINARY" << std::endl;
}
else
{
os << "ASCII" << std::endl;
}
}
void Foam::writeFuns::writeCellDataHeader
(
std::ostream& os,
const label nCells,
const label nFields
)
{
os << "CELL_DATA " << nCells << std::endl
<< "FIELD attributes " << nFields << std::endl;
}
void Foam::writeFuns::writePointDataHeader
(
std::ostream& os,
const label nPoints,
const label nFields
)
{
os << "POINT_DATA " << nPoints << std::endl
<< "FIELD attributes " << nFields << std::endl;
}
void Foam::writeFuns::insert(const scalar src, DynamicList<floatScalar>& dest)
{
dest.append(float(src));
}
void Foam::writeFuns::insert(const vector& src, DynamicList<floatScalar>& dest)
{
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
{
dest.append(float(src[cmpt]));
}
}
void Foam::writeFuns::insert
(
const sphericalTensor& src,
DynamicList<floatScalar>& dest
)
{
for (direction cmpt = 0; cmpt < sphericalTensor::nComponents; ++cmpt)
{
dest.append(float(src[cmpt]));
}
}
void Foam::writeFuns::insert
(
const symmTensor& src,
DynamicList<floatScalar>& dest
)
{
dest.append(float(src.xx()));
dest.append(float(src.yy()));
dest.append(float(src.zz()));
dest.append(float(src.xy()));
dest.append(float(src.yz()));
dest.append(float(src.xz()));
}
void Foam::writeFuns::insert(const tensor& src, DynamicList<floatScalar>& dest)
{
for (direction cmpt = 0; cmpt < tensor::nComponents; ++cmpt)
{
dest.append(float(src[cmpt]));
}
}
void Foam::writeFuns::insert(const labelList& src, DynamicList<label>& dest)
{
dest.append(src);
}
// ************************************************************************* //

View File

@ -1,161 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
Class
Foam::writeFuns
Description
Various functions for collecting and writing binary data.
SourceFiles
writeFuns.C
\*---------------------------------------------------------------------------*/
#ifndef writeFuns_H
#define writeFuns_H
#include "floatScalar.H"
#include "DynamicList.H"
#include "volFieldsFwd.H"
#include "pointFieldsFwd.H"
#include "vtkMesh.H"
#include "volPointInterpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class writeFuns Declaration
\*---------------------------------------------------------------------------*/
class writeFuns
{
// Private Member Functions
// Swap halves of word.
static void swapWord(label& word32);
static void swapWords(const label nWords, label* words32);
public:
// Write ascii or binary. If binary optionally in-place swaps argument
static void write(std::ostream&, const bool, List<floatScalar>&);
static void write(std::ostream&, const bool, DynamicList<floatScalar>&);
static void write(std::ostream&, const bool, labelList&);
static void write(std::ostream&, const bool, DynamicList<label>&);
// Write header
static void writeHeader
(
std::ostream&,
const bool isBinary,
const std::string& title
);
static void writeCellDataHeader
(
std::ostream&,
const label nCells,
const label nFields
);
static void writePointDataHeader
(
std::ostream&,
const label nPoints,
const label nFields
);
// Convert to VTK and store
static void insert(const scalar, DynamicList<floatScalar>&);
static void insert(const point&, DynamicList<floatScalar>&);
static void insert(const sphericalTensor&, DynamicList<floatScalar>&);
static void insert(const symmTensor&, DynamicList<floatScalar>&);
static void insert(const tensor&, DynamicList<floatScalar>&);
//- Append elements to DynamicList
static void insert(const labelList&, DynamicList<label>&);
template<class Type>
static void insert(const List<Type>&, DynamicList<floatScalar>&);
//- Write volField with cell values (including decomposed cells)
template<class Type>
static void write
(
std::ostream&,
const bool binary,
const DimensionedField<Type, volMesh>&,
const vtkMesh&
);
//- Write pointField on all mesh points. Interpolate to cell centre
// for decomposed cell centres.
template<class Type>
static void write
(
std::ostream&,
const bool binary,
const GeometricField<Type, pointPatchField, pointMesh>&,
const vtkMesh&
);
//- Write interpolated field on points and original cell values on
// decomposed cell centres.
template<class Type>
static void write
(
std::ostream&,
const bool binary,
const DimensionedField<Type, volMesh>&,
const DimensionedField<Type, pointMesh>&,
const vtkMesh&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "writeFunsTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,146 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "writeFuns.H"
#include "interpolatePointToCell.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Store List in dest
template<class Type>
void Foam::writeFuns::insert
(
const List<Type>& source,
DynamicList<floatScalar>& dest
)
{
forAll(source, i)
{
insert(source[i], dest);
}
}
template<class Type>
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
const DimensionedField<Type, volMesh>& df,
const vtkMesh& vMesh
)
{
const fvMesh& mesh = vMesh.mesh();
const labelList& superCells = vMesh.topo().superCells();
label nValues = mesh.nCells() + superCells.size();
os << df.name() << ' '
<< int(pTraits<Type>::nComponents) << ' '
<< nValues << " float" << std::endl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
insert(df.field(), fField);
forAll(superCells, superCelli)
{
label origCelli = superCells[superCelli];
insert(df[origCelli], fField);
}
write(os, binary, fField);
}
template<class Type>
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
const GeometricField<Type, pointPatchField, pointMesh>& pvf,
const vtkMesh& vMesh
)
{
const fvMesh& mesh = vMesh.mesh();
const vtkTopo& topo = vMesh.topo();
const labelList& addPointCellLabels = topo.addPointCellLabels();
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
os << pvf.name() << ' '
<< int(pTraits<Type>::nComponents) << ' '
<< nTotPoints << " float" << std::endl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
insert(pvf, fField);
forAll(addPointCellLabels, api)
{
label origCelli = addPointCellLabels[api];
insert(interpolatePointToCell(pvf, origCelli), fField);
}
write(os, binary, fField);
}
template<class Type>
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
const DimensionedField<Type, volMesh>& vvf,
const DimensionedField<Type, pointMesh>& pvf,
const vtkMesh& vMesh
)
{
const fvMesh& mesh = vMesh.mesh();
const vtkTopo& topo = vMesh.topo();
const labelList& addPointCellLabels = topo.addPointCellLabels();
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
os << vvf.name() << ' '
<< int(pTraits<Type>::nComponents) << ' '
<< nTotPoints << " float" << std::endl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
insert(pvf, fField);
forAll(addPointCellLabels, api)
{
label origCelli = addPointCellLabels[api];
insert(vvf[origCelli], fField);
}
write(os, binary, fField);
}
// ************************************************************************* //

View File

@ -1,103 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "writePointSet.H"
#include "OFstream.H"
#include "writeFuns.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void writePointSet
(
const bool binary,
const fvMesh& mesh,
const pointSet& set,
const fileName& fileName
)
{
std::ofstream ostr(fileName.c_str());
writeFuns::writeHeader
(
ostr,
binary,
set.name()
);
ostr<< "DATASET POLYDATA" << std::endl;
//------------------------------------------------------------------
//
// Write topology
//
//------------------------------------------------------------------
// Write points
ostr<< "POINTS " << set.size() << " float" << std::endl;
DynamicList<floatScalar> ptField(3*set.size());
writeFuns::insert
(
UIndirectList<point>(mesh.points(), set.toc())(),
ptField
);
writeFuns::write(ostr, binary, ptField);
//-----------------------------------------------------------------
//
// Write data
//
//-----------------------------------------------------------------
// Write faceID
ostr
<< "POINT_DATA " << set.size() << std::endl
<< "FIELD attributes 1" << std::endl;
// Cell ids first
ostr<< "pointID 1 " << set.size() << " int" << std::endl;
labelList pointIDs(set.toc());
writeFuns::write(ostr, binary, pointIDs);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,63 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
InClass
Foam::writePointSet
Description
Write pointSet to vtk polydata file. Only one data which is original
pointID.
SourceFiles
writePointSet.C
\*---------------------------------------------------------------------------*/
#ifndef writePointSet_H
#define writePointSet_H
#include "fvMesh.H"
#include "pointSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Write lagrangian fields.
void writePointSet
(
const bool binary,
const fvMesh& mesh,
const pointSet& set,
const fileName& fileName
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,81 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ 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 off;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
functions
{
writeVTK
{
type writeVTK;
// Where to load it from
libs ("libfoamToVTK.so");
// When to write:
// timeStep (with optional writeInterval)
// writeTime (with optional writeInterval)
// adjustableTime
// runTime
// clockTime
// cpuTime
writeControl writeTime;
// Write every writeInterval (only valid for timeStemp, writeTime)
writeInterval 1;
// Interval of time (valid for adjustableTime, runTime, clockTime,
// cpuTime)
writeInterval 1;
// Objects to write
objectNames ();
}
}
// ************************************************************************* //

View File

@ -23,14 +23,13 @@ License
\*---------------------------------------------------------------------------*/
#include "lagrangianWriter.H"
#include "writeFuns.H"
#include "foamVtkLagrangianWriter.H"
#include "Cloud.H"
#include "passiveParticle.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::lagrangianWriter::lagrangianWriter
Foam::foamVtkOutput::lagrangianWriter::lagrangianWriter
(
const fvMesh& mesh,
const bool binary,
@ -40,20 +39,27 @@ Foam::lagrangianWriter::lagrangianWriter
)
:
mesh_(mesh),
binary_(binary),
fName_(fName),
format_(),
cloudName_(cloudName),
os_(fName.c_str())
os_(fName.c_str()),
nParcels_(0)
{
// Write header
writeFuns::writeHeader(os_, binary_, mesh_.time().caseName());
os_ << "DATASET POLYDATA" << std::endl;
format_ = foamVtkOutput::newFormatter
(
os_,
(
binary
? foamVtkOutput::LEGACY_BINARY
: foamVtkOutput::LEGACY_ASCII
)
);
foamVtkOutput::legacy::fileHeader(format(), mesh_.time().caseName())
<< "DATASET POLYDATA" << nl;
if (dummyCloud)
{
nParcels_ = 0;
os_ << "POINTS " << nParcels_ << " float" << std::endl;
os_ << "POINTS " << nParcels_ << " float" << nl;
}
else
{
@ -61,27 +67,32 @@ Foam::lagrangianWriter::lagrangianWriter
nParcels_ = parcels.size();
os_ << "POINTS " << nParcels_ << " float" << std::endl;
os_ << "POINTS " << nParcels_ << " float" << nl;
DynamicList<floatScalar> partField(3*parcels.size());
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
forAllConstIters(parcels, iter)
{
writeFuns::insert(elmnt().position(), partField);
const point& pt = iter().position();
foamVtkOutput::write(format(), pt);
}
writeFuns::write(os_, binary_, partField);
format().flush();
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::lagrangianWriter::writeParcelHeader(const label nFields)
void Foam::foamVtkOutput::lagrangianWriter::beginParcelData
(
const label nFields
)
{
os_ << "POINT_DATA " << nParcels_ << std::endl
<< "FIELD attributes " << nFields
<< std::endl;
foamVtkOutput::legacy::pointDataHeader(os_, nParcels_, nFields);
}
void Foam::foamVtkOutput::lagrangianWriter::endParcelData()
{}
// ************************************************************************* //

View File

@ -33,21 +33,24 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef lagrangianWriter_H
#define lagrangianWriter_H
#ifndef foamVtkLagrangianWriter_H
#define foamVtkLagrangianWriter_H
#include "OFstream.H"
#include "Cloud.H"
#include "volFields.H"
#include "pointFields.H"
#include "foamVtkOutput.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class volPointInterpolation;
namespace foamVtkOutput
{
/*---------------------------------------------------------------------------*\
Class lagrangianWriter Declaration
\*---------------------------------------------------------------------------*/
@ -56,9 +59,7 @@ class lagrangianWriter
{
const fvMesh& mesh_;
const bool binary_;
const fileName fName_;
autoPtr<foamVtkOutput::formatter> format_;
const word cloudName_;
@ -74,7 +75,7 @@ public:
//- Construct from components
lagrangianWriter
(
const fvMesh&,
const fvMesh& mesh,
const bool binary,
const fileName&,
const word&,
@ -84,12 +85,24 @@ public:
// Member Functions
std::ofstream& os()
inline std::ofstream& os()
{
return os_;
}
void writeParcelHeader(const label nFields);
inline foamVtkOutput::formatter& format()
{
return format_();
}
inline label nParcels() const
{
return nParcels_;
}
void beginParcelData(const label nFields);
void endParcelData();
//- Write IOField
template<class Type>
@ -99,12 +112,13 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "lagrangianWriterTemplates.C"
#include "foamVtkLagrangianWriterTemplates.C"
#endif

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,14 +23,16 @@ License
\*---------------------------------------------------------------------------*/
#include "lagrangianWriter.H"
#include "writeFuns.H"
#include "foamVtkLagrangianWriter.H"
#include "IOField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::lagrangianWriter::writeIOField(const wordList& objects)
void Foam::foamVtkOutput::lagrangianWriter::writeIOField
(
const wordList& objects
)
{
forAll(objects, i)
{
@ -49,15 +51,13 @@ void Foam::lagrangianWriter::writeIOField(const wordList& objects)
IOField<Type> fld(header);
os_ << object << ' '
// Legacy
os()<< object << ' '
<< int(pTraits<Type>::nComponents) << ' '
<< fld.size() << " float" << std::endl;
<< fld.size() << " float" << nl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*fld.size());
writeFuns::insert(fld, fField);
writeFuns::write(os_, binary_, fField);
foamVtkOutput::writeList(format(), fld);
format().flush();
}
}

View File

@ -48,7 +48,7 @@ namespace Foam
template<class GeoField>
void readFields
(
const meshSubsetHelper&,
const meshSubsetHelper& helper,
const typename GeoField::Mesh& mesh,
const IOobjectList& objects,
const HashSet<word>& selectedFields,

View File

@ -24,6 +24,11 @@ starcd/STARCDMeshWriter.C
polyDualMesh/polyDualMesh.C
vtk/output/foamVtkInternalWriter.H
vtk/output/foamVtkPatchWriter.H
vtk/output/foamVtkSurfaceMeshWriter.C
vtk/output/foamVtkWriteSurfFields.C
vtk/part/foamVtkCells.C
vtk/part/foamVtkMeshMaps.C
vtk/part/foamVtuSizing.C

View File

@ -0,0 +1,132 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "foamVtkInternalWriter.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::internalWriter::internalWriter
(
const fvMesh& mesh,
enum foamVtkOutput::formatType fmtType,
const foamVtkCells& cells,
const fileName& outputName
)
:
mesh_(mesh),
format_(),
vtkCells_(cells),
os_(outputName.c_str())
{
format_ = foamVtkOutput::newFormatter(os_, fmtType);
// Write header
foamVtkOutput::legacy::fileHeader(format(), mesh.time().caseName())
<< "DATASET UNSTRUCTURED_GRID" << nl;
//------------------------------------------------------------------
//
// Write topology
//
//------------------------------------------------------------------
os_ << "POINTS " << vtkCells_.nFieldPoints() << " float" << nl;
foamVtkOutput::writeList(format(), mesh.points());
const pointField& ctrs = mesh.cellCentres();
foamVtkOutput::writeList(format(), ctrs, vtkCells_.addPointCellLabels());
format().flush();
//
// Write cells
//
const List<uint8_t>& cellTypes = vtkCells_.cellTypes();
const labelList& vertLabels = vtkCells_.vertLabels();
os_ << "CELLS " << vtkCells_.nFieldCells() << ' '
<< vertLabels.size() << nl;
foamVtkOutput::writeList(format(), vertLabels);
format().flush();
os_ << "CELL_TYPES " << cellTypes.size() << nl;
// No nComponents for char, so cannot use foamVtkOutput::writeList
forAll(cellTypes, i)
{
format().write(cellTypes[i]);
}
format().flush();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::internalWriter::beginCellData(label nFields)
{
foamVtkOutput::legacy::cellDataHeader
(
os(),
vtkCells_.nFieldCells(),
nFields
);
}
void Foam::foamVtkOutput::internalWriter::endCellData()
{}
void Foam::foamVtkOutput::internalWriter::beginPointData(label nFields)
{
foamVtkOutput::legacy::pointDataHeader
(
os(),
vtkCells_.nFieldPoints(),
nFields
);
}
void Foam::foamVtkOutput::internalWriter::endPointData()
{}
void Foam::foamVtkOutput::internalWriter::writeCellIDs()
{
const labelList& cellMap = vtkCells_.cellMap();
// Cell ids first
os_ << "cellID 1 " << vtkCells_.nFieldCells() << " int" << nl;
foamVtkOutput::writeList(format(), cellMap);
format().flush();
}
// ************************************************************************* //

View File

@ -0,0 +1,191 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 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 <http://www.gnu.org/licenses/>.
Class
Foam::foamVtkOutput::internalWriter
Description
Write fields (internal).
SourceFiles
foamVtkInternalWriter.C
foamVtkInternalWriterTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef foamVtkInternalWriter_H
#define foamVtkInternalWriter_H
#include "OFstream.H"
#include "volFields.H"
#include "pointFields.H"
#include "foamVtkCells.H"
#include "foamVtkOutputFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class volPointInterpolation;
namespace foamVtkOutput
{
/*---------------------------------------------------------------------------*\
Class internalWriter Declaration
\*---------------------------------------------------------------------------*/
class internalWriter
{
// Private Member Data
//- Reference to the OpenFOAM mesh (or subset)
const fvMesh& mesh_;
autoPtr<foamVtkOutput::formatter> format_;
//- The volume cells (internalMesh)
const foamVtkCells& vtkCells_;
std::ofstream os_;
public:
// Constructors
//- Construct from components
internalWriter
(
const fvMesh& mesh,
enum foamVtkOutput::formatType fmtType,
const foamVtkCells& cells,
const fileName& outputName
);
// Member Functions
inline std::ofstream& os()
{
return os_;
}
inline foamVtkOutput::formatter& format()
{
return format_();
}
//- Open write for CellData of count fields.
// The parameters are only used for the legacy format.
void beginCellData(label nFields);
//- Close write for CellData
void endCellData();
//- Open write for PointData of count fields
// The parameters are only used for the legacy format.
void beginPointData(label nFields);
//- Close write for PointData
void endPointData();
//- Write cellIDs
void writeCellIDs();
//- Write internal fields
template<class Type>
void write
(
const UPtrList
<
const DimensionedField<Type, volMesh>
>& flds
);
//- Write volFields
template<class Type, template<class> class PatchField>
void write
(
const UPtrList
<
const GeometricField<Type, PatchField, volMesh>
>& flds
);
//- Write pointFields on all mesh points.
// Interpolate to cell centre for decomposed cell centres.
template<class Type, template<class> class PatchField>
void write
(
const UPtrList
<
const GeometricField<Type, PatchField, pointMesh>
>& flds
);
//- Interpolated internal fields
template<class Type>
void write
(
const volPointInterpolation& pInterp,
const UPtrList
<
const DimensionedField<Type, volMesh>
>& flds
);
//- Interpolated volFields
template<class Type, template<class> class PatchField>
void write
(
const volPointInterpolation& pInterp,
const UPtrList
<
const GeometricField<Type, PatchField, volMesh>
>& flds
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "foamVtkInternalWriterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,195 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "foamVtkInternalWriter.H"
#include "foamVtkOutput.H"
#include "volPointInterpolation.H"
#include "interpolatePointToCell.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::foamVtkOutput::internalWriter::write
(
const UPtrList<const DimensionedField<Type, volMesh>>& flds
)
{
const int nCmpt(pTraits<Type>::nComponents);
const labelList& cellMap = vtkCells_.cellMap();
forAll(flds, i)
{
const auto& fld = flds[i];
// Legacy
os()<< fld.name() << ' '
<< nCmpt << ' '
<< cellMap.size() << " float"
<< nl;
// writeField includes payload size
foamVtkOutput::writeField(format(), fld, cellMap);
}
}
template<class Type, template<class> class PatchField>
void Foam::foamVtkOutput::internalWriter::write
(
const UPtrList<const GeometricField<Type, PatchField, volMesh>>& flds
)
{
const int nCmpt(pTraits<Type>::nComponents);
const labelList& cellMap = vtkCells_.cellMap();
forAll(flds, i)
{
const auto& fld = flds[i];
// Legacy
os()<< fld.name() << ' '
<< nCmpt << ' '
<< cellMap.size() << " float"
<< nl;
// writeField includes payload size
foamVtkOutput::writeField(format(), fld, cellMap);
}
}
template<class Type, template<class> class PatchField>
void Foam::foamVtkOutput::internalWriter::write
(
const UPtrList<const GeometricField<Type, PatchField, pointMesh>>& flds
)
{
const int nCmpt(pTraits<Type>::nComponents);
const int nVals(vtkCells_.nFieldPoints());
const labelList& addPointCellLabels = vtkCells_.addPointCellLabels();
// Only needed for non-legacy
const uint64_t payLoad
(
nVals * nCmpt * sizeof(float)
);
forAll(flds, i)
{
const auto& fld = flds[i];
// Legacy
os()<< fld.name() << ' '
<< nCmpt << ' '
<< nVals << " float"
<< nl;
format().writeSize(payLoad);
foamVtkOutput::writeList(format(), fld);
forAll(addPointCellLabels, i)
{
const Type val = interpolatePointToCell(fld, addPointCellLabels[i]);
foamVtkOutput::write(format(), val);
}
format().flush();
}
}
template<class Type>
void Foam::foamVtkOutput::internalWriter::write
(
const volPointInterpolation& pInterp,
const UPtrList<const DimensionedField<Type, volMesh>>& flds
)
{
const int nCmpt(pTraits<Type>::nComponents);
const int nVals(vtkCells_.nFieldPoints());
const labelList& addPointCellLabels = vtkCells_.addPointCellLabels();
// Only needed for non-legacy
const uint64_t payLoad
(
nVals * nCmpt * sizeof(float)
);
forAll(flds, i)
{
const auto& vfield = flds[i];
const auto& pfield = pInterp.interpolate(vfield)();
// Legacy
os()<< vfield.name() << ' '
<< nCmpt << ' '
<< nVals << " float"
<< nl;
format().writeSize(payLoad);
foamVtkOutput::writeList(format(), pfield);
foamVtkOutput::writeList(format(), vfield, addPointCellLabels);
format().flush();
}
}
template<class Type, template<class> class PatchField>
void Foam::foamVtkOutput::internalWriter::write
(
const volPointInterpolation& pInterp,
const UPtrList<const GeometricField<Type, PatchField, volMesh>>& flds
)
{
const int nCmpt(pTraits<Type>::nComponents);
const int nVals(vtkCells_.nFieldPoints());
const labelList& addPointCellLabels = vtkCells_.addPointCellLabels();
// Only needed for non-legacy
const uint64_t payLoad
(
nVals * nCmpt * sizeof(float)
);
forAll(flds, i)
{
const auto& vfield = flds[i];
const auto& pfield = pInterp.interpolate(vfield)();
// Legacy
os()<< vfield.name() << ' '
<< nCmpt << ' '
<< nVals << " float"
<< nl;
format().writeSize(payLoad);
foamVtkOutput::writeList(format(), pfield);
foamVtkOutput::writeList(format(), vfield, addPointCellLabels);
format().flush();
}
}
// ************************************************************************* //

View File

@ -25,7 +25,6 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::foamVtkOutput::writeField
(

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,12 +23,12 @@ License
\*---------------------------------------------------------------------------*/
#include "patchWriter.H"
#include "writeFuns.H"
#include "foamVtkPatchWriter.H"
#include "foamVtkOutput.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::patchWriter::patchWriter
Foam::foamVtkOutput::patchWriter::patchWriter
(
const fvMesh& mesh,
const bool binary,
@ -38,24 +38,34 @@ Foam::patchWriter::patchWriter
)
:
mesh_(mesh),
binary_(binary),
format_(),
nearCellValue_(nearCellValue),
fName_(fName),
patchIDs_(patchIDs),
os_(fName.c_str())
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Write header
if (patchIDs_.size() == 1)
{
writeFuns::writeHeader(os_, binary_, patches[patchIDs_[0]].name());
}
else
{
writeFuns::writeHeader(os_, binary_, "patches");
}
os_ << "DATASET POLYDATA" << std::endl;
format_ = foamVtkOutput::newFormatter
(
os_,
(
binary
? foamVtkOutput::LEGACY_BINARY
: foamVtkOutput::LEGACY_ASCII
)
);
foamVtkOutput::legacy::fileHeader
(
format(),
(
patchIDs_.size() == 1
? patches[patchIDs_.first()].name()
: "patches"
)
) << "DATASET POLYDATA" << nl;
//------------------------------------------------------------------
// Write topology
nPoints_ = 0;
@ -69,30 +79,26 @@ Foam::patchWriter::patchWriter
nPoints_ += pp.nPoints();
nFaces_ += pp.size();
nFaceVerts += pp.size();
forAll(pp, facei)
{
nFaceVerts += pp[facei].size() + 1;
nFaceVerts += pp[facei].size();
}
}
os_ << "POINTS " << nPoints_ << " float" << std::endl;
DynamicList<floatScalar> ptField(3*nPoints_);
os_ << "POINTS " << nPoints_ << " float" << nl;
forAll(patchIDs_, i)
{
const polyPatch& pp = patches[patchIDs_[i]];
writeFuns::insert(pp.localPoints(), ptField);
foamVtkOutput::writeList(format(), pp.localPoints());
}
writeFuns::write(os_, binary_, ptField);
format().flush();
os_ << "POLYGONS " << nFaces_ << ' ' << nFaceVerts << std::endl;
DynamicList<label> vertLabels(nFaceVerts);
label offset = 0;
os_ << "POLYGONS " << nFaces_ << ' ' << nFaceVerts << nl;
label off = 0;
forAll(patchIDs_, i)
{
const polyPatch& pp = patches[patchIDs_[i]];
@ -101,35 +107,57 @@ Foam::patchWriter::patchWriter
{
const face& f = pp.localFaces()[facei];
vertLabels.append(f.size());
writeFuns::insert(f + offset, vertLabels);
format().write(f.size());
forAll(f, fi)
{
format().write(off + f[fi]);
}
offset += pp.nPoints();
}
writeFuns::write(os_, binary_, vertLabels);
off += pp.nPoints();
}
format().flush();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::patchWriter::writePatchIDs()
void Foam::foamVtkOutput::patchWriter::beginCellData(label nFields)
{
DynamicList<floatScalar> fField(nFaces_);
foamVtkOutput::legacy::cellDataHeader(os(), nFaces_, nFields);
}
os_ << "patchID 1 " << nFaces_ << " float" << std::endl;
void Foam::foamVtkOutput::patchWriter::endCellData()
{}
void Foam::foamVtkOutput::patchWriter::beginPointData(label nFields)
{
foamVtkOutput::legacy::pointDataHeader(os(), nPoints_, nFields);
}
void Foam::foamVtkOutput::patchWriter::endPointData()
{}
void Foam::foamVtkOutput::patchWriter::writePatchIDs()
{
os_ << "patchID 1 " << nFaces_ << " float" << nl;
forAll(patchIDs_, i)
{
label patchi = patchIDs_[i];
const label patchId = patchIDs_[i];
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
const polyPatch& pp = mesh_.boundaryMesh()[patchId];
if (!isA<emptyPolyPatch>(pp))
forAll(pp, facei)
{
writeFuns::insert(scalarField(pp.size(), patchi), fField);
format().write(patchId);
}
}
writeFuns::write(os_, binary_, fField);
format().flush();
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -22,19 +22,19 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::patchWriter
Foam::foamVtkOutput::patchWriter
Description
Write patch fields
SourceFiles
patchWriter.C
patchWriterTemplates.C
foamVtkPatchWriter.C
foamVtkPatchWriterTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef patchWriter_H
#define patchWriter_H
#ifndef foamVtkPatchWriter_H
#define foamVtkPatchWriter_H
#include "pointMesh.H"
#include "OFstream.H"
@ -42,14 +42,17 @@ SourceFiles
#include "pointFields.H"
#include "indirectPrimitivePatch.H"
#include "PrimitivePatchInterpolation.H"
#include "foamVtkOutput.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class volPointInterpolation;
namespace foamVtkOutput
{
/*---------------------------------------------------------------------------*\
Class patchWriter Declaration
\*---------------------------------------------------------------------------*/
@ -59,12 +62,10 @@ class patchWriter
//- Reference to the OpenFOAM mesh (or subset)
const fvMesh& mesh_;
const bool binary_;
autoPtr<foamVtkOutput::formatter> format_;
const bool nearCellValue_;
const fileName fName_;
const labelList patchIDs_;
std::ofstream os_;
@ -80,69 +81,95 @@ public:
//- Construct from components
patchWriter
(
const fvMesh&,
const fvMesh& mesh,
const bool binary,
const bool nearCellValue,
const fileName&,
const fileName& fName,
const labelList& patchIDs
);
// Member Functions
std::ofstream& os()
inline std::ofstream& os()
{
return os_;
}
label nPoints() const
inline foamVtkOutput::formatter& format()
{
return format_();
}
inline label nPoints() const
{
return nPoints_;
}
label nFaces() const
inline label nFaces() const
{
return nFaces_;
}
//- Open write for CellData of count fields.
// The parameters are only used for the legacy format.
void beginCellData(label nFields);
//- Close write for CellData
void endCellData();
//- Open write for PointData of count fields
// The parameters are only used for the legacy format.
void beginPointData(label nFields);
//- Close write for PointData
void endPointData();
//- Write cellIDs
void writePatchIDs();
//- Write volFields
template<class Type>
void write
(
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>&
);
//- Write pointFields
template<class Type>
template<class Type, template<class> class PatchField>
void write
(
const UPtrList
<
const GeometricField<Type, pointPatchField, pointMesh>
const GeometricField<Type, PatchField, volMesh>
>& flds
);
//- Write pointFields
template<class Type, template<class> class PatchField>
void write
(
const UPtrList
<
const GeometricField<Type, PatchField, pointMesh>
>&
);
//- Interpolate and write volFields
//- Interpolated volFields
template<class Type>
void write
(
const PrimitivePatchInterpolation<primitivePatch>&,
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>&
const PrimitivePatchInterpolation<primitivePatch>& pInterp,
const UPtrList
<
const GeometricField<Type, fvPatchField, volMesh>
>& flds
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "patchWriterTemplates.C"
#include "foamVtkPatchWriterTemplates.C"
#endif

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,79 +23,71 @@ License
\*---------------------------------------------------------------------------*/
#include "patchWriter.H"
#include "writeFuns.H"
#include "foamVtkPatchWriter.H"
#include "foamVtkOutput.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::patchWriter::write
template<class Type, template<class> class PatchField>
void Foam::foamVtkOutput::patchWriter::write
(
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
const UPtrList<const GeometricField<Type, PatchField, volMesh>>& flds
)
{
forAll(flds, fieldi)
{
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi];
const auto& fld = flds[fieldi];
os_ << fld.name() << ' '
<< int(pTraits<Type>::nComponents) << ' '
<< nFaces_ << " float" << std::endl;
<< nFaces_ << " float" << nl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nFaces_);
forAll(patchIDs_, j)
forAll(patchIDs_, i)
{
label patchi = patchIDs_[j];
const fvPatchField<Type>& pfld = fld.boundaryField()[patchi];
const auto& pfld = fld.boundaryField()[patchIDs_[i]];
if (nearCellValue_)
{
writeFuns::insert(pfld.patchInternalField()(), fField);
foamVtkOutput::writeList(format(), pfld.patchInternalField()());
}
else
{
writeFuns::insert(pfld, fField);
foamVtkOutput::writeList(format(), pfld);
}
}
writeFuns::write(os_, binary_, fField);
format().flush();
}
}
template<class Type>
void Foam::patchWriter::write
template<class Type, template<class> class PatchField>
void Foam::foamVtkOutput::patchWriter::write
(
const UPtrList<const GeometricField<Type, pointPatchField, pointMesh>>& flds
const UPtrList<const GeometricField<Type, PatchField, pointMesh>>& flds
)
{
forAll(flds, fieldi)
{
const GeometricField<Type, pointPatchField, pointMesh>& fld =
flds[fieldi];
const auto& fld = flds[fieldi];
os_ << fld.name() << ' '
<< int(pTraits<Type>::nComponents) << ' '
<< nPoints_ << " float" << std::endl;
<< nPoints_ << " float" << nl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
forAll(patchIDs_, j)
forAll(patchIDs_, i)
{
label patchi = patchIDs_[j];
const auto& pfld = fld.boundaryField()[patchIDs_[i]];
const pointPatchField<Type>& pfld = fld.boundaryField()[patchi];
writeFuns::insert(pfld.patchInternalField()(), fField);
foamVtkOutput::writeList(format(), pfld.patchInternalField()());
}
writeFuns::write(os_, binary_, fField);
format().flush();
}
}
template<class Type>
void Foam::patchWriter::write
void Foam::foamVtkOutput::patchWriter::write
(
const PrimitivePatchInterpolation<primitivePatch>& pInter,
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
@ -103,41 +95,33 @@ void Foam::patchWriter::write
{
forAll(flds, fieldi)
{
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi];
const auto& fld = flds[fieldi];
os_ << fld.name() << ' '
<< int(pTraits<Type>::nComponents) << ' '
<< nPoints_ << " float" << std::endl;
<< nPoints_ << " float" << nl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
forAll(patchIDs_, j)
forAll(patchIDs_, i)
{
label patchi = patchIDs_[j];
const fvPatchField<Type>& pfld = fld.boundaryField()[patchi];
const auto& pfld = fld.boundaryField()[patchIDs_[i]];
if (nearCellValue_)
{
writeFuns::insert
(
pInter.faceToPointInterpolate
(
pfld.patchInternalField()()
)(),
fField
);
auto tfield =
pInter.faceToPointInterpolate(pfld.patchInternalField()());
foamVtkOutput::writeList(format(), tfield());
}
else
{
writeFuns::insert
(
pInter.faceToPointInterpolate(pfld)(),
fField
);
auto tfield = pInter.faceToPointInterpolate(pfld);
foamVtkOutput::writeList(format(), tfield());
}
}
writeFuns::write(os_, binary_, fField);
format().flush();
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,12 +23,12 @@ License
\*---------------------------------------------------------------------------*/
#include "surfaceMeshWriter.H"
#include "writeFuns.H"
#include "foamVtkSurfaceMeshWriter.H"
#include "foamVtkOutput.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceMeshWriter::surfaceMeshWriter
Foam::foamVtkOutput::surfaceMeshWriter::surfaceMeshWriter
(
const bool binary,
const indirectPrimitivePatch& pp,
@ -36,44 +36,61 @@ Foam::surfaceMeshWriter::surfaceMeshWriter
const fileName& fName
)
:
binary_(binary),
pp_(pp),
fName_(fName),
format_(),
os_(fName.c_str())
{
// Write header
writeFuns::writeHeader(os_, binary_, name);
format_ = foamVtkOutput::newFormatter
(
os_,
(
binary
? foamVtkOutput::LEGACY_BINARY
: foamVtkOutput::LEGACY_ASCII
)
);
os_ << "DATASET POLYDATA" << std::endl;
foamVtkOutput::legacy::fileHeader(format(), name)
<< "DATASET POLYDATA" << nl;
//------------------------------------------------------------------
// Write topology
label nFaceVerts = 0;
label nFaceVerts = pp.size();
forAll(pp, facei)
{
nFaceVerts += pp[facei].size() + 1;
nFaceVerts += pp[facei].size();
}
os_ << "POINTS " << pp.nPoints() << " float" << std::endl;
os_ << "POINTS " << pp.nPoints() << " float" << nl;
DynamicList<floatScalar> ptField(3*pp.nPoints());
writeFuns::insert(pp.localPoints(), ptField);
writeFuns::write(os_, binary, ptField);
foamVtkOutput::writeList(format(), pp.localPoints());
format().flush();
os_ << "POLYGONS " << pp.size() << ' ' << nFaceVerts << std::endl;
DynamicList<label> vertLabels(nFaceVerts);
os_ << "POLYGONS " << pp.size() << ' ' << nFaceVerts << nl;
forAll(pp, facei)
{
const face& f = pp.localFaces()[facei];
vertLabels.append(f.size());
writeFuns::insert(f, vertLabels);
format().write(f.size());
foamVtkOutput::writeList(format(), f);
}
writeFuns::write(os_, binary_, vertLabels);
format().flush();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::surfaceMeshWriter::beginCellData(label nFields)
{
foamVtkOutput::legacy::cellDataHeader(os(), pp_.size(), nFields);
}
void Foam::foamVtkOutput::surfaceMeshWriter::endCellData()
{}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -22,44 +22,45 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::surfaceMeshWriter
Foam::foamVtkOutput::surfaceMeshWriter
Description
Write faces with fields
SourceFiles
surfaceMeshWriter.C
surfaceMeshWriterTemplates.C
foamVtkSurfaceMeshWriter.C
foamVtkSurfaceMeshWriterTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef surfaceMeshWriter_H
#define surfaceMeshWriter_H
#ifndef foamVtkSurfaceMeshWriter_H
#define foamVtkSurfaceMeshWriter_H
#include "pointMesh.H"
#include "OFstream.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "indirectPrimitivePatch.H"
#include "foamVtkOutput.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class volPointInterpolation;
namespace foamVtkOutput
{
/*---------------------------------------------------------------------------*\
Class surfaceMeshWriter Declaration
\*---------------------------------------------------------------------------*/
class surfaceMeshWriter
{
const bool binary_;
const indirectPrimitivePatch& pp_;
const fileName fName_;
autoPtr<foamVtkOutput::formatter> format_;
std::ofstream os_;
@ -80,16 +81,26 @@ public:
// Member Functions
std::ofstream& os()
inline std::ofstream& os()
{
return os_;
}
inline foamVtkOutput::formatter& format()
{
return format_();
}
void beginCellData(label nFields);
void endCellData();
//- Extract face data
template<class Type>
tmp<Field<Type>> getFaceField
(
const GeometricField<Type, fvsPatchField, surfaceMesh>&
const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld
) const;
//- Write surfaceFields
@ -99,19 +110,20 @@ public:
const UPtrList
<
const GeometricField<Type, fvsPatchField, surfaceMesh>
>&
>& sflds
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "surfaceMeshWriterTemplates.C"
#include "foamVtkSurfaceMeshWriterTemplates.C"
#endif

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,14 +23,13 @@ License
\*---------------------------------------------------------------------------*/
#include "surfaceMeshWriter.H"
#include "writeFuns.H"
#include "foamVtkSurfaceMeshWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::surfaceMeshWriter::getFaceField
Foam::foamVtkOutput::surfaceMeshWriter::getFaceField
(
const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld
) const
@ -42,9 +41,8 @@ Foam::surfaceMeshWriter::getFaceField
forAll(pp_.addressing(), i)
{
label facei = pp_.addressing()[i];
label patchi = patches.whichPatch(facei);
const label facei = pp_.addressing()[i];
const label patchi = patches.whichPatch(facei);
if (patchi == -1)
{
@ -62,7 +60,7 @@ Foam::surfaceMeshWriter::getFaceField
template<class Type>
void Foam::surfaceMeshWriter::write
void Foam::foamVtkOutput::surfaceMeshWriter::write
(
const UPtrList
<
@ -79,9 +77,9 @@ void Foam::surfaceMeshWriter::write
<< int(pTraits<Type>::nComponents) << ' '
<< pp_.size() << " float" << std::endl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*pp_.size());
writeFuns::insert(getFaceField(fld)(), fField);
writeFuns::write(os_, binary_, fField);
foamVtkOutput::writeList(format(), getFaceField(fld)());
format().flush();
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,16 +23,16 @@ License
\*---------------------------------------------------------------------------*/
#include "writeSurfFields.H"
#include "foamVtkWriteSurfFields.H"
#include "OFstream.H"
#include "floatScalar.H"
#include "writeFuns.H"
#include "emptyFvsPatchFields.H"
#include "fvsPatchFields.H"
#include "surfaceFields.H"
#include "foamVtkOutput.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::writeSurfFields
void Foam::foamVtkOutput::writeSurfFields
(
const bool binary,
const fvMesh& mesh,
@ -40,72 +40,67 @@ void Foam::writeSurfFields
const UPtrList<const surfaceVectorField>& surfVectorFields
)
{
std::ofstream str(fileName.c_str());
std::ofstream os(fileName.c_str());
writeFuns::writeHeader
autoPtr<foamVtkOutput::formatter> format = foamVtkOutput::newFormatter
(
str,
binary,
"surfaceFields"
os,
(
binary
? foamVtkOutput::LEGACY_BINARY
: foamVtkOutput::LEGACY_ASCII
)
);
str << "DATASET POLYDATA" << std::endl;
foamVtkOutput::legacy::fileHeader(format(), "surfaceFields")
<< "DATASET POLYDATA" << nl;
const pointField& fc = mesh.faceCentres();
str << "POINTS " << mesh.nFaces() << " float" << std::endl;
os << "POINTS " << mesh.nFaces() << " float" << nl;
DynamicList<floatScalar> pField(3*mesh.nFaces());
foamVtkOutput::writeList(format(), fc);
format().flush();
for (label facei = 0; facei < mesh.nFaces(); facei++)
{
writeFuns::insert(fc[facei], pField);
}
foamVtkOutput::legacy::pointDataHeader
(
os,
mesh.nFaces(),
surfVectorFields.size()
);
writeFuns::write(str, binary, pField);
str << "POINT_DATA " << mesh.nFaces() << std::endl
<< "FIELD attributes " << surfVectorFields.size() << std::endl;
// surfVectorFields
forAll(surfVectorFields, fieldi)
{
const surfaceVectorField& svf = surfVectorFields[fieldi];
str << svf.name() << " 3 "
<< mesh.nFaces() << " float" << std::endl;
DynamicList<floatScalar> fField(3*mesh.nFaces());
for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
os << svf.name() << " 3 " << mesh.nFaces() << " float" << nl;
for (label facei=0; facei < mesh.nInternalFaces(); ++facei)
{
writeFuns::insert(svf[facei], fField);
foamVtkOutput::write(format(), svf[facei]);
}
forAll(svf.boundaryField(), patchi)
{
const fvsPatchVectorField& pf = svf.boundaryField()[patchi];
const fvPatch& pp = mesh.boundary()[patchi];
const fvsPatchVectorField& pf = svf.boundaryField()[patchi];
if (isA<emptyFvsPatchVectorField>(pf))
{
// Note: loop over polypatch size, not fvpatch size.
forAll(pp.patch(), i)
{
writeFuns::insert(vector::zero, fField);
foamVtkOutput::write(format(), vector::zero);
}
}
else
{
forAll(pf, i)
{
writeFuns::insert(pf[i], fField);
}
foamVtkOutput::writeList(format(), pf);
}
}
writeFuns::write(str, binary, fField);
format().flush();
}
}

View File

@ -21,19 +21,19 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
Foam::writeSurfFields
InNamespace
Foam::foamVtkOutput
Description
Write a patch with its data.
SourceFiles
writeSurfFields.C
foamVtkWriteSurfFields.C
\*---------------------------------------------------------------------------*/
#ifndef writeSurfFields_H
#define writeSurfFields_H
#ifndef foamVtkWriteSurfFields_H
#define foamVtkWriteSurfFields_H
#include "fvMesh.H"
#include "surfaceMesh.H"
@ -43,16 +43,19 @@ SourceFiles
namespace Foam
{
namespace foamVtkOutput
{
// Write surface vector fields
//- Write surface vector fields
void writeSurfFields
(
const bool binary,
const fvMesh&,
const fvMesh& mesh,
const fileName& fileName,
const UPtrList<const surfaceVectorField>& surfVectorFields
);
} // End namespace foamVtkOutput
} // End namespace Foam

View File

@ -2,6 +2,7 @@ abort/abort.C
codedFunctionObject/codedFunctionObject.C
ensightWrite/ensightWrite.C
writeVTK/writeVTK.C
removeRegisteredObject/removeRegisteredObject.C

View File

@ -26,8 +26,7 @@ License
#include "writeVTK.H"
#include "dictionary.H"
#include "Time.H"
#include "vtkMesh.H"
#include "internalWriter.H"
#include "foamVtkInternalWriter.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -107,7 +106,7 @@ bool Foam::functionObjects::writeVTK::write()
}
// Create file and write header
fileName vtkFileName
fileName outputName
(
fvPath/vtkName
+ "_"
@ -115,12 +114,24 @@ bool Foam::functionObjects::writeVTK::write()
+ ".vtk"
);
Info<< " Internal : " << vtkFileName << endl;
Info<< " Internal : " << outputName << endl;
vtkMesh vMesh(const_cast<fvMesh&>(mesh_));
foamVtkCells foamVtkMeshCells
(
mesh_,
foamVtkCells::contentType::LEGACY,
true // decompose
);
// Write mesh
internalWriter writer(vMesh, false, vtkFileName);
foamVtkOutput::internalWriter writer
(
mesh_,
foamVtkOutput::LEGACY_ASCII,
foamVtkMeshCells,
outputName
);
UPtrList<const volScalarField> vsf(lookupFields<volScalarField>());
UPtrList<const volVectorField> vvf(lookupFields<volVectorField>());
@ -131,13 +142,12 @@ bool Foam::functionObjects::writeVTK::write()
UPtrList<const volSymmTensorField> vstf(lookupFields<volSymmTensorField>());
UPtrList<const volTensorField> vtf(lookupFields<volTensorField>());
// Write header for cellID and volFields
writeFuns::writeCellDataHeader
(
writer.os(),
vMesh.nFieldCells(),
1 + vsf.size() + vvf.size() + vsptf.size() + vstf.size() + vtf.size()
);
const label nVolFields =
vsf.size() + vvf.size() + vsptf.size() + vstf.size() + vtf.size();
// CellData
{
writer.beginCellData(1 + nVolFields);
// Write cellID field
writer.writeCellIDs();
@ -148,6 +158,7 @@ bool Foam::functionObjects::writeVTK::write()
writer.write(vsptf);
writer.write(vstf);
writer.write(vtf);
}
return true;
}

View File

@ -28,10 +28,9 @@ Group
grpUtilitiesFunctionObjects
Description
This functionObject writes objects registered to the database in VTK format
using the foamToVTK library.
This functionObject writes objects registered to the database in VTK format.
Currently only the writing of the cell-values of volFields is supported but
Currently only supports writing of the cell-values of volFields but
support for other field types, patch fields, Lagrangian data etc. will be
added.
@ -49,7 +48,7 @@ Description
Usage
\table
Property | Description | Required | Default value
type | type name: writeVTK | yes |
type | Type name: writeVTK | yes |
objectNames | objects to write | yes |
\endtable
@ -108,7 +107,6 @@ class writeVTK
//- Names of objects
wordReList objectNames_;
//- Result name
word resultName_;
@ -121,10 +119,10 @@ class writeVTK
UPtrList<const GeoField> lookupFields() const;
//- Disallow default bitwise copy construct
writeVTK(const writeVTK&);
writeVTK(const writeVTK&) = delete;
//- Disallow default bitwise assignment
void operator=(const writeVTK&);
void operator=(const writeVTK&) = delete;
public:
@ -140,7 +138,7 @@ public:
(
const word& name,
const Time& t,
const dictionary&
const dictionary& dict
);
@ -151,7 +149,7 @@ public:
// Member Functions
//- Read the writeVTK data
virtual bool read(const dictionary&);
virtual bool read(const dictionary& dict);
//- Execute, currently does nothing
virtual bool execute();