Commit cde12ad9 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: consolidate vtk classes into 'Foam::vtk' namespace

- elminate the foamVtkFormatter operator() in favour of xmlAttr.
  Improves readability and the purpose is clearer.
parent edc1bd22
......@@ -82,33 +82,33 @@ void writeVTK
if (isA<faceSet>(currentSet))
{
// Faces of set with OpenFOAM faceID as value
foamVtkOutput::writeFaceSet
vtk::writeFaceSet
(
mesh,
currentSet,
mesh.time().path()/vtkBaseName,
foamVtkOutput::formatType::LEGACY_BINARY
vtk::formatType::LEGACY_BINARY
);
}
else if (isA<cellSet>(currentSet))
{
// External faces of cellset with OpenFOAM cellID as value
foamVtkOutput::writeCellSetFaces
vtk::writeCellSetFaces
(
mesh,
currentSet,
mesh.time().path()/vtkBaseName,
foamVtkOutput::formatType::LEGACY_BINARY
vtk::formatType::LEGACY_BINARY
);
}
else if (isA<pointSet>(currentSet))
{
foamVtkOutput::writePointSet
vtk::writePointSet
(
mesh,
currentSet,
mesh.time().path()/vtkBaseName,
foamVtkOutput::formatType::LEGACY_BINARY
vtk::formatType::LEGACY_BINARY
);
}
else
......
......@@ -242,9 +242,9 @@ labelList getSelectedPatches
// Process args for output options
// Default from foamVtkOutputOptions is inline ASCII xml
//
foamVtkOutput::outputOptions getOutputOptions(const argList& args)
vtk::outputOptions getOutputOptions(const argList& args)
{
foamVtkOutput::outputOptions opts;
vtk::outputOptions opts;
if (args.optionFound("xml"))
{
......@@ -421,7 +421,7 @@ int main(int argc, char *argv[])
const bool noLagrangian = args.optionFound("noLagrangian");
const bool nearCellValue = args.optionFound("nearCellValue");
const foamVtkOutput::outputOptions fmtType = getOutputOptions(args);
const vtk::outputOptions fmtType = getOutputOptions(args);
if (nearCellValue)
{
......@@ -515,7 +515,7 @@ int main(int argc, char *argv[])
meshSubsetHelper meshRef(mesh, meshSubsetHelper::SET, cellSetName);
// Collect decomposition information etc.
foamVtkCells foamVtkMeshCells(fmtType, decomposePoly);
vtk::vtuCells vtuMeshCells(fmtType, decomposePoly);
Info<< "VTK mesh topology: "
<< timer.cpuTimeIncrement() << " s, "
......@@ -544,7 +544,7 @@ int main(int argc, char *argv[])
)
{
// Trigger change for vtk cells too
foamVtkMeshCells.clear();
vtuMeshCells.clear();
}
// If faceSet: write faceSet only (as polydata)
......@@ -565,7 +565,7 @@ int main(int argc, char *argv[])
Info<< " faceSet : "
<< relativeName(runTime, outputName) << nl;
foamVtkOutput::writeFaceSet
vtk::writeFaceSet
(
meshRef.mesh(),
set,
......@@ -593,7 +593,7 @@ int main(int argc, char *argv[])
Info<< " pointSet : "
<< relativeName(runTime, outputName) << nl;
foamVtkOutput::writePointSet
vtk::writePointSet
(
meshRef.mesh(),
set,
......@@ -830,14 +830,14 @@ int main(int argc, char *argv[])
if (doWriteInternal)
{
if (foamVtkMeshCells.empty())
if (vtuMeshCells.empty())
{
foamVtkMeshCells.reset(meshRef.mesh());
vtuMeshCells.reset(meshRef.mesh());
// Convert cellMap, addPointCellLabels to global cell ids
if (meshRef.useSubMesh())
{
foamVtkMeshCells.renumberCells
vtuMeshCells.renumberCells
(
meshRef.subsetter().cellMap()
);
......@@ -855,10 +855,10 @@ int main(int argc, char *argv[])
<< relativeName(runTime, outputName) << endl;
// Write mesh
foamVtkOutput::internalWriter writer
vtk::internalWriter writer
(
meshRef.baseMesh(),
foamVtkMeshCells,
vtuMeshCells,
outputName,
fmtType
);
......@@ -980,7 +980,7 @@ int main(int argc, char *argv[])
+ timeDesc
);
foamVtkOutput::writeSurfFields
vtk::writeSurfFields
(
meshRef.mesh(),
outputName,
......@@ -1013,7 +1013,7 @@ int main(int argc, char *argv[])
Info<< " Combined patches : "
<< relativeName(runTime, outputName) << nl;
foamVtkOutput::patchWriter writer
vtk::patchWriter writer
(
meshRef.mesh(),
outputName,
......@@ -1083,7 +1083,7 @@ int main(int argc, char *argv[])
Info<< " Patch : "
<< relativeName(runTime, outputName) << nl;
foamVtkOutput::patchWriter writer
vtk::patchWriter writer
(
meshRef.mesh(),
outputName,
......@@ -1194,7 +1194,7 @@ int main(int argc, char *argv[])
mesh.points()
);
foamVtkOutput::surfaceMeshWriter writer
vtk::surfaceMeshWriter writer
(
pp,
fz.name(),
......@@ -1281,7 +1281,7 @@ int main(int argc, char *argv[])
Info<< " tensors :";
print(Info, tensorNames);
foamVtkOutput::lagrangianWriter writer
vtk::lagrangianWriter writer
(
meshRef.mesh(),
cloudName,
......@@ -1314,7 +1314,7 @@ int main(int argc, char *argv[])
}
else
{
foamVtkOutput::lagrangianWriter writer
vtk::lagrangianWriter writer
(
meshRef.mesh(),
cloudName,
......
......@@ -29,30 +29,30 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::foamVtkOutput::lagrangianWriter::beginPiece()
void Foam::vtk::lagrangianWriter::beginPiece()
{
if (!legacy_)
{
if (useVerts_)
{
format()
.openTag(vtkFileTag::PIECE)
( "NumberOfPoints", nParcels_ )
( "NumberOfVerts", nParcels_ )
.openTag(vtk::fileTag::PIECE)
.xmlAttr(fileAttr::NUMBER_OF_POINTS, nParcels_)
.xmlAttr(fileAttr::NUMBER_OF_VERTS, nParcels_)
.closeTag();
}
else
{
format()
.openTag(vtkFileTag::PIECE)
( "NumberOfPoints", nParcels_ )
.openTag(vtk::fileTag::PIECE)
.xmlAttr(fileAttr::NUMBER_OF_POINTS, nParcels_)
.closeTag();
}
}
}
void Foam::foamVtkOutput::lagrangianWriter::writePoints()
void Foam::vtk::lagrangianWriter::writePoints()
{
Cloud<passiveParticle> parcels(mesh_, cloudName_, false);
nParcels_ = parcels.size();
......@@ -67,8 +67,8 @@ void Foam::foamVtkOutput::lagrangianWriter::writePoints()
{
beginPiece(); // Tricky - hide in here
format().tag(vtkFileTag::POINTS)
.openDataArray<float,3>(vtkFileTag::POINTS)
format().tag(vtk::fileTag::POINTS)
.openDataArray<float,3>(vtk::dataArrayAttr::POINTS)
.closeTag();
}
......@@ -78,7 +78,7 @@ void Foam::foamVtkOutput::lagrangianWriter::writePoints()
{
const point& pt = iter().position();
foamVtkOutput::write(format(), pt);
vtk::write(format(), pt);
}
format().flush();
......@@ -86,12 +86,12 @@ void Foam::foamVtkOutput::lagrangianWriter::writePoints()
{
format()
.endDataArray()
.endTag(vtkFileTag::POINTS);
.endTag(vtk::fileTag::POINTS);
}
}
void Foam::foamVtkOutput::lagrangianWriter::writeVertsLegacy()
void Foam::vtk::lagrangianWriter::writeVertsLegacy()
{
os_ << "VERTICES " << nParcels_ << ' ' << 2*nParcels_ << nl;
......@@ -107,9 +107,9 @@ void Foam::foamVtkOutput::lagrangianWriter::writeVertsLegacy()
}
void Foam::foamVtkOutput::lagrangianWriter::writeVerts()
void Foam::vtk::lagrangianWriter::writeVerts()
{
format().tag(vtkFileTag::VERTS);
format().tag(vtk::fileTag::VERTS);
// Same payload throughout
const uint64_t payLoad = (nParcels_ * sizeof(label));
......@@ -119,7 +119,7 @@ void Foam::foamVtkOutput::lagrangianWriter::writeVerts()
// = linear mapping onto points
//
{
format().openDataArray<label>("connectivity")
format().openDataArray<label>(vtk::dataArrayAttr::CONNECTIVITY)
.closeTag();
format().writeSize(payLoad);
......@@ -138,7 +138,7 @@ void Foam::foamVtkOutput::lagrangianWriter::writeVerts()
// = linear mapping onto points (with 1 offset)
//
{
format().openDataArray<label>("offsets")
format().openDataArray<label>(vtk::dataArrayAttr::OFFSETS)
.closeTag();
format().writeSize(payLoad);
......@@ -151,18 +151,18 @@ void Foam::foamVtkOutput::lagrangianWriter::writeVerts()
format().endDataArray();
}
format().endTag(vtkFileTag::VERTS);
format().endTag(vtk::fileTag::VERTS);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::lagrangianWriter::lagrangianWriter
Foam::vtk::lagrangianWriter::lagrangianWriter
(
const fvMesh& mesh,
const word& cloudName,
const fileName& baseName,
const foamVtkOutput::outputOptions outOpts,
const vtk::outputOptions outOpts,
const bool dummyCloud
)
:
......@@ -185,7 +185,7 @@ Foam::foamVtkOutput::lagrangianWriter::lagrangianWriter
if (legacy_)
{
legacy::fileHeader(format(), title, vtkFileTag::POLY_DATA);
legacy::fileHeader(format(), title, vtk::fileTag::POLY_DATA);
if (dummyCloud)
{
......@@ -204,7 +204,7 @@ Foam::foamVtkOutput::lagrangianWriter::lagrangianWriter
format()
.xmlHeader()
.xmlComment(title)
.beginVTKFile(vtkFileTag::POLY_DATA, "0.1");
.beginVTKFile(vtk::fileTag::POLY_DATA, "0.1");
if (dummyCloud)
{
......@@ -221,19 +221,19 @@ Foam::foamVtkOutput::lagrangianWriter::lagrangianWriter
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::lagrangianWriter::~lagrangianWriter()
Foam::vtk::lagrangianWriter::~lagrangianWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::lagrangianWriter::beginParcelData(label nFields)
void Foam::vtk::lagrangianWriter::beginParcelData(label nFields)
{
const vtkFileTag dataType =
const vtk::fileTag dataType =
(
useVerts_
? vtkFileTag::CELL_DATA
: vtkFileTag::POINT_DATA
? vtk::fileTag::CELL_DATA
: vtk::fileTag::POINT_DATA
);
if (legacy_)
......@@ -247,13 +247,13 @@ void Foam::foamVtkOutput::lagrangianWriter::beginParcelData(label nFields)
}
void Foam::foamVtkOutput::lagrangianWriter::endParcelData()
void Foam::vtk::lagrangianWriter::endParcelData()
{
const vtkFileTag dataType =
const vtk::fileTag dataType =
(
useVerts_
? vtkFileTag::CELL_DATA
: vtkFileTag::POINT_DATA
? vtk::fileTag::CELL_DATA
: vtk::fileTag::POINT_DATA
);
if (!legacy_)
......@@ -263,14 +263,14 @@ void Foam::foamVtkOutput::lagrangianWriter::endParcelData()
}
void Foam::foamVtkOutput::lagrangianWriter::writeFooter()
void Foam::vtk::lagrangianWriter::writeFooter()
{
if (!legacy_)
{
// slight cheat. </Piece> too
format().endTag(vtkFileTag::PIECE);
format().endTag(vtk::fileTag::PIECE);
format().endTag(vtkFileTag::POLY_DATA)
format().endTag(vtk::fileTag::POLY_DATA)
.endVTKFile();
}
}
......
......@@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::lagrangianWriter
Foam::vtk::lagrangianWriter
Description
Write fields (internal).
......@@ -48,7 +48,7 @@ namespace Foam
{
class volPointInterpolation;
namespace foamVtkOutput
namespace vtk
{
/*---------------------------------------------------------------------------*\
......@@ -68,7 +68,7 @@ class lagrangianWriter
//- Write lagrangian as cell data (verts) or point data?
const bool useVerts_;
autoPtr<foamVtkOutput::formatter> format_;
autoPtr<vtk::formatter> format_;
const word cloudName_;
......@@ -109,7 +109,7 @@ public:
const fvMesh& mesh,
const word& cloudName,
const fileName& baseName,
const foamVtkOutput::outputOptions outOpts,
const vtk::outputOptions outOpts,
const bool dummyCloud = false
);
......@@ -125,7 +125,7 @@ public:
return os_;
}
inline foamVtkOutput::formatter& format()
inline vtk::formatter& format()
{
return format_();
}
......@@ -149,7 +149,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput
} // End namespace vtk
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -29,7 +29,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::foamVtkOutput::lagrangianWriter::writeIOField
void Foam::vtk::lagrangianWriter::writeIOField
(
const wordList& objectNames
)
......@@ -94,7 +94,7 @@ void Foam::foamVtkOutput::lagrangianWriter::writeIOField
}
format().writeSize(payLoad);
foamVtkOutput::writeList(format(), fld);
vtk::writeList(format(), fld);
}
format().flush();
......
......@@ -119,7 +119,7 @@ vtkSmartPointer<vtkUnstructuredGrid> Foam::vtkPVFoam::volumeVTKMesh
printMemory();
}
foamVtuSizing sizing(mesh, decompPoly);
vtk::vtuSizing sizing(mesh, decompPoly);
auto cellTypes = vtkSmartPointer<vtkUnsignedCharArray>::New();
......@@ -141,28 +141,28 @@ vtkSmartPointer<vtkUnstructuredGrid> Foam::vtkPVFoam::volumeVTKMesh
(
cells,
sizing.nFieldCells(),
sizing.sizeInternal(foamVtuSizing::slotType::CELLS)
sizing.sizeInternal(vtk::vtuSizing::slotType::CELLS)
);
UList<vtkIdType> cellLocationsUL =
vtkUList
(
cellLocations,
sizing.sizeInternal(foamVtuSizing::slotType::CELLS_OFFSETS)
sizing.sizeInternal(vtk::vtuSizing::slotType::CELLS_OFFSETS)
);
UList<vtkIdType> facesUL =
vtkUList
(
faces,
sizing.sizeInternal(foamVtuSizing::slotType::FACES)
sizing.sizeInternal(vtk::vtuSizing::slotType::FACES)
);
UList<vtkIdType> faceLocationsUL =
vtkUList
(
faceLocations,
sizing.sizeInternal(foamVtuSizing::slotType::FACES_OFFSETS)
sizing.sizeInternal(vtk::vtuSizing::slotType::FACES_OFFSETS)
);
......
......@@ -29,8 +29,8 @@ vtk/output/foamVtkPatchWriter.H
vtk/output/foamVtkSurfaceMeshWriter.C
vtk/output/foamVtkWriteSurfFields.C
vtk/part/foamVtkCells.C
vtk/part/foamVtkMeshMaps.C
vtk/part/foamVtuCells.C
vtk/part/foamVtuSizing.C
LIB = $(FOAM_LIBBIN)/libconversion
......@@ -25,47 +25,46 @@ License
#include "foamVtkInternalWriter.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::foamVtkOutput::internalWriter::beginPiece()
void Foam::vtk::internalWriter::beginPiece()
{
if (!legacy_)
{
format()
.openTag(vtkFileTag::PIECE)
( "NumberOfPoints", vtkCells_.nFieldPoints() )
( "NumberOfCells", vtkCells_.nFieldCells() )
.openTag(vtk::fileTag::PIECE)
.xmlAttr(vtk::fileAttr::NUMBER_OF_POINTS, vtuCells_.nFieldPoints())
.xmlAttr(vtk::fileAttr::NUMBER_OF_CELLS, vtuCells_.nFieldCells())
.closeTag();
}
}
void Foam::foamVtkOutput::internalWriter::writePoints()
void Foam::vtk::internalWriter::writePoints()
{
// payload size
const uint64_t payLoad = (vtkCells_.nFieldPoints() * 3 * sizeof(float));
const uint64_t payLoad = (vtuCells_.nFieldPoints() * 3 * sizeof(float));
if (legacy_)
{
legacy::beginPoints(os_, vtkCells_.nFieldPoints());
legacy::beginPoints(os_, vtuCells_.nFieldPoints());
}
else
{
format()
.tag(vtkFileTag::POINTS)
.openDataArray<float,3>(vtkFileTag::POINTS)
.tag(vtk::fileTag::POINTS)
.openDataArray<float,3>(vtk::dataArrayAttr::POINTS)
.closeTag();
}
format().writeSize(payLoad);
foamVtkOutput::writeList(format(), mesh_.points());
foamVtkOutput::writeList
vtk::writeList(format(), mesh_.points());
vtk::writeList
(
format(),
mesh_.cellCentres(),
vtkCells_.addPointCellLabels()
vtuCells_.addPointCellLabels()
);
format().flush();
......@@ -74,25 +73,25 @@ void Foam::foamVtkOutput::internalWriter::writePoints()
{
format()
.endDataArray()
.endTag(vtkFileTag::POINTS);
.endTag(vtk::fileTag::POINTS);
}
}
void Foam::foamVtkOutput::internalWriter::writeCellsLegacy()
void Foam::vtk::internalWriter::writeCellsLegacy()
{
const List<uint8_t>& cellTypes = vtkCells_.cellTypes();
const labelList& vertLabels = vtkCells_.vertLabels();
const List<uint8_t>& cellTypes = vtuCells_.cellTypes();
const labelList& vertLabels = vtuCells_.vertLabels();
os_ << "CELLS " << vtkCells_.nFieldCells() << ' '
os_ << "CELLS " << vtuCells_.nFieldCells() << ' '
<< vertLabels.size() << nl;
foamVtkOutput::writeList(format(), vertLabels);
vtk::writeList(format(), vertLabels);
format().flush();
os_ << "CELL_TYPES " << cellTypes.size() << nl;
// No nComponents for char, so cannot use foamVtkOutput::writeList
// No nComponents for char, so cannot use vtk::writeList
forAll(cellTypes, i)
{
format().write(cellTypes[i]);
......@@ -101,22 +100,22 @@ void Foam::foamVtkOutput::internalWriter::writeCellsLegacy()