34 template<
class LabelListListType>
38 const LabelListListType& listOfLists,
39 const label pointOffset
42 const label off = (pointOffset + 1);
46 for (
const label pointi : listOfLists[listi])
48 os.write(pointi + off);
55 template<
template<
typename>
class FieldContainer,
class Type>
58 const FieldContainer<Type>&
input,
66 <<
"Component buffer too small: " 71 auto iter = cmptBuffer.
begin();
73 if (std::is_same<
float,
typename pTraits<Type>::cmptType>::value)
76 for (
const Type& val :
input)
85 for (
const Type& val :
input)
94 template<
template<
typename>
class FieldContainer,
class Type>
100 const FieldContainer<Type>&
fld,
104 parallel = parallel && Pstream::parRun();
106 const label localSize =
fld.size();
112 ? globalIndex(globalIndex::gatherOnly{}, localSize)
113 : globalIndex(globalIndex::gatherNone{}, localSize)
116 if (Pstream::master() &&
key)
118 os.writeKeyword(
key);
121 if (Pstream::master())
129 const label minSize(
max(localSize,
procAddr.maxSize()));
132 const label maxSize =
143 scratch.resize_nocopy
145 max(
max(minSize, maxSize), scratch.capacity())
148 if (Pstream::master() &&
debug > 1)
157 <<
" buf-size:" << scratch.size() <<
"/" << scratch.capacity()
158 <<
" any-proc:" << minSize
159 <<
" off-proc:" << (
procAddr.totalSize() - localSize) <<
endl;
161 Info<<
"proc-sends: (";
163 label nPending = localSize;
165 Info<< (localSize ?
'0' :
'_');
168 for (
const label proci :
procAddr.subProcs())
170 const label procSize =
procAddr.localSize(proci);
174 if (nPending + procSize > scratch.size())
186 nPending += procSize;
195 const direction cmpt = ensightPTraits<Type>::componentOrder[d];
199 label nPending = localSize;
202 for (
const label proci :
procAddr.subProcs())
204 const label procSize =
procAddr.localSize(proci);
208 if (nPending + procSize > scratch.size())
211 os.writeList(SubList<float>(scratch, nPending));
215 SubList<float> slot(scratch, procSize, nPending);
216 nPending += procSize;
220 UPstream::commsTypes::scheduled,
231 os.writeList(SubList<float>(scratch, nPending));
235 else if (parallel && localSize)
237 scratch.resize_nocopy(localSize);
241 const direction cmpt = ensightPTraits<Type>::componentOrder[d];
247 UPstream::commsTypes::scheduled,
248 UPstream::masterNo(),
249 scratch.cdata_bytes(),
257 template<
template<
typename>
class FieldContainer>
262 const word& partName,
264 const FieldContainer<Foam::point>&
fld,
268 if (Pstream::master())
270 os.beginPart(partId, partName);
274 bool ok = (Pstream::master() && (
nPoints > 0));
277 Pstream::broadcast(ok);
307 parallel = parallel && Pstream::parRun();
323 if (Pstream::master())
328 for (
int typei=0; typei < ensightFaces::nTypes; ++typei)
330 const auto etype = ensightFaces::elemType(typei);
333 if (parallel ? part.
total(etype) : part.
size(etype))
340 SubField<Type>(
fld, part.
range(etype)),
360 parallel = parallel && Pstream::parRun();
380 Pstream::reduceOr(validAddressing);
383 if (!validAddressing)
386 <<
"Called without faceOrder having been set" <<
nl 391 if (Pstream::master())
396 for (
int typei=0; typei < ensightFaces::nTypes; ++typei)
398 const auto etype = ensightFaces::elemType(typei);
401 if (parallel ? part.
total(etype) : part.
size(etype))
430 parallel = parallel && Pstream::parRun();
446 if (Pstream::master())
451 for (
int typei=0; typei < ensightCells::nTypes; ++typei)
453 const auto etype = ensightCells::elemType(typei);
456 if (parallel ? part.
total(etype) : part.
size(etype))
463 UIndirectList<Type>(
fld, part.
cellIds(etype)),
483 parallel = parallel && Pstream::parRun();
499 if (Pstream::master())
504 for (
int typei=0; typei < ensightFaces::nTypes; ++typei)
506 const auto etype = ensightFaces::elemType(typei);
509 if (parallel ? part.
total(etype) : part.
size(etype))
516 UIndirectList<Type>(
fld, part.
faceIds(etype)),
A variant of OFstream with specialised handling for Ensight writing of strings, integers and floats (...
void size(const label n)
Older name for setAddressableSize.
float narrowFloat(const double val)
Type narrowing from double to float.
label total() const noexcept
Same as totalSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A variant of ensightFile (Ensight writing) that includes the extra geometry file header information...
labelRange range(const elemType etype) const
Processor-local offset/size of element type.
Sorting/classification of faces (2D) into corresponding ensight types.
bool writeFaceSubField(ensightOutput::floatBufferType &scratch, ensightFile &os, const Field< Type > &fld, const ensightFaces &part, bool parallel)
Write a sub-field of faces values as an indirect list, using the sub-list sizing information from ens...
const labelList & faceOrder() const noexcept
Processor-local face order (where applicable)
bool writeFaceLocalField(ensightOutput::floatBufferType &scratch, ensightFile &os, const Field< Type > &fld, const ensightFaces &part, bool parallel)
Write a field of faces values as an indirect list, using the face order from ensightFaces.
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
bool writeField(ensightOutput::floatBufferType &scratch, ensightFile &os, const Field< Type > &fld, const ensightCells &part, bool parallel)
Write a field of cell values as an indirect list, using the cell ids from ensightCells.
#define forAll(list, i)
Loop across all elements in list.
void copyComponent(const FieldContainer< Type > &input, const direction cmpt, UList< float > &cmptBuffer)
Copy specified field component into a scalar buffer. Works for various lists types. Must be adequately sized before calling.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
label total() const noexcept
Same as totalSize()
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
void writeFieldComponents(ensightOutput::floatBufferType &scratch, ensightFile &os, const char *key, const FieldContainer< Type > &fld, bool parallel)
Write field content (component-wise) for the given ensight element type.
Generic templated field type.
label size(const elemType etype) const
Processor-local size of the specified element type.
Sorting/classification of cells (3D) into corresponding ensight element types.
static Istream & input(Istream &is, IntRange< T > &range)
label size(const elemType etype) const
Processor-local size of the specified element type.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
DynamicList< float > floatBufferType
The list type used for component-wise buffering.
const labelList & faceIds() const noexcept
Processor-local face ids of all elements.
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
label index() const noexcept
The index in a list (0-based)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void writeLabelListList(ensightGeoFile &os, const labelUList &offsets, const labelUList &values, const label pointOffset)
Write CompactListList<label> by components.
globalIndex procAddr(aMesh.nFaces())
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
messageStream Info
Information stream (stdout output on master, null elsewhere)
int maxChunk_
Upper limit on number of items for bundled off-processor field transfers. The component-wise transfer...
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
bool writeCoordinates(ensightGeoFile &os, const label partId, const word &partName, const label nPoints, const FieldContainer< Foam::point > &fld, bool parallel)
Write coordinates (component-wise) for the given part.
const labelList & cellIds() const
Processor-local cell ids of all elements.