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,
68 <<
"Component buffer too small: " 73 auto iter = cmptBuffer.
begin();
75 for (
const Type& val :
input)
77 if constexpr (std::is_same_v<float, cmptType>)
92 template<
template<
typename>
class FieldContainer,
class Type>
98 const FieldContainer<Type>&
fld,
102 parallel = parallel && Pstream::parRun();
104 const label localSize =
fld.size();
111 : globalIndex(globalIndex::gatherNone{}, localSize)
114 if (Pstream::master() &&
key)
116 os.writeKeyword(
key);
119 if (Pstream::master())
127 const label minSize(
max(localSize,
procAddr.maxSize()));
130 const label maxSize =
146 if (Pstream::master() &&
debug > 1)
155 <<
" buf-size:" << scratch.
size() <<
"/" << scratch.
capacity()
156 <<
" any-proc:" << minSize
157 <<
" off-proc:" << (
procAddr.totalSize() - localSize) <<
endl;
159 Info<<
"proc-sends: (";
161 label nPending = localSize;
163 Info<< (localSize ?
'0' :
'_');
166 for (
const label proci :
procAddr.subProcs())
168 const label procSize =
procAddr.localSize(proci);
172 if (nPending + procSize > scratch.
size())
184 nPending += procSize;
193 const direction cmpt = ensightPTraits<Type>::componentOrder[d];
197 label nPending = localSize;
200 for (
const label proci :
procAddr.subProcs())
202 const label procSize =
procAddr.localSize(proci);
206 if (nPending + procSize > scratch.
size())
209 os.writeList(SubList<float>(scratch, nPending));
213 SubList<float> slot(scratch, procSize, nPending);
214 nPending += procSize;
218 UPstream::commsTypes::scheduled,
228 os.writeList(SubList<float>(scratch, nPending));
232 else if (parallel && localSize)
238 const direction cmpt = ensightPTraits<Type>::componentOrder[d];
244 UPstream::commsTypes::scheduled,
245 UPstream::masterNo(),
253 template<
template<
typename>
class FieldContainer>
258 const word& partName,
260 const FieldContainer<Foam::point>&
fld,
264 if (Pstream::master())
266 os.beginPart(partId, partName);
270 bool ok = (Pstream::master() && (
nPoints > 0));
303 parallel = parallel && Pstream::parRun();
319 if (Pstream::master())
324 for (
int typei=0; typei < ensightFaces::nTypes; ++typei)
326 const auto etype = ensightFaces::elemType(typei);
329 if (parallel ? part.
total(etype) : part.
size(etype))
336 SubField<Type>(
fld, part.
range(etype)),
356 parallel = parallel && Pstream::parRun();
376 Pstream::reduceOr(validAddressing);
379 if (!validAddressing)
382 <<
"Called without faceOrder having been set" <<
nl 387 if (Pstream::master())
392 for (
int typei=0; typei < ensightFaces::nTypes; ++typei)
394 const auto etype = ensightFaces::elemType(typei);
397 if (parallel ? part.
total(etype) : part.
size(etype))
426 parallel = parallel && Pstream::parRun();
442 if (Pstream::master())
447 for (
int typei=0; typei < ensightCells::nTypes; ++typei)
449 const auto etype = ensightCells::elemType(typei);
452 if (parallel ? part.
total(etype) : part.
size(etype))
459 UIndirectList<Type>(
fld, part.
cellIds(etype)),
479 parallel = parallel && Pstream::parRun();
495 if (Pstream::master())
500 for (
int typei=0; typei < ensightFaces::nTypes; ++typei)
502 const auto etype = ensightFaces::elemType(typei);
505 if (parallel ? part.
total(etype) : part.
size(etype))
512 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 traits class, which is primarily used for primitives and vector-space.
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.
Dispatch tag: Construct 'one-sided' from local sizes, using gather but no broadcast.
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 broadcast(Type *values, int count, MPI_Datatype datatype, const int communicator)
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.
label capacity() const noexcept
Size of the underlying storage.
#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)
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
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.
auto key(const Type &t) -> std::enable_if_t< std::is_enum_v< Type >, std::underlying_type_t< Type > >
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
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())
messageStream Info
Information stream (stdout output on master, null elsewhere)
void resize_nocopy(const label len)
Alter addressable list size, allocating new space if required without necessarily recovering old cont...
int maxChunk_
Upper limit on number of items for bundled off-processor field transfers. The component-wise transfer...
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.