ENH: ParticlePostProcessing: refactor PatchPostProcessing function object
- enable 'faceZones' support. - enable 'writeFile' support to better control file output. - rename 'PatchPostProcessing' as 'ParticlePostProcessing' for better clarity. - fix #1808
This commit is contained in:
parent
c177637db2
commit
2eb2de5f8e
@ -39,9 +39,9 @@ License
|
||||
#include "ParticleTrap.H"
|
||||
#include "ParticleZoneInfo.H"
|
||||
#include "ParticleHistogram.H"
|
||||
#include "ParticlePostProcessing.H"
|
||||
#include "PatchCollisionDensity.H"
|
||||
#include "PatchInteractionFields.H"
|
||||
#include "PatchPostProcessing.H"
|
||||
#include "RemoveParcels.H"
|
||||
#include "VoidFraction.H"
|
||||
#include "KinematicReynoldsNumber.H"
|
||||
@ -61,9 +61,9 @@ License
|
||||
makeCloudFunctionObjectType(ParticleTrap, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticleZoneInfo, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticleHistogram, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticlePostProcessing, CloudType); \
|
||||
makeCloudFunctionObjectType(PatchCollisionDensity, CloudType); \
|
||||
makeCloudFunctionObjectType(PatchInteractionFields, CloudType); \
|
||||
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
|
||||
makeCloudFunctionObjectType(RemoveParcels, CloudType); \
|
||||
makeCloudFunctionObjectType(VoidFraction, CloudType); \
|
||||
makeCloudFunctionObjectType(KinematicReynoldsNumber, CloudType); \
|
||||
|
@ -39,9 +39,9 @@ License
|
||||
#include "ParticleTrap.H"
|
||||
#include "ParticleZoneInfo.H"
|
||||
#include "ParticleHistogram.H"
|
||||
#include "ParticlePostProcessing.H"
|
||||
#include "PatchCollisionDensity.H"
|
||||
#include "PatchInteractionFields.H"
|
||||
#include "PatchPostProcessing.H"
|
||||
#include "RemoveParcels.H"
|
||||
#include "VoidFraction.H"
|
||||
#include "NusseltNumber.H"
|
||||
@ -64,9 +64,9 @@ License
|
||||
makeCloudFunctionObjectType(ParticleTrap, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticleZoneInfo, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticleHistogram, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticlePostProcessing, CloudType); \
|
||||
makeCloudFunctionObjectType(PatchCollisionDensity, CloudType); \
|
||||
makeCloudFunctionObjectType(PatchInteractionFields, CloudType); \
|
||||
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
|
||||
makeCloudFunctionObjectType(RemoveParcels, CloudType); \
|
||||
makeCloudFunctionObjectType(VoidFraction, CloudType); \
|
||||
makeCloudFunctionObjectType(NusseltNumber, CloudType); \
|
||||
|
@ -38,9 +38,9 @@ License
|
||||
#include "ParticleTrap.H"
|
||||
#include "ParticleZoneInfo.H"
|
||||
#include "ParticleHistogram.H"
|
||||
#include "ParticlePostProcessing.H"
|
||||
#include "PatchCollisionDensity.H"
|
||||
#include "PatchInteractionFields.H"
|
||||
#include "PatchPostProcessing.H"
|
||||
#include "RemoveParcels.H"
|
||||
#include "VoidFraction.H"
|
||||
#include "NusseltNumber.H"
|
||||
@ -62,9 +62,9 @@ License
|
||||
makeCloudFunctionObjectType(ParticleTrap, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticleZoneInfo, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticleHistogram, CloudType); \
|
||||
makeCloudFunctionObjectType(ParticlePostProcessing, CloudType); \
|
||||
makeCloudFunctionObjectType(PatchCollisionDensity, CloudType); \
|
||||
makeCloudFunctionObjectType(PatchInteractionFields, CloudType); \
|
||||
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
|
||||
makeCloudFunctionObjectType(RemoveParcels, CloudType); \
|
||||
makeCloudFunctionObjectType(VoidFraction, CloudType); \
|
||||
makeCloudFunctionObjectType(NusseltNumber, CloudType); \
|
||||
|
@ -0,0 +1,269 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ParticlePostProcessing.H"
|
||||
#include "Pstream.H"
|
||||
#include "stringListOps.H"
|
||||
#include "ListOps.H"
|
||||
#include "ListListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ParticlePostProcessing<CloudType>::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
this->writeCommented(os, "Time");
|
||||
os << ' ' << "currentProc";
|
||||
|
||||
if (!header_.empty())
|
||||
{
|
||||
os << ' ' << header_;
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
Foam::ParticlePostProcessing<CloudType>::ParticlePostProcessing
|
||||
(
|
||||
const dictionary& dict,
|
||||
CloudType& owner,
|
||||
const word& modelName
|
||||
)
|
||||
:
|
||||
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
|
||||
functionObjects::writeFile
|
||||
(
|
||||
owner,
|
||||
this->localPath(),
|
||||
typeName
|
||||
),
|
||||
collector_(this->coeffDict(), owner.mesh()),
|
||||
maxStoredParcels_(this->coeffDict().getScalar("maxStoredParcels")),
|
||||
header_(),
|
||||
fields_(),
|
||||
times_(),
|
||||
data_()
|
||||
{
|
||||
writeFile::read(this->coeffDict());
|
||||
|
||||
this->coeffDict().readIfPresent("fields", fields_);
|
||||
|
||||
if (maxStoredParcels_ <= 0)
|
||||
{
|
||||
FatalIOErrorInFunction(this->coeffDict())
|
||||
<< "maxStoredParcels = " << maxStoredParcels_
|
||||
<< ", cannot be equal to or less than zero"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
const label sz = collector_.size();
|
||||
times_.resize(sz);
|
||||
data_.resize(sz);
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
Foam::ParticlePostProcessing<CloudType>::ParticlePostProcessing
|
||||
(
|
||||
const ParticlePostProcessing<CloudType>& ppp
|
||||
)
|
||||
:
|
||||
CloudFunctionObject<CloudType>(ppp),
|
||||
writeFile(ppp),
|
||||
collector_(ppp.collector_),
|
||||
maxStoredParcels_(ppp.maxStoredParcels_),
|
||||
header_(ppp.header_),
|
||||
fields_(ppp.fields_),
|
||||
times_(ppp.times_),
|
||||
data_(ppp.data_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ParticlePostProcessing<CloudType>::postPatch
|
||||
(
|
||||
const parcelType& p,
|
||||
const polyPatch& pp,
|
||||
bool&
|
||||
)
|
||||
{
|
||||
if (!collector_.isPatch())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const label patchi = pp.index();
|
||||
const label localPatchi = collector_.IDs().find(patchi);
|
||||
|
||||
if (header_.empty())
|
||||
{
|
||||
OStringStream data;
|
||||
p.writeProperties(data, fields_, " ", true);
|
||||
header_ = data.str();
|
||||
}
|
||||
|
||||
if (localPatchi != -1 && data_[localPatchi].size() < maxStoredParcels_)
|
||||
{
|
||||
times_[localPatchi].append(this->owner().time().value());
|
||||
|
||||
OStringStream data;
|
||||
data<< Pstream::myProcNo();
|
||||
p.writeProperties(data, fields_, " ", false);
|
||||
|
||||
data_[localPatchi].append(data.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ParticlePostProcessing<CloudType>::postFace
|
||||
(
|
||||
const parcelType& p,
|
||||
bool&
|
||||
)
|
||||
{
|
||||
if (collector_.isPatch())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const labelList& IDs = collector_.IDs();
|
||||
const List<boundBox>& BBs = collector_.BBs();
|
||||
const faceZoneMesh& fzm = this->owner().mesh().faceZones();
|
||||
|
||||
if (header_.empty())
|
||||
{
|
||||
OStringStream data;
|
||||
p.writeProperties(data, fields_, " ", true);
|
||||
header_ = data.str();
|
||||
}
|
||||
|
||||
forAll(IDs, i)
|
||||
{
|
||||
if (!BBs[i].contains(p.position()))
|
||||
{
|
||||
// Quick reject if the particle is not in the face zone bound box
|
||||
continue;
|
||||
}
|
||||
|
||||
const label zonei = IDs[i];
|
||||
const label localFacei = fzm[zonei].find(p.face());
|
||||
|
||||
if (localFacei != -1 && data_[localFacei].size() < maxStoredParcels_)
|
||||
{
|
||||
times_[i].append(this->owner().time().value());
|
||||
|
||||
OStringStream data;
|
||||
data<< Pstream::myProcNo();
|
||||
p.writeProperties(data, fields_, " ", false);
|
||||
|
||||
data_[i].append(data.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ParticlePostProcessing<CloudType>::write()
|
||||
{
|
||||
const wordList& names = collector_.names();
|
||||
|
||||
forAll(names, i)
|
||||
{
|
||||
List<scalarList> procTimes(Pstream::nProcs());
|
||||
procTimes[Pstream::myProcNo()] = times_[i];
|
||||
Pstream::gatherList(procTimes);
|
||||
|
||||
List<List<string>> procData(Pstream::nProcs());
|
||||
procData[Pstream::myProcNo()] = data_[i];
|
||||
Pstream::gatherList(procData);
|
||||
|
||||
Pstream::combineReduce
|
||||
(
|
||||
header_,
|
||||
[](string& x, const string& y)
|
||||
{
|
||||
if (y.size() > x.size())
|
||||
{
|
||||
x = y;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
List<string> globalData;
|
||||
globalData = ListListOps::combine<List<string>>
|
||||
(
|
||||
procData,
|
||||
accessOp<List<string>>()
|
||||
);
|
||||
|
||||
scalarList globalTimes;
|
||||
globalTimes = ListListOps::combine<scalarList>
|
||||
(
|
||||
procTimes,
|
||||
accessOp<scalarList>()
|
||||
);
|
||||
|
||||
if (this->writeToFile())
|
||||
{
|
||||
autoPtr<OFstream> osPtr = this->newFileAtTime
|
||||
(
|
||||
names[i],
|
||||
this->owner().time().value()
|
||||
);
|
||||
OFstream& os = osPtr.ref();
|
||||
|
||||
writeFileHeader(os);
|
||||
|
||||
const labelList indices(sortedOrder(globalTimes));
|
||||
forAll(globalTimes, j)
|
||||
{
|
||||
const label datai = indices[j];
|
||||
|
||||
os << globalTimes[datai] << tab
|
||||
<< globalData[datai].c_str()
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
times_[i].clearStorage();
|
||||
data_[i].clearStorage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,226 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::ParticlePostProcessing
|
||||
|
||||
Description
|
||||
Writes out various standard Lagrangian data elements of
|
||||
particles hitting on a given list of patches or face zones.
|
||||
|
||||
Operands:
|
||||
\table
|
||||
Operand | Type | Location
|
||||
input | - | -
|
||||
output file | dat | \<case\>/postProcessing/\<FO\>/\<time\>/\<file\>
|
||||
output field | - | -
|
||||
\endtable
|
||||
|
||||
The output file contains columns depending on the \c fields entry.
|
||||
|
||||
Usage
|
||||
Minimal example by using
|
||||
\c constant/reactingCloud1Properties.cloudFunctions:
|
||||
\verbatim
|
||||
ParticlePostProcessing1
|
||||
{
|
||||
// Mandatory entries
|
||||
type particlePostProcessing;
|
||||
maxStoredParcels <scalar>;
|
||||
|
||||
// Optional entries
|
||||
fields (<wordRes>);
|
||||
|
||||
// Conditional entries
|
||||
|
||||
// Option-1
|
||||
patches (<wordRes>);
|
||||
|
||||
// Option-2
|
||||
faceZones (<wordRes>);
|
||||
|
||||
// Inherited entries
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
where the entries mean:
|
||||
\table
|
||||
Property | Description | Type | Reqd | Deflt
|
||||
type | Type name: particlePostProcessing | word | yes | -
|
||||
maxStoredParcels | Maximum number of parcels to process | label | yes | -
|
||||
fields | Names of standard Lagrangian fields | wordRes | no | all
|
||||
patches | Names of operand patches | wordRes | choice | -
|
||||
faceZones | Names of operand face zones | wordRes | choice | -
|
||||
\endtable
|
||||
|
||||
The inherited entries are elaborated in:
|
||||
- \link CloudFunctionObject.H \endlink
|
||||
- \link writeFile.H \endlink
|
||||
|
||||
Note
|
||||
- The underlying type of \c maxStoredParcels is set as a scalar for I/O.
|
||||
- Empty files indicate that no particles hit selected surfaces.
|
||||
|
||||
SourceFiles
|
||||
ParticlePostProcessing.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_ParticlePostProcessing_H
|
||||
#define Foam_ParticlePostProcessing_H
|
||||
|
||||
#include "CloudFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "cloudFunctionObjectTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ParticlePostProcessing Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class CloudType>
|
||||
class ParticlePostProcessing
|
||||
:
|
||||
public CloudFunctionObject<CloudType>,
|
||||
public functionObjects::writeFile
|
||||
{
|
||||
// Private Data
|
||||
|
||||
// Typedefs
|
||||
|
||||
//- Convenience typedef for parcel type
|
||||
typedef typename CloudType::particleType parcelType;
|
||||
|
||||
//- Collector surfaces
|
||||
cloudFunctionObjectTools::collector collector_;
|
||||
|
||||
//- Maximum number of parcels to store - set as a scalar for I/O
|
||||
scalar maxStoredParcels_;
|
||||
|
||||
//- Field header
|
||||
string header_;
|
||||
|
||||
//- Field name filters
|
||||
wordRes fields_;
|
||||
|
||||
//- List of times for each data record
|
||||
List<DynamicList<scalar>> times_;
|
||||
|
||||
//- List of output data per surface
|
||||
List<DynamicList<string>> data_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Write output file header
|
||||
void writeFileHeader(Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("particlePostProcessing");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
ParticlePostProcessing
|
||||
(
|
||||
const dictionary& dict,
|
||||
CloudType& owner,
|
||||
const word& modelName
|
||||
);
|
||||
|
||||
//- Copy construct
|
||||
ParticlePostProcessing(const ParticlePostProcessing<CloudType>& ppp);
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const ParticlePostProcessing<CloudType>&) = delete;
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<CloudFunctionObject<CloudType>> clone() const
|
||||
{
|
||||
return autoPtr<CloudFunctionObject<CloudType>>
|
||||
(
|
||||
new ParticlePostProcessing<CloudType>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ParticlePostProcessing() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return maximum number of parcels to store per surface
|
||||
label maxStoredParcels() const noexcept { return maxStoredParcels_; }
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Post-patch hook
|
||||
virtual void postPatch
|
||||
(
|
||||
const parcelType& p,
|
||||
const polyPatch& pp,
|
||||
bool& keepParticle
|
||||
);
|
||||
|
||||
//- Post-face hook
|
||||
virtual void postFace(const parcelType& p, bool& keepParticle);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write post-processing info
|
||||
virtual void write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "ParticlePostProcessing.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -1,216 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "PatchPostProcessing.H"
|
||||
#include "Pstream.H"
|
||||
#include "stringListOps.H"
|
||||
#include "ListOps.H"
|
||||
#include "ListListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
Foam::label Foam::PatchPostProcessing<CloudType>::applyToPatch
|
||||
(
|
||||
const label globalPatchi
|
||||
) const
|
||||
{
|
||||
return patchIDs_.find(globalPatchi);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * protected Member Functions * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::PatchPostProcessing<CloudType>::write()
|
||||
{
|
||||
forAll(patchData_, i)
|
||||
{
|
||||
List<List<scalar>> procTimes(Pstream::nProcs());
|
||||
procTimes[Pstream::myProcNo()] = times_[i];
|
||||
Pstream::gatherList(procTimes);
|
||||
|
||||
List<List<string>> procData(Pstream::nProcs());
|
||||
procData[Pstream::myProcNo()] = patchData_[i];
|
||||
Pstream::gatherList(procData);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
const fvMesh& mesh = this->owner().mesh();
|
||||
|
||||
// Create directory if it doesn't exist
|
||||
mkDir(this->writeTimeDir());
|
||||
|
||||
const word& patchName = mesh.boundaryMesh()[patchIDs_[i]].name();
|
||||
|
||||
OFstream patchOutFile
|
||||
(
|
||||
this->writeTimeDir()/patchName + ".post",
|
||||
IOstreamOption::ASCII,
|
||||
mesh.time().writeCompression()
|
||||
);
|
||||
|
||||
List<string> globalData;
|
||||
globalData = ListListOps::combine<List<string>>
|
||||
(
|
||||
procData,
|
||||
accessOp<List<string>>()
|
||||
);
|
||||
|
||||
List<scalar> globalTimes;
|
||||
globalTimes = ListListOps::combine<List<scalar>>
|
||||
(
|
||||
procTimes,
|
||||
accessOp<List<scalar>>()
|
||||
);
|
||||
|
||||
labelList indices(sortedOrder(globalTimes));
|
||||
|
||||
string header("# Time currentProc " + header_);
|
||||
patchOutFile<< header.c_str() << nl;
|
||||
|
||||
forAll(globalTimes, i)
|
||||
{
|
||||
label dataI = indices[i];
|
||||
|
||||
patchOutFile
|
||||
<< globalTimes[dataI] << ' '
|
||||
<< globalData[dataI].c_str()
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
patchData_[i].clearStorage();
|
||||
times_[i].clearStorage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
|
||||
(
|
||||
const dictionary& dict,
|
||||
CloudType& owner,
|
||||
const word& modelName
|
||||
)
|
||||
:
|
||||
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
|
||||
maxStoredParcels_(this->coeffDict().getScalar("maxStoredParcels")),
|
||||
fields_(),
|
||||
patchIDs_(),
|
||||
times_(),
|
||||
patchData_(),
|
||||
header_()
|
||||
{
|
||||
// The "fields" filter is optional
|
||||
this->coeffDict().readIfPresent("fields", fields_);
|
||||
|
||||
// The "patches" are required
|
||||
const wordRes patchMatcher(this->coeffDict().lookup("patches"));
|
||||
|
||||
patchIDs_ = patchMatcher.matching(owner.mesh().boundaryMesh().names());
|
||||
|
||||
if (patchIDs_.empty())
|
||||
{
|
||||
WarningInFunction
|
||||
<< "No matching patches found: "
|
||||
<< flatOutput(patchMatcher) << nl;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Post-process fields "
|
||||
<< flatOutput(fields_) << nl;
|
||||
|
||||
Info<< "On patches (";
|
||||
|
||||
for (const label patchi : patchIDs_)
|
||||
{
|
||||
Info<< ' ' << owner.mesh().boundaryMesh()[patchi].name();
|
||||
}
|
||||
|
||||
Info<< " )" << nl;
|
||||
}
|
||||
|
||||
patchData_.setSize(patchIDs_.size());
|
||||
times_.setSize(patchIDs_.size());
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
|
||||
(
|
||||
const PatchPostProcessing<CloudType>& ppm
|
||||
)
|
||||
:
|
||||
CloudFunctionObject<CloudType>(ppm),
|
||||
maxStoredParcels_(ppm.maxStoredParcels_),
|
||||
fields_(ppm.fields_),
|
||||
patchIDs_(ppm.patchIDs_),
|
||||
times_(ppm.times_),
|
||||
patchData_(ppm.patchData_),
|
||||
header_(ppm.header_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::PatchPostProcessing<CloudType>::postPatch
|
||||
(
|
||||
const parcelType& p,
|
||||
const polyPatch& pp,
|
||||
bool&
|
||||
)
|
||||
{
|
||||
const label patchi = pp.index();
|
||||
const label localPatchi = applyToPatch(patchi);
|
||||
|
||||
if (header_.empty())
|
||||
{
|
||||
OStringStream data;
|
||||
p.writeProperties(data, fields_, " ", true);
|
||||
header_ = data.str();
|
||||
}
|
||||
|
||||
if (localPatchi != -1 && patchData_[localPatchi].size() < maxStoredParcels_)
|
||||
{
|
||||
times_[localPatchi].append(this->owner().time().value());
|
||||
|
||||
OStringStream data;
|
||||
data<< Pstream::myProcNo();
|
||||
p.writeProperties(data, fields_, " ", false);
|
||||
|
||||
patchData_[localPatchi].append(data.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,171 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::PatchPostProcessing
|
||||
|
||||
Group
|
||||
grpLagrangianIntermediateFunctionObjects
|
||||
|
||||
Description
|
||||
Standard post-processing
|
||||
|
||||
SourceFiles
|
||||
PatchPostProcessing.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PatchPostProcessing_H
|
||||
#define PatchPostProcessing_H
|
||||
|
||||
#include "CloudFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PatchPostProcessing Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class CloudType>
|
||||
class PatchPostProcessing
|
||||
:
|
||||
public CloudFunctionObject<CloudType>
|
||||
{
|
||||
// Private data
|
||||
|
||||
typedef typename CloudType::particleType parcelType;
|
||||
|
||||
//- Maximum number of parcels to store - set as a scalar for I/O
|
||||
scalar maxStoredParcels_;
|
||||
|
||||
//- Field name filters
|
||||
wordRes fields_;
|
||||
|
||||
//- List of patch indices to post-process
|
||||
labelList patchIDs_;
|
||||
|
||||
//- List of time for each data record
|
||||
List<DynamicList<scalar>> times_;
|
||||
|
||||
//- List of output data per patch
|
||||
List<DynamicList<string>> patchData_;
|
||||
|
||||
//- Field header
|
||||
string header_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Returns local patchi if patch is in patchIds_ list
|
||||
label applyToPatch(const label globalPatchi) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write post-processing info
|
||||
void write();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("patchPostProcessing");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
PatchPostProcessing
|
||||
(
|
||||
const dictionary& dict,
|
||||
CloudType& owner,
|
||||
const word& modelName
|
||||
);
|
||||
|
||||
//- Construct copy
|
||||
PatchPostProcessing(const PatchPostProcessing<CloudType>& ppm);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<CloudFunctionObject<CloudType>> clone() const
|
||||
{
|
||||
return autoPtr<CloudFunctionObject<CloudType>>
|
||||
(
|
||||
new PatchPostProcessing<CloudType>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~PatchPostProcessing() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return maximum number of parcels to store per patch
|
||||
inline label maxStoredParcels() const;
|
||||
|
||||
//- Return const mapping from local to global patch ids
|
||||
inline const labelList& patchIDs() const;
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Post-patch hook
|
||||
virtual void postPatch
|
||||
(
|
||||
const parcelType& p,
|
||||
const polyPatch& pp,
|
||||
bool& keepParticle
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "PatchPostProcessingI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "PatchPostProcessing.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -1,42 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class CloudType>
|
||||
Foam::label Foam::PatchPostProcessing<CloudType>::maxStoredParcels() const
|
||||
{
|
||||
return maxStoredParcels_;
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
const Foam::labelList& Foam::PatchPostProcessing<CloudType>::patchIDs() const
|
||||
{
|
||||
return patchIDs_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -564,9 +564,9 @@ in this ways the particles hitting the patches will be classified in the followi
|
||||
maxStoredParcels 100000000;
|
||||
}
|
||||
|
||||
patchPostProcessing1
|
||||
particlePostProcessing1
|
||||
{
|
||||
type patchPostProcessing;
|
||||
type particlePostProcessing;
|
||||
fields (position origId d);
|
||||
maxStoredParcels 100000000;
|
||||
patches
|
||||
|
@ -181,9 +181,9 @@ cloudFunctions
|
||||
maxStoredParcels 20;
|
||||
}
|
||||
|
||||
patchPostProcessing1
|
||||
particlePostProcessing1
|
||||
{
|
||||
type patchPostProcessing;
|
||||
type particlePostProcessing;
|
||||
fields (position "U.*" d T nParticle);
|
||||
maxStoredParcels 20;
|
||||
patches
|
||||
|
@ -175,9 +175,9 @@ subModels
|
||||
|
||||
cloudFunctions
|
||||
{
|
||||
patchPostProcessing1
|
||||
particlePostProcessing1
|
||||
{
|
||||
type patchPostProcessing;
|
||||
type particlePostProcessing;
|
||||
maxStoredParcels 100;
|
||||
patches ( outlet );
|
||||
}
|
||||
|
@ -177,9 +177,9 @@ subModels
|
||||
|
||||
cloudFunctions
|
||||
{
|
||||
patchPostProcessing1
|
||||
particlePostProcessing1
|
||||
{
|
||||
type patchPostProcessing;
|
||||
type particlePostProcessing;
|
||||
maxStoredParcels 100;
|
||||
patches ( outlet );
|
||||
}
|
||||
|
@ -177,9 +177,9 @@ subModels
|
||||
|
||||
cloudFunctions
|
||||
{
|
||||
patchPostProcessing1
|
||||
particlePostProcessing1
|
||||
{
|
||||
type patchPostProcessing;
|
||||
type particlePostProcessing;
|
||||
maxStoredParcels 100;
|
||||
patches ( outlet );
|
||||
}
|
||||
|
@ -158,9 +158,9 @@ subModels
|
||||
|
||||
cloudFunctions
|
||||
{
|
||||
patchPostProcessing1
|
||||
particlePostProcessing1
|
||||
{
|
||||
type patchPostProcessing;
|
||||
type particlePostProcessing;
|
||||
maxStoredParcels 20;
|
||||
patches
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user