46 os <<
tab << binPoints[pointi].x();
53 os <<
tab << binPoints[pointi].y();
60 os <<
tab << binPoints[pointi].z();
67 for (label i = 0; i <
nBin_; ++i)
94 const word& fieldName = fieldNames_[fieldi];
98 const VolFieldType* fieldPtr = mesh_.findObject<VolFieldType>(fieldName);
105 if (writeToFile() && !writtenHeader_)
107 writeFileHeader<Type>(filePtrs_[fieldi]);
110 const VolFieldType&
fld = *fieldPtr;
123 if (decomposePatchValues_)
128 List<List<Type>> data(nField);
129 for (
auto& binList : data)
131 binList.resize(nBin_,
Zero);
134 const auto whichBin = [&](
const scalar d) -> label
136 if (d >= binLimits_.min() && d <= binLimits_.max())
141 (d - binLimits_.min())/binWidth_
143 return min(
max(bini, 0), nBin_ - 1);
152 for (
const label zonei : cellZoneIDs_)
154 const cellZone& cZone = mesh_.cellZones()[zonei];
156 for (
const label celli : cZone)
158 const label bini = whichBin(mesh_.C()[celli] & binDir_);
162 data[0][bini] +=
fld[celli];
167 for (
const label patchi : patchIDs_)
169 const polyPatch&
pp = mesh_.boundaryMesh()[patchi];
170 const vectorField np(mesh_.boundary()[patchi].nf());
172 const auto&
pts =
pp.faceCentres();
178 const label bini = whichBin(
pts[facei] & binDir_);
182 const Type& v =
fld.boundaryField()[patchi][facei];
184 if (!decomposePatchValues(data, bini, v, np[facei]))
192 for (
auto& binList : data)
194 reduce(binList, sumOp<List<Type>>());
199 writeBinnedData(data, filePtrs_[fieldi]);
virtual void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Output to file stream as an OSstream, normally using std::ofstream for the actual output...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool decomposePatchValues_
Decompose patch values into normal and tangential components.
label nBin_
Total number of bins.
constexpr char tab
The tab '\t' character(0x09)
Generic GeometricField class.
#define forAll(list, i)
Loop across all elements in list.
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
const T & min() const noexcept
The min value (first)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
void writeHeaderValue(Ostream &os, const string &property, const Type &value) const
Write a (commented) header property and value pair.
OBJstream os(runTime.globalPath()/outputName)
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))
const T & max() const noexcept
The max value (second)
Field< vector > vectorField
Specialisation of Field<T> for vector.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static constexpr const zero Zero
Global zero (0)
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.