diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.C b/src/functionObjects/field/fieldAverage/fieldAverage.C index f2be570fd9..b9559a0f7c 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverage.C +++ b/src/functionObjects/field/fieldAverage/fieldAverage.C @@ -269,12 +269,12 @@ Foam::functionObjects::fieldAverage::fieldAverage : fvMeshFunctionObject(name, runTime, dict), prevTimeIndex_(-1), + initialised_(false), restartOnRestart_(false), restartOnOutput_(false), periodicRestart_(false), restartPeriod_(GREAT), restartTime_(GREAT), - initialised_(false), faItems_(), periodIndex_(1) { @@ -282,12 +282,6 @@ Foam::functionObjects::fieldAverage::fieldAverage } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::fieldAverage::~fieldAverage() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::functionObjects::fieldAverage::read(const dictionary& dict) diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.H b/src/functionObjects/field/fieldAverage/fieldAverage.H index a14c959c98..6985a21670 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverage.H +++ b/src/functionObjects/field/fieldAverage/fieldAverage.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2017 OpenFOAM Foundation @@ -161,6 +161,9 @@ protected: //- Time at last call, prevents repeated averaging label prevTimeIndex_; + //- Initialised flag + bool initialised_; + //- Restart the averaging process on restart Switch restartOnRestart_; @@ -176,9 +179,6 @@ protected: //- Specific restart time scalar restartTime_; - //- Initialised flag - bool initialised_; - //- List of field average items, describing what averages to be // calculated and output List faItems_; @@ -301,7 +301,7 @@ public: //- Destructor - virtual ~fieldAverage(); + virtual ~fieldAverage() = default; // Member Functions diff --git a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C index 61eee7ac2b..6b7fe6e1be 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2017 OpenFOAM Foundation @@ -77,9 +77,11 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType meanFieldName, obr().time().timeName(obr().time().startTime().value()), obr(), - restartOnOutput_ ? - IOobject::NO_READ - : IOobject::READ_IF_PRESENT, + ( + restartOnOutput_ + ? IOobject::NO_READ + : IOobject::READ_IF_PRESENT + ), IOobject::NO_WRITE ), 1*baseField diff --git a/src/functionObjects/field/fieldExpression/fieldExpression.C b/src/functionObjects/field/fieldExpression/fieldExpression.C index 335d993b4a..4f89fd4a7e 100644 --- a/src/functionObjects/field/fieldExpression/fieldExpression.C +++ b/src/functionObjects/field/fieldExpression/fieldExpression.C @@ -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) 2016 OpenFOAM Foundation @@ -85,12 +85,6 @@ Foam::functionObjects::fieldExpression::fieldExpression } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::fieldExpression::~fieldExpression() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::functionObjects::fieldExpression::read(const dictionary& dict) @@ -102,10 +96,7 @@ bool Foam::functionObjects::fieldExpression::read(const dictionary& dict) dict.readEntry("field", fieldName_); } - if (dict.found("result")) - { - dict.readEntry("result", resultName_); - } + dict.readIfPresent("result", resultName_); return true; } @@ -124,10 +115,8 @@ bool Foam::functionObjects::fieldExpression::execute() return false; } - else - { - return true; - } + + return true; } diff --git a/src/functionObjects/field/fieldExpression/fieldExpression.H b/src/functionObjects/field/fieldExpression/fieldExpression.H index 3475c2f597..e90def3a8e 100644 --- a/src/functionObjects/field/fieldExpression/fieldExpression.H +++ b/src/functionObjects/field/fieldExpression/fieldExpression.H @@ -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-2016 OpenFOAM Foundation @@ -63,7 +63,7 @@ class fieldExpression { protected: - // Protected member data + // Protected Member Data //- Name of field to process word fieldName_; @@ -72,7 +72,7 @@ protected: word resultName_; - // Protected member functions + // Protected Member Functions virtual bool calc() = 0; @@ -81,11 +81,6 @@ protected: template bool foundObject(const word& name, const bool verbose = true) const; - -private: - - // Private Member Functions - //- No copy construct fieldExpression(const fieldExpression&) = delete; @@ -113,13 +108,13 @@ public: //- Destructor - virtual ~fieldExpression(); + virtual ~fieldExpression() = default; // Member Functions //- Read the fieldExpression data - virtual bool read(const dictionary&); + virtual bool read(const dictionary& dict); //- Calculate the result field virtual bool execute(); diff --git a/src/functionObjects/field/fieldExpression/fieldExpressionTemplates.C b/src/functionObjects/field/fieldExpression/fieldExpressionTemplates.C index 53aa52134f..c07d2ef07b 100644 --- a/src/functionObjects/field/fieldExpression/fieldExpressionTemplates.C +++ b/src/functionObjects/field/fieldExpression/fieldExpressionTemplates.C @@ -40,18 +40,16 @@ bool Foam::functionObjects::fieldExpression::foundObject { return true; } - else - { - if (debug || verbose) - { - Warning - << " functionObjects::" << type() << " " << this->name() - << " cannot find required object " << name << " of type " - << Type::typeName << endl; - } - return false; + if (debug || verbose) + { + Warning + << " functionObjects::" << type() << " " << this->name() + << " cannot find required object " << name << " of type " + << Type::typeName << endl; } + + return false; } diff --git a/src/functionObjects/field/fieldsExpression/fieldsExpression.C b/src/functionObjects/field/fieldsExpression/fieldsExpression.C index fb59f7d0bf..1b01e201f0 100644 --- a/src/functionObjects/field/fieldsExpression/fieldsExpression.C +++ b/src/functionObjects/field/fieldsExpression/fieldsExpression.C @@ -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) 2016 OpenFOAM Foundation @@ -57,7 +57,7 @@ void Foam::functionObjects::fieldsExpression::setResultName if (!fieldNames_.empty()) { resultName_ = typeName + '(' + fieldNames_[0]; - for (label i=1; i bool calcAllTypes(FOType& fo); + //- Calculate expression virtual bool calc() = 0; - -private: - - // Private Member Functions - //- No copy construct fieldsExpression(const fieldsExpression&) = delete; @@ -127,13 +123,13 @@ public: //- Destructor - virtual ~fieldsExpression(); + virtual ~fieldsExpression() = default; // Member Functions //- Read the fieldsExpression data - virtual bool read(const dictionary&); + virtual bool read(const dictionary& dict); //- Calculate the result fields virtual bool execute(); diff --git a/src/functionObjects/field/fieldsExpression/fieldsExpressionTemplates.C b/src/functionObjects/field/fieldsExpression/fieldsExpressionTemplates.C index 924346e66e..6704dd75f0 100644 --- a/src/functionObjects/field/fieldsExpression/fieldsExpressionTemplates.C +++ b/src/functionObjects/field/fieldsExpression/fieldsExpressionTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2016 OpenFOAM Foundation @@ -62,10 +62,8 @@ bool Foam::functionObjects::fieldsExpression::calcFieldTypes(FOType& fo) fo.template calcFieldType() ); } - else - { - return false; - } + + return false; } diff --git a/src/functionObjects/field/fluxSummary/fluxSummary.C b/src/functionObjects/field/fluxSummary/fluxSummary.C index a3dcaa6c74..9aff420a03 100644 --- a/src/functionObjects/field/fluxSummary/fluxSummary.C +++ b/src/functionObjects/field/fluxSummary/fluxSummary.C @@ -74,20 +74,7 @@ Foam::functionObjects::fluxSummary::modeTypeNames_ bool Foam::functionObjects::fluxSummary::isSurfaceMode() const { - bool isSurf = false; - - switch (mode_) - { - case mdSurface: - case mdSurfaceAndDirection: - isSurf = true; - break; - - default: - break; - } - - return isSurf; + return (mdSurface == mode_ || mdSurfaceAndDirection == mode_); } @@ -99,8 +86,8 @@ Foam::word Foam::functionObjects::fluxSummary::checkFlowType { // Surfaces are multipled by their area, so account for that // in the dimension checking - dimensionSet dims = - fieldDims * (isSurfaceMode() ? dimTime*dimArea : dimTime); + const dimensionSet dims = + (fieldDims * (isSurfaceMode() ? dimTime*dimArea : dimTime)); if (dims == dimVolume) { @@ -110,16 +97,14 @@ Foam::word Foam::functionObjects::fluxSummary::checkFlowType { return "mass"; } - else - { - FatalErrorInFunction - << "Unsupported flux field " << fieldName << " with dimensions " - << fieldDims - << ". Expected either mass flow or volumetric flow rate." - << abort(FatalError); - return Foam::word::null; - } + FatalErrorInFunction + << "Unsupported flux field " << fieldName << " with dimensions " + << fieldDims + << ". Expected either mass flow or volumetric flow rate." + << abort(FatalError); + + return word::null; } @@ -143,8 +128,8 @@ void Foam::functionObjects::fluxSummary::initialiseSurface } names.append(surfName); - directions.append(Zero); // dummy value - faceFlip.append(boolList()); // no flip-map + directions.append(Zero); // Dummy value + faceFlip.append(boolList()); // No flip-map } @@ -168,19 +153,19 @@ void Foam::functionObjects::fluxSummary::initialiseSurfaceAndDirection << exit(FatalError); } - const surfMesh& s = *surfptr; + const auto& s = *surfptr; const vector refDir = dir/(mag(dir) + ROOTVSMALL); names.append(surfName); directions.append(refDir); - faceFlip.append(boolList(0)); + faceFlip.append(boolList()); // No flip-map boolList& flips = faceFlip[faceFlip.size()-1]; flips.setSize(s.size(), false); forAll(s, i) { - // orientation set by comparison with reference direction + // Orientation set by comparison with reference direction const vector& n = s.faceNormals()[i]; if ((n & refDir) > tolerance_) diff --git a/src/functionObjects/field/fluxSummary/fluxSummary.H b/src/functionObjects/field/fluxSummary/fluxSummary.H index ac04c519c2..0e76c0c49a 100644 --- a/src/functionObjects/field/fluxSummary/fluxSummary.H +++ b/src/functionObjects/field/fluxSummary/fluxSummary.H @@ -58,12 +58,12 @@ Usage Where the entries comprise: \table - Property | Description | Required | Default value - type | type name: fluxSummary | yes | - write | write flux data to file | no | yes - log | write flux data to standard output | no | yes - mode | mode to generate faces to test | yes | - scaleFactor | optional factor to scale result | no | 1 + Property | Description | Required | Default + type | Type name: fluxSummary | yes | + write | Write flux data to file | no | yes + log | Write flux data to standard output | no | yes + mode | Mode to generate faces to test | yes | + scaleFactor | Optional factor to scale result | no | 1 \endtable The mode is one of: @@ -97,6 +97,8 @@ SourceFiles namespace Foam { + +// Forward Declarations class dimensionSet; namespace functionObjects @@ -288,7 +290,7 @@ public: // Member Functions //- Read the field fluxSummary data - virtual bool read(const dictionary&); + virtual bool read(const dictionary& dict); //- Execute, currently does nothing virtual bool execute(); diff --git a/src/functionObjects/field/grad/grad.C b/src/functionObjects/field/grad/grad.C index 4efb7cb83b..676e20ede8 100644 --- a/src/functionObjects/field/grad/grad.C +++ b/src/functionObjects/field/grad/grad.C @@ -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) 2013-2016 OpenFOAM Foundation @@ -66,10 +66,4 @@ Foam::functionObjects::grad::grad {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::grad::~grad() -{} - - // ************************************************************************* // diff --git a/src/functionObjects/field/grad/grad.H b/src/functionObjects/field/grad/grad.H index f4d1040b4a..36b5368840 100644 --- a/src/functionObjects/field/grad/grad.H +++ b/src/functionObjects/field/grad/grad.H @@ -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-2016 OpenFOAM Foundation @@ -91,7 +91,7 @@ public: //- Destructor - virtual ~grad(); + virtual ~grad() = default; }; diff --git a/src/functionObjects/field/grad/gradTemplates.C b/src/functionObjects/field/grad/gradTemplates.C index 85a065ad90..2e0f0e585f 100644 --- a/src/functionObjects/field/grad/gradTemplates.C +++ b/src/functionObjects/field/grad/gradTemplates.C @@ -53,10 +53,8 @@ bool Foam::functionObjects::grad::calcGrad() mesh_.changing() && mesh_.cache(resultName_) ); } - else - { - return false; - } + + return false; } diff --git a/src/functionObjects/field/mag/mag.C b/src/functionObjects/field/mag/mag.C index 4aa8a008dc..131659dddf 100644 --- a/src/functionObjects/field/mag/mag.C +++ b/src/functionObjects/field/mag/mag.C @@ -69,10 +69,4 @@ Foam::functionObjects::mag::mag {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::mag::~mag() -{} - - // ************************************************************************* // diff --git a/src/functionObjects/field/mag/mag.H b/src/functionObjects/field/mag/mag.H index 36d8c09062..e8b09cf855 100644 --- a/src/functionObjects/field/mag/mag.H +++ b/src/functionObjects/field/mag/mag.H @@ -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-2016 OpenFOAM Foundation @@ -92,7 +92,7 @@ public: //- Destructor - virtual ~mag(); + virtual ~mag() = default; }; diff --git a/src/functionObjects/field/mag/magTemplates.C b/src/functionObjects/field/mag/magTemplates.C index b5873c5ae3..82f59f601e 100644 --- a/src/functionObjects/field/mag/magTemplates.C +++ b/src/functionObjects/field/mag/magTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2012-2016 OpenFOAM Foundation @@ -62,10 +62,8 @@ bool Foam::functionObjects::mag::calcMag() Foam::mag(lookupObject(fieldName_)) ); } - else - { - return false; - } + + return false; } diff --git a/src/functionObjects/field/magSqr/magSqr.C b/src/functionObjects/field/magSqr/magSqr.C index a628be423b..c83b5e48bc 100644 --- a/src/functionObjects/field/magSqr/magSqr.C +++ b/src/functionObjects/field/magSqr/magSqr.C @@ -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) 2016 OpenFOAM Foundation @@ -69,10 +69,4 @@ Foam::functionObjects::magSqr::magSqr {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::magSqr::~magSqr() -{} - - // ************************************************************************* // diff --git a/src/functionObjects/field/magSqr/magSqr.H b/src/functionObjects/field/magSqr/magSqr.H index 8f7be147d2..5e92bbbd26 100644 --- a/src/functionObjects/field/magSqr/magSqr.H +++ b/src/functionObjects/field/magSqr/magSqr.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2016 OpenFOAM Foundation @@ -94,7 +94,7 @@ public: //- Destructor - virtual ~magSqr(); + virtual ~magSqr() = default; }; diff --git a/src/functionObjects/field/magSqr/magSqrTemplates.C b/src/functionObjects/field/magSqr/magSqrTemplates.C index f34a21ebb5..1f636b2496 100644 --- a/src/functionObjects/field/magSqr/magSqrTemplates.C +++ b/src/functionObjects/field/magSqr/magSqrTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2016 OpenFOAM Foundation @@ -62,10 +62,8 @@ bool Foam::functionObjects::magSqr::calcMagSqr() Foam::magSqr(lookupObject(fieldName_)) ); } - else - { - return false; - } + + return false; }