35 template<
class CloudType>
38 this->writeHeaderValue(
os,
"nBin", nBins_);
39 this->writeHeaderValue(
os,
"min", range_.min());
40 this->writeHeaderValue(
os,
"max", range_.max());
42 this->writeCommented(
os,
"dEdge1");
44 <<
tab <<
"nParticles" 45 <<
tab <<
"nParticlesCumulative" 52 template<
class CloudType>
61 functionObjects::writeFile
67 collector_(this->coeffDict(), owner.
mesh()),
70 this->coeffDict().template getCheck<label>(
"nBins",
labelMinMax::ge(1))
72 maxStoredParcels_(this->coeffDict().getScalar(
"maxStoredParcels")),
75 this->coeffDict().getScalar(
"min"),
76 this->coeffDict().getScalar(
"max")
78 binEdges_(nBins_ + 1),
79 nParticlesCumulative_(),
88 <<
"Invalid histogram range: " << range_
92 if (maxStoredParcels_ <= 0)
95 <<
"maxStoredParcels = " << maxStoredParcels_
96 <<
", cannot be equal to or less than zero" 101 binEdges_[0] = range_.
min();
102 const scalar
delta = range_.
span()/scalar(nBins_);
103 for (label i = 0; i < nBins_; ++i)
105 const scalar next = range_.
min() + (i+1)*
delta;
106 binEdges_[i+1] = next;
109 const label sz = collector_.
size();
110 nParticlesCumulative_ = List<scalarList>(sz,
scalarList(nBins_,
Zero));
111 dParticles_.resize(sz);
112 nParticles_.resize(sz);
116 template<
class CloudType>
124 collector_(ph.collector_),
126 maxStoredParcels_(ph.maxStoredParcels_),
128 binEdges_(ph.binEdges_),
129 nParticlesCumulative_(ph.nParticlesCumulative_),
130 dParticles_(ph.dParticles_),
131 nParticles_(ph.nParticles_)
137 template<
class CloudType>
142 const typename parcelType::trackingData&
td 145 if (!collector_.isPatch())
150 const label patchi =
pp.index();
151 const label localPatchi = collector_.IDs().find(patchi);
156 && dParticles_[localPatchi].size() < maxStoredParcels_
159 dParticles_[localPatchi].append(
p.d());
160 nParticles_[localPatchi].append(
p.nParticle());
167 template<
class CloudType>
171 const typename parcelType::trackingData&
td 174 if (collector_.isPatch())
180 const List<boundBox>& BBs = collector_.BBs();
185 if (!BBs[i].contains(
p.position()))
191 const label zonei = IDs[i];
192 const label localFacei = fzm[zonei].find(
p.face());
197 && dParticles_[i].size() < maxStoredParcels_
200 dParticles_[i].append(
p.d());
201 nParticles_[i].append(
p.nParticle());
209 template<
class CloudType>
227 globalDiameters = ListListOps::combine<scalarList>
230 accessOp<scalarList>()
234 globalParticles = ListListOps::combine<scalarList>
237 accessOp<scalarList>()
242 const scalar
delta = range_.span()/scalar(nBins_);
243 forAll(globalDiameters, j)
245 const label bini = (globalDiameters[j] - range_.min())/
delta;
246 if (bini >= 0 && bini < nBins_)
248 nParticles[bini] += globalParticles[j];
249 nParticlesCumulative_[i][bini] += globalParticles[j];
253 if (this->writeToFile())
255 autoPtr<OFstream> osPtr = this->newFileAtTime
258 this->owner().time().value()
260 OFstream&
os = osPtr.ref();
266 os << binEdges_[j] <<
tab 267 << binEdges_[j + 1] <<
tab 268 << nParticles[j] <<
tab 269 << nParticlesCumulative_[i][j]
275 dParticles_[i].clearStorage();
276 nParticles_[i].clearStorage();
List< scalar > scalarList
List of scalar.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
ParticleHistogram(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
static void writeHeader(Ostream &os, const word &fieldName)
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
constexpr char nl
The newline '\n' character (0x0a)
virtual bool postFace(const parcelType &p, const typename parcelType::trackingData &td)
Post-face hook.
A min/max value pair with additional methods. In addition to conveniently storing values...
virtual bool postPatch(const parcelType &p, const polyPatch &pp, const typename parcelType::trackingData &td)
Post-patch hook.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void gatherList(const UList< commsStruct > &comms, UList< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
constexpr char tab
The tab '\t' character(0x09)
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
bool good() const
Range is non-inverted.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
virtual void write()
Write post-processing info.
Computes a histogram for the distribution of particle diameters and corresponding number of particles...
const T & min() const noexcept
The min value (first)
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
A class for handling words, derived from Foam::string.
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
OBJstream os(runTime.globalPath()/outputName)
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
List< word > wordList
List of word.
const fvMesh & mesh() const
Return reference to the mesh.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
T span() const
The min to max span. Zero if the range is invalid.
List< label > labelList
A List of labels.
A patch is a list of labels that address the faces in the global face list.
Templated base class for dsmc cloud.
Templated cloud function object base class.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)