36template<
class CloudType>
37void Foam::RemoveParcels<CloudType>::makeLogFile
50 if (Pstream::master())
53 mkDir(this->writeTimeDir());
61 this->writeTimeDir()/(
type() +
'_' + zoneName +
".dat")
66 <<
"# Source : " <<
type() <<
nl
67 <<
"# Face zone : " << zoneName <<
nl
68 <<
"# Faces : " << nFaces <<
nl
69 <<
"# Area : " << totArea <<
nl
70 <<
"# Time" <<
tab <<
"nParcels" <<
tab <<
"mass" <<
endl;
78template<
class CloudType>
81 const typename parcelType::trackingData&
td
84 Log_<< this->modelName() <<
" output:" << nl;
86 const fvMesh&
mesh = this->owner().mesh();
87 const faceZoneMesh& fzm =
mesh.faceZones();
91 const word& zoneName = fzm[faceZoneIDs_[i]].name();
93 scalar zoneMass =
returnReduce(mass_[i], sumOp<scalar>());
94 label zoneNParcels =
returnReduce(nParcels_[i], sumOp<label>());
96 Log_<<
" faceZone " << zoneName
97 <<
": removed " << zoneNParcels
98 <<
" parcels with mass " << zoneMass
106template<
class CloudType>
109 const fvMesh&
mesh = this->owner().mesh();
110 const Time& time =
mesh.time();
113 List<scalar> allZoneMass(faceZoneIDs_.size(), 0.0);
114 List<label> allZoneNParcels(faceZoneIDs_.size(), 0);
118 allZoneMass[i] =
returnReduce(mass_[i], sumOp<scalar>());
119 allZoneNParcels[i] =
returnReduce(nParcels_[i], sumOp<label>());
121 if (outputFilePtr_.set(i))
123 OFstream&
os = outputFilePtr_[i];
124 os << time.timeName() << token::TAB
125 << allZoneNParcels[i] << token::TAB
126 << allZoneMass[i] << endl;
141 this->setModelProperty(
"mass", allZoneMass);
148template<
class CloudType>
153 const word& modelName
160 typeId_(this->coeffDict().template getOrDefault<label>(
"parcelType", -1)),
161 logToFile_(this->coeffDict().getBool(
"log")),
162 resetOnWrite_(this->coeffDict().getBool(
"resetOnWrite")),
163 resetOnStart_(this->coeffDict().getBool(
"resetOnStart")),
168 nParcels_.
setSize(faceZoneNames.size(), 0);
169 mass_.
setSize(faceZoneNames.size(), 0.0);
177 outputFilePtr_.setSize(faceZoneNames.size());
186 const word& zoneName = faceZoneNames[i];
187 label zonei = fzm.findZoneID(zoneName);
192 const faceZone& fz = fzm[zonei];
195 Info<<
" " << zoneName <<
" faces: " << nFaces <<
nl;
197 scalar totArea = 0.0;
198 for (
const label facei : fz)
202 totArea += magSf[facei];
206 const label patchi =
pbm.patchID(facei);
207 const polyPatch&
pp =
pbm[patchi];
211 !magSf.boundaryField()[patchi].coupled()
215 label localFacei =
pp.whichFace(facei);
216 totArea += magSf.boundaryField()[patchi][localFacei];
222 makeLogFile(zoneName, i, nFaces, totArea);
230template<
class CloudType>
233 const RemoveParcels<CloudType>& rpf
237 faceZoneIDs_(rpf.faceZoneIDs_),
238 nParcels_(rpf.nParcels_),
240 typeId_(rpf.typeId_),
241 logToFile_(rpf.logToFile_),
242 resetOnWrite_(rpf.resetOnWrite_),
243 resetOnStart_(rpf.resetOnStart_),
250template<
class CloudType>
254 const typename parcelType::trackingData&
td
257 bool keepParticle =
true;
259 if ((typeId_ >= 0) && (
p.typeId() != typeId_))
267 this->owner().solution().output()
268 || this->owner().solution().transient()
275 const faceZone& fz = fzm[faceZoneIDs_[i]];
276 if (fz.found(
p.face()))
279 mass_[i] +=
p.mass()*
p.nParticle();
280 keepParticle =
false;
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
Templated cloud function object base class.
CloudFunctionObject(CloudType &owner)
Construct null from owner.
virtual void postEvolve(const typename parcelType::trackingData &td)
Post-evolve hook.
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.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
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().
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
RemoveParcels(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
virtual void postEvolve(const typename parcelType::trackingData &td)
Post-evolve hook.
void write()
Write post-processing info.
virtual bool postFace(const parcelType &p, const typename parcelType::trackingData &td)
Post-face hook.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
bool found(const T &val, label pos=0) const
Same as contains().
void size(const label n)
Older name for setAddressableSize.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
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.
Mesh data needed to do the Finite Volume discretisation.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
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.
label nInternalFaces() const noexcept
Number of internal faces.
Lookup type of boundary radiation properties.
Selector class for relaxation factors, solver type and solution.
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.
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 DebugInfo
Report an information message using Foam::Info.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
List< word > wordList
List of word.
DSMCCloud< dsmcParcel > CloudType
messageStream Info
Information stream (stdout output on master, null elsewhere).
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with faceZone content on a polyMesh.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
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.
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.