81 Field<Type> result(data.
size());
85 result[i] = data[i].*
field;
96 template<
class CloudType>
99 const UList<particleInfo>& data
106 getData(data, &particleInfo::position),
110 writerPtr_->open(coords, this->baseTimeDir() /
"zoneParticles");
111 writerPtr_->beginTime(this->owner().time());
114 #define writeLocal(field) \ 115 writerPtr_->write(#field, getData(data, &particleInfo::field)); 127 writerPtr_->endTime();
132 template<
class CloudType>
135 this->writeHeaderValue(
os,
"cellZone", cellZoneName_);
136 this->writeHeaderValue(
os,
"time", this->owner().time().timeOutputValue());
138 this->writeCommented(
os,
"origID");
139 os <<
tab <<
"origProc" 151 template<
class CloudType>
154 return this->owner().mesh().cellZones()[cellZoneId_].whichCell(celli) != -1;
158 template<
class CloudType>
161 const particleInfo&
p 166 const auto& d = data_[i];
167 if ((d.origProc ==
p.origProc) && (d.origID ==
p.origID))
179 template<
class CloudType>
184 const word& modelName
188 functionObjects::writeFile
194 cellZoneName_(this->coeffDict().getWord(
"cellZone")),
216 cellZoneId_ = cellZones.findZoneID(cellZoneName_);
217 if (cellZoneId_ == -1)
220 <<
"Unable to find cellZone " << cellZoneName_
221 <<
". Available cellZones are:" << cellZones.names()
225 Info<<
" Processing cellZone" << cellZoneName_ <<
" with id " 226 << cellZoneId_ <<
endl;
240 Info<<
" Restarting with " << data_.size()
241 <<
" particles" <<
endl;
246 <<
"Case restarted with a different number of processors." 247 <<
" Restarting particle statistics." <<
endl;
257 template<
class CloudType>
260 const ParticleZoneInfo<CloudType>& pzi
265 cellZoneName_(pzi.cellZoneName_),
266 cellZoneId_(pzi.cellZoneId_),
268 movedParticles_(pzi.movedParticles_),
269 maxIDs_(Pstream::nProcs()),
276 template<
class CloudType>
279 const typename parcelType::trackingData&
td 284 template<
class CloudType>
287 const typename parcelType::trackingData&
td 291 <<
" Cell zone = " << cellZoneName_ <<
nl 292 <<
" Contributions = " 296 if (!this->writeTime())
301 for (
const auto&
p : movedParticles_)
303 const label
id = getParticleID(
p);
309 maxIDs_[
p.origProc] =
max(maxIDs_[
p.origProc],
p.origID);
318 movedParticles_.
clear();
325 template<
class CloudType>
331 const typename parcelType::trackingData&
td 334 if (inZone(
p.cell()))
347 movedParticles_.append(newData);
354 template<
class CloudType>
357 autoPtr<OFstream> osPtr =
361 this->owner().time().timeOutputValue()
372 DynamicList<particleInfo> globalParticles(
n);
375 forAll(procParticles, proci)
377 procParticles[proci].resize(allMaxIDs[proci] + 1);
381 for (
const auto& d : data_)
383 procParticles[d.origProc][d.origID] = d;
386 for (
auto& particles : procParticles)
389 for (
const auto&
p : particles)
393 globalParticles.append(
p);
401 writeWriter(globalParticles);
408 for (
const auto&
p : globalParticles)
417 Log_<<
" Number of particles = " << nData <<
nl 420 this->setModelProperty(
"data", globalParticles);
421 this->setModelProperty(
"maxIDs", allMaxIDs);
426 this->setModelProperty(
"data", List<particleInfo>());
427 this->setModelProperty(
"maxIDs",
labelList());
437 for (
const auto&
p : data_)
442 Log_<<
" Number of particles = " << data_.size() <<
nl 445 this->setModelProperty(
"data", data_);
446 this->setModelProperty(
"maxIDs", maxIDs_);
virtual void postEvolve(const typename parcelType::trackingData &td)
Post-evolve hook.
static void listCombineGather(UList< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements.
List< scalar > scalarList
List of scalar.
const Type & value() const noexcept
Return const reference to value.
void size(const label n)
Older name for setAddressableSize.
DSMCCloud< dsmcParcel > CloudType
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...
virtual const fileName & name() const override
Read/write access to the name of the stream.
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
ParticleZoneInfo(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
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.
static bool & parRun() noexcept
Test if this a parallel run.
constexpr char tab
The tab '\t' character(0x09)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
virtual void postEvolve(const typename parcelType::trackingData &td)
Post-evolve hook.
const CloudType & owner() const
Return const access to the owner cloud.
#define forAll(list, i)
Loop across all elements in list.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
static autoPtr< coordSetWriter > New(const word &writeFormat)
Return a reference to the selected writer.
virtual void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve hook.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
#define Log_
Report write to Foam::Info if the class log switch is true.
#define writeLocal(field)
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from Foam::string.
const Time & time() const noexcept
Return time registry.
Inter-processor communications stream.
virtual void write()
Write.
scalar isOlderThan(const particleInfo &p) const
bool getModelProperty(const word &entryName, Type &value) const
Retrieve generic property from the sub-model.
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
word getWord(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< word >(const word&, keyType::option)
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
virtual bool postMove(parcelType &p, const scalar dt, const point &position0, const typename parcelType::trackingData &td)
Post-move hook.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
Reports cloud information for particles passing through a specified cell zone.
const fvMesh & mesh() const
Return reference to the mesh.
#define WarningInFunction
Report a warning using Foam::Warning.
#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.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.
Field< Type > getData(const Foam::UList< Foam::particleInfo > &data, Type Foam::particleInfo::*field)
Templated base class for dsmc cloud.
Templated cloud function object base class.
void operator()(particleInfo &p1, const particleInfo &p2) const
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements. After completion all processors have the same data.
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)