GIT: relocate ensight components to library locations

This commit is contained in:
Mark Olesen
2016-10-05 13:13:12 +02:00
parent e57ca15bda
commit b04a6a05e5
9 changed files with 3 additions and 4 deletions

View File

@ -1,7 +1,3 @@
ensightMesh.C
ensightMeshIO.C
ensightMeshOptions.C
ensightOutputCloud.C
meshSubsetHelper.C

View File

@ -1,434 +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 "ensightMesh.H"
#include "fvMesh.H"
#include "globalMeshData.H"
#include "PstreamCombineReduceOps.H"
#include "processorPolyPatch.H"
#include "mapDistribute.H"
#include "stringListOps.H"
#include "ensightFile.H"
#include "ensightGeoFile.H"
#include "demandDrivenData.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::ensightMesh::clear()
{
meshCells_.clear();
boundaryPatchFaces_.clear();
faceZoneFaces_.clear();
patchLookup_.clear();
globalPointsPtr_.clear();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightMesh::ensightMesh
(
const fvMesh& mesh,
const ensightMesh::options& opts
)
:
options_(new options(opts)),
mesh_(mesh),
needsUpdate_(true)
{
if (!option().lazy())
{
correct();
}
}
Foam::ensightMesh::ensightMesh
(
const fvMesh& mesh,
const IOstream::streamFormat format
)
:
options_(new options(format)),
mesh_(mesh),
needsUpdate_(true)
{
if (!option().lazy())
{
correct();
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightMesh::~ensightMesh()
{
deleteDemandDrivenData(options_);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::ensightMesh::needsUpdate() const
{
return needsUpdate_;
}
bool Foam::ensightMesh::expire()
{
clear();
// already marked as expired
if (needsUpdate_)
{
return false;
}
needsUpdate_ = true;
return true;
}
void Foam::ensightMesh::correct()
{
clear();
// First see if patches are allowed/disallowed
// and if only particular patches should be selected
label nParts = 1; // provisionally (for internalMesh)
if (option().usePatches())
{
// Patches are output. Check that they are synced.
mesh_.boundaryMesh().checkParallelSync(true);
wordList patchNames = mesh_.boundaryMesh().names();
if (Pstream::parRun())
{
patchNames.setSize
(
mesh_.boundary().size()
- mesh_.globalData().processorPatches().size()
);
}
labelList matched;
bool useAll = true;
const wordReList& matcher = option().patchSelection();
if (notNull(matcher))
{
nParts = 0; // no internalMesh
if (!matcher.empty())
{
useAll = false;
matched = findMatchingStrings
(
wordReListMatcher(matcher),
patchNames
);
}
}
if (useAll)
{
matched = identity(patchNames.size());
}
forAll(matched, matchi)
{
const label patchId = matched[matchi];
const word& patchName = patchNames[patchId];
// use fvPatch (not polyPatch) to automatically remove empty patches
const fvPatch& p = mesh_.boundary()[patchId];
// yes we most likely want this patch.
// - can use insert or set, since hash was cleared before
boundaryPatchFaces_.set(patchName, ensightFaces());
ensightFaces& ensFaces = boundaryPatchFaces_[patchName];
if (p.size())
{
// use local face addressing (offset = 0),
// since this is what we'll need later when writing fields
ensFaces.classify(p.patch());
}
else
{
// patch is empty (on this processor)
// or the patch is 'empty' (as fvPatch type)
ensFaces.clear();
}
// finalize
ensFaces.reduce();
if (ensFaces.total())
{
patchLookup_.set(patchId, patchName);
ensFaces.index() = nParts++;
}
else
{
boundaryPatchFaces_.erase(patchName);
}
}
// At this point,
// * patchLookup_ is a map of (patchId, name)
// * boundaryPatchFaces_ is a lookup by name for the faces elements
}
if (useInternalMesh())
{
meshCells_.index() = 0;
meshCells_.classify(mesh_);
// Determine parallel shared points
globalPointsPtr_ = mesh_.globalData().mergePoints
(
pointToGlobal_,
uniquePointMap_
);
}
meshCells_.reduce();
// faceZones
if (option().useFaceZones())
{
// Mark boundary faces to be excluded from export
PackedBoolList excludeFace(mesh_.nFaces()); // all false
forAll(mesh_.boundaryMesh(), patchi)
{
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
if
(
isA<processorPolyPatch>(pp)
&& !refCast<const processorPolyPatch>(pp).owner()
)
{
label bFaceI = pp.start();
forAll(pp, i)
{
excludeFace.set(bFaceI++);
}
}
}
const wordReList& matcher = option().faceZoneSelection();
wordList selectZones = mesh_.faceZones().names();
inplaceSubsetMatchingStrings
(
wordReListMatcher(matcher),
selectZones
);
// have same order as later with sortedToc()
Foam::sort(selectZones);
// Count face types in each selected faceZone
forAll(selectZones, zoneI)
{
const word& zoneName = selectZones[zoneI];
const label zoneID = mesh_.faceZones().findZoneID(zoneName);
const faceZone& fz = mesh_.faceZones()[zoneID];
// yes we most likely want this zone
// - can use insert or set, since hash was cleared before
faceZoneFaces_.set(zoneName, ensightFaces());
ensightFaces& ensFaces = faceZoneFaces_[zoneName];
if (fz.size())
{
ensFaces.classify
(
mesh_.faces(),
fz,
fz.flipMap(),
excludeFace
);
}
// finalize
ensFaces.reduce();
if (ensFaces.total())
{
ensFaces.index() = nParts++;
}
else
{
faceZoneFaces_.erase(zoneName);
}
}
}
needsUpdate_ = false;
}
void Foam::ensightMesh::write(ensightGeoFile& os) const
{
if (useInternalMesh())
{
label nPoints = globalPoints().size();
const pointField uniquePoints(mesh_.points(), uniquePointMap_);
// writePartHeader(os, 0, "internalMesh");
// beginCoordinates(os, nPoints);
writeAllPoints
(
meshCells_.index(),
"internalMesh",
nPoints,
uniquePoints,
os
);
writeCellConnectivity(meshCells_, pointToGlobal_, os);
}
//
// write patches
// use sortedToc for extra safety
//
const labelList patchIds = patchLookup_.sortedToc();
forAll(patchIds, listi)
{
const label patchId = patchIds[listi];
const word& patchName = patchLookup_[patchId];
const ensightFaces& ensFaces = boundaryPatchFaces_[patchName];
const polyPatch& pp = mesh_.boundaryMesh()[patchId];
// Renumber the patch points/faces into unique points
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPointsPtr =
mesh_.globalData().mergePoints
(
pp.meshPoints(),
pp.meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels
);
pointField uniquePoints(mesh_.points(), uniqueMeshPointLabels);
// Renumber the patch faces
faceList patchFaces(pp.localFaces());
forAll(patchFaces, i)
{
inplaceRenumber(pointToGlobal, patchFaces[i]);
}
writeAllPoints
(
ensFaces.index(),
patchName,
globalPointsPtr().size(),
uniquePoints,
os
);
writeFaceConnectivity(ensFaces, patchFaces, os);
}
//
// write faceZones, if requested
//
const wordList zoneNames = faceZoneFaces_.sortedToc();
forAll(zoneNames, zonei)
{
const word& zoneName = zoneNames[zonei];
const ensightFaces& ensFaces = faceZoneFaces_[zoneName];
label zoneId = mesh_.faceZones().findZoneID(zoneName);
const faceZone& fz = mesh_.faceZones()[zoneId];
// Renumber the faceZone points/faces into unique points
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPointsPtr =
mesh_.globalData().mergePoints
(
fz().meshPoints(),
fz().meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels
);
pointField uniquePoints(mesh_.points(), uniqueMeshPointLabels);
primitiveFacePatch facePatch
(
faceList(mesh_.faces(), ensFaces.faceIds()),
mesh_.points()
);
const boolList& flip = ensFaces.flipMap();
forAll(facePatch[faceI], faceI)
{
if (flip[faceI])
{
facePatch[faceI].flip();
}
}
// Faces belonging to the faceZone, in local numbering
faceList localFaces(facePatch.localFaces());
// Renumber the faceZone master faces
forAll(localFaces, i)
{
inplaceRenumber(pointToGlobal, localFaces[i]);
}
writeAllPoints
(
ensFaces.index(),
zoneName,
globalPointsPtr().size(),
uniquePoints,
os
);
writeFaceConnectivity(ensFaces, localFaces, os, true);
}
}
// ************************************************************************* //

View File

@ -1,453 +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::ensightMesh
Description
Encapsulation of volume meshes for writing in ensight format.
SourceFiles
ensightMesh.C
ensightMeshIO.C
ensightMeshOptions.C
\*---------------------------------------------------------------------------*/
#ifndef ensightMesh_H
#define ensightMesh_H
#include "ensightCells.H"
#include "ensightFaces.H"
#include "ensightGeoFile.H"
#include "cellList.H"
#include "faceList.H"
#include "cellShapeList.H"
#include "HashTable.H"
#include "Map.H"
#include "scalarField.H"
#include "wordReList.H"
#include "globalIndex.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
class fvMesh;
class ensightMesh;
/*---------------------------------------------------------------------------*\
Class ensightMesh Declaration
\*---------------------------------------------------------------------------*/
class ensightMesh
{
public:
// Forward declarations
class options;
private:
// Private data
//- Writer options
const options* options_;
//- Reference to the OpenFOAM mesh
const fvMesh& mesh_;
//- The volume cells (internalMesh)
ensightCells meshCells_;
//- Face elements per patch
HashTable<ensightFaces> boundaryPatchFaces_;
//- Face elements per faceZone
HashTable<ensightFaces> faceZoneFaces_;
//- The list of patches to be output
Map<word> patchLookup_;
//- Track if it needs an update
mutable bool needsUpdate_;
// Parallel merged points
//- Global numbering for merged points
autoPtr<globalIndex> globalPointsPtr_;
//- From mesh point to global merged point
labelList pointToGlobal_;
//- Local points that are unique
labelList uniquePointMap_;
// Private Member Functions
//- Clear some storage
void clear();
//- Inplace renumber of cell-shapes
static cellShapeList& renumberShapes
(
cellShapeList&,
const labelUList& pointToGlobal
);
static cellShapeList map
(
const cellShapeList&,
const labelUList& prims,
const labelUList& pointToGlobal
);
//- Write list of faces
static void writeFaceList
(
const faceList&,
ensightGeoFile&
);
//- Write list of faces
static void writeFaceList
(
const UIndirectList<face>&,
ensightGeoFile&
);
//- Write sizes of faces in the list
static void writeFaceSizes
(
const faceList&,
ensightGeoFile&
);
//- Write sizes of faces in the list
static void writeFaceSizes
(
const UIndirectList<face>&,
ensightGeoFile&
);
//- Write cell connectivity via shell shapes
static void writeCellShapes
(
const cellShapeList&,
ensightGeoFile&
);
void writePolysNFaces
(
const labelList& polys,
const cellList& cellFaces,
ensightGeoFile&
) const;
void writePolysNPointsPerFace
(
const labelList& polys,
const cellList& cellFaces,
const faceList& faces,
ensightGeoFile&
) const;
void writePolysPoints
(
const labelList& polys,
const cellList& cellFaces,
const faceList& faces,
const labelList& faceOwner,
ensightGeoFile&
) const;
void writePolysConnectivity
(
const labelList& addr,
const labelList& pointToGlobal,
ensightGeoFile&
) const;
void writeCellConnectivity
(
const ensightCells&,
const labelList& pointToGlobal,
ensightGeoFile&
) const;
void writeCellConnectivity
(
ensightCells::elemType elemType,
const ensightCells&,
const labelList& pointToGlobal,
ensightGeoFile&
) const;
void writeFaceConnectivity
(
ensightFaces::elemType elemType,
const label nTotal,
const faceList& faceLst,
const labelList& addr,
ensightGeoFile&
) const;
void writeFaceConnectivity
(
ensightFaces::elemType elemType,
const label nTotal,
const faceList& faceLst,
ensightGeoFile&
) const;
void writeFaceConnectivity
(
const ensightFaces&,
const faceList& faceLst,
ensightGeoFile&,
const bool raw = false
) const;
void writeAllPoints
(
const label partId,
const word& ensightPartName,
const label nTotal,
const pointField& uniquePoints,
ensightGeoFile&
) const;
//- Disallow default bitwise copy construct
ensightMesh(const ensightMesh&) = delete;
//- Disallow default bitwise assignment
void operator=(const ensightMesh&) = delete;
public:
// Constructors
//- Construct from components
ensightMesh
(
const fvMesh& mesh,
const options& opts
);
//- Construct from fvMesh with all default options
ensightMesh
(
const fvMesh& mesh,
const IOstream::streamFormat format = IOstream::BINARY
);
//- Destructor
~ensightMesh();
// Member Functions
// Access
//- Reference to the underlying fvMesh
inline const fvMesh& mesh() const;
//- Reference to the writer/mesh options
inline const ensightMesh::options& option() const;
//- Ascii/Binary file output
inline IOstream::streamFormat format() const;
//- Using internalMesh?
inline bool useInternalMesh() const;
//- Using deprecated order? (hex prism pyr tet poly)
inline bool deprecatedOrder() const;
//- The volume cells (internalMesh)
inline const ensightCells& meshCells() const;
//- The list of patches to be output
inline const Map<word>& patches() const;
//- Face elements per selected patch
inline const HashTable<ensightFaces>& boundaryPatchFaces() const;
//- Face elements per selected faceZone.
// To be output in sorted order.
inline const HashTable<ensightFaces>& faceZoneFaces() const;
// Parallel point merging
//- Global numbering for merged points
const globalIndex& globalPoints() const
{
return globalPointsPtr_();
}
//- From mesh point to global merged point
const labelList& pointToGlobal() const
{
return pointToGlobal_;
}
//- Local points that are unique
const labelList& uniquePointMap() const
{
return uniquePointMap_;
}
// Other
//- Does the content need an update?
bool needsUpdate() const;
//- Mark as needing an update.
// May also free up unneeded data.
// Return false if already marked as expired.
bool expire();
//- Update for new mesh
void correct();
// I-O
//- Write to file
inline void write(autoPtr<ensightGeoFile>& os) const;
//- Write to file
void write(ensightGeoFile& os) const;
};
//- Configuration options for the ensightMesh
class ensightMesh::options
{
//- Ascii/Binary file output
IOstream::streamFormat format_;
//- Create in 'expired' mode
bool lazy_;
//- Suppress patches
bool noPatches_;
//- Using deprecated order (hex prism pyr tet poly)
bool deprecatedOrder_;
//- Output selected patches only
autoPtr<wordReList> patchPatterns_;
//- Output selected faceZones
autoPtr<wordReList> faceZonePatterns_;
public:
// Constructors
//- Construct with the specified format (default is binary)
options(IOstream::streamFormat format = IOstream::BINARY);
// Member Functions
// Access
//- Ascii/Binary file output
IOstream::streamFormat format() const;
//- Lazy creation? (ie, ensightMesh starts as needsUpdate)
bool lazy() const;
//- Using internalMesh?
bool useInternalMesh() const;
//- Using deprecated order? (hex prism pyr tet poly)
bool deprecatedOrder() const;
//- Using patches?
bool usePatches() const;
//- Using faceZones?
bool useFaceZones() const;
//- Selection of patches in effect?
bool usePatchSelection() const;
//- Selection of patches - null reference if not available
const wordReList& patchSelection() const;
//- Selection of faceZones - null reference if not available
const wordReList& faceZoneSelection() const;
// Edit
//- Reset to defaults
void reset();
//- Lazy creation - ensightMesh starts as needsUpdate.
void lazy(const bool);
//- Alter deprecated order.
void deprecatedOrder(const bool);
//- Alter the patches/no-patches state
void noPatches(const bool);
//- Define patch selection matcher
void patchSelection(const wordReList&);
//- Define faceZone selection matcher
void faceZoneSelection(const wordReList&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "ensightMeshI.H"
#endif
// ************************************************************************* //

View File

@ -1,90 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline const Foam::fvMesh& Foam::ensightMesh::mesh() const
{
return mesh_;
}
inline const Foam::ensightMesh::options& Foam::ensightMesh::option() const
{
return *options_;
}
inline Foam::IOstream::streamFormat Foam::ensightMesh::format() const
{
return options_->format();
}
inline bool Foam::ensightMesh::useInternalMesh() const
{
return options_->useInternalMesh();
}
inline bool Foam::ensightMesh::deprecatedOrder() const
{
return options_->deprecatedOrder();
}
inline const Foam::ensightCells& Foam::ensightMesh::meshCells() const
{
return meshCells_;
}
inline const Foam::Map<Foam::word>& Foam::ensightMesh::patches() const
{
return patchLookup_;
}
inline const Foam::HashTable<Foam::ensightFaces>&
Foam::ensightMesh::boundaryPatchFaces() const
{
return boundaryPatchFaces_;
}
inline const Foam::HashTable<Foam::ensightFaces>&
Foam::ensightMesh::faceZoneFaces() const
{
return faceZoneFaces_;
}
inline void Foam::ensightMesh::write(autoPtr<ensightGeoFile>& os) const
{
write(os.rawRef());
}
// ************************************************************************* //

View File

@ -1,698 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 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 "ensightMesh.H"
#include "fvMesh.H"
#include "globalMeshData.H"
#include "PstreamCombineReduceOps.H"
#include "processorPolyPatch.H"
#include "mapDistribute.H"
#include "stringListOps.H"
#include "ensightFile.H"
#include "ensightGeoFile.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::cellShapeList& Foam::ensightMesh::renumberShapes
(
cellShapeList& shapes,
const labelUList& pointToGlobal
)
{
forAll(shapes, i)
{
inplaceRenumber(pointToGlobal, shapes[i]);
}
return shapes;
}
Foam::cellShapeList Foam::ensightMesh::map
(
const cellShapeList& shapes,
const labelUList& addr,
const labelUList& pointToGlobal
)
{
cellShapeList lst(addr.size());
forAll(addr, i)
{
lst[i] = shapes[addr[i]];
inplaceRenumber(pointToGlobal, lst[i]);
}
return lst;
}
void Foam::ensightMesh::writeFaceList
(
const faceList& faceLst,
ensightGeoFile& os
)
{
forAll(faceLst, i)
{
const face& f = faceLst[i];
forAll(f, fp)
{
os.write(f[fp] + 1);
}
os.newline();
}
}
void Foam::ensightMesh::writeFaceList
(
const UIndirectList<face>& faceLst,
ensightGeoFile& os
)
{
forAll(faceLst, i)
{
const face& f = faceLst[i];
forAll(f, fp)
{
os.write(f[fp] + 1);
}
os.newline();
}
}
void Foam::ensightMesh::writeFaceSizes
(
const faceList& faceLst,
ensightGeoFile& os
)
{
forAll(faceLst, i)
{
const face& f = faceLst[i];
os.write(f.size());
}
}
void Foam::ensightMesh::writeFaceSizes
(
const UIndirectList<face>& faceLst,
ensightGeoFile& os
)
{
forAll(faceLst, i)
{
const face& f = faceLst[i];
os.write(f.size());
}
}
void Foam::ensightMesh::writeCellShapes
(
const cellShapeList& shapes,
ensightGeoFile& os
)
{
forAll(shapes, i)
{
const cellShape& cellPoints = shapes[i];
// convert global -> local index
// (note: Ensight indices start with 1)
// In ASCII, write one cell per line
forAll(cellPoints, pointI)
{
os.write(cellPoints[pointI] + 1);
}
os.newline();
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::ensightMesh::writePolysNFaces
(
const labelList& addr,
const cellList& cellFaces,
ensightGeoFile& os
) const
{
forAll(addr, i)
{
const labelList& cf = cellFaces[addr[i]];
os.write(cf.size());
}
}
void Foam::ensightMesh::writePolysNPointsPerFace
(
const labelList& addr,
const cellList& cellFaces,
const faceList& faces,
ensightGeoFile& os
) const
{
forAll(addr, i)
{
const labelList& cf = cellFaces[addr[i]];
forAll(cf, faceI)
{
os.write(faces[cf[faceI]].size());
}
}
}
void Foam::ensightMesh::writePolysPoints
(
const labelList& addr,
const cellList& cellFaces,
const faceList& faces,
const labelList& faceOwner,
ensightGeoFile& os
) const
{
forAll(addr, i)
{
const label cellId = addr[i];
const labelList& cf = cellFaces[cellId];
forAll(cf, faceI)
{
const label faceId = cf[faceI];
const face& f = faces[faceId]; // face points (in global points)
if (faceId < faceOwner.size() && faceOwner[faceId] != cellId)
{
// internal face, neighbour
//
// as per face::reverseFace(), but without copying
os.write(f[0] + 1);
for (label ptI = f.size()-1; ptI > 0; --ptI)
{
os.write(f[ptI] + 1);
}
}
else
{
forAll(f, ptI)
{
os.write(f[ptI] + 1);
}
}
os.newline();
}
}
}
void Foam::ensightMesh::writePolysConnectivity
(
const labelList& addr,
const labelList& pointToGlobal,
ensightGeoFile& os
) const
{
const cellList& cellFaces = mesh_.cells();
const faceList& meshFaces = mesh_.faces();
const labelList& faceOwner = mesh_.faceOwner();
if (Pstream::master())
{
// Number of faces for each poly cell
// Master
writePolysNFaces(addr, cellFaces, os);
// Slaves
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
labelList addr(fromSlave);
cellList cellFaces(fromSlave);
writePolysNFaces(addr, cellFaces, os);
}
}
else
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster
<< addr
<< cellFaces;
}
// Number of points for each face of the above list
if (Pstream::master())
{
// Master
writePolysNPointsPerFace
(
addr,
cellFaces,
meshFaces,
os
);
// Slaves
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
labelList addr(fromSlave);
cellList cellFaces(fromSlave);
faceList meshFaces(fromSlave);
writePolysNPointsPerFace
(
addr,
cellFaces,
meshFaces,
os
);
}
}
else
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster
<< addr
<< cellFaces
<< meshFaces;
}
// Renumber faces to use global point numbers
faceList faces(mesh_.faces());
forAll(faces, i)
{
inplaceRenumber(pointToGlobal, faces[i]);
}
// List of points id for each face of the above list
if (Pstream::master())
{
// Master
writePolysPoints
(
addr,
cellFaces,
faces,
faceOwner,
os
);
// Slaves
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
labelList addr(fromSlave);
cellList cellFaces(fromSlave);
faceList faces(fromSlave);
labelList faceOwner(fromSlave);
writePolysPoints
(
addr,
cellFaces,
faces,
faceOwner,
os
);
}
}
else
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster
<< addr
<< cellFaces
<< faces
<< faceOwner;
}
}
void Foam::ensightMesh::writeCellConnectivity
(
const ensightCells::elemType elemType,
const ensightCells& ensCells,
const labelList& pointToGlobal,
ensightGeoFile& os
) const
{
const label nTotal = ensCells.total(elemType);
if (nTotal)
{
const labelUList& addr = ensCells.cellIds(elemType);
if (Pstream::master())
{
os.writeKeyword(ensightCells::key(elemType));
os.write(nTotal);
os.newline();
}
if (elemType == ensightCells::NFACED)
{
writePolysConnectivity
(
addr,
pointToGlobal,
os
);
}
else
{
const cellShapeList shapes = map
(
mesh_.cellShapes(),
addr,
pointToGlobal
);
if (Pstream::master())
{
writeCellShapes(shapes, os);
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
cellShapeList received(fromSlave);
writeCellShapes(received, os);
}
}
else
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster
<< shapes;
}
}
}
}
void Foam::ensightMesh::writeCellConnectivity
(
const ensightCells& ensCells,
const labelList& pointToGlobal,
ensightGeoFile& os
) const
{
if (deprecatedOrder())
{
// element ordering used in older versions
ensightCells::elemType oldOrder[5] =
{
ensightCells::HEXA8,
ensightCells::PENTA6,
ensightCells::PYRAMID5,
ensightCells::TETRA4,
ensightCells::NFACED
};
for (int i=0; i < 5; ++i)
{
const ensightCells::elemType& what = oldOrder[i];
writeCellConnectivity(what, ensCells, pointToGlobal, os);
}
}
else
{
const List<ensightCells::elemType> enums =
ensightCells::elemEnum.enums();
forAllConstIter(List<ensightCells::elemType>, enums, iter)
{
const ensightCells::elemType what = *iter;
writeCellConnectivity(what, ensCells, pointToGlobal, os);
}
}
}
void Foam::ensightMesh::writeFaceConnectivity
(
ensightFaces::elemType elemType,
const label nTotal,
const faceList& faces,
ensightGeoFile& os
) const
{
if (nTotal)
{
if (Pstream::master())
{
os.writeKeyword(ensightFaces::key(elemType));
os.write(nTotal);
os.newline();
}
if (elemType == ensightFaces::NSIDED)
{
// Number of points per face
if (Pstream::master())
{
writeFaceSizes(faces, os);
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
faceList received(fromSlave);
writeFaceSizes(received, os);
}
}
else
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster
<< faces;
}
}
// List of points id for each face
if (Pstream::master())
{
writeFaceList(faces, os);
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
faceList received(fromSlave);
writeFaceList(received, os);
}
}
else
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster
<< faces;
}
}
}
void Foam::ensightMesh::writeFaceConnectivity
(
ensightFaces::elemType elemType,
const label nTotal,
const faceList& faceLst,
const labelList& addr,
ensightGeoFile& os
) const
{
if (nTotal)
{
if (Pstream::master())
{
os.writeKeyword(ensightFaces::key(elemType));
os.write(nTotal);
os.newline();
}
const UIndirectList<face> faces(faceLst, addr);
if (elemType == ensightFaces::NSIDED)
{
// Number of points per face
if (Pstream::master())
{
writeFaceSizes(faces, os);
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
faceList received(fromSlave);
writeFaceSizes(received, os);
}
}
else
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster
<< faces;
}
}
// List of points id per face
if (Pstream::master())
{
writeFaceList(faces, os);
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
faceList received(fromSlave);
writeFaceList(received, os);
}
}
else
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster
<< faces;
}
}
}
void Foam::ensightMesh::writeFaceConnectivity
(
const ensightFaces& ensFaces,
const faceList& faceLst,
ensightGeoFile& os,
const bool raw
) const
{
const List<ensightFaces::elemType> enums = ensightFaces::elemEnum.enums();
if (raw)
{
forAllConstIter(List<ensightFaces::elemType>, enums, iter)
{
const ensightFaces::elemType what = *iter;
writeFaceConnectivity
(
what,
ensFaces.total(what),
SubList<face>
(
faceLst,
ensFaces.faceIds(what).size(),
ensFaces.offset(what)
),
os
);
}
}
else
{
forAllConstIter(List<ensightFaces::elemType>, enums, iter)
{
const ensightFaces::elemType what = *iter;
writeFaceConnectivity
(
what,
ensFaces.total(what),
faceLst,
ensFaces.faceIds(what),
os
);
}
}
}
void Foam::ensightMesh::writeAllPoints
(
const label partId,
const word& ensightPartName,
const label nPoints,
const pointField& uniquePoints,
ensightGeoFile& os
) const
{
if (Pstream::master())
{
os.beginPart(partId, ensightPartName);
// write points
os.beginCoordinates(nPoints);
for (direction cmpt=0; cmpt < point::nComponents; ++cmpt)
{
os.writeList(uniquePoints.component(cmpt));
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
scalarField received(fromSlave);
os.writeList(received);
}
}
}
else
{
for (direction cmpt=0; cmpt < point::nComponents; ++cmpt)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster
<< uniquePoints.component(cmpt);
}
}
}
// ************************************************************************* //

View File

@ -1,174 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ 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 "ensightMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightMesh::options::options(IOstream::streamFormat format)
:
format_(format),
lazy_(false),
noPatches_(false),
deprecatedOrder_(false),
patchPatterns_(),
faceZonePatterns_()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::IOstream::streamFormat Foam::ensightMesh::options::format() const
{
return format_;
}
bool Foam::ensightMesh::options::lazy() const
{
return lazy_;
}
bool Foam::ensightMesh::options::useInternalMesh() const
{
return noPatches_ ? true : !patchPatterns_.valid();
}
bool Foam::ensightMesh::options::deprecatedOrder() const
{
return deprecatedOrder_;
}
bool Foam::ensightMesh::options::usePatches() const
{
return !noPatches_;
}
bool Foam::ensightMesh::options::useFaceZones() const
{
return faceZonePatterns_.valid();
}
bool Foam::ensightMesh::options::usePatchSelection() const
{
return noPatches_ ? false : patchPatterns_.valid();
}
void Foam::ensightMesh::options::reset()
{
noPatches_ = false;
patchPatterns_.clear();
faceZonePatterns_.clear();
}
void Foam::ensightMesh::options::lazy(const bool b)
{
lazy_ = b;
}
void Foam::ensightMesh::options::deprecatedOrder(const bool b)
{
deprecatedOrder_ = b;
}
void Foam::ensightMesh::options::noPatches(const bool b)
{
noPatches_ = b;
if (noPatches_ && patchPatterns_.valid())
{
WarningInFunction
<< " existing patch selection disabled"
<< endl;
patchPatterns_.clear();
}
}
void Foam::ensightMesh::options::patchSelection
(
const wordReList& patterns
)
{
if (noPatches_)
{
WarningInFunction
<< " patch selection specified, but noPatches was already active"
<< endl;
}
else
{
patchPatterns_.reset(new wordReList(patterns));
}
}
void Foam::ensightMesh::options::faceZoneSelection
(
const wordReList& patterns
)
{
faceZonePatterns_.reset(new wordReList(patterns));
}
const Foam::wordReList& Foam::ensightMesh::options::patchSelection() const
{
if (usePatchSelection())
{
return patchPatterns_();
}
else
{
return wordReList::null();
}
}
const Foam::wordReList& Foam::ensightMesh::options::faceZoneSelection() const
{
if (faceZonePatterns_.valid())
{
return faceZonePatterns_();
}
else
{
return wordReList::null();
}
}
// ************************************************************************* //

View File

@ -1,151 +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::ensightOutput
Description
A collection of functions for writing ensight file content in parallel.
SourceFiles
ensightOutput.C
ensightOutputTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef ensightOutput_H
#define ensightOutput_H
#include "ensightFile.H"
#include "ensightMesh.H"
#include "autoPtr.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class ensightOutput Declaration
\*---------------------------------------------------------------------------*/
class ensightOutput
{
// Private Methods
template<class Type>
static void writeField
(
const char* key,
const Field<Type>& fld,
ensightFile& os
);
template<class Type>
static bool writePatchField
(
const Field<Type>& pf,
const ensightFaces& ensFaces,
ensightFile& os
);
template<class Type>
static bool writeVolField
(
const Field<Type>& vf,
const ensightCells& ensCells,
ensightFile& os,
const bool deprecatedOrder = false
);
//- Write volume field component-wise
template<class Type>
static bool writeField
(
const GeometricField<Type, fvPatchField, volMesh>& vf,
const ensightMesh& ensMesh,
ensightFile& os
);
//- Write point field component-wise
template<class Type>
static bool ensightPointField
(
const GeometricField<Type, pointPatchField, pointMesh>& pf,
const ensightMesh& ensMesh,
ensightFile& os
);
//- Disallow null constructor
ensightOutput() = delete;
public:
// Public Methods
//- Write volume field component-wise
template<class Type>
static bool writeField
(
const GeometricField<Type, fvPatchField, volMesh>&,
const ensightMesh& ensMesh,
ensightFile& os,
const bool nodeValues
);
//- Write volume field component-wise
template<class Type>
static inline bool writeField
(
const GeometricField<Type, fvPatchField, volMesh>& vf,
const ensightMesh& ensMesh,
autoPtr<ensightFile>& output,
const bool nodeValues = false
)
{
return writeField(vf, ensMesh, output.rawRef(), nodeValues);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "ensightOutputTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,461 +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 "ensightFile.H"
#include "ensightOutput.H"
#include "ensightPTraits.H"
#include "fvMesh.H"
#include "volFields.H"
#include "IOField.H"
#include "OFstream.H"
#include "IOmanip.H"
#include "Time.H"
#include "volPointInterpolation.H"
#include "globalIndex.H"
#include "uindirectPrimitivePatch.H"
#include "interpolation.H"
#include "linear.H"
// * * * * * * * * * * Static Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::ensightOutput::writeField
(
const char* key,
const Field<Type>& fld,
ensightFile& os
)
{
if (returnReduce(fld.size(), sumOp<label>()) > 0)
{
if (Pstream::master())
{
os.writeKeyword(key);
for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{
const label cmpt = ensightPTraits<Type>::componentOrder[d];
os.writeList(fld.component(cmpt));
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
scalarField received(fromSlave);
os.writeList(received);
}
}
}
else
{
for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{
const label cmpt = ensightPTraits<Type>::componentOrder[d];
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster
<< fld.component(cmpt);
}
}
}
}
template<class Type>
bool Foam::ensightOutput::writePatchField
(
const Field<Type>& pf,
const ensightFaces& ensFaces,
Foam::ensightFile& os
)
{
if (ensFaces.total())
{
if (Pstream::master())
{
os.beginPart(ensFaces.index());
}
const List<ensightFaces::elemType> enums =
ensightFaces::elemEnum.enums();
forAllConstIter(List<ensightFaces::elemType>, enums, iter)
{
const ensightFaces::elemType& what = *iter;
writeField
(
ensightFaces::key(what),
Field<Type>(pf, ensFaces.faceIds(what)),
os
);
}
return true;
}
else
{
return false;
}
}
template<class Type>
bool Foam::ensightOutput::writeVolField
(
const Field<Type>& vf,
const ensightCells& ensCells,
ensightFile& os,
const bool deprecatedOrder
)
{
if (ensCells.total())
{
if (Pstream::master())
{
os.beginPart(ensCells.index());
}
if (deprecatedOrder)
{
// element ordering used in older versions
ensightCells::elemType oldOrder[5] =
{
ensightCells::HEXA8,
ensightCells::PENTA6,
ensightCells::PYRAMID5,
ensightCells::TETRA4,
ensightCells::NFACED
};
for (int i=0; i < 5; ++i)
{
const ensightCells::elemType& what = oldOrder[i];
writeField
(
ensightCells::key(what),
Field<Type>(vf, ensCells.cellIds(what)),
os
);
}
}
else
{
const List<ensightCells::elemType> enums =
ensightCells::elemEnum.enums();
forAllConstIter(List<ensightCells::elemType>, enums, iter)
{
const ensightCells::elemType& what = *iter;
writeField
(
ensightCells::key(what),
Field<Type>(vf, ensCells.cellIds(what)),
os
);
}
}
return true;
}
else
{
return false;
}
}
template<class Type>
bool Foam::ensightOutput::writeField
(
const GeometricField<Type, fvPatchField, volMesh>& vf,
const ensightMesh& ensMesh,
ensightFile& os
)
{
const fvMesh& mesh = ensMesh.mesh();
const ensightCells& meshCells = ensMesh.meshCells();
const Map<word>& patchLookup = ensMesh.patches();
const HashTable<ensightFaces>& patchFaces = ensMesh.boundaryPatchFaces();
const HashTable<ensightFaces>& zoneFaces = ensMesh.faceZoneFaces();
//
// write internalMesh, unless patch-selection was requested
//
if (ensMesh.useInternalMesh())
{
writeVolField(vf, meshCells, os, ensMesh.deprecatedOrder());
}
//
// write patches
// use sortedToc for extra safety
//
const labelList patchIds = patchLookup.sortedToc();
forAll(patchIds, listi)
{
const label patchId = patchIds[listi];
const word& patchName = patchLookup[listi];
const ensightFaces& ensFaces = patchFaces[patchName];
writePatchField
(
vf.boundaryField()[patchId],
ensFaces,
os
);
}
//
// write faceZones, if requested
// use sortedToc for extra safety
//
const wordList zoneNames = zoneFaces.sortedToc();
if (!zoneNames.empty())
{
// Interpolates cell values to faces - needed only when exporting
// faceZones...
GeometricField<Type, fvsPatchField, surfaceMesh> sf
(
Foam::linearInterpolate(vf)
);
// flat boundary field
// as per volPointInterpolation::flatBoundaryField()
Field<Type> flat(mesh.nFaces() - mesh.nInternalFaces());
const fvBoundaryMesh& bm = mesh.boundary();
forAll(vf.boundaryField(), patchI)
{
const polyPatch& pp = bm[patchI].patch();
const label bFaceI = pp.start() - mesh.nInternalFaces();
if
(
isA<emptyFvPatch>(bm[patchI])
|| vf.boundaryField()[patchI].coupled()
)
{
SubList<Type>
(
flat,
pp.size(),
bFaceI
) = Zero;
}
else
{
SubList<Type>
(
flat,
vf.boundaryField()[patchI].size(),
bFaceI
) = vf.boundaryField()[patchI];
}
}
forAll(zoneNames, zonei)
{
const word& zoneName = zoneNames[zonei];
const ensightFaces& ensFaces = zoneFaces[zoneName];
// field (local size)
Field<Type> values(ensFaces.size());
// Loop over face ids to store the needed field values
// - internal faces use linear interpolation
// - boundary faces use the corresponding patch value
forAll(ensFaces, i)
{
label faceId = ensFaces[i];
values[i] =
(
mesh.isInternalFace(faceId)
? sf[faceId]
: flat[faceId - mesh.nInternalFaces()]
);
}
writePatchField(values, ensFaces, os);
}
}
return true;
}
template<class Type>
bool Foam::ensightOutput::ensightPointField
(
const GeometricField<Type, pointPatchField, pointMesh>& pf,
const ensightMesh& ensMesh,
ensightFile& os
)
{
const fvMesh& mesh = ensMesh.mesh();
const Map<word>& patchLookup = ensMesh.patches();
const HashTable<ensightFaces>& patchFaces = ensMesh.boundaryPatchFaces();
const HashTable<ensightFaces>& zoneFaces = ensMesh.faceZoneFaces();
//
// write internalMesh, unless patch-selection was requested
//
if (ensMesh.useInternalMesh())
{
if (Pstream::master())
{
os.beginPart(0); // 0 = internalMesh
}
writeField
(
"coordinates",
Field<Type>(pf.internalField(), ensMesh.uniquePointMap()),
os
);
}
//
// write patches
// use sortedToc for extra safety
//
const labelList patchIds = patchLookup.sortedToc();
forAll(patchIds, listi)
{
const label patchId = patchIds[listi];
const word& patchName = patchLookup[patchId];
const ensightFaces& ensFaces = patchFaces[patchName];
const fvPatch& p = mesh.boundary()[patchId];
// Renumber the patch points/faces into unique points
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPointsPtr =
mesh.globalData().mergePoints
(
p.patch().meshPoints(),
p.patch().meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels
);
if (Pstream::master())
{
os.beginPart(ensFaces.index());
}
writeField
(
"coordinates",
Field<Type>(pf.internalField(), uniqueMeshPointLabels),
os
);
}
//
// write faceZones, if requested
//
const wordList zoneNames = zoneFaces.sortedToc();
forAll(zoneNames, zonei)
{
const word& zoneName = zoneNames[zonei];
const ensightFaces& ensFaces = zoneFaces[zoneName];
uindirectPrimitivePatch p
(
UIndirectList<face>
(
mesh.faces(),
ensFaces.faceIds()
),
mesh.points()
);
// Renumber the patch points/faces into unique points
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPointsPtr =
mesh.globalData().mergePoints
(
p.meshPoints(),
p.meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels
);
if (Pstream::master())
{
os.beginPart(ensFaces.index());
}
writeField
(
"coordinates",
Field<Type>(pf.internalField(), uniqueMeshPointLabels),
os
);
}
return true;
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type>
bool Foam::ensightOutput::writeField
(
const GeometricField<Type, fvPatchField, volMesh>& vf,
const ensightMesh& ensMesh,
ensightFile& os,
const bool nodeValues
)
{
if (nodeValues)
{
tmp<GeometricField<Type, pointPatchField, pointMesh>> pfld
(
volPointInterpolation::New(vf.mesh()).interpolate(vf)
);
pfld.ref().checkOut();
pfld.ref().rename(vf.name());
return ensightPointField<Type>(pfld, ensMesh, os);
}
else
{
return writeField<Type>(vf, ensMesh, os);
}
}
// ************************************************************************* //