77 const Foam::UList<Foam::particleInfo>& data,
78 Type Foam::particleInfo::*
field
85 result[i] = data[i].*
field;
96template<
class CloudType>
97void Foam::ParticleZoneInfo<CloudType>::writeWriter
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();
132template<
class CloudType>
133void Foam::ParticleZoneInfo<CloudType>::writeFileHeader(Ostream&
os)
const
135 this->writeHeaderValue(
os,
"cellZone", cellZoneName_);
136 this->writeHeaderValue(
os,
"time", this->owner().time().timeOutputValue());
137 this->writeHeader(
os,
"");
138 this->writeCommented(
os,
"origID");
139 os <<
tab <<
"origProc"
151template<
class CloudType>
152bool Foam::ParticleZoneInfo<CloudType>::inZone(
const label celli)
const
154 return this->owner().mesh().cellZones()[cellZoneId_].whichCell(celli) != -1;
158template<
class CloudType>
159Foam::label Foam::ParticleZoneInfo<CloudType>::getParticleID
161 const particleInfo&
p
166 const auto& d = data_[i];
167 if ((d.origProc ==
p.origProc) && (d.origID ==
p.origID))
179template<
class CloudType>
184 const word& modelName
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;
257template<
class CloudType>
265 cellZoneName_(pzi.cellZoneName_),
266 cellZoneId_(pzi.cellZoneId_),
268 movedParticles_(pzi.movedParticles_),
276template<
class CloudType>
284template<
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();
325template<
class CloudType>
331 const typename parcelType::trackingData&
td
334 if (inZone(
p.cell()))
347 movedParticles_.append(newData);
354template<
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);
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_);
#define writeLocal(field)
Templated cloud function object base class.
CloudFunctionObject(CloudType &owner)
Construct null from owner.
virtual void postEvolve(const typename parcelType::trackingData &td)
Post-evolve hook.
virtual fileName localPath() const
Output directory.
const CloudType & owner() const
Return const access to the owner cloud.
virtual bool writeTime() const
Flag to indicate when to write a property.
const fvMesh & mesh() const
Return reference to the mesh.
particle::trackingData trackingData
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
virtual const fileName & name() const override
Read/write access to the name of the stream.
Reports cloud information for particles passing through a specified cell zone.
virtual void postEvolve(const typename parcelType::trackingData &td)
Post-evolve hook.
virtual void write()
Write.
ParticleZoneInfo(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
virtual void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve hook.
virtual bool postMove(parcelType &p, const scalar dt, const point &position0, const typename parcelType::trackingData &td)
Post-move hook.
Inter-processor communications stream.
static void listCombineGather(UList< T > &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::listGather with an in-place cop.
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
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.
static bool & parRun() noexcept
Test if this a parallel run.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static autoPtr< coordSetWriter > New(const word &writeFormat)
Return a reference to the selected writer.
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
word getWord(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get<word>(const word&, keyType::option).
const Type & value() const noexcept
Return const reference to value.
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 autoPtr< OFstream > newFileAtTime(const word &name, scalar timeValue) const
Return autoPtr to a new file for a given time.
const Time & time() const noexcept
Return time registry.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
bool getModelProperty(const word &entryName, Type &value) const
Retrieve generic property from the sub-model.
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.
void setModelProperty(const word &entryName, const Type &value)
Add generic property to 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)
#define Log_
Report write to Foam::Info if the class log switch is true.
#define WarningInFunction
Report a warning using Foam::Warning.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
DSMCCloud< dsmcParcel > CloudType
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< Type > getData(const Foam::UList< Foam::particleInfo > &data, Type Foam::particleInfo::*field)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
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 ...
vector point
Point is a vector.
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.
void operator()(particleInfo &p1, const particleInfo &p2) const
scalar isOlderThan(const particleInfo &p) const