mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -154,6 +154,11 @@ int main(int argc, char *argv[])
|
||||
"Suppress writing lagrangian positions and fields"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noInternal",
|
||||
"Do not generate file for mesh, only for patches"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noPatches",
|
||||
"Suppress writing any patches"
|
||||
@ -162,8 +167,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
"patches",
|
||||
"wordRes",
|
||||
"Specify particular patches to write - eg '(outlet \"inlet.*\")'. "
|
||||
"An empty list suppresses writing the internalMesh."
|
||||
"Specify particular patches to write - eg '(outlet \"inlet.*\")'."
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
@ -267,7 +271,8 @@ int main(int argc, char *argv[])
|
||||
// Output configuration (geometry related)
|
||||
//
|
||||
ensightMesh::options writeOpts(format);
|
||||
writeOpts.noPatches(args.found("noPatches"));
|
||||
writeOpts.useInternalMesh(!args.found("noInternal"));
|
||||
writeOpts.useBoundaryMesh(!args.found("noPatches"));
|
||||
|
||||
if (args.found("patches"))
|
||||
{
|
||||
|
||||
@ -66,6 +66,12 @@ Foam::ensightMesh::ensightMesh
|
||||
}
|
||||
|
||||
|
||||
Foam::ensightMesh::ensightMesh(const fvMesh& mesh)
|
||||
:
|
||||
ensightMesh(mesh, IOstream::streamFormat::BINARY)
|
||||
{}
|
||||
|
||||
|
||||
Foam::ensightMesh::ensightMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
@ -103,7 +109,7 @@ bool Foam::ensightMesh::expire()
|
||||
{
|
||||
clear();
|
||||
|
||||
// already marked as expired
|
||||
// Already marked as expired
|
||||
if (needsUpdate_)
|
||||
{
|
||||
return false;
|
||||
@ -118,12 +124,25 @@ void Foam::ensightMesh::correct()
|
||||
{
|
||||
clear();
|
||||
|
||||
// First see if patches are allowed/disallowed
|
||||
// and if only particular patches should be selected
|
||||
// Part number
|
||||
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.
|
||||
mesh_.boundaryMesh().checkParallelSync(true);
|
||||
@ -132,55 +151,42 @@ void Foam::ensightMesh::correct()
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// 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();
|
||||
if (notNull(matcher))
|
||||
{
|
||||
nParts = 0; // no internalMesh
|
||||
|
||||
if (!matcher.empty())
|
||||
{
|
||||
useAll = false;
|
||||
matched = matcher.matching(patchNames);
|
||||
}
|
||||
}
|
||||
const labelList patchIds =
|
||||
(
|
||||
matcher.empty()
|
||||
? identity(patchNames.size()) // Use all
|
||||
: findStrings(matcher, patchNames) // Use specified names
|
||||
);
|
||||
|
||||
if (useAll)
|
||||
{
|
||||
matched = identity(patchNames.size());
|
||||
}
|
||||
|
||||
for (const label patchId : matched)
|
||||
for (const label patchId : patchIds)
|
||||
{
|
||||
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];
|
||||
|
||||
// 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];
|
||||
ensightFaces& ensFaces = boundaryPatchFaces_(patchName);
|
||||
ensFaces.clear();
|
||||
|
||||
if (p.size())
|
||||
{
|
||||
// use local face addressing (offset = 0),
|
||||
// since this is what we'll need later when writing fields
|
||||
// Local face addressing (offset = 0),
|
||||
// - this is what we'll need later when writing fields
|
||||
ensFaces.classify(p.patch());
|
||||
}
|
||||
else
|
||||
{
|
||||
// patch is empty (on this processor)
|
||||
// The patch is empty (on this processor)
|
||||
// or the patch is 'empty' (as fvPatch type)
|
||||
ensFaces.clear();
|
||||
}
|
||||
|
||||
// finalize
|
||||
// Finalize
|
||||
ensFaces.reduce();
|
||||
|
||||
if (ensFaces.total())
|
||||
@ -199,26 +205,11 @@ void Foam::ensightMesh::correct()
|
||||
// * 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
|
||||
bitSet excludeFace(mesh_.nFaces()); // all false
|
||||
bitSet excludeFace(mesh_.nFaces()); // all false
|
||||
|
||||
for (const polyPatch& pp : mesh_.boundaryMesh())
|
||||
{
|
||||
@ -228,32 +219,22 @@ void Foam::ensightMesh::correct()
|
||||
&& !refCast<const processorPolyPatch>(pp).owner()
|
||||
)
|
||||
{
|
||||
label bFaceI = pp.start();
|
||||
forAll(pp, i)
|
||||
{
|
||||
excludeFace.set(bFaceI++);
|
||||
}
|
||||
excludeFace.set(pp.range());
|
||||
}
|
||||
}
|
||||
|
||||
const wordRes& matcher = option().faceZoneSelection();
|
||||
|
||||
wordList selectZones = mesh_.faceZones().names();
|
||||
subsetMatchingStrings(matcher, selectZones);
|
||||
|
||||
// have same order as later with sortedToc()
|
||||
Foam::sort(selectZones);
|
||||
// Use sorted order for later consistency
|
||||
const wordList zoneNames =
|
||||
mesh_.faceZones().sortedNames(option().faceZoneSelection());
|
||||
|
||||
// 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 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];
|
||||
ensightFaces& ensFaces = faceZoneFaces_(zoneName);
|
||||
ensFaces.clear();
|
||||
|
||||
if (fz.size())
|
||||
{
|
||||
@ -266,7 +247,7 @@ void Foam::ensightMesh::correct()
|
||||
);
|
||||
}
|
||||
|
||||
// finalize
|
||||
// Finalize
|
||||
ensFaces.reduce();
|
||||
|
||||
if (ensFaces.total())
|
||||
@ -286,9 +267,12 @@ void Foam::ensightMesh::correct()
|
||||
|
||||
void Foam::ensightMesh::write(ensightGeoFile& os) const
|
||||
{
|
||||
//
|
||||
// Write internalMesh
|
||||
//
|
||||
if (useInternalMesh())
|
||||
{
|
||||
label nPoints = globalPoints().size();
|
||||
const label nPoints = globalPoints().size();
|
||||
|
||||
const pointField uniquePoints(mesh_.points(), uniquePointMap_);
|
||||
|
||||
@ -308,11 +292,9 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
|
||||
|
||||
|
||||
//
|
||||
// write patches
|
||||
// use sortedToc for extra safety
|
||||
// Write patches - sorted by Id
|
||||
//
|
||||
const labelList patchIds = patchLookup_.sortedToc();
|
||||
for (const label patchId : patchIds)
|
||||
for (const label patchId : patchLookup_.sortedToc())
|
||||
{
|
||||
const word& patchName = patchLookup_[patchId];
|
||||
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 : zoneNames)
|
||||
for (const word& zoneName : faceZoneFaces_.sortedToc())
|
||||
{
|
||||
const ensightFaces& ensFaces = faceZoneFaces_[zoneName];
|
||||
|
||||
|
||||
@ -66,6 +66,7 @@ class ensightMesh;
|
||||
class ensightMesh
|
||||
{
|
||||
public:
|
||||
|
||||
// Forward declarations
|
||||
class options;
|
||||
|
||||
@ -121,7 +122,8 @@ private:
|
||||
const labelUList& pointToGlobal
|
||||
);
|
||||
|
||||
static cellShapeList map
|
||||
//- Copy and return renumbered cell-shapes
|
||||
static cellShapeList renumberShapes
|
||||
(
|
||||
const cellShapeList& shapes,
|
||||
const labelUList& addr,
|
||||
@ -142,6 +144,18 @@ private:
|
||||
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
|
||||
static void writeFaceSizes
|
||||
(
|
||||
@ -163,32 +177,47 @@ private:
|
||||
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
|
||||
void writePolysNFaces
|
||||
static void writePolysNFaces
|
||||
(
|
||||
const labelUList& polys,
|
||||
const cellList& cellFaces,
|
||||
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
|
||||
void writePolysNPointsPerFace
|
||||
static void writePolysNPointsPerFace
|
||||
(
|
||||
const labelUList& polys,
|
||||
const cellList& cellFaces,
|
||||
const faceList& faces,
|
||||
ensightGeoFile&
|
||||
) const;
|
||||
ensightGeoFile& os
|
||||
);
|
||||
|
||||
//- Write the point ids per poly element
|
||||
void writePolysPoints
|
||||
static void writePolysPoints
|
||||
(
|
||||
const labelUList& addr,
|
||||
const cellList& cellFaces,
|
||||
const faceList& faces,
|
||||
const labelList& faceOwner,
|
||||
ensightGeoFile&
|
||||
) const;
|
||||
ensightGeoFile& os
|
||||
);
|
||||
|
||||
//- Write the poly connectivity
|
||||
void writePolysConnectivity
|
||||
@ -267,18 +296,13 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
ensightMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const options& opts
|
||||
);
|
||||
ensightMesh(const fvMesh& mesh, const options& opts);
|
||||
|
||||
//- Construct from fvMesh with all default options
|
||||
ensightMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const IOstream::streamFormat format = IOstream::BINARY
|
||||
);
|
||||
//- Construct from fvMesh with all default options, binary output
|
||||
explicit ensightMesh(const fvMesh& mesh);
|
||||
|
||||
//- Construct from fvMesh with all default options and specified format
|
||||
ensightMesh(const fvMesh& mesh, const IOstream::streamFormat format);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -298,9 +322,12 @@ public:
|
||||
//- Ascii/Binary file output
|
||||
inline IOstream::streamFormat format() const;
|
||||
|
||||
//- Using internalMesh?
|
||||
//- Using internal?
|
||||
inline bool useInternalMesh() const;
|
||||
|
||||
//- Using boundary?
|
||||
inline bool useBoundaryMesh() const;
|
||||
|
||||
//- The volume cells (internalMesh)
|
||||
inline const ensightCells& meshCells() const;
|
||||
|
||||
@ -346,12 +373,11 @@ public:
|
||||
// Return false if already marked as expired.
|
||||
bool expire();
|
||||
|
||||
|
||||
//- Update for new mesh
|
||||
void correct();
|
||||
|
||||
|
||||
// I-O
|
||||
// Output
|
||||
|
||||
//- Write to file
|
||||
inline void write(autoPtr<ensightGeoFile>& os) const;
|
||||
@ -371,49 +397,53 @@ class ensightMesh::options
|
||||
//- Create in 'expired' mode
|
||||
bool lazy_;
|
||||
|
||||
//- Suppress patches
|
||||
bool noPatches_;
|
||||
//- Use the internal mesh
|
||||
bool internal_;
|
||||
|
||||
//- Output selected patches only
|
||||
autoPtr<wordRes> patchPatterns_;
|
||||
//- Use the boundary mesh
|
||||
bool boundary_;
|
||||
|
||||
//- Output of selected patches only
|
||||
wordRes patchPatterns_;
|
||||
|
||||
//- Output of selected faceZones
|
||||
wordRes faceZonePatterns_;
|
||||
|
||||
//- Output selected faceZones
|
||||
autoPtr<wordRes> faceZonePatterns_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct with the specified format (default is binary)
|
||||
options(IOstream::streamFormat format = IOstream::BINARY);
|
||||
//- Construct for binary output
|
||||
options();
|
||||
|
||||
//- Construct for specified format
|
||||
explicit options(IOstream::streamFormat format);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Ascii/Binary file output
|
||||
//- File output format (ascii | binary)
|
||||
IOstream::streamFormat format() const;
|
||||
|
||||
//- Lazy creation? (ie, ensightMesh starts as needsUpdate)
|
||||
bool lazy() const;
|
||||
|
||||
//- Using internalMesh?
|
||||
//- Using internal?
|
||||
bool useInternalMesh() const;
|
||||
|
||||
//- Using patches?
|
||||
bool usePatches() const;
|
||||
//- Using boundary?
|
||||
bool useBoundaryMesh() const;
|
||||
|
||||
//- Using faceZones?
|
||||
bool useFaceZones() const;
|
||||
|
||||
//- Selection of patches in effect?
|
||||
bool usePatchSelection() const;
|
||||
|
||||
//- Selection of patches - null reference if not available
|
||||
//- Selection of patches. Empty if unspecified.
|
||||
const wordRes& patchSelection() const;
|
||||
|
||||
//- Selection of faceZones - null reference if not available
|
||||
//- Selection of faceZones. Empty if unspecified.
|
||||
const wordRes& faceZoneSelection() const;
|
||||
|
||||
|
||||
@ -423,16 +453,37 @@ public:
|
||||
void reset();
|
||||
|
||||
//- Lazy creation - ensightMesh starts as needsUpdate.
|
||||
void lazy(const bool);
|
||||
void lazy(bool beLazy);
|
||||
|
||||
//- Alter the patches/no-patches state
|
||||
void noPatches(const bool);
|
||||
//- Alter the useBoundaryMesh state
|
||||
void useInternalMesh(bool on);
|
||||
|
||||
//- Alter the useBoundaryMesh state
|
||||
void useBoundaryMesh(bool on);
|
||||
|
||||
//- Define patch selection matcher
|
||||
void patchSelection(const UList<wordRe>& patterns);
|
||||
|
||||
//- Define patch selection matcher
|
||||
void patchSelection(List<wordRe>&& patterns);
|
||||
|
||||
//- Define faceZone selection matcher
|
||||
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); }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
{
|
||||
return meshCells_;
|
||||
|
||||
@ -51,20 +51,16 @@ Foam::cellShapeList& Foam::ensightMesh::renumberShapes
|
||||
}
|
||||
|
||||
|
||||
Foam::cellShapeList Foam::ensightMesh::map
|
||||
Foam::cellShapeList Foam::ensightMesh::renumberShapes
|
||||
(
|
||||
const cellShapeList& shapes,
|
||||
const labelUList& addr,
|
||||
const labelUList& pointToGlobal
|
||||
)
|
||||
{
|
||||
cellShapeList list(addr.size());
|
||||
cellShapeList list(shapes, addr);
|
||||
|
||||
forAll(addr, i)
|
||||
{
|
||||
list[i] = shapes[addr[i]];
|
||||
inplaceRenumber(pointToGlobal, list[i]);
|
||||
}
|
||||
renumberShapes(list, pointToGlobal);
|
||||
|
||||
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
|
||||
(
|
||||
const faceList& faceLst,
|
||||
@ -142,7 +176,7 @@ void Foam::ensightMesh::writeCellShapes
|
||||
{
|
||||
for (const cellShape& cellPoints : shapes)
|
||||
{
|
||||
// convert global -> local index
|
||||
// Convert global -> local index
|
||||
// (note: Ensight indices start with 1)
|
||||
|
||||
// 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
|
||||
(
|
||||
const labelUList& addr,
|
||||
const cellList& cellFaces,
|
||||
ensightGeoFile& os
|
||||
) const
|
||||
)
|
||||
{
|
||||
// Write the number of faces per element (1/line in ASCII)
|
||||
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
|
||||
(
|
||||
const labelUList& addr,
|
||||
const cellList& cellFaces,
|
||||
const faceList& faces,
|
||||
ensightGeoFile& os
|
||||
) const
|
||||
)
|
||||
{
|
||||
// Write the number of points per element face (1/line in ASCII)
|
||||
for (const label cellId : addr)
|
||||
@ -198,6 +290,8 @@ void Foam::ensightMesh::writePolysNPointsPerFace
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::ensightMesh::writePolysPoints
|
||||
(
|
||||
const labelUList& addr,
|
||||
@ -205,7 +299,7 @@ void Foam::ensightMesh::writePolysPoints
|
||||
const faceList& faces,
|
||||
const labelList& faceOwner,
|
||||
ensightGeoFile& os
|
||||
) const
|
||||
)
|
||||
{
|
||||
for (const label cellId : addr)
|
||||
{
|
||||
@ -252,10 +346,9 @@ void Foam::ensightMesh::writePolysConnectivity
|
||||
const faceList& meshFaces = mesh_.faces();
|
||||
const labelList& faceOwner = mesh_.faceOwner();
|
||||
|
||||
// Number of faces for each poly cell
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Number of faces for each poly cell
|
||||
|
||||
// Master
|
||||
writePolysNFaces(addr, cellFaces, os);
|
||||
|
||||
@ -288,6 +381,7 @@ void Foam::ensightMesh::writePolysConnectivity
|
||||
meshFaces,
|
||||
os
|
||||
);
|
||||
|
||||
// Slaves
|
||||
for (int slave=1; slave<Pstream::nProcs(); ++slave)
|
||||
{
|
||||
@ -334,6 +428,7 @@ void Foam::ensightMesh::writePolysConnectivity
|
||||
faceOwner,
|
||||
os
|
||||
);
|
||||
|
||||
// Slaves
|
||||
for (int slave=1; slave<Pstream::nProcs(); ++slave)
|
||||
{
|
||||
@ -399,7 +494,7 @@ void Foam::ensightMesh::writeCellConnectivity
|
||||
{
|
||||
const cellShapeList shapes
|
||||
(
|
||||
map
|
||||
renumberShapes
|
||||
(
|
||||
mesh_.cellShapes(),
|
||||
addr,
|
||||
@ -415,9 +510,9 @@ void Foam::ensightMesh::writeCellConnectivity
|
||||
for (int slave=1; slave<Pstream::nProcs(); ++slave)
|
||||
{
|
||||
IPstream fromSlave(Pstream::commsTypes::scheduled, slave);
|
||||
cellShapeList received(fromSlave);
|
||||
cellShapeList recv(fromSlave);
|
||||
|
||||
writeCellShapes(received, os);
|
||||
writeCellShapes(recv, os);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -559,9 +654,9 @@ void Foam::ensightMesh::writeFaceConnectivity
|
||||
for (int slave=1; slave<Pstream::nProcs(); ++slave)
|
||||
{
|
||||
IPstream fromSlave(Pstream::commsTypes::scheduled, slave);
|
||||
faceList received(fromSlave);
|
||||
faceList recv(fromSlave);
|
||||
|
||||
writeFaceSizes(received, os);
|
||||
writeFaceSizes(recv, os);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -585,9 +680,9 @@ void Foam::ensightMesh::writeFaceConnectivity
|
||||
for (int slave=1; slave<Pstream::nProcs(); ++slave)
|
||||
{
|
||||
IPstream fromSlave(Pstream::commsTypes::scheduled, slave);
|
||||
faceList received(fromSlave);
|
||||
faceList recv(fromSlave);
|
||||
|
||||
writeFaceList(received, os);
|
||||
writeFaceList(recv, os);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -661,7 +756,7 @@ void Foam::ensightMesh::writeAllPoints
|
||||
{
|
||||
os.beginPart(partId, ensightPartName);
|
||||
|
||||
// write points
|
||||
// Write points
|
||||
os.beginCoordinates(nPoints);
|
||||
|
||||
for (direction cmpt=0; cmpt < point::nComponents; ++cmpt)
|
||||
@ -671,8 +766,8 @@ void Foam::ensightMesh::writeAllPoints
|
||||
for (int slave=1; slave<Pstream::nProcs(); ++slave)
|
||||
{
|
||||
IPstream fromSlave(Pstream::commsTypes::scheduled, slave);
|
||||
scalarField received(fromSlave);
|
||||
os.writeList(received);
|
||||
scalarField recv(fromSlave);
|
||||
os.writeList(recv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,11 +27,18 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ensightMesh::options::options()
|
||||
:
|
||||
options(IOstream::streamFormat::BINARY)
|
||||
{}
|
||||
|
||||
|
||||
Foam::ensightMesh::options::options(IOstream::streamFormat format)
|
||||
:
|
||||
format_(format),
|
||||
lazy_(false),
|
||||
noPatches_(false),
|
||||
internal_(true),
|
||||
boundary_(true),
|
||||
patchPatterns_(),
|
||||
faceZonePatterns_()
|
||||
{}
|
||||
@ -53,53 +60,54 @@ bool Foam::ensightMesh::options::lazy() 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
|
||||
{
|
||||
return faceZonePatterns_.valid();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::ensightMesh::options::usePatchSelection() const
|
||||
{
|
||||
return noPatches_ ? false : patchPatterns_.valid();
|
||||
return faceZonePatterns_.size();
|
||||
}
|
||||
|
||||
|
||||
void Foam::ensightMesh::options::reset()
|
||||
{
|
||||
noPatches_ = false;
|
||||
internal_ = true;
|
||||
boundary_ = true;
|
||||
patchPatterns_.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();
|
||||
|
||||
WarningInFunction
|
||||
<< "Deactivating boundary and removing old patch selection"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,15 +117,33 @@ void Foam::ensightMesh::options::patchSelection
|
||||
const UList<wordRe>& patterns
|
||||
)
|
||||
{
|
||||
if (noPatches_)
|
||||
patchPatterns_ = wordRes(patterns);
|
||||
|
||||
if (!boundary_ && patchPatterns_.size())
|
||||
{
|
||||
patchPatterns_.clear();
|
||||
|
||||
WarningInFunction
|
||||
<< " patch selection specified, but noPatches was already active"
|
||||
<< "Ignoring patch selection, boundary is not active"
|
||||
<< 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
|
||||
)
|
||||
{
|
||||
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
|
||||
{
|
||||
if (usePatchSelection())
|
||||
{
|
||||
return *patchPatterns_;
|
||||
}
|
||||
|
||||
return wordRes::null();
|
||||
return patchPatterns_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::wordRes& Foam::ensightMesh::options::faceZoneSelection() const
|
||||
{
|
||||
if (faceZonePatterns_.valid())
|
||||
{
|
||||
return *faceZonePatterns_;
|
||||
}
|
||||
|
||||
return wordRes::null();
|
||||
return faceZonePatterns_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -295,7 +295,7 @@ bool Foam::ensightOutput::writeField
|
||||
{
|
||||
const ensightFaces& ensFaces = zoneFaces[zoneName];
|
||||
|
||||
// field (local size)
|
||||
// Field (local size)
|
||||
Field<Type> values(ensFaces.size());
|
||||
|
||||
// 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
|
||||
forAll(ensFaces, i)
|
||||
{
|
||||
label faceId = ensFaces[i];
|
||||
const label faceId = ensFaces[i];
|
||||
values[i] =
|
||||
(
|
||||
mesh.isInternalFace(faceId)
|
||||
|
||||
Reference in New Issue
Block a user