35template<
class CloudType>
36void Foam::ParticleHistogram<CloudType>::writeFileHeader(Ostream&
os)
const
38 this->writeHeaderValue(
os,
"nBin", nBins_);
39 this->writeHeaderValue(
os,
"min", range_.min());
40 this->writeHeaderValue(
os,
"max", range_.max());
41 this->writeHeader(
os,
"");
42 this->writeCommented(
os,
"dEdge1");
44 <<
tab <<
"nParticles"
45 <<
tab <<
"nParticlesCumulative"
52template<
class CloudType>
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();
111 dParticles_.resize(sz);
112 nParticles_.resize(sz);
116template<
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_)
137template<
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());
167template<
class CloudType>
171 const typename parcelType::trackingData&
td
174 if (collector_.isPatch())
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());
209template<
class CloudType>
230 accessOp<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();
Various functions to operate on Lists.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Templated cloud function object base class.
CloudFunctionObject(CloudType &owner)
Construct null from owner.
virtual fileName localPath() const
Output directory.
const CloudType & owner() const
Return const access to the owner cloud.
const fvMesh & mesh() const
Return reference to the mesh.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool good() const
Range is non-inverted.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
Computes a histogram for the distribution of particle diameters and corresponding number of particles...
ParticleHistogram(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
virtual void write()
Write post-processing info.
virtual bool postFace(const parcelType &p, const typename parcelType::trackingData &td)
Post-face hook.
virtual bool postPatch(const parcelType &p, const polyPatch &pp, const typename parcelType::trackingData &td)
Post-patch hook.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
@ gatherList
gatherList [manual algorithm]
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
T & ref()
Return reference to the managed object without nullptr checking.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat")
Construct from objectRegistry, prefix, fileName.
virtual bool writeToFile() const
Flag to allow writing to file.
virtual autoPtr< OFstream > newFileAtTime(const word &name, scalar timeValue) const
Return autoPtr to a new file for a given time.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
A patch is a list of labels that address the faces in the global face list.
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
const dictionary & dict() const
Return const access to the cloud dictionary.
const word & modelName() const
Return const access to the name of the sub-model.
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
AccessType combine(const UList< T > &lists, AccessOp aop=accessOp< T >())
Combines sub-lists into a single list.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
List< word > wordList
List of word.
DSMCCloud< dsmcParcel > CloudType
List< label > labelList
A List of labels.
MinMax< label > labelMinMax
A label min/max range.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with faceZone content on a polyMesh.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
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).
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< scalar > scalarList
List of scalar.
constexpr char nl
The newline '\n' character (0x0a).
constexpr char tab
The tab '\t' character(0x09).
#define forAll(list, i)
Loop across all elements in list.
Object access operator or list access operator (default is pass-through).