STYLE: code cleanup in fileFormats, conversion

This commit is contained in:
Mark Olesen
2018-07-24 16:12:32 +02:00
parent 4a3bb8a9bc
commit 3963cd95d9
34 changed files with 229 additions and 308 deletions

View File

@ -131,11 +131,8 @@ void Foam::ensightMesh::correct()
wordList patchNames = mesh_.boundaryMesh().names(); wordList patchNames = mesh_.boundaryMesh().names();
if (Pstream::parRun()) if (Pstream::parRun())
{ {
patchNames.setSize // Do not include processor patches in matching
( patchNames.setSize(mesh_.boundaryMesh().nNonProcessor());
mesh_.boundary().size()
- mesh_.globalData().processorPatches().size()
);
} }
labelList matched; labelList matched;
@ -158,9 +155,8 @@ void Foam::ensightMesh::correct()
matched = identity(patchNames.size()); matched = identity(patchNames.size());
} }
forAll(matched, matchi) for (const label patchId : matched)
{ {
const label patchId = matched[matchi];
const word& patchName = patchNames[patchId]; const word& patchName = patchNames[patchId];
// use fvPatch (not polyPatch) to automatically remove empty patches // use fvPatch (not polyPatch) to automatically remove empty patches
@ -224,9 +220,8 @@ void Foam::ensightMesh::correct()
// Mark boundary faces to be excluded from export // Mark boundary faces to be excluded from export
bitSet excludeFace(mesh_.nFaces()); // all false bitSet excludeFace(mesh_.nFaces()); // all false
forAll(mesh_.boundaryMesh(), patchi) for (const polyPatch& pp : mesh_.boundaryMesh())
{ {
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
if if
( (
isA<processorPolyPatch>(pp) isA<processorPolyPatch>(pp)
@ -250,9 +245,8 @@ void Foam::ensightMesh::correct()
Foam::sort(selectZones); Foam::sort(selectZones);
// Count face types in each selected faceZone // Count face types in each selected faceZone
forAll(selectZones, zonei) for (const word& zoneName : selectZones)
{ {
const word& zoneName = selectZones[zonei];
const label zoneID = mesh_.faceZones().findZoneID(zoneName); const label zoneID = mesh_.faceZones().findZoneID(zoneName);
const faceZone& fz = mesh_.faceZones()[zoneID]; const faceZone& fz = mesh_.faceZones()[zoneID];
@ -318,9 +312,8 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
// use sortedToc for extra safety // use sortedToc for extra safety
// //
const labelList patchIds = patchLookup_.sortedToc(); const labelList patchIds = patchLookup_.sortedToc();
forAll(patchIds, listi) for (const label patchId : patchIds)
{ {
const label patchId = patchIds[listi];
const word& patchName = patchLookup_[patchId]; const word& patchName = patchLookup_[patchId];
const ensightFaces& ensFaces = boundaryPatchFaces_[patchName]; const ensightFaces& ensFaces = boundaryPatchFaces_[patchName];
@ -341,9 +334,9 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
// Renumber the patch faces, // Renumber the patch faces,
// from local patch indexing to unique global index // from local patch indexing to unique global index
faceList patchFaces(pp.localFaces()); faceList patchFaces(pp.localFaces());
forAll(patchFaces, i) for (face& f : patchFaces)
{ {
inplaceRenumber(pointToGlobal, patchFaces[i]); inplaceRenumber(pointToGlobal, f);
} }
writeAllPoints writeAllPoints
@ -363,9 +356,8 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
// write faceZones, if requested // write faceZones, if requested
// //
const wordList zoneNames = faceZoneFaces_.sortedToc(); const wordList zoneNames = faceZoneFaces_.sortedToc();
forAll(zoneNames, zonei) for (const word& zoneName : zoneNames)
{ {
const word& zoneName = zoneNames[zonei];
const ensightFaces& ensFaces = faceZoneFaces_[zoneName]; const ensightFaces& ensFaces = faceZoneFaces_[zoneName];
// Use the properly sorted faceIds (ensightFaces) and do NOT use the // Use the properly sorted faceIds (ensightFaces) and do NOT use the

View File

@ -98,14 +98,14 @@ private:
// Parallel merged points // Parallel merged points
//- Global numbering for merged points //- Global numbering for merged points
autoPtr<globalIndex> globalPointsPtr_; autoPtr<globalIndex> globalPointsPtr_;
//- From mesh point to global merged point //- From mesh point to global merged point
labelList pointToGlobal_; labelList pointToGlobal_;
//- Local points that are unique //- Local points that are unique
labelList uniquePointMap_; labelList uniquePointMap_;
// Private Member Functions // Private Member Functions
@ -117,122 +117,130 @@ private:
//- Inplace renumber of cell-shapes //- Inplace renumber of cell-shapes
static cellShapeList& renumberShapes static cellShapeList& renumberShapes
( (
cellShapeList&, cellShapeList& shapes,
const labelUList& pointToGlobal const labelUList& pointToGlobal
); );
static cellShapeList map static cellShapeList map
( (
const cellShapeList&, const cellShapeList& shapes,
const labelUList& prims, const labelUList& addr,
const labelUList& pointToGlobal const labelUList& pointToGlobal
); );
//- Write list of faces //- Write list of faces
static void writeFaceList static void writeFaceList
( (
const faceList&, const faceList& faces,
ensightGeoFile& ensightGeoFile& os
); );
//- Write list of faces //- Write list of faces
static void writeFaceList static void writeFaceList
( (
const UIndirectList<face>&, const UIndirectList<face>& faces,
ensightGeoFile& ensightGeoFile& os
); );
//- Write sizes of faces in the list //- Write sizes of faces in the list
static void writeFaceSizes static void writeFaceSizes
( (
const faceList&, const faceList& faces,
ensightGeoFile& ensightGeoFile& os
); );
//- Write sizes of faces in the list //- Write sizes of faces in the list
static void writeFaceSizes static void writeFaceSizes
( (
const UIndirectList<face>&, const UIndirectList<face>& faces,
ensightGeoFile& ensightGeoFile& os
); );
//- Write cell connectivity via shell shapes //- Write cell connectivity via cell shapes
static void writeCellShapes static void writeCellShapes
( (
const cellShapeList&, const cellShapeList& shapes,
ensightGeoFile& ensightGeoFile& os
); );
//- Write the number of faces per poly element
void writePolysNFaces void writePolysNFaces
( (
const labelList& polys, const labelUList& polys,
const cellList& cellFaces, const cellList& cellFaces,
ensightGeoFile& ensightGeoFile& os
) const; ) const;
//- Write the number of points per poly element
void writePolysNPointsPerFace void writePolysNPointsPerFace
( (
const labelList& polys, const labelUList& polys,
const cellList& cellFaces, const cellList& cellFaces,
const faceList& faces, const faceList& faces,
ensightGeoFile& ensightGeoFile&
) const; ) const;
//- Write the point ids per poly element
void writePolysPoints void writePolysPoints
( (
const labelList& polys, const labelUList& addr,
const cellList& cellFaces, const cellList& cellFaces,
const faceList& faces, const faceList& faces,
const labelList& faceOwner, const labelList& faceOwner,
ensightGeoFile& ensightGeoFile&
) const; ) const;
//- Write the poly connectivity
void writePolysConnectivity void writePolysConnectivity
( (
const labelList& addr, const labelUList& polys,
const labelList& pointToGlobal, const labelList& pointToGlobal,
ensightGeoFile& ensightGeoFile&
) const; ) const;
//- Write the regular cell connectivity for all types
void writeCellConnectivity void writeCellConnectivity
( (
const ensightCells&, const ensightCells& ensCells,
const labelList& pointToGlobal, const labelList& pointToGlobal,
ensightGeoFile& ensightGeoFile& os
) const; ) const;
//- Write the regular cell connectivity for specified type
void writeCellConnectivity void writeCellConnectivity
( (
ensightCells::elemType elemType, ensightCells::elemType elemType,
const ensightCells&, const ensightCells& ensCells,
const labelList& pointToGlobal, const labelList& pointToGlobal,
ensightGeoFile& ensightGeoFile& os
) const; ) const;
//- Write the regular face connectivity for specified type and
//- and specified faces
void writeFaceConnectivity void writeFaceConnectivity
( (
ensightFaces::elemType elemType, ensightFaces::elemType elemType,
const label nTotal, const label nTotal,
const faceList& faceLst, const faceList& faces,
const labelList& addr, const labelUList& addr,
ensightGeoFile& ensightGeoFile&
) const; ) const;
//- Write the regular face connectivity for specified type
void writeFaceConnectivity void writeFaceConnectivity
( (
ensightFaces::elemType elemType, ensightFaces::elemType elemType,
const label nTotal, const label nTotal,
const faceList& faceLst, const faceList& faces,
ensightGeoFile& ensightGeoFile& os
) const; ) const;
void writeFaceConnectivity void writeFaceConnectivity
( (
const ensightFaces&, const ensightFaces& ensFaces,
const faceList& faceLst, const faceList& faces,
ensightGeoFile&, ensightGeoFile& os,
const bool raw = false const bool raw = false
) const; ) const;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -42,9 +42,9 @@ Foam::cellShapeList& Foam::ensightMesh::renumberShapes
const labelUList& pointToGlobal const labelUList& pointToGlobal
) )
{ {
forAll(shapes, i) for (cellShape& shape : shapes)
{ {
inplaceRenumber(pointToGlobal, shapes[i]); inplaceRenumber(pointToGlobal, shape);
} }
return shapes; return shapes;
@ -58,15 +58,15 @@ Foam::cellShapeList Foam::ensightMesh::map
const labelUList& pointToGlobal const labelUList& pointToGlobal
) )
{ {
cellShapeList lst(addr.size()); cellShapeList list(addr.size());
forAll(addr, i) forAll(addr, i)
{ {
lst[i] = shapes[addr[i]]; list[i] = shapes[addr[i]];
inplaceRenumber(pointToGlobal, lst[i]); inplaceRenumber(pointToGlobal, list[i]);
} }
return lst; return list;
} }
@ -76,13 +76,11 @@ void Foam::ensightMesh::writeFaceList
ensightGeoFile& os ensightGeoFile& os
) )
{ {
forAll(faceLst, i) for (const face& f : faceLst)
{ {
const face& f = faceLst[i]; for (const label labi : f)
forAll(f, fp)
{ {
os.write(f[fp] + 1); os.write(labi + 1);
} }
os.newline(); os.newline();
@ -96,13 +94,11 @@ void Foam::ensightMesh::writeFaceList
ensightGeoFile& os ensightGeoFile& os
) )
{ {
forAll(faceLst, i) for (const face& f : faceLst)
{ {
const face& f = faceLst[i]; for (const label labi : f)
forAll(f, fp)
{ {
os.write(f[fp] + 1); os.write(labi + 1);
} }
os.newline(); os.newline();
@ -116,10 +112,8 @@ void Foam::ensightMesh::writeFaceSizes
ensightGeoFile& os ensightGeoFile& os
) )
{ {
forAll(faceLst, i) for (const face& f : faceLst)
{ {
const face& f = faceLst[i];
os.write(f.size()); os.write(f.size());
os.newline(); os.newline();
} }
@ -132,10 +126,8 @@ void Foam::ensightMesh::writeFaceSizes
ensightGeoFile& os ensightGeoFile& os
) )
{ {
forAll(faceLst, i) for (const face& f : faceLst)
{ {
const face& f = faceLst[i];
os.write(f.size()); os.write(f.size());
os.newline(); os.newline();
} }
@ -148,17 +140,15 @@ void Foam::ensightMesh::writeCellShapes
ensightGeoFile& os ensightGeoFile& os
) )
{ {
forAll(shapes, i) for (const cellShape& cellPoints : shapes)
{ {
const cellShape& cellPoints = shapes[i];
// convert global -> local index // convert global -> local index
// (note: Ensight indices start with 1) // (note: Ensight indices start with 1)
// In ASCII, write one cell per line // In ASCII, write one cell per line
forAll(cellPoints, pointI) for (const label pointi : cellPoints)
{ {
os.write(cellPoints[pointI] + 1); os.write(pointi + 1);
} }
os.newline(); os.newline();
@ -170,15 +160,15 @@ void Foam::ensightMesh::writeCellShapes
void Foam::ensightMesh::writePolysNFaces void Foam::ensightMesh::writePolysNFaces
( (
const labelList& addr, const labelUList& addr,
const cellList& cellFaces, const cellList& cellFaces,
ensightGeoFile& os ensightGeoFile& os
) const ) const
{ {
// write the number of faces per element (1/line in ASCII) // Write the number of faces per element (1/line in ASCII)
forAll(addr, i) for (const label cellId : addr)
{ {
const labelUList& cf = cellFaces[addr[i]]; const labelUList& cf = cellFaces[cellId];
os.write(cf.size()); os.write(cf.size());
os.newline(); os.newline();
@ -188,20 +178,20 @@ void Foam::ensightMesh::writePolysNFaces
void Foam::ensightMesh::writePolysNPointsPerFace void Foam::ensightMesh::writePolysNPointsPerFace
( (
const labelList& addr, const labelUList& addr,
const cellList& cellFaces, const cellList& cellFaces,
const faceList& faces, const faceList& faces,
ensightGeoFile& os ensightGeoFile& os
) const ) const
{ {
// write the number of points per element face (1/line in ASCII) // Write the number of points per element face (1/line in ASCII)
forAll(addr, i) for (const label cellId : addr)
{ {
const labelUList& cf = cellFaces[addr[i]]; const labelUList& cf = cellFaces[cellId];
forAll(cf, facei) for (const label facei : cf)
{ {
os.write(faces[cf[facei]].size()); os.write(faces[facei].size());
os.newline(); os.newline();
} }
} }
@ -210,21 +200,19 @@ void Foam::ensightMesh::writePolysNPointsPerFace
void Foam::ensightMesh::writePolysPoints void Foam::ensightMesh::writePolysPoints
( (
const labelList& addr, const labelUList& addr,
const cellList& cellFaces, const cellList& cellFaces,
const faceList& faces, const faceList& faces,
const labelList& faceOwner, const labelList& faceOwner,
ensightGeoFile& os ensightGeoFile& os
) const ) const
{ {
forAll(addr, i) for (const label cellId : addr)
{ {
const label cellId = addr[i];
const labelUList& cf = cellFaces[cellId]; const labelUList& cf = cellFaces[cellId];
forAll(cf, facei) for (const label faceId : cf)
{ {
const label faceId = cf[facei];
const face& f = faces[faceId]; // face points (in global points) const face& f = faces[faceId]; // face points (in global points)
if (faceId < faceOwner.size() && faceOwner[faceId] != cellId) if (faceId < faceOwner.size() && faceOwner[faceId] != cellId)
@ -234,16 +222,16 @@ void Foam::ensightMesh::writePolysPoints
// as per face::reverseFace(), but without copying // as per face::reverseFace(), but without copying
os.write(f[0] + 1); os.write(f[0] + 1);
for (label ptI = f.size()-1; ptI > 0; --ptI) for (label pti = f.size()-1; pti > 0; --pti)
{ {
os.write(f[ptI] + 1); os.write(f[pti] + 1);
} }
} }
else else
{ {
forAll(f, ptI) for (const label labi : f)
{ {
os.write(f[ptI] + 1); os.write(labi + 1);
} }
} }
@ -255,7 +243,7 @@ void Foam::ensightMesh::writePolysPoints
void Foam::ensightMesh::writePolysConnectivity void Foam::ensightMesh::writePolysConnectivity
( (
const labelList& addr, const labelUList& addr,
const labelList& pointToGlobal, const labelList& pointToGlobal,
ensightGeoFile& os ensightGeoFile& os
) const ) const
@ -329,9 +317,9 @@ void Foam::ensightMesh::writePolysConnectivity
// Renumber faces to use global point numbers // Renumber faces to use global point numbers
faceList faces(mesh_.faces()); faceList faces(mesh_.faces());
forAll(faces, i) for (face& f : faces)
{ {
inplaceRenumber(pointToGlobal, faces[i]); inplaceRenumber(pointToGlobal, f);
} }
// List of points id for each face of the above list // List of points id for each face of the above list
@ -409,11 +397,14 @@ void Foam::ensightMesh::writeCellConnectivity
} }
else else
{ {
const cellShapeList shapes = map const cellShapeList shapes
( (
mesh_.cellShapes(), map
addr, (
pointToGlobal mesh_.cellShapes(),
addr,
pointToGlobal
)
); );
@ -454,7 +445,8 @@ void Foam::ensightMesh::writeCellConnectivity
{ {
for (label typei=0; typei < ensightCells::nTypes; ++typei) for (label typei=0; typei < ensightCells::nTypes; ++typei)
{ {
const ensightCells::elemType what = ensightCells::elemType(typei); const ensightCells::elemType what =
ensightCells::elemType(typei);
writeCellConnectivity(what, ensCells, pointToGlobal, os); writeCellConnectivity(what, ensCells, pointToGlobal, os);
} }
@ -489,9 +481,9 @@ void Foam::ensightMesh::writeFaceConnectivity
for (int slave=1; slave<Pstream::nProcs(); ++slave) for (int slave=1; slave<Pstream::nProcs(); ++slave)
{ {
IPstream fromSlave(Pstream::commsTypes::scheduled, slave); IPstream fromSlave(Pstream::commsTypes::scheduled, slave);
faceList received(fromSlave); faceList recv(fromSlave);
writeFaceSizes(received, os); writeFaceSizes(recv, os);
} }
} }
else else
@ -516,9 +508,9 @@ void Foam::ensightMesh::writeFaceConnectivity
for (int slave=1; slave<Pstream::nProcs(); ++slave) for (int slave=1; slave<Pstream::nProcs(); ++slave)
{ {
IPstream fromSlave(Pstream::commsTypes::scheduled, slave); IPstream fromSlave(Pstream::commsTypes::scheduled, slave);
faceList received(fromSlave); faceList recv(fromSlave);
writeFaceList(received, os); writeFaceList(recv, os);
} }
} }
else else
@ -541,7 +533,7 @@ void Foam::ensightMesh::writeFaceConnectivity
ensightFaces::elemType elemType, ensightFaces::elemType elemType,
const label nTotal, const label nTotal,
const faceList& faceLst, const faceList& faceLst,
const labelList& addr, const labelUList& addr,
ensightGeoFile& os ensightGeoFile& os
) const ) const
{ {
@ -621,12 +613,13 @@ void Foam::ensightMesh::writeFaceConnectivity
const bool raw const bool raw
) const ) const
{ {
if (raw) for (label typei=0; typei < ensightFaces::nTypes; ++typei)
{ {
for (label typei=0; typei < ensightFaces::nTypes; ++typei) const ensightFaces::elemType what =
{ ensightFaces::elemType(typei);
const ensightFaces::elemType what = ensightFaces::elemType(typei);
if (raw)
{
writeFaceConnectivity writeFaceConnectivity
( (
what, what,
@ -640,13 +633,8 @@ void Foam::ensightMesh::writeFaceConnectivity
os os
); );
} }
} else
else
{
for (label typei=0; typei < ensightFaces::nTypes; ++typei)
{ {
const ensightFaces::elemType what = ensightFaces::elemType(typei);
writeFaceConnectivity writeFaceConnectivity
( (
what, what,

View File

@ -25,7 +25,6 @@ License
#include "ensightMesh.H" #include "ensightMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightMesh::options::options(IOstream::streamFormat format) Foam::ensightMesh::options::options(IOstream::streamFormat format)

View File

@ -144,7 +144,9 @@ bool Foam::ensightOutput::writeFaceSubField
label start = 0; // start of sublist label start = 0; // start of sublist
for (label typei=0; typei < ensightFaces::nTypes; ++typei) for (label typei=0; typei < ensightFaces::nTypes; ++typei)
{ {
const ensightFaces::elemType what = ensightFaces::elemType(typei); const ensightFaces::elemType what =
ensightFaces::elemType(typei);
const label size = ensFaces.faceIds(what).size(); const label size = ensFaces.faceIds(what).size();
writeFieldContent writeFieldContent
@ -159,10 +161,8 @@ bool Foam::ensightOutput::writeFaceSubField
return true; return true;
} }
else
{ return false;
return false;
}
} }
@ -183,7 +183,8 @@ bool Foam::ensightOutput::writeCellField
for (label typei=0; typei < ensightCells::nTypes; ++typei) for (label typei=0; typei < ensightCells::nTypes; ++typei)
{ {
const ensightCells::elemType what = ensightCells::elemType(typei); const ensightCells::elemType what =
ensightCells::elemType(typei);
writeFieldContent writeFieldContent
( (
@ -195,10 +196,8 @@ bool Foam::ensightOutput::writeCellField
return true; return true;
} }
else
{ return false;
return false;
}
} }
@ -229,9 +228,8 @@ bool Foam::ensightOutput::writeField
// use sortedToc for extra safety // use sortedToc for extra safety
// //
const labelList patchIds = patchLookup.sortedToc(); const labelList patchIds = patchLookup.sortedToc();
forAll(patchIds, listi) for (const label patchId : patchIds)
{ {
const label patchId = patchIds[listi];
const word& patchName = patchLookup[patchId]; const word& patchName = patchLookup[patchId];
const ensightFaces& ensFaces = patchFaces[patchName]; const ensightFaces& ensFaces = patchFaces[patchName];
@ -293,9 +291,8 @@ bool Foam::ensightOutput::writeField
} }
} }
forAll(zoneNames, zonei) for (const word& zoneName : zoneNames)
{ {
const word& zoneName = zoneNames[zonei];
const ensightFaces& ensFaces = zoneFaces[zoneName]; const ensightFaces& ensFaces = zoneFaces[zoneName];
// field (local size) // field (local size)
@ -362,9 +359,8 @@ bool Foam::ensightOutput::ensightPointField
// use sortedToc for extra safety // use sortedToc for extra safety
// //
const labelList patchIds = patchLookup.sortedToc(); const labelList patchIds = patchLookup.sortedToc();
forAll(patchIds, listi) for (const label patchId : patchIds)
{ {
const label patchId = patchIds[listi];
const word& patchName = patchLookup[patchId]; const word& patchName = patchLookup[patchId];
const ensightFaces& ensFaces = patchFaces[patchName]; const ensightFaces& ensFaces = patchFaces[patchName];
@ -399,9 +395,8 @@ bool Foam::ensightOutput::ensightPointField
// write faceZones, if requested // write faceZones, if requested
// //
const wordList zoneNames = zoneFaces.sortedToc(); const wordList zoneNames = zoneFaces.sortedToc();
forAll(zoneNames, zonei) for (const word& zoneName : zoneNames)
{ {
const word& zoneName = zoneNames[zonei];
const ensightFaces& ensFaces = zoneFaces[zoneName]; const ensightFaces& ensFaces = zoneFaces[zoneName];
uindirectPrimitivePatch p uindirectPrimitivePatch p

View File

@ -115,7 +115,8 @@ bool Foam::ensightSerialOutput::writeField
for (label typei=0; typei < ensightCells::nTypes; ++typei) for (label typei=0; typei < ensightCells::nTypes; ++typei)
{ {
const ensightCells::elemType what = ensightCells::elemType(typei); const ensightCells::elemType what =
ensightCells::elemType(typei);
writeFieldContent writeFieldContent
( (

View File

@ -66,7 +66,8 @@ void Foam::ensightCase::initialize()
} }
else else
{ {
Info<<"Warning: re-using existing directory" << nl DetailInfo
<<"Warning: re-using existing directory" << nl
<< " " << ensightDir_ << endl; << " " << ensightDir_ << endl;
} }
} }

View File

@ -87,7 +87,7 @@ private:
//- Case name (with ".case" ending) //- Case name (with ".case" ending)
word caseName_; word caseName_;
//- Output stream //- Output stream (master only)
mutable OFstream* os_; mutable OFstream* os_;
//- Track state changes since last write //- Track state changes since last write

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -123,12 +123,6 @@ Foam::ensightFile::ensightFile
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightFile::~ensightFile()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::ensightFile::allowUndef() bool Foam::ensightFile::allowUndef()
@ -137,10 +131,10 @@ bool Foam::ensightFile::allowUndef()
} }
bool Foam::ensightFile::allowUndef(bool value) bool Foam::ensightFile::allowUndef(bool enabled)
{ {
bool old = allowUndef_; bool old = allowUndef_;
allowUndef_ = value; allowUndef_ = enabled;
return old; return old;
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -112,7 +112,7 @@ public:
//- Destructor //- Destructor
~ensightFile(); ~ensightFile() = default;
// Access // Access
@ -136,12 +136,13 @@ public:
// Edit // Edit
static bool allowUndef(bool); //- Enable/disable use of \c undef keyword and value
static bool allowUndef(bool enabled);
//- Assign the value to represent undef in the results //- Assign the value to represent undef in the results
// Returns the previous value // Returns the previous value
// NB: do not use values larger than floatScalarVGREAT // NB: do not use values larger than floatScalarVGREAT
static scalar undefValue(const scalar); static scalar undefValue(const scalar value);
// Output // Output
@ -150,10 +151,10 @@ public:
using Ostream::write; using Ostream::write;
//- Binary write //- Binary write
virtual Ostream& write(const char*, std::streamsize count); virtual Ostream& write(const char* buf, std::streamsize count);
//- Write element keyword with trailing newline, optionally with undef //- Write element keyword with trailing newline, optionally with undef
virtual Ostream& writeKeyword(const keyType&); virtual Ostream& writeKeyword(const keyType& key);
//- Write "C Binary" for binary files (eg, geometry/measured) //- Write "C Binary" for binary files (eg, geometry/measured)
Ostream& writeBinaryHeader(); Ostream& writeBinaryHeader();
@ -182,7 +183,7 @@ public:
// Convenience Output Methods // Convenience Output Methods
//- Begin a part (0-based index). //- Begin a part (0-based index internally).
void beginPart(const label index); void beginPart(const label index);
//- Begin a "particle coordinates" block (measured data) //- Begin a "particle coordinates" block (measured data)

View File

@ -80,17 +80,11 @@ Foam::ensightGeoFile::ensightGeoFile
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightGeoFile::~ensightGeoFile()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::Ostream& Foam::ensightGeoFile::writeKeyword(const keyType& key) Foam::Ostream& Foam::ensightGeoFile::writeKeyword(const keyType& key)
{ {
// ensure we get ensightFile::write(const string&) // Ensure we get ensightFile::write(const string&)
write(static_cast<const string&>(key)); write(static_cast<const string&>(key));
newline(); newline();

View File

@ -91,7 +91,7 @@ public:
//- Destructor //- Destructor
~ensightGeoFile(); ~ensightGeoFile() = default;
// Output // Output
@ -102,6 +102,7 @@ public:
// Convenience Output Methods // Convenience Output Methods
//- Begin a part (0-based index).
using ensightFile::beginPart; using ensightFile::beginPart;
//- Begin a "part" (0-based index), with a description. //- Begin a "part" (0-based index), with a description.

View File

@ -65,25 +65,25 @@ public:
// Constructors // Constructors
//- Construct as copy //- Copy construct
inline explicit FileName(const FileName&); inline FileName(const FileName& fn);
//- Construct as copy of character array //- Construct as copy of character array
inline explicit FileName(const char*); inline explicit FileName(const char* s);
//- Construct as copy of std::string //- Construct as copy of std::string
inline explicit FileName(const std::string&); inline explicit FileName(const std::string& s);
// Member functions // Member functions
//- Is this character valid for an ensight file-name //- Is this character valid for an ensight file-name
inline static bool valid(char); inline static bool valid(char c);
// Member operators // Member Operators
// Assignment (disabled) // Assignment (disabled)
void operator=(const fileName&) = delete; void operator=(const fileName&) = delete;
void operator=(const word&) = delete; void operator=(const word&) = delete;

View File

@ -67,25 +67,26 @@ public:
// Constructors // Constructors
//- Construct as copy //- Copy construct
inline explicit VarName(const VarName&); inline VarName(const VarName& vn);
//- Construct as copy of character array //- Construct as copy of character array
inline explicit VarName(const char*); inline explicit VarName(const char* s);
//- Construct as copy of std::string //- Construct as copy of std::string
inline explicit VarName(const std::string&); inline explicit VarName(const std::string& s);
// Member functions // Member Functions
//- Is this character valid for an ensight var-name //- Is this character valid for an ensight var-name
inline static bool valid(char); inline static bool valid(char c);
// Member operators // Member Operators
// Assignment (disabled)
// Assignment (disabled)
void operator=(const word&) = delete; void operator=(const word&) = delete;
void operator=(const string&) = delete; void operator=(const string&) = delete;
void operator=(const std::string&) = delete; void operator=(const std::string&) = delete;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -30,8 +30,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::label Foam::ensightCells::nTypes = 5;
const char* Foam::ensightCells::elemNames[5] = const char* Foam::ensightCells::elemNames[5] =
{ "tetra4", "pyramid5", "penta6", "hexa8", "nfaced" }; { "tetra4", "pyramid5", "penta6", "hexa8", "nfaced" };
@ -62,6 +60,12 @@ void Foam::ensightCells::resizeAll()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightCells::ensightCells()
:
ensightCells(0)
{}
Foam::ensightCells::ensightCells(const label partIndex) Foam::ensightCells::ensightCells(const label partIndex)
: :
index_(partIndex), index_(partIndex),
@ -93,12 +97,6 @@ Foam::ensightCells::ensightCells(const ensightCells& obj)
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightCells::~ensightCells()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::FixedList<Foam::label, 5> Foam::ensightCells::sizes() const Foam::FixedList<Foam::label, 5> Foam::ensightCells::sizes() const

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -41,6 +41,7 @@ Description
namespace Foam namespace Foam
{ {
// Forward declarations
class polyMesh; class polyMesh;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -64,7 +65,7 @@ public:
}; };
//- Number of element types (5) //- Number of element types (5)
static const label nTypes; static constexpr label nTypes = 5;
//- The ensight element type names //- The ensight element type names
static const char* elemNames[5]; static const char* elemNames[5];
@ -108,15 +109,18 @@ public:
// Constructors // Constructors
//- Construct null, optionally with index //- Construct null, with part index 0
ensightCells(label partIndex = 0); ensightCells();
//- Construct null, with specified part index
explicit ensightCells(const label partIndex);
//- Copy constructor. Needed for lists etc. //- Copy constructor. Needed for lists etc.
ensightCells(const ensightCells& obj); ensightCells(const ensightCells& obj);
//- Destructor //- Destructor
~ensightCells(); ~ensightCells() = default;
// Member Functions // Member Functions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -30,8 +30,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::label Foam::ensightFaces::nTypes = 3;
const char* Foam::ensightFaces::elemNames[3] = const char* Foam::ensightFaces::elemNames[3] =
{ "tria3", "quad4", "nsided" }; { "tria3", "quad4", "nsided" };
@ -101,7 +99,13 @@ void Foam::ensightFaces::resizeAll()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightFaces::ensightFaces(label partIndex) Foam::ensightFaces::ensightFaces()
:
ensightFaces(0)
{}
Foam::ensightFaces::ensightFaces(const label partIndex)
: :
index_(partIndex), index_(partIndex),
address_(), address_(),
@ -134,12 +138,6 @@ Foam::ensightFaces::ensightFaces(const ensightFaces& obj)
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightFaces::~ensightFaces()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::FixedList<Foam::label, 3> Foam::ensightFaces::sizes() const Foam::FixedList<Foam::label, 3> Foam::ensightFaces::sizes() const

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -62,7 +62,7 @@ public:
}; };
//- Number of element types (3) //- Number of element types (3)
static const label nTypes; static constexpr label nTypes = 3;
//- The ensight element type names //- The ensight element type names
static const char* elemNames[3]; static const char* elemNames[3];
@ -115,15 +115,18 @@ public:
// Constructors // Constructors
//- Construct null, optionally with index //- Construct null, with part index 0
ensightFaces(label partIndex = 0); ensightFaces();
//- Construct null, with specified part index
explicit ensightFaces(const label partIndex);
//- Copy constructor. Needed for lists etc. //- Copy constructor. Needed for lists etc.
ensightFaces(const ensightFaces& obj); ensightFaces(const ensightFaces& obj);
//- Destructor //- Destructor
~ensightFaces(); ~ensightFaces() = default;
// Member Functions // Member Functions

View File

@ -37,12 +37,6 @@ Foam::ensightReadFile::ensightReadFile
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightReadFile::~ensightReadFile()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::Istream& Foam::ensightReadFile::read Foam::Istream& Foam::ensightReadFile::read

View File

@ -62,7 +62,7 @@ public:
// Constructors // Constructors
//- Construct from pathname //- Construct from pathname. Default format is binary.
ensightReadFile ensightReadFile
( (
const fileName& pathname, const fileName& pathname,
@ -71,7 +71,7 @@ public:
//- Destructor //- Destructor
~ensightReadFile(); ~ensightReadFile() = default;
// Output // Output

View File

@ -76,7 +76,7 @@ public:
appendBase64Formatter(std::ostream& os); appendBase64Formatter(std::ostream& os);
//- Destructor //- Destructor. Closes/flushes the underlying layer.
virtual ~appendBase64Formatter(); virtual ~appendBase64Formatter();

View File

@ -55,12 +55,6 @@ Foam::vtk::appendRawFormatter::appendRawFormatter(std::ostream& os)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtk::appendRawFormatter::~appendRawFormatter()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::vtk::outputOptions& const Foam::vtk::outputOptions&

View File

@ -85,7 +85,7 @@ public:
//- Destructor //- Destructor
virtual ~appendRawFormatter(); virtual ~appendRawFormatter() = default;
// Member Functions // Member Functions

View File

@ -90,7 +90,7 @@ public:
asciiFormatter(std::ostream& os, unsigned precision); asciiFormatter(std::ostream& os, unsigned precision);
//- Destructor //- Destructor. Finishes the output line as required.
virtual ~asciiFormatter(); virtual ~asciiFormatter();

View File

@ -74,7 +74,7 @@ public:
base64Formatter(std::ostream& os); base64Formatter(std::ostream& os);
//- Destructor //- Destructor. Closes/flushes the underlying layer.
virtual ~base64Formatter(); virtual ~base64Formatter();

View File

@ -80,7 +80,7 @@ protected:
public: public:
//- Destructor //- Destructor. Closes/flushes the underlying layer
virtual ~foamVtkBase64Layer(); virtual ~foamVtkBase64Layer();

View File

@ -55,12 +55,6 @@ Foam::vtk::legacyAsciiFormatter::legacyAsciiFormatter
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtk::legacyAsciiFormatter::~legacyAsciiFormatter()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::vtk::outputOptions& const Foam::vtk::outputOptions&

View File

@ -80,7 +80,7 @@ public:
//- Destructor //- Destructor
virtual ~legacyAsciiFormatter(); virtual ~legacyAsciiFormatter() = default;
// Member Functions // Member Functions

View File

@ -58,12 +58,6 @@ Foam::vtk::legacyRawFormatter::legacyRawFormatter
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::vtk::legacyRawFormatter::~legacyRawFormatter()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::vtk::outputOptions& const Foam::vtk::outputOptions&

View File

@ -87,7 +87,7 @@ public:
//- Destructor //- Destructor
virtual ~legacyRawFormatter(); virtual ~legacyRawFormatter() = default;
// Member Functions // Member Functions

View File

@ -92,7 +92,7 @@ public:
// Member Functions // Member Functions
// Access // Access
//- The output format type //- The output format type
inline formatType fmt() const; inline formatType fmt() const;
@ -116,7 +116,7 @@ public:
inline unsigned precision() const; inline unsigned precision() const;
// Edit // Edit
//- Toggle ASCII mode on/off. //- Toggle ASCII mode on/off.
// In XML append mode, this switches between base64 and raw binary. // In XML append mode, this switches between base64 and raw binary.

View File

@ -376,18 +376,10 @@ void Foam::vtkUnstructuredReader::readField
case VTK_ULONG: case VTK_ULONG:
case VTK_ID: case VTK_ID:
{ {
autoPtr<labelIOField> fieldVals auto fieldVals = autoPtr<labelIOField>::New
( (
new labelIOField IOobject(arrayName, "", obj),
( size
IOobject
(
arrayName,
"",
obj
),
size
)
); );
readBlock(inFile, fieldVals().size(), fieldVals()); readBlock(inFile, fieldVals().size(), fieldVals());
regIOobject::store(fieldVals); regIOobject::store(fieldVals);
@ -397,18 +389,10 @@ void Foam::vtkUnstructuredReader::readField
case VTK_FLOAT: case VTK_FLOAT:
case VTK_DOUBLE: case VTK_DOUBLE:
{ {
autoPtr<scalarIOField> fieldVals auto fieldVals = autoPtr<scalarIOField>::New
( (
new scalarIOField IOobject(arrayName, "", obj),
( size
IOobject
(
arrayName,
"",
obj
),
size
)
); );
readBlock(inFile, fieldVals().size(), fieldVals()); readBlock(inFile, fieldVals().size(), fieldVals());
regIOobject::store(fieldVals); regIOobject::store(fieldVals);
@ -421,18 +405,10 @@ void Foam::vtkUnstructuredReader::readField
{ {
Info<< "Reading strings:" << size << endl; Info<< "Reading strings:" << size << endl;
} }
autoPtr<stringIOList> fieldVals auto fieldVals = autoPtr<stringIOList>::New
( (
new stringIOList IOobject(arrayName, "", obj),
( size
IOobject
(
arrayName,
"",
obj
),
size
)
); );
// Consume current line. // Consume current line.
inFile.getLine(fieldVals()[0]); inFile.getLine(fieldVals()[0]);
@ -536,10 +512,8 @@ Foam::objectRegistry& Foam::vtkUnstructuredReader::selectRegistry
{ {
return pointData_; return pointData_;
} }
else
{ return otherData_;
return otherData_;
}
} }
@ -827,18 +801,10 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
objectRegistry::iterator iter = reg.find(dataName); objectRegistry::iterator iter = reg.find(dataName);
scalarField s(*dynamic_cast<const scalarField*>(iter())); scalarField s(*dynamic_cast<const scalarField*>(iter()));
reg.erase(iter); reg.erase(iter);
autoPtr<vectorIOField> fieldVals auto fieldVals = autoPtr<vectorIOField>::New
( (
new vectorIOField IOobject(dataName, "", reg),
( s.size()/3
IOobject
(
dataName,
"",
reg
),
s.size()/3
)
); );
label elemI = 0; label elemI = 0;

View File

@ -163,7 +163,7 @@ private:
( (
Istream& inFile, Istream& inFile,
const label n, const label n,
List<T>& lst List<T>& list
) const; ) const;
void warnUnhandledType void warnUnhandledType

View File

@ -37,13 +37,13 @@ void Foam::vtkUnstructuredReader::readBlock
( (
Istream& inFile, Istream& inFile,
const label n, const label n,
List<T>& lst List<T>& list
) const ) const
{ {
lst.setSize(n); list.setSize(n);
forAll(lst, i) forAll(list, i)
{ {
inFile >> lst[i]; inFile >> list[i];
} }
} }
@ -59,13 +59,14 @@ void Foam::vtkUnstructuredReader::printFieldStats
if (fieldNames.size()) if (fieldNames.size())
{ {
Info<< "Read " << fieldNames.size() << " " << Type::typeName Info<< "Read " << fieldNames.size() << " " << Type::typeName
<< " fields:" << endl; << " fields:" << nl
Info<< "Size\tName" << nl << "Size\tName" << nl
<< "----\t----" << endl; << "----\t----" << endl;
forAll(fieldNames, i)
for (const word& fieldName : fieldNames)
{ {
Info<< obj.lookupObject<Type>(fieldNames[i]).size() Info<< obj.lookupObject<Type>(fieldName).size()
<< "\t" << fieldNames[i] << "\t" << fieldName
<< endl; << endl;
} }
Info<< endl; Info<< endl;