33template<
class CloudType>
37 { interactionType::STICK,
"stick" },
38 { interactionType::ESCAPE,
"escape" },
45template<
class CloudType>
49 const label localZonei
52 if (!faceZoneBBs_[localZonei].contains(
p.position()))
58 if ((
p.d() > dMax_) || (
p.d() < dMin_))
67template<
class CloudType>
70 const fvMesh&
mesh = this->owner().mesh();
71 const faceZoneMesh& fzm =
mesh.faceZones();
73 Log_<< type() <<
" output:" << nl;
76 const label nZones = faceZoneIDs_.size();
77 labelList npe0(nZones, Zero);
78 labelList nps0(nZones, Zero);
79 labelList npr0(nZones, Zero);
81 this->getModelProperty(
"nEscape", npe0);
82 this->getModelProperty(
"nStick", nps0);
83 this->getModelProperty(
"nRebound", npr0);
86 labelList npe(
returnReduce(nEscapeParticles_, sumOp<labelList>()));
87 labelList nps(
returnReduce(nStickParticles_, sumOp<labelList>()));
88 labelList npr(
returnReduce(nReboundParticles_, sumOp<labelList>()));
91 npe[i] = npe[i] + npe0[i];
92 nps[i] = nps[i] + nps0[i];
93 npr[i] = npr[i] + npr0[i];
100 const label zonei = faceZoneIDs_[i];
101 Log_<<
" Zone : " << fzm[zonei].name() <<
nl
102 <<
" Escape : " << npe[i] <<
nl
103 <<
" Stick : " << nps[i] <<
nl
104 <<
" Rebound : " << npr[i] <<
nl;
106 if (this->writeToFile())
108 auto&
os = filePtrs_[i];
110 writeCurrentTime(
os);
113 os <<
tab << scalar(npe[i])
114 <<
tab << scalar(nps[i])
115 <<
tab << scalar(npr[i])
122 this->setModelProperty(
"nEscape", npe);
123 this->setModelProperty(
"nStick", nps);
124 this->setModelProperty(
"nRebound", npr);
126 nEscapeParticles_ = Zero;
127 nStickParticles_ = Zero;
134template<
class CloudType>
139 const word& modelName
152 faceZoneInteraction_(),
156 nReboundParticles_(),
157 dMin_(this->coeffDict().getOrDefault(
"dMin", -GREAT)),
158 dMax_(this->coeffDict().getOrDefault(
"dMax", GREAT))
165 filePtrs_.setSize(nameAndInteraction.
size());
167 faceZoneBBs_.setSize(nameAndInteraction.
size());
168 faceZoneInteraction_.
setSize(nameAndInteraction.
size());
176 for (
const auto& zoneInfo : nameAndInteraction)
178 const word& zoneName = zoneInfo.first();
187 Info<<
" " << zoneName <<
" faces: " << nFaces <<
nl;
190 faceZoneInteraction_[nZone] =
194 auto& bb = faceZoneBBs_[nZone];
195 for (
const label facei : fz)
197 for (
const label fpi : faces[facei])
222 filePtrs_[nZone] <<
nl;
229 <<
"Unable to find faceZone " << zoneName
230 <<
" - removing" <<
endl;
235 filePtrs_.setSize(nZone);
236 faceZoneBBs_.setSize(nZone);
237 faceZoneInteraction_.
setSize(nZone);
238 nEscapeParticles_.setSize(nZone,
Zero);
239 nStickParticles_.setSize(nZone,
Zero);
240 nReboundParticles_.setSize(nZone,
Zero);
244template<
class CloudType>
252 faceZoneIDs_(pfi.faceZoneIDs_),
253 faceZoneBBs_(pfi.faceZoneBBs_),
255 nEscapeParticles_(pfi.nEscapeParticles_),
256 nStickParticles_(pfi.nStickParticles_),
257 nReboundParticles_(pfi.nReboundParticles_),
265template<
class CloudType>
269 const typename parcelType::trackingData&
td
272 bool keepParticle =
true;
278 if (!processParticle(
p, i))
283 const label zonei = faceZoneIDs_[i];
285 const label localFacei = fzm[zonei].find(
p.face());
287 if (localFacei != -1)
289 const label facei = fzm[zonei][localFacei];
291 switch (faceZoneInteraction_[i])
293 case interactionType::ESCAPE:
295 keepParticle =
false;
296 ++nEscapeParticles_[i];
299 case interactionType::STICK:
301 auto& pRef =
const_cast<parcelType&
>(
p);
304 ++nStickParticles_[i];
307 case interactionType::REBOUND:
310 const auto n =
f.unitNormal(this->owner().
mesh().
points());
312 auto& pRef =
const_cast<parcelType&
>(
p);
313 pRef.U() -= 2*
n*(pRef.U() &
n);
314 ++nReboundParticles_[i];
320 <<
"Unhandled enumeration "
321 << interactionTypeNames_[faceZoneInteraction_[i]]
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.
particle::trackingData trackingData
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Face zone-based particle interactions.
static const Enum< interactionType > interactionTypeNames_
Names for the interaction types.
FaceInteraction(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
@ STICK
particles stick to the faceZone faces
@ ESCAPE
particles escape/are removed
@ REBOUND
particles rebound from the faceZone faces
bool processParticle(const parcelType &p, const label localZonei)
Return true if this particle will be assessed.
void write()
Write post-processing info.
virtual bool postFace(const parcelType &p, const typename parcelType::trackingData &td)
Post-face hook.
CloudType::parcelType parcelType
Convenience typedef for parcel type.
const word & name() const noexcept
Return the object name.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void setSize(label n)
Alias for resize().
void size(const label n)
Older name for setAddressableSize.
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A subset of mesh faces organised as a primitive patch.
A face is a list of labels corresponding to mesh vertices.
virtual autoPtr< OFstream > newFileAtStartTime(const word &name) const
Return autoPtr to a new file using the simulation start time.
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
void writeHeaderValue(Ostream &os, const string &property, const Type &value) const
Write a (commented) header property and value pair.
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 void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
virtual void writeCurrentTime(Ostream &os) const
Write the current time to stream.
virtual bool writeToFile() const
Flag to allow writing to file.
Mesh data needed to do the Finite Volume discretisation.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
Lookup type of boundary radiation properties.
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 FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const labelIOList & zoneIDs
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
return returnReduce(nRefine-oldNRefine, sumOp< label >())
#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.
DSMCCloud< dsmcParcel > CloudType
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with faceZone content on a polyMesh.
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.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
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.