Commit dcdc9e68 authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

STYLE: improved layout and bool vs Switch for some CloudFunctionObjects

- add output verbosity in debug mode
parent 8760f6c9
...@@ -201,6 +201,11 @@ void Foam::FacePostProcessing<CloudType>::write() ...@@ -201,6 +201,11 @@ void Foam::FacePostProcessing<CloudType>::write()
.subOrEmptyDict(surfaceFormat_) .subOrEmptyDict(surfaceFormat_)
); );
if (debug)
{
writer->verbose() = true;
}
writer->open writer->open
( (
allPoints, allPoints,
...@@ -212,8 +217,6 @@ void Foam::FacePostProcessing<CloudType>::write() ...@@ -212,8 +217,6 @@ void Foam::FacePostProcessing<CloudType>::write()
writer->write("massTotal", zoneMassTotal[zoneI]); writer->write("massTotal", zoneMassTotal[zoneI]);
writer->write("massFlowRate", zoneMassFlowRate[zoneI]); writer->write("massFlowRate", zoneMassFlowRate[zoneI]);
writer->clear();
} }
} }
} }
...@@ -251,12 +254,12 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing ...@@ -251,12 +254,12 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName), CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
faceZoneIDs_(), faceZoneIDs_(),
surfaceFormat_(this->coeffDict().lookup("surfaceFormat")), surfaceFormat_(this->coeffDict().lookup("surfaceFormat")),
resetOnWrite_(this->coeffDict().lookup("resetOnWrite")), resetOnWrite_(this->coeffDict().getBool("resetOnWrite")),
log_(this->coeffDict().getBool("log")),
totalTime_(0.0), totalTime_(0.0),
mass_(), mass_(),
massTotal_(), massTotal_(),
massFlowRate_(), massFlowRate_(),
log_(this->coeffDict().lookup("log")),
outputFilePtr_(), outputFilePtr_(),
timeOld_(owner.mesh().time().value()) timeOld_(owner.mesh().time().value())
{ {
...@@ -333,11 +336,11 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing ...@@ -333,11 +336,11 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing
faceZoneIDs_(pff.faceZoneIDs_), faceZoneIDs_(pff.faceZoneIDs_),
surfaceFormat_(pff.surfaceFormat_), surfaceFormat_(pff.surfaceFormat_),
resetOnWrite_(pff.resetOnWrite_), resetOnWrite_(pff.resetOnWrite_),
log_(pff.log_),
totalTime_(pff.totalTime_), totalTime_(pff.totalTime_),
mass_(pff.mass_), mass_(pff.mass_),
massTotal_(pff.massTotal_), massTotal_(pff.massTotal_),
massFlowRate_(pff.massFlowRate_), massFlowRate_(pff.massFlowRate_),
log_(pff.log_),
outputFilePtr_(), outputFilePtr_(),
timeOld_(0.0) timeOld_(0.0)
{} {}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
...@@ -61,13 +61,11 @@ class FacePostProcessing ...@@ -61,13 +61,11 @@ class FacePostProcessing
: :
public CloudFunctionObject<CloudType> 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
//- Face zone IDs //- Face zone IDs
labelList faceZoneIDs_; labelList faceZoneIDs_;
...@@ -75,8 +73,11 @@ class FacePostProcessing ...@@ -75,8 +73,11 @@ class FacePostProcessing
//- Surface output format //- Surface output format
const word surfaceFormat_; const word surfaceFormat_;
//- Flag to indicate whether data should be reset/cleared on writing //- Should be reset/cleared on writing?
Switch resetOnWrite_; bool resetOnWrite_;
//- Flag to indicate whether data should be written to file
bool log_;
//- Total time //- Total time
scalar totalTime_; scalar totalTime_;
...@@ -90,9 +91,6 @@ class FacePostProcessing ...@@ -90,9 +91,6 @@ class FacePostProcessing
//- Mass flow rate storage //- Mass flow rate storage
List<scalarField> massFlowRate_; List<scalarField> massFlowRate_;
//- Flag to indicate whether data should be written to file
Switch log_;
//- Output file pointer per zone //- Output file pointer per zone
PtrList<OFstream> outputFilePtr_; PtrList<OFstream> outputFilePtr_;
...@@ -155,16 +153,16 @@ public: ...@@ -155,16 +153,16 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Return const access to the reset on write flag //- Should data be reset on write?
inline const Switch& resetOnWrite() const; inline bool resetOnWrite() const;
// Evaluation // Evaluation
//- Post-face hook //- Post-face hook
virtual void postFace(const parcelType& p, bool& keepParticle); virtual void postFace(const parcelType& p, bool& keepParticle);
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation | Copyright (C) 2011 OpenFOAM Foundation
...@@ -26,8 +26,7 @@ License ...@@ -26,8 +26,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class CloudType> template<class CloudType>
inline const Foam::Switch& inline bool Foam::FacePostProcessing<CloudType>::resetOnWrite() const
Foam::FacePostProcessing<CloudType>::resetOnWrite() const
{ {
return resetOnWrite_; return resetOnWrite_;
} }
......
...@@ -471,6 +471,11 @@ void Foam::ParticleCollector<CloudType>::write() ...@@ -471,6 +471,11 @@ void Foam::ParticleCollector<CloudType>::write()
.subOrEmptyDict(surfaceFormat_) .subOrEmptyDict(surfaceFormat_)
); );
if (debug)
{
writer->verbose() = true;
}
writer->open writer->open
( (
points_, points_,
...@@ -522,7 +527,9 @@ Foam::ParticleCollector<CloudType>::ParticleCollector ...@@ -522,7 +527,9 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName), CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
mode_(mtUnknown), mode_(mtUnknown),
parcelType_(this->coeffDict().lookupOrDefault("parcelType", -1)), 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_(), points_(),
faces_(), faces_(),
faceTris_(), faceTris_(),
...@@ -535,12 +542,10 @@ Foam::ParticleCollector<CloudType>::ParticleCollector ...@@ -535,12 +542,10 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
this->coeffDict().getBool("negateParcelsOppositeNormal") this->coeffDict().getBool("negateParcelsOppositeNormal")
), ),
surfaceFormat_(this->coeffDict().lookup("surfaceFormat")), surfaceFormat_(this->coeffDict().lookup("surfaceFormat")),
resetOnWrite_(this->coeffDict().lookup("resetOnWrite")),
totalTime_(0.0), totalTime_(0.0),
mass_(), mass_(),
massTotal_(), massTotal_(),
massFlowRate_(), massFlowRate_(),
log_(this->coeffDict().lookup("log")),
outputFilePtr_(), outputFilePtr_(),
timeOld_(owner.mesh().time().value()), timeOld_(owner.mesh().time().value()),
hitFaceIDs_() hitFaceIDs_()
...@@ -608,6 +613,8 @@ Foam::ParticleCollector<CloudType>::ParticleCollector ...@@ -608,6 +613,8 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
mode_(pc.mode_), mode_(pc.mode_),
parcelType_(pc.parcelType_), parcelType_(pc.parcelType_),
removeCollected_(pc.removeCollected_), removeCollected_(pc.removeCollected_),
resetOnWrite_(pc.resetOnWrite_),
log_(pc.log_),
points_(pc.points_), points_(pc.points_),
faces_(pc.faces_), faces_(pc.faces_),
faceTris_(pc.faceTris_), faceTris_(pc.faceTris_),
...@@ -618,12 +625,10 @@ Foam::ParticleCollector<CloudType>::ParticleCollector ...@@ -618,12 +625,10 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
normal_(pc.normal_), normal_(pc.normal_),
negateParcelsOppositeNormal_(pc.negateParcelsOppositeNormal_), negateParcelsOppositeNormal_(pc.negateParcelsOppositeNormal_),
surfaceFormat_(pc.surfaceFormat_), surfaceFormat_(pc.surfaceFormat_),
resetOnWrite_(pc.resetOnWrite_),
totalTime_(pc.totalTime_), totalTime_(pc.totalTime_),
mass_(pc.mass_), mass_(pc.mass_),
massTotal_(pc.massTotal_), massTotal_(pc.massTotal_),
massFlowRate_(pc.massFlowRate_), massFlowRate_(pc.massFlowRate_),
log_(pc.log_),
outputFilePtr_(), outputFilePtr_(),
timeOld_(0.0), timeOld_(0.0),
hitFaceIDs_() hitFaceIDs_()
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2012-2017 OpenFOAM Foundation | Copyright (C) 2012-2017 OpenFOAM Foundation
...@@ -97,7 +97,6 @@ SourceFiles ...@@ -97,7 +97,6 @@ SourceFiles
#include "CloudFunctionObject.H" #include "CloudFunctionObject.H"
#include "cylindricalCS.H" #include "cylindricalCS.H"
#include "face.H" #include "face.H"
#include "Switch.H"
#include "OFstream.H" #include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...@@ -126,12 +125,10 @@ public: ...@@ -126,12 +125,10 @@ public:
private: private:
// Private Data //- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
// Typedefs
//- Convenience typedef for parcel type // Private Data
typedef typename CloudType::parcelType parcelType;
//- Collector mode type //- Collector mode type
modeType mode_; modeType mode_;
...@@ -140,7 +137,13 @@ private: ...@@ -140,7 +137,13 @@ private:
const label parcelType_; const label parcelType_;
//- Flag to remove collected particles //- 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 //- List of points
Field<point> points_; Field<point> points_;
...@@ -178,9 +181,6 @@ private: ...@@ -178,9 +181,6 @@ private:
//- Surface output format //- Surface output format
const word surfaceFormat_; const word surfaceFormat_;
//- Flag to indicate whether data should be reset/cleared on writing
Switch resetOnWrite_;
//- Total time //- Total time
scalar totalTime_; scalar totalTime_;
...@@ -193,9 +193,6 @@ private: ...@@ -193,9 +193,6 @@ private:
//- Mass flow rate storage //- Mass flow rate storage
List<scalar> massFlowRate_; List<scalar> massFlowRate_;
//- Flag to indicate whether data should be written to file
Switch log_;
//- Output file pointer //- Output file pointer
autoPtr<OFstream> outputFilePtr_; autoPtr<OFstream> outputFilePtr_;
...@@ -280,22 +277,22 @@ public: ...@@ -280,22 +277,22 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Return const access to the reset on write flag //- Should data be reset on write?
inline const Switch& resetOnWrite() const; inline bool resetOnWrite() const;
// Evaluation // Evaluation
//- Post-move hook //- Post-move hook
virtual void postMove virtual void postMove
( (
parcelType& p, parcelType& p,
const scalar dt, const scalar dt,
const point& position0, const point& position0,
bool& keepParticle bool& keepParticle
); );
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2012 OpenFOAM Foundation | Copyright (C) 2012 OpenFOAM Foundation
...@@ -26,8 +26,7 @@ License ...@@ -26,8 +26,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class CloudType> template<class CloudType>
inline const Foam::Switch& inline bool Foam::ParticleCollector<CloudType>::resetOnWrite() const
Foam::ParticleCollector<CloudType>::resetOnWrite() const
{ {
return resetOnWrite_; return resetOnWrite_;
} }
......
...@@ -64,7 +64,7 @@ Foam::ParticleTracks<CloudType>::ParticleTracks ...@@ -64,7 +64,7 @@ Foam::ParticleTracks<CloudType>::ParticleTracks
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName), CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
trackInterval_(this->coeffDict().getLabel("trackInterval")), trackInterval_(this->coeffDict().getLabel("trackInterval")),
maxSamples_(this->coeffDict().getLabel("maxSamples")), maxSamples_(this->coeffDict().getLabel("maxSamples")),
resetOnWrite_(this->coeffDict().lookup("resetOnWrite")), resetOnWrite_(this->coeffDict().getBool("resetOnWrite")),
faceHitCounter_(), faceHitCounter_(),
cloudPtr_(nullptr) cloudPtr_(nullptr)
{} {}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
...@@ -57,13 +57,11 @@ class ParticleTracks ...@@ -57,13 +57,11 @@ class ParticleTracks
: :
public CloudFunctionObject<CloudType> 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 //- Number of face-hit intervals between storing parcel data
label trackInterval_; label trackInterval_;
...@@ -71,8 +69,8 @@ class ParticleTracks ...@@ -71,8 +69,8 @@ class ParticleTracks
//- Maximum number of particles to store per track //- Maximum number of particles to store per track
label maxSamples_; label maxSamples_;
//- Flag to indicate whether data should be reset/cleared on writing //- Should data should be reset/cleared on writing?
Switch resetOnWrite_; bool resetOnWrite_;
//- Table of number of times a particle has hit a face //- Table of number of times a particle has hit a face
labelPairLookup faceHitCounter_; labelPairLookup faceHitCounter_;
...@@ -83,7 +81,7 @@ class ParticleTracks ...@@ -83,7 +81,7 @@ class ParticleTracks
protected: protected:
// Protected member functions // Protected Member Functions
//- Write post-processing info //- Write post-processing info
void write(); void write();
...@@ -124,31 +122,31 @@ public: ...@@ -124,31 +122,31 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Return const access to the track interval //- Return const access to the track interval
inline label trackInterval() const; inline label trackInterval() const;
//- Return const access to the max samples //- Return const access to the max samples
inline label maxSamples() const; inline label maxSamples() const;
//- Return const access to the reset on write flag //- Should data be reset on write?
inline const Switch& resetOnWrite() const; inline bool resetOnWrite() const;
//- Return the table of number of times a particle has hit a face //- Return the table of number of times a particle has hit a face
inline const labelPairLookup& faceHitCounter() const; inline const labelPairLookup& faceHitCounter() const;
//- Return const access to the cloud //- Return const access to the cloud
inline const Cloud<parcelType>& cloud() const; inline const Cloud<parcelType>& cloud() const;
// Evaluation // Evaluation
//- Pre-evolve hook //- Pre-evolve hook
virtual void preEvolve(); virtual void preEvolve();