STYLE: improved layout and bool vs Switch for some CloudFunctionObjects

- add output verbosity in debug mode
This commit is contained in:
Mark Olesen 2019-02-22 09:29:08 +01:00 committed by Andrew Heather
parent 8760f6c9a9
commit dcdc9e68f8
9 changed files with 87 additions and 88 deletions

View File

@ -201,6 +201,11 @@ void Foam::FacePostProcessing<CloudType>::write()
.subOrEmptyDict(surfaceFormat_)
);
if (debug)
{
writer->verbose() = true;
}
writer->open
(
allPoints,
@ -212,8 +217,6 @@ void Foam::FacePostProcessing<CloudType>::write()
writer->write("massTotal", zoneMassTotal[zoneI]);
writer->write("massFlowRate", zoneMassFlowRate[zoneI]);
writer->clear();
}
}
}
@ -251,12 +254,12 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
faceZoneIDs_(),
surfaceFormat_(this->coeffDict().lookup("surfaceFormat")),
resetOnWrite_(this->coeffDict().lookup("resetOnWrite")),
resetOnWrite_(this->coeffDict().getBool("resetOnWrite")),
log_(this->coeffDict().getBool("log")),
totalTime_(0.0),
mass_(),
massTotal_(),
massFlowRate_(),
log_(this->coeffDict().lookup("log")),
outputFilePtr_(),
timeOld_(owner.mesh().time().value())
{
@ -333,11 +336,11 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing
faceZoneIDs_(pff.faceZoneIDs_),
surfaceFormat_(pff.surfaceFormat_),
resetOnWrite_(pff.resetOnWrite_),
log_(pff.log_),
totalTime_(pff.totalTime_),
mass_(pff.mass_),
massTotal_(pff.massTotal_),
massFlowRate_(pff.massFlowRate_),
log_(pff.log_),
outputFilePtr_(),
timeOld_(0.0)
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -61,22 +61,23 @@ class FacePostProcessing
:
public CloudFunctionObject<CloudType>
{
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
// Private Data
// Typedefs
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
//- Face zone IDs
labelList faceZoneIDs_;
//- Surface output format
const word surfaceFormat_;
//- Flag to indicate whether data should be reset/cleared on writing
Switch resetOnWrite_;
//- Should be reset/cleared on writing?
bool resetOnWrite_;
//- Flag to indicate whether data should be written to file
bool log_;
//- Total time
scalar totalTime_;
@ -90,9 +91,6 @@ class FacePostProcessing
//- Mass flow rate storage
List<scalarField> massFlowRate_;
//- Flag to indicate whether data should be written to file
Switch log_;
//- Output file pointer per zone
PtrList<OFstream> outputFilePtr_;
@ -155,16 +153,16 @@ public:
// Member Functions
// Access
// Access
//- Return const access to the reset on write flag
inline const Switch& resetOnWrite() const;
//- Should data be reset on write?
inline bool resetOnWrite() const;
// Evaluation
// Evaluation
//- Post-face hook
virtual void postFace(const parcelType& p, bool& keepParticle);
//- Post-face hook
virtual void postFace(const parcelType& p, bool& keepParticle);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
@ -26,8 +26,7 @@ License
\*---------------------------------------------------------------------------*/
template<class CloudType>
inline const Foam::Switch&
Foam::FacePostProcessing<CloudType>::resetOnWrite() const
inline bool Foam::FacePostProcessing<CloudType>::resetOnWrite() const
{
return resetOnWrite_;
}

View File

@ -471,6 +471,11 @@ void Foam::ParticleCollector<CloudType>::write()
.subOrEmptyDict(surfaceFormat_)
);
if (debug)
{
writer->verbose() = true;
}
writer->open
(
points_,
@ -522,7 +527,9 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
mode_(mtUnknown),
parcelType_(this->coeffDict().lookupOrDefault("parcelType", -1)),
removeCollected_(this->coeffDict().lookup("removeCollected")),
removeCollected_(this->coeffDict().getBool("removeCollected")),
resetOnWrite_(this->coeffDict().getBool("resetOnWrite")),
log_(this->coeffDict().getBool("log")),
points_(),
faces_(),
faceTris_(),
@ -535,12 +542,10 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
this->coeffDict().getBool("negateParcelsOppositeNormal")
),
surfaceFormat_(this->coeffDict().lookup("surfaceFormat")),
resetOnWrite_(this->coeffDict().lookup("resetOnWrite")),
totalTime_(0.0),
mass_(),
massTotal_(),
massFlowRate_(),
log_(this->coeffDict().lookup("log")),
outputFilePtr_(),
timeOld_(owner.mesh().time().value()),
hitFaceIDs_()
@ -608,6 +613,8 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
mode_(pc.mode_),
parcelType_(pc.parcelType_),
removeCollected_(pc.removeCollected_),
resetOnWrite_(pc.resetOnWrite_),
log_(pc.log_),
points_(pc.points_),
faces_(pc.faces_),
faceTris_(pc.faceTris_),
@ -618,12 +625,10 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
normal_(pc.normal_),
negateParcelsOppositeNormal_(pc.negateParcelsOppositeNormal_),
surfaceFormat_(pc.surfaceFormat_),
resetOnWrite_(pc.resetOnWrite_),
totalTime_(pc.totalTime_),
mass_(pc.mass_),
massTotal_(pc.massTotal_),
massFlowRate_(pc.massFlowRate_),
log_(pc.log_),
outputFilePtr_(),
timeOld_(0.0),
hitFaceIDs_()

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2012-2017 OpenFOAM Foundation
@ -97,7 +97,6 @@ SourceFiles
#include "CloudFunctionObject.H"
#include "cylindricalCS.H"
#include "face.H"
#include "Switch.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -126,13 +125,11 @@ public:
private:
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
// Private Data
// Typedefs
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
//- Collector mode type
modeType mode_;
@ -140,7 +137,13 @@ private:
const label parcelType_;
//- Flag to remove collected particles
Switch removeCollected_;
bool removeCollected_;
//- Should data be reset/cleared on writing?
bool resetOnWrite_;
//- Flag to indicate whether data should be written to file
bool log_;
//- List of points
Field<point> points_;
@ -178,9 +181,6 @@ private:
//- Surface output format
const word surfaceFormat_;
//- Flag to indicate whether data should be reset/cleared on writing
Switch resetOnWrite_;
//- Total time
scalar totalTime_;
@ -193,9 +193,6 @@ private:
//- Mass flow rate storage
List<scalar> massFlowRate_;
//- Flag to indicate whether data should be written to file
Switch log_;
//- Output file pointer
autoPtr<OFstream> outputFilePtr_;
@ -280,22 +277,22 @@ public:
// Member Functions
// Access
// Access
//- Return const access to the reset on write flag
inline const Switch& resetOnWrite() const;
//- Should data be reset on write?
inline bool resetOnWrite() const;
// Evaluation
// Evaluation
//- Post-move hook
virtual void postMove
(
parcelType& p,
const scalar dt,
const point& position0,
bool& keepParticle
);
//- Post-move hook
virtual void postMove
(
parcelType& p,
const scalar dt,
const point& position0,
bool& keepParticle
);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2012 OpenFOAM Foundation
@ -26,8 +26,7 @@ License
\*---------------------------------------------------------------------------*/
template<class CloudType>
inline const Foam::Switch&
Foam::ParticleCollector<CloudType>::resetOnWrite() const
inline bool Foam::ParticleCollector<CloudType>::resetOnWrite() const
{
return resetOnWrite_;
}

View File

@ -64,7 +64,7 @@ Foam::ParticleTracks<CloudType>::ParticleTracks
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
trackInterval_(this->coeffDict().getLabel("trackInterval")),
maxSamples_(this->coeffDict().getLabel("maxSamples")),
resetOnWrite_(this->coeffDict().lookup("resetOnWrite")),
resetOnWrite_(this->coeffDict().getBool("resetOnWrite")),
faceHitCounter_(),
cloudPtr_(nullptr)
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -57,13 +57,11 @@ class ParticleTracks
:
public CloudFunctionObject<CloudType>
{
// Private data
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
// Typedefs
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
// Private Data
//- Number of face-hit intervals between storing parcel data
label trackInterval_;
@ -71,8 +69,8 @@ class ParticleTracks
//- Maximum number of particles to store per track
label maxSamples_;
//- Flag to indicate whether data should be reset/cleared on writing
Switch resetOnWrite_;
//- Should data should be reset/cleared on writing?
bool resetOnWrite_;
//- Table of number of times a particle has hit a face
labelPairLookup faceHitCounter_;
@ -83,7 +81,7 @@ class ParticleTracks
protected:
// Protected member functions
// Protected Member Functions
//- Write post-processing info
void write();
@ -124,31 +122,31 @@ public:
// Member Functions
// Access
// Access
//- Return const access to the track interval
inline label trackInterval() const;
//- Return const access to the track interval
inline label trackInterval() const;
//- Return const access to the max samples
inline label maxSamples() const;
//- Return const access to the max samples
inline label maxSamples() const;
//- Return const access to the reset on write flag
inline const Switch& resetOnWrite() const;
//- Should data be reset on write?
inline bool resetOnWrite() const;
//- Return the table of number of times a particle has hit a face
inline const labelPairLookup& faceHitCounter() const;
//- Return the table of number of times a particle has hit a face
inline const labelPairLookup& faceHitCounter() const;
//- Return const access to the cloud
inline const Cloud<parcelType>& cloud() const;
//- Return const access to the cloud
inline const Cloud<parcelType>& cloud() const;
// Evaluation
// Evaluation
//- Pre-evolve hook
virtual void preEvolve();
//- Pre-evolve hook
virtual void preEvolve();
//- Post-face hook
virtual void postFace(const parcelType& p, bool& keepParticle);
//- Post-face hook
virtual void postFace(const parcelType& p, bool& keepParticle);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
@ -44,7 +44,7 @@ inline Foam::label Foam::ParticleTracks<CloudType>::maxSamples() const
template<class CloudType>
inline const Foam::Switch& Foam::ParticleTracks<CloudType>::resetOnWrite() const
inline bool Foam::ParticleTracks<CloudType>::resetOnWrite() const
{
return resetOnWrite_;
}