ENH: cleanup ensightMesh method names and handling of internal vs boundary

- this removes the old 'magically' means of suppressing the internal
  mesh in favour of specifying it directly.
This commit is contained in:
Mark Olesen
2018-10-09 17:49:15 +02:00
parent 42bb497084
commit e4fac35d60
7 changed files with 348 additions and 185 deletions

View File

@ -154,6 +154,11 @@ int main(int argc, char *argv[])
"Suppress writing lagrangian positions and fields" "Suppress writing lagrangian positions and fields"
); );
argList::addBoolOption argList::addBoolOption
(
"noInternal",
"Do not generate file for mesh, only for patches"
);
argList::addBoolOption
( (
"noPatches", "noPatches",
"Suppress writing any patches" "Suppress writing any patches"
@ -162,8 +167,7 @@ int main(int argc, char *argv[])
( (
"patches", "patches",
"wordRes", "wordRes",
"Specify particular patches to write - eg '(outlet \"inlet.*\")'. " "Specify particular patches to write - eg '(outlet \"inlet.*\")'."
"An empty list suppresses writing the internalMesh."
); );
argList::addOption argList::addOption
( (
@ -267,7 +271,8 @@ int main(int argc, char *argv[])
// Output configuration (geometry related) // Output configuration (geometry related)
// //
ensightMesh::options writeOpts(format); ensightMesh::options writeOpts(format);
writeOpts.noPatches(args.found("noPatches")); writeOpts.useInternalMesh(!args.found("noInternal"));
writeOpts.useBoundaryMesh(!args.found("noPatches"));
if (args.found("patches")) if (args.found("patches"))
{ {

View File

@ -66,6 +66,12 @@ Foam::ensightMesh::ensightMesh
} }
Foam::ensightMesh::ensightMesh(const fvMesh& mesh)
:
ensightMesh(mesh, IOstream::streamFormat::BINARY)
{}
Foam::ensightMesh::ensightMesh Foam::ensightMesh::ensightMesh
( (
const fvMesh& mesh, const fvMesh& mesh,
@ -103,7 +109,7 @@ bool Foam::ensightMesh::expire()
{ {
clear(); clear();
// already marked as expired // Already marked as expired
if (needsUpdate_) if (needsUpdate_)
{ {
return false; return false;
@ -118,12 +124,25 @@ void Foam::ensightMesh::correct()
{ {
clear(); clear();
// First see if patches are allowed/disallowed // Part number
// and if only particular patches should be selected label nParts = 0;
label nParts = 1; // provisionally (for internalMesh) if (useInternalMesh())
{
meshCells_.index() = nParts++;
meshCells_.classify(mesh_);
if (option().usePatches()) // Determine parallel shared points
globalPointsPtr_ = mesh_.globalData().mergePoints
(
pointToGlobal_,
uniquePointMap_
);
}
meshCells_.reduce();
if (useBoundaryMesh())
{ {
// Patches are output. Check that they are synced. // Patches are output. Check that they are synced.
mesh_.boundaryMesh().checkParallelSync(true); mesh_.boundaryMesh().checkParallelSync(true);
@ -132,55 +151,42 @@ void Foam::ensightMesh::correct()
if (Pstream::parRun()) if (Pstream::parRun())
{ {
// Do not include processor patches in matching // Do not include processor patches in matching
patchNames.setSize(mesh_.boundaryMesh().nNonProcessor()); patchNames.resize(mesh_.boundaryMesh().nNonProcessor());
} }
labelList matched;
bool useAll = true;
const wordRes& matcher = option().patchSelection(); const wordRes& matcher = option().patchSelection();
if (notNull(matcher))
{
nParts = 0; // no internalMesh
if (!matcher.empty()) const labelList patchIds =
{ (
useAll = false; matcher.empty()
matched = matcher.matching(patchNames); ? identity(patchNames.size()) // Use all
} : findStrings(matcher, patchNames) // Use specified names
} );
if (useAll) for (const label patchId : patchIds)
{
matched = identity(patchNames.size());
}
for (const label patchId : matched)
{ {
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
const fvPatch& p = mesh_.boundary()[patchId]; const fvPatch& p = mesh_.boundary()[patchId];
// yes we most likely want this patch. ensightFaces& ensFaces = boundaryPatchFaces_(patchName);
// - can use insert or set, since hash was cleared before ensFaces.clear();
boundaryPatchFaces_.set(patchName, ensightFaces());
ensightFaces& ensFaces = boundaryPatchFaces_[patchName];
if (p.size()) if (p.size())
{ {
// use local face addressing (offset = 0), // Local face addressing (offset = 0),
// since this is what we'll need later when writing fields // - this is what we'll need later when writing fields
ensFaces.classify(p.patch()); ensFaces.classify(p.patch());
} }
else else
{ {
// patch is empty (on this processor) // The patch is empty (on this processor)
// or the patch is 'empty' (as fvPatch type) // or the patch is 'empty' (as fvPatch type)
ensFaces.clear(); ensFaces.clear();
} }
// finalize // Finalize
ensFaces.reduce(); ensFaces.reduce();
if (ensFaces.total()) if (ensFaces.total())
@ -199,26 +205,11 @@ void Foam::ensightMesh::correct()
// * boundaryPatchFaces_ is a lookup by name for the faces elements // * 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()) if (option().useFaceZones())
{ {
// 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
for (const polyPatch& pp : mesh_.boundaryMesh()) for (const polyPatch& pp : mesh_.boundaryMesh())
{ {
@ -228,32 +219,22 @@ void Foam::ensightMesh::correct()
&& !refCast<const processorPolyPatch>(pp).owner() && !refCast<const processorPolyPatch>(pp).owner()
) )
{ {
label bFaceI = pp.start(); excludeFace.set(pp.range());
forAll(pp, i)
{
excludeFace.set(bFaceI++);
}
} }
} }
const wordRes& matcher = option().faceZoneSelection(); // Use sorted order for later consistency
const wordList zoneNames =
wordList selectZones = mesh_.faceZones().names(); mesh_.faceZones().sortedNames(option().faceZoneSelection());
subsetMatchingStrings(matcher, selectZones);
// have same order as later with sortedToc()
Foam::sort(selectZones);
// Count face types in each selected faceZone // Count face types in each selected faceZone
for (const word& zoneName : selectZones) for (const word& zoneName : zoneNames)
{ {
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];
// yes we most likely want this zone ensightFaces& ensFaces = faceZoneFaces_(zoneName);
// - can use insert or set, since hash was cleared before ensFaces.clear();
faceZoneFaces_.set(zoneName, ensightFaces());
ensightFaces& ensFaces = faceZoneFaces_[zoneName];
if (fz.size()) if (fz.size())
{ {
@ -266,7 +247,7 @@ void Foam::ensightMesh::correct()
); );
} }
// finalize // Finalize
ensFaces.reduce(); ensFaces.reduce();
if (ensFaces.total()) if (ensFaces.total())
@ -286,9 +267,12 @@ void Foam::ensightMesh::correct()
void Foam::ensightMesh::write(ensightGeoFile& os) const void Foam::ensightMesh::write(ensightGeoFile& os) const
{ {
//
// Write internalMesh
//
if (useInternalMesh()) if (useInternalMesh())
{ {
label nPoints = globalPoints().size(); const label nPoints = globalPoints().size();
const pointField uniquePoints(mesh_.points(), uniquePointMap_); const pointField uniquePoints(mesh_.points(), uniquePointMap_);
@ -308,11 +292,9 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
// //
// write patches // Write patches - sorted by Id
// use sortedToc for extra safety
// //
const labelList patchIds = patchLookup_.sortedToc(); for (const label patchId : patchLookup_.sortedToc())
for (const label patchId : patchIds)
{ {
const word& patchName = patchLookup_[patchId]; const word& patchName = patchLookup_[patchId];
const ensightFaces& ensFaces = boundaryPatchFaces_[patchName]; const ensightFaces& ensFaces = boundaryPatchFaces_[patchName];
@ -353,10 +335,9 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
// //
// write faceZones, if requested // Write faceZones, if requested
// //
const wordList zoneNames = faceZoneFaces_.sortedToc(); for (const word& zoneName : faceZoneFaces_.sortedToc())
for (const word& zoneName : zoneNames)
{ {
const ensightFaces& ensFaces = faceZoneFaces_[zoneName]; const ensightFaces& ensFaces = faceZoneFaces_[zoneName];

View File

@ -66,6 +66,7 @@ class ensightMesh;
class ensightMesh class ensightMesh
{ {
public: public:
// Forward declarations // Forward declarations
class options; class options;
@ -121,7 +122,8 @@ private:
const labelUList& pointToGlobal const labelUList& pointToGlobal
); );
static cellShapeList map //- Copy and return renumbered cell-shapes
static cellShapeList renumberShapes
( (
const cellShapeList& shapes, const cellShapeList& shapes,
const labelUList& addr, const labelUList& addr,
@ -142,6 +144,18 @@ private:
ensightGeoFile& os ensightGeoFile& os
); );
//- Return sizes of faces in the list
static labelList getFaceSizes
(
const faceList& faces
);
//- Return sizes of faces in the list
static labelList getFaceSizes
(
const UIndirectList<face>& faces
);
//- Write sizes of faces in the list //- Write sizes of faces in the list
static void writeFaceSizes static void writeFaceSizes
( (
@ -163,32 +177,47 @@ private:
ensightGeoFile& os ensightGeoFile& os
); );
//- Return the number of faces per poly element
static labelList getPolysNFaces
(
const labelUList& polys,
const cellList& cellFaces
);
//- Write the number of faces per poly element //- Write the number of faces per poly element
void writePolysNFaces static void writePolysNFaces
( (
const labelUList& polys, const labelUList& polys,
const cellList& cellFaces, const cellList& cellFaces,
ensightGeoFile& os ensightGeoFile& os
) const; );
//- Return the number of points per poly element
static labelList getPolysNPointsPerFace
(
const labelUList& polys,
const cellList& cellFaces,
const faceList& faces
);
//- Write the number of points per poly element //- Write the number of points per poly element
void writePolysNPointsPerFace static void writePolysNPointsPerFace
( (
const labelUList& polys, const labelUList& polys,
const cellList& cellFaces, const cellList& cellFaces,
const faceList& faces, const faceList& faces,
ensightGeoFile& ensightGeoFile& os
) const; );
//- Write the point ids per poly element //- Write the point ids per poly element
void writePolysPoints static void writePolysPoints
( (
const labelUList& addr, const labelUList& addr,
const cellList& cellFaces, const cellList& cellFaces,
const faceList& faces, const faceList& faces,
const labelList& faceOwner, const labelList& faceOwner,
ensightGeoFile& ensightGeoFile& os
) const; );
//- Write the poly connectivity //- Write the poly connectivity
void writePolysConnectivity void writePolysConnectivity
@ -267,18 +296,13 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
ensightMesh ensightMesh(const fvMesh& mesh, const options& opts);
(
const fvMesh& mesh,
const options& opts
);
//- Construct from fvMesh with all default options //- Construct from fvMesh with all default options, binary output
ensightMesh explicit ensightMesh(const fvMesh& mesh);
(
const fvMesh& mesh, //- Construct from fvMesh with all default options and specified format
const IOstream::streamFormat format = IOstream::BINARY ensightMesh(const fvMesh& mesh, const IOstream::streamFormat format);
);
//- Destructor //- Destructor
@ -298,9 +322,12 @@ public:
//- Ascii/Binary file output //- Ascii/Binary file output
inline IOstream::streamFormat format() const; inline IOstream::streamFormat format() const;
//- Using internalMesh? //- Using internal?
inline bool useInternalMesh() const; inline bool useInternalMesh() const;
//- Using boundary?
inline bool useBoundaryMesh() const;
//- The volume cells (internalMesh) //- The volume cells (internalMesh)
inline const ensightCells& meshCells() const; inline const ensightCells& meshCells() const;
@ -346,12 +373,11 @@ public:
// Return false if already marked as expired. // Return false if already marked as expired.
bool expire(); bool expire();
//- Update for new mesh //- Update for new mesh
void correct(); void correct();
// I-O // Output
//- Write to file //- Write to file
inline void write(autoPtr<ensightGeoFile>& os) const; inline void write(autoPtr<ensightGeoFile>& os) const;
@ -371,49 +397,53 @@ class ensightMesh::options
//- Create in 'expired' mode //- Create in 'expired' mode
bool lazy_; bool lazy_;
//- Suppress patches //- Use the internal mesh
bool noPatches_; bool internal_;
//- Output selected patches only //- Use the boundary mesh
autoPtr<wordRes> patchPatterns_; bool boundary_;
//- Output of selected patches only
wordRes patchPatterns_;
//- Output of selected faceZones
wordRes faceZonePatterns_;
//- Output selected faceZones
autoPtr<wordRes> faceZonePatterns_;
public: public:
// Constructors // Constructors
//- Construct with the specified format (default is binary) //- Construct for binary output
options(IOstream::streamFormat format = IOstream::BINARY); options();
//- Construct for specified format
explicit options(IOstream::streamFormat format);
// Member Functions // Member Functions
// Access // Access
//- Ascii/Binary file output //- File output format (ascii | binary)
IOstream::streamFormat format() const; IOstream::streamFormat format() const;
//- Lazy creation? (ie, ensightMesh starts as needsUpdate) //- Lazy creation? (ie, ensightMesh starts as needsUpdate)
bool lazy() const; bool lazy() const;
//- Using internalMesh? //- Using internal?
bool useInternalMesh() const; bool useInternalMesh() const;
//- Using patches? //- Using boundary?
bool usePatches() const; bool useBoundaryMesh() const;
//- Using faceZones? //- Using faceZones?
bool useFaceZones() const; bool useFaceZones() const;
//- Selection of patches in effect? //- Selection of patches. Empty if unspecified.
bool usePatchSelection() const;
//- Selection of patches - null reference if not available
const wordRes& patchSelection() const; const wordRes& patchSelection() const;
//- Selection of faceZones - null reference if not available //- Selection of faceZones. Empty if unspecified.
const wordRes& faceZoneSelection() const; const wordRes& faceZoneSelection() const;
@ -423,16 +453,37 @@ public:
void reset(); void reset();
//- Lazy creation - ensightMesh starts as needsUpdate. //- Lazy creation - ensightMesh starts as needsUpdate.
void lazy(const bool); void lazy(bool beLazy);
//- Alter the patches/no-patches state //- Alter the useBoundaryMesh state
void noPatches(const bool); void useInternalMesh(bool on);
//- Alter the useBoundaryMesh state
void useBoundaryMesh(bool on);
//- Define patch selection matcher //- Define patch selection matcher
void patchSelection(const UList<wordRe>& patterns); void patchSelection(const UList<wordRe>& patterns);
//- Define patch selection matcher
void patchSelection(List<wordRe>&& patterns);
//- Define faceZone selection matcher //- Define faceZone selection matcher
void faceZoneSelection(const UList<wordRe>& patterns); void faceZoneSelection(const UList<wordRe>& patterns);
//- Define faceZone selection matcher
void faceZoneSelection(List<wordRe>&& patterns);
// Housekeeping
//- Older name for useBoundaryMesh()
// \deprecated OCT-2018
bool usePatches() const { return useBoundaryMesh(); }
//- Older name for useBoundaryMesh()
// \deprecated OCT-2018
void noPatches(bool off) { useBoundaryMesh(!off); }
}; };

View File

@ -49,6 +49,12 @@ inline bool Foam::ensightMesh::useInternalMesh() const
} }
inline bool Foam::ensightMesh::useBoundaryMesh() const
{
return options_->useBoundaryMesh();
}
inline const Foam::ensightCells& Foam::ensightMesh::meshCells() const inline const Foam::ensightCells& Foam::ensightMesh::meshCells() const
{ {
return meshCells_; return meshCells_;

View File

@ -51,20 +51,16 @@ Foam::cellShapeList& Foam::ensightMesh::renumberShapes
} }
Foam::cellShapeList Foam::ensightMesh::map Foam::cellShapeList Foam::ensightMesh::renumberShapes
( (
const cellShapeList& shapes, const cellShapeList& shapes,
const labelUList& addr, const labelUList& addr,
const labelUList& pointToGlobal const labelUList& pointToGlobal
) )
{ {
cellShapeList list(addr.size()); cellShapeList list(shapes, addr);
forAll(addr, i) renumberShapes(list, pointToGlobal);
{
list[i] = shapes[addr[i]];
inplaceRenumber(pointToGlobal, list[i]);
}
return list; return list;
} }
@ -106,6 +102,44 @@ void Foam::ensightMesh::writeFaceList
} }
Foam::labelList Foam::ensightMesh::getFaceSizes
(
const faceList& faceLst
)
{
labelList list(faceLst.size());
auto outIter = list.begin();
for (const face& f : faceLst)
{
*outIter = f.size();
++outIter;
}
return list;
}
Foam::labelList Foam::ensightMesh::getFaceSizes
(
const UIndirectList<face>& faceLst
)
{
labelList list(faceLst.size());
auto outIter = list.begin();
for (const face& f : faceLst)
{
*outIter = f.size();
++outIter;
}
return list;
}
void Foam::ensightMesh::writeFaceSizes void Foam::ensightMesh::writeFaceSizes
( (
const faceList& faceLst, const faceList& faceLst,
@ -142,7 +176,7 @@ void Foam::ensightMesh::writeCellShapes
{ {
for (const cellShape& cellPoints : shapes) for (const cellShape& cellPoints : shapes)
{ {
// 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
@ -156,14 +190,35 @@ void Foam::ensightMesh::writeCellShapes
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::labelList Foam::ensightMesh::getPolysNFaces
(
const labelUList& addr,
const cellList& cellFaces
)
{
labelList list(addr.size());
auto outIter = list.begin();
// The number of faces per element
for (const label cellId : addr)
{
const labelUList& cf = cellFaces[cellId];
*outIter = cf.size();
++outIter;
}
return list;
}
void Foam::ensightMesh::writePolysNFaces void Foam::ensightMesh::writePolysNFaces
( (
const labelUList& addr, const labelUList& addr,
const cellList& cellFaces, const cellList& cellFaces,
ensightGeoFile& os ensightGeoFile& os
) const )
{ {
// Write the number of faces per element (1/line in ASCII) // Write the number of faces per element (1/line in ASCII)
for (const label cellId : addr) for (const label cellId : addr)
@ -176,13 +231,50 @@ void Foam::ensightMesh::writePolysNFaces
} }
Foam::labelList Foam::ensightMesh::getPolysNPointsPerFace
(
const labelUList& addr,
const cellList& cellFaces,
const faceList& faces
)
{
// Count the number of faces per element
label nTotFaces = 0;
for (const label cellId : addr)
{
const labelUList& cf = cellFaces[cellId];
nTotFaces += cf.size();
}
labelList list(nTotFaces);
auto outIter = list.begin();
// The number of points per element face
for (const label cellId : addr)
{
const labelUList& cf = cellFaces[cellId];
for (const label facei : cf)
{
*outIter = faces[facei].size();
++outIter;
}
}
return list;
}
void Foam::ensightMesh::writePolysNPointsPerFace void Foam::ensightMesh::writePolysNPointsPerFace
( (
const labelUList& addr, const labelUList& addr,
const cellList& cellFaces, const cellList& cellFaces,
const faceList& faces, const faceList& faces,
ensightGeoFile& os ensightGeoFile& os
) 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)
for (const label cellId : addr) for (const label cellId : addr)
@ -198,6 +290,8 @@ void Foam::ensightMesh::writePolysNPointsPerFace
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::ensightMesh::writePolysPoints void Foam::ensightMesh::writePolysPoints
( (
const labelUList& addr, const labelUList& addr,
@ -205,7 +299,7 @@ void Foam::ensightMesh::writePolysPoints
const faceList& faces, const faceList& faces,
const labelList& faceOwner, const labelList& faceOwner,
ensightGeoFile& os ensightGeoFile& os
) const )
{ {
for (const label cellId : addr) for (const label cellId : addr)
{ {
@ -252,10 +346,9 @@ void Foam::ensightMesh::writePolysConnectivity
const faceList& meshFaces = mesh_.faces(); const faceList& meshFaces = mesh_.faces();
const labelList& faceOwner = mesh_.faceOwner(); const labelList& faceOwner = mesh_.faceOwner();
// Number of faces for each poly cell
if (Pstream::master()) if (Pstream::master())
{ {
// Number of faces for each poly cell
// Master // Master
writePolysNFaces(addr, cellFaces, os); writePolysNFaces(addr, cellFaces, os);
@ -288,6 +381,7 @@ void Foam::ensightMesh::writePolysConnectivity
meshFaces, meshFaces,
os os
); );
// Slaves // Slaves
for (int slave=1; slave<Pstream::nProcs(); ++slave) for (int slave=1; slave<Pstream::nProcs(); ++slave)
{ {
@ -334,6 +428,7 @@ void Foam::ensightMesh::writePolysConnectivity
faceOwner, faceOwner,
os os
); );
// Slaves // Slaves
for (int slave=1; slave<Pstream::nProcs(); ++slave) for (int slave=1; slave<Pstream::nProcs(); ++slave)
{ {
@ -399,7 +494,7 @@ void Foam::ensightMesh::writeCellConnectivity
{ {
const cellShapeList shapes const cellShapeList shapes
( (
map renumberShapes
( (
mesh_.cellShapes(), mesh_.cellShapes(),
addr, addr,
@ -415,9 +510,9 @@ void Foam::ensightMesh::writeCellConnectivity
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);
cellShapeList received(fromSlave); cellShapeList recv(fromSlave);
writeCellShapes(received, os); writeCellShapes(recv, os);
} }
} }
else else
@ -559,9 +654,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
@ -585,9 +680,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
@ -661,7 +756,7 @@ void Foam::ensightMesh::writeAllPoints
{ {
os.beginPart(partId, ensightPartName); os.beginPart(partId, ensightPartName);
// write points // Write points
os.beginCoordinates(nPoints); os.beginCoordinates(nPoints);
for (direction cmpt=0; cmpt < point::nComponents; ++cmpt) for (direction cmpt=0; cmpt < point::nComponents; ++cmpt)
@ -671,8 +766,8 @@ void Foam::ensightMesh::writeAllPoints
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);
scalarField received(fromSlave); scalarField recv(fromSlave);
os.writeList(received); os.writeList(recv);
} }
} }
} }

View File

@ -27,11 +27,18 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightMesh::options::options()
:
options(IOstream::streamFormat::BINARY)
{}
Foam::ensightMesh::options::options(IOstream::streamFormat format) Foam::ensightMesh::options::options(IOstream::streamFormat format)
: :
format_(format), format_(format),
lazy_(false), lazy_(false),
noPatches_(false), internal_(true),
boundary_(true),
patchPatterns_(), patchPatterns_(),
faceZonePatterns_() faceZonePatterns_()
{} {}
@ -53,53 +60,54 @@ bool Foam::ensightMesh::options::lazy() const
bool Foam::ensightMesh::options::useInternalMesh() const bool Foam::ensightMesh::options::useInternalMesh() const
{ {
return noPatches_ ? true : !patchPatterns_.valid(); return internal_;
} }
bool Foam::ensightMesh::options::usePatches() const bool Foam::ensightMesh::options::useBoundaryMesh() const
{ {
return !noPatches_; return boundary_;
} }
bool Foam::ensightMesh::options::useFaceZones() const bool Foam::ensightMesh::options::useFaceZones() const
{ {
return faceZonePatterns_.valid(); return faceZonePatterns_.size();
}
bool Foam::ensightMesh::options::usePatchSelection() const
{
return noPatches_ ? false : patchPatterns_.valid();
} }
void Foam::ensightMesh::options::reset() void Foam::ensightMesh::options::reset()
{ {
noPatches_ = false; internal_ = true;
boundary_ = true;
patchPatterns_.clear(); patchPatterns_.clear();
faceZonePatterns_.clear(); faceZonePatterns_.clear();
} }
void Foam::ensightMesh::options::lazy(const bool b) void Foam::ensightMesh::options::lazy(bool beLazy)
{ {
lazy_ = b; lazy_ = beLazy;
} }
void Foam::ensightMesh::options::noPatches(const bool b) void Foam::ensightMesh::options::useInternalMesh(bool on)
{ {
noPatches_ = b; internal_ = on;
}
if (noPatches_ && patchPatterns_.valid())
void Foam::ensightMesh::options::useBoundaryMesh(bool on)
{
boundary_ = on;
if (!boundary_ && patchPatterns_.size())
{ {
WarningInFunction
<< " existing patch selection disabled"
<< endl;
patchPatterns_.clear(); patchPatterns_.clear();
WarningInFunction
<< "Deactivating boundary and removing old patch selection"
<< endl;
} }
} }
@ -109,15 +117,33 @@ void Foam::ensightMesh::options::patchSelection
const UList<wordRe>& patterns const UList<wordRe>& patterns
) )
{ {
if (noPatches_) patchPatterns_ = wordRes(patterns);
if (!boundary_ && patchPatterns_.size())
{ {
patchPatterns_.clear();
WarningInFunction WarningInFunction
<< " patch selection specified, but noPatches was already active" << "Ignoring patch selection, boundary is not active"
<< endl; << endl;
} }
else }
void Foam::ensightMesh::options::patchSelection
(
List<wordRe>&& patterns
)
{
patchPatterns_ = wordRes(std::move(patterns));
if (!boundary_ && patchPatterns_.size())
{ {
patchPatterns_.reset(new wordRes(patterns)); patchPatterns_.clear();
WarningInFunction
<< "Ignoring patch selection, boundary is not active"
<< endl;
} }
} }
@ -127,29 +153,28 @@ void Foam::ensightMesh::options::faceZoneSelection
const UList<wordRe>& patterns const UList<wordRe>& patterns
) )
{ {
faceZonePatterns_.reset(new wordRes(patterns)); faceZonePatterns_ = wordRes(patterns);
}
void Foam::ensightMesh::options::faceZoneSelection
(
List<wordRe>&& patterns
)
{
faceZonePatterns_ = wordRes(std::move(patterns));
} }
const Foam::wordRes& Foam::ensightMesh::options::patchSelection() const const Foam::wordRes& Foam::ensightMesh::options::patchSelection() const
{ {
if (usePatchSelection()) return patchPatterns_;
{
return *patchPatterns_;
}
return wordRes::null();
} }
const Foam::wordRes& Foam::ensightMesh::options::faceZoneSelection() const const Foam::wordRes& Foam::ensightMesh::options::faceZoneSelection() const
{ {
if (faceZonePatterns_.valid()) return faceZonePatterns_;
{
return *faceZonePatterns_;
}
return wordRes::null();
} }

View File

@ -295,7 +295,7 @@ bool Foam::ensightOutput::writeField
{ {
const ensightFaces& ensFaces = zoneFaces[zoneName]; const ensightFaces& ensFaces = zoneFaces[zoneName];
// field (local size) // Field (local size)
Field<Type> values(ensFaces.size()); Field<Type> values(ensFaces.size());
// Loop over face ids to store the needed field values // Loop over face ids to store the needed field values
@ -303,7 +303,7 @@ bool Foam::ensightOutput::writeField
// - boundary faces use the corresponding patch value // - boundary faces use the corresponding patch value
forAll(ensFaces, i) forAll(ensFaces, i)
{ {
label faceId = ensFaces[i]; const label faceId = ensFaces[i];
values[i] = values[i] =
( (
mesh.isInternalFace(faceId) mesh.isInternalFace(faceId)