ENH: simplify parallel/serial checks in ensight output

BUG: inadvertant type conversion in ensightFileTemplates::writeLabels
This commit is contained in:
Mark Olesen
2022-09-28 09:24:46 +02:00
parent 55f5f8774b
commit 159a7a5a38
6 changed files with 21 additions and 54 deletions

View File

@ -214,24 +214,26 @@ public:
void beginParticleCoordinates(const label nparticles);
//- Write a list of integers
// With carriage return after each value (ascii stream)
// Adds newline after each value (ascii stream)
void writeLabels(const UList<label>& list);
//- Write a list of integers
// With carriage return after each value (ascii stream)
// Adds newline after each value (ascii stream)
template<class Addr>
void writeLabels(const IndirectListBase<label, Addr>& list);
//- Write a list of integers as float values
// With carriage return after each value (ascii stream)
// Adds newline after each value (ascii stream)
void writeList(const UList<label>& field);
//- Write a list of floats as "%12.5e" or as binary
// With carriage return after each value (ascii stream)
//- Write a list of floating-point as "%12.5e" or as binary
//- (double is narrowed to float).
// Adds newline after each value (ascii stream)
void writeList(const UList<scalar>& field);
//- Write an indirect list of scalars as "%12.5e" or as binary
// With carriage return after each value (ascii stream)
//- (double is narrowed to float)
// Adds newline after each value (ascii stream)
template<class Addr>
void writeList(const IndirectListBase<scalar, Addr>& field);

View File

@ -47,7 +47,7 @@ bool Foam::ensightFile::hasUndef(const IndirectListBase<scalar, Addr>& field)
template<class Addr>
void Foam::ensightFile::writeLabels(const IndirectListBase<label, Addr>& list)
{
for (const scalar val : list)
for (const label val : list)
{
write(val);
newline();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -212,7 +212,7 @@ void Foam::ensightMesh::correct()
const word& zoneName = czNames[zoneId];
const cellZone& zn = mesh_.cellZones()[zoneId];
if (returnReduce(!zn.empty(), orOp<bool>()))
if (returnReduceOr(!zn.empty()))
{
// Ensure full mesh coverage
cellSelection.resize(mesh_.nCells());
@ -264,7 +264,7 @@ void Foam::ensightMesh::correct()
// Unzoned cells - flip selection from zoned to unzoned
cellSelection.flip();
if (returnReduce(cellSelection.any(), orOp<bool>()))
if (returnReduceOr(cellSelection.any()))
{
ensightCells& part = cellZoneParts_(internalZone);
@ -295,7 +295,7 @@ void Foam::ensightMesh::correct()
// Face exclusion based on cellZones
if (returnReduce(!cellSelection.empty(), orOp<bool>()))
if (returnReduceOr(!cellSelection.empty()))
{
// Ensure full mesh coverage
excludeFace.resize(mesh_.nFaces());

View File

@ -186,15 +186,8 @@ bool Foam::ensightOutput::Detail::writeFieldComponents
// Preliminary checks
{
bool hasField = !fld.empty();
if (parallel)
{
reduce(hasField, orOp<bool>());
}
// No field
if (!hasField) return false;
if (parallel ? returnReduceAnd(fld.empty()) : fld.empty()) return false;
}
@ -225,15 +218,8 @@ bool Foam::ensightOutput::Detail::writeFaceSubField
// No geometry
if (parallel ? !part.total() : !part.size()) return false;
bool hasField = !fld.empty();
if (parallel)
{
reduce(hasField, orOp<bool>());
}
// No field
if (!hasField) return false;
if (parallel ? returnReduceAnd(fld.empty()) : fld.empty()) return false;
}
@ -275,22 +261,15 @@ bool Foam::ensightOutput::Detail::writeFaceLocalField
// No geometry
if (parallel ? !part.total() : !part.size()) return false;
bool hasField = !fld.empty();
if (parallel)
{
reduce(hasField, orOp<bool>());
}
// No field
if (!hasField) return false;
if (parallel ? returnReduceAnd(fld.empty()) : fld.empty()) return false;
}
bool validAddressing = (part.size() == part.faceOrder().size());
if (parallel)
{
reduce(validAddressing, orOp<bool>());
Pstream::reduceOr(validAddressing);
}
if (!validAddressing)
@ -341,15 +320,8 @@ bool Foam::ensightOutput::writeField
// No geometry
if (parallel ? !part.total() : !part.size()) return false;
bool hasField = !fld.empty();
if (parallel)
{
reduce(hasField, orOp<bool>());
}
// No field
if (!hasField) return false;
if (parallel ? returnReduceAnd(fld.empty()) : fld.empty()) return false;
}
@ -391,15 +363,8 @@ bool Foam::ensightOutput::writeField
// No geometry
if (parallel ? !part.total() : !part.size()) return false;
bool hasField = !fld.empty();
if (parallel)
{
reduce(hasField, orOp<bool>());
}
// No field
if (!hasField) return false;
if (parallel ? returnReduceAnd(fld.empty()) : fld.empty()) return false;
}

View File

@ -99,7 +99,7 @@ Foam::label Foam::ensightCells::meshPointMapppings
if (parallel)
{
Foam::reduce(allCells, andOp<bool>());
Pstream::reduceAnd(allCells);
if (allCells)
{

View File

@ -600,7 +600,7 @@ bool Foam::vtk::fileWriter::writeProcIDs(const label nValues)
this->endDataArray();
// MPI barrier
return parallel_ ? returnReduce(good, orOp<bool>()) : good;
return parallel_ ? returnReduceOr(good) : good;
}