diff --git a/applications/utilities/preProcessing/setFields/setFields.C b/applications/utilities/preProcessing/setFields/setFields.C index cdca73df55..14f3a5acf7 100644 --- a/applications/utilities/preProcessing/setFields/setFields.C +++ b/applications/utilities/preProcessing/setFields/setFields.C @@ -440,7 +440,7 @@ int main(int argc, char *argv[]) autoPtr source = topoSetSource::New(region.keyword(), mesh, region.dict()); - if (source().setType() == topoSetSource::CELLSETSOURCE) + if (source().setType() == topoSetSource::CELLSET_SOURCE) { cellSet selectedCellSet ( @@ -461,7 +461,7 @@ int main(int argc, char *argv[]) setCellField::iNew(mesh, selectedCellSet.sortedToc()) ); } - else if (source().setType() == topoSetSource::FACESETSOURCE) + else if (source().setType() == topoSetSource::FACESET_SOURCE) { faceSet selectedFaceSet ( diff --git a/src/faOptions/corrections/limitVelocity/limitVelocity.C b/src/faOptions/corrections/limitVelocity/limitVelocity.C index fa2f484fab..a7440549a6 100644 --- a/src/faOptions/corrections/limitVelocity/limitVelocity.C +++ b/src/faOptions/corrections/limitVelocity/limitVelocity.C @@ -95,15 +95,11 @@ void Foam::fa::limitVelocity::correct(areaVectorField& U) } } - // handle boundaries in the case of 'all' - if (selectionMode_ == smAll) + // Handle boundaries in the case of 'all' + if (!cellSetOption::useSubMesh()) { - areaVectorField::Boundary& Ubf = U.boundaryFieldRef(); - - forAll(Ubf, patchi) + for (faPatchVectorField& Up : U.boundaryFieldRef()) { - faPatchVectorField& Up = Ubf[patchi]; - if (!Up.fixesValue()) { forAll(Up, facei) diff --git a/src/faOptions/faceSetOption/faceSetOption.C b/src/faOptions/faceSetOption/faceSetOption.C index 90d10014e7..e2436cd854 100644 --- a/src/faOptions/faceSetOption/faceSetOption.C +++ b/src/faOptions/faceSetOption/faceSetOption.C @@ -105,7 +105,7 @@ void Foam::fa::faceSetOption::setArea() } -void Foam::fa::faceSetOption::setFaceSet() +void Foam::fa::faceSetOption::setFaceSelection() { switch (selectionMode_) { @@ -182,18 +182,18 @@ Foam::fa::faceSetOption::faceSetOption ) : fa::option(name, modelType, dict, patch), - timeStart_(-1.0), - duration_(0.0), + timeStart_(-1), + duration_(0), selectionMode_(selectionModeTypeNames_.get("selectionMode", coeffs_)), faceSetName_("none"), - A_(0.0) + A_(0) { if (isActive()) { Info<< incrIndent; read(dict); setSelection(coeffs_); - setFaceSet(); + setFaceSelection(); setArea(); Info<< decrIndent; } diff --git a/src/faOptions/faceSetOption/faceSetOption.H b/src/faOptions/faceSetOption/faceSetOption.H index 559cacdae2..46abaed1ca 100644 --- a/src/faOptions/faceSetOption/faceSetOption.H +++ b/src/faOptions/faceSetOption/faceSetOption.H @@ -132,7 +132,7 @@ protected: //- Face selection mode selectionModeType selectionMode_; - //- Name of zone for "faceZone" selectionMode + //- Name of "volFaceZone" selection word faceSetName_; //- Set of faces to apply source to @@ -144,11 +144,11 @@ protected: // Protected Functions - //- Set the face selection + //- Set face selection name from dictionary input void setSelection(const dictionary& dict); - //- Set the face set based on the user input selection mode - void setFaceSet(); + //- Set face selection based on user input selection mode + void setFaceSelection(); //- Recalculate the area void setArea(); @@ -181,35 +181,38 @@ public: // Access //- Return const access to the time start - inline scalar timeStart() const; + inline scalar timeStart() const noexcept; //- Return const access to the duration - inline scalar duration() const; + inline scalar duration() const noexcept; //- Return true if within time limits - inline bool inTimeLimits(const scalar time) const; + inline bool inTimeLimits(const scalar timeValue) const; //- Return const access to the face selection mode - inline const selectionModeType& selectionMode() const; + inline selectionModeType selectionMode() const noexcept; + + //- True if sub-selection should be used + inline bool useSubMesh() const noexcept; //- Return const access to the name of face set for "faceZone" //- selectionMode - inline const word& faceSetName() const; + inline const word& faceSetName() const noexcept; //- Return const access to the total face area - inline scalar A() const; + inline scalar A() const noexcept; - //- Return const access to the face set - inline const labelList& faces() const; + //- Return const access to the face selection + inline const labelList& faces() const noexcept; // Edit - //- Return access to the time start - inline scalar& timeStart(); + //- Adjust the time start, return the old value + inline scalar timeStart(scalar val) noexcept; - //- Return access to the duration - inline scalar& duration(); + //- Adjust the duration, return the old value + inline scalar duration(scalar val) noexcept; // Checks diff --git a/src/faOptions/faceSetOption/faceSetOptionI.H b/src/faOptions/faceSetOption/faceSetOptionI.H index d63ee88560..1bc9b5ed25 100644 --- a/src/faOptions/faceSetOption/faceSetOptionI.H +++ b/src/faOptions/faceSetOption/faceSetOptionI.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,19 +27,19 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline Foam::scalar Foam::fa::faceSetOption::timeStart() const +inline Foam::scalar Foam::fa::faceSetOption::timeStart() const noexcept { return timeStart_; } -inline Foam::scalar Foam::fa::faceSetOption::duration() const +inline Foam::scalar Foam::fa::faceSetOption::duration() const noexcept { return duration_; } -inline bool Foam::fa::faceSetOption::inTimeLimits(const scalar time) const +inline bool Foam::fa::faceSetOption::inTimeLimits(const scalar timeValue) const { return ( @@ -53,40 +53,50 @@ inline bool Foam::fa::faceSetOption::inTimeLimits(const scalar time) const } -inline const Foam::fa::faceSetOption::selectionModeType& -Foam::fa::faceSetOption::selectionMode() const +inline Foam::fa::faceSetOption::selectionModeType +Foam::fa::faceSetOption::selectionMode() const noexcept { return selectionMode_; } -inline const Foam::word& Foam::fa::faceSetOption::faceSetName() const +inline bool Foam::fa::faceSetOption::useSubMesh() const noexcept +{ + return selectionMode_ != selectionModeType::smAll; +} + + +inline const Foam::word& Foam::fa::faceSetOption::faceSetName() const noexcept { return faceSetName_; } -inline Foam::scalar Foam::fa::faceSetOption::A() const +inline Foam::scalar Foam::fa::faceSetOption::A() const noexcept { return A_; } -inline const Foam::labelList& Foam::fa::faceSetOption::faces() const +inline const Foam::labelList& Foam::fa::faceSetOption::faces() const noexcept { return faces_; } -inline Foam::scalar& Foam::fa::faceSetOption::timeStart() +inline Foam::scalar Foam::fa::faceSetOption::timeStart(scalar val) noexcept { - return timeStart_; + scalar old(timeStart_); + timeStart_ = val; + return old; } -inline Foam::scalar& Foam::fa::faceSetOption::duration() +inline Foam::scalar Foam::fa::faceSetOption::duration(scalar val) noexcept { - return duration_; + scalar old(duration_); + duration_ = val; + return old; } diff --git a/src/fvOptions/cellSetOption/cellSetOption.C b/src/fvOptions/cellSetOption/cellSetOption.C index b74fb597db..bede9ebc04 100644 --- a/src/fvOptions/cellSetOption/cellSetOption.C +++ b/src/fvOptions/cellSetOption/cellSetOption.C @@ -118,7 +118,7 @@ void Foam::fv::cellSetOption::setVol() } -void Foam::fv::cellSetOption::setCellSet() +void Foam::fv::cellSetOption::setCellSelection() { switch (selectionMode_) { @@ -205,16 +205,16 @@ Foam::fv::cellSetOption::cellSetOption ) : fv::option(name, modelType, dict, mesh), - timeStart_(-1.0), - duration_(0.0), + timeStart_(-1), + duration_(0), selectionMode_(selectionModeTypeNames_.get("selectionMode", coeffs_)), cellSetName_("none"), - V_(0.0) + V_(0) { Info<< incrIndent; read(dict); setSelection(coeffs_); - setCellSet(); + setCellSelection(); setVol(); Info<< decrIndent; } @@ -231,14 +231,14 @@ bool Foam::fv::cellSetOption::isActive() { if (mesh_.topoChanging()) { - setCellSet(); + setCellSelection(); // Force printing of new set volume V_ = -GREAT; } else if (selectionMode_ == smPoints) { // This is the only geometric selection mode - setCellSet(); + setCellSelection(); } // Report new volume (if changed) diff --git a/src/fvOptions/cellSetOption/cellSetOption.H b/src/fvOptions/cellSetOption/cellSetOption.H index 02b2931fdc..0b630e7463 100644 --- a/src/fvOptions/cellSetOption/cellSetOption.H +++ b/src/fvOptions/cellSetOption/cellSetOption.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -126,10 +126,10 @@ public: //- Enumeration for selection mode types enum selectionModeType { - smPoints, + smAll, smCellSet, smCellZone, - smAll + smPoints }; //- List of selection mode type names @@ -138,7 +138,7 @@ public: protected: - // Protected data + // Protected Data //- Start time of fvOption scalar timeStart_; @@ -162,13 +162,13 @@ protected: scalar V_; - // Protected functions + // Protected Functions - //- Set the cellSet or points selection + //- Set cell selection name or points selection from dictionary input void setSelection(const dictionary& dict); - //- Set the cell set based on the user input selection mode - void setCellSet(); + //- Set the cell selection based on user input selection mode + void setCellSelection(); //- Recalculate the volume void setVol(); @@ -201,35 +201,38 @@ public: // Access //- Return const access to the time start - inline scalar timeStart() const; + inline scalar timeStart() const noexcept; //- Return const access to the duration - inline scalar duration() const; + inline scalar duration() const noexcept; - //- Return true if within time limits - inline bool inTimeLimits(const scalar time) const; + //- True if within time limits + inline bool inTimeLimits(const scalar timeValue) const; - //- Return const access to the cell selection mode - inline const selectionModeType& selectionMode() const; + //- Return the cell selection mode + inline selectionModeType selectionMode() const noexcept; - //- Return const access to the name of cell set for "cellSet" - // selectionMode - inline const word& cellSetName() const; + //- True if sub-selection should be used + inline bool useSubMesh() const noexcept; + + //- Return const access to the name of cell set/zone for + //- "cellSet" / "cellZone" selection modes + inline const word& cellSetName() const noexcept; //- Return const access to the total cell volume - inline scalar V() const; + inline scalar V() const noexcept; - //- Return const access to the cell set - inline const labelList& cells() const; + //- Return const access to the cell selection + inline const labelList& cells() const noexcept; // Edit - //- Return access to the time start - inline scalar& timeStart(); + //- Adjust the time start, return the old value + inline scalar timeStart(scalar val) noexcept; - //- Return access to the duration - inline scalar& duration(); + //- Adjust the duration, return the old value + inline scalar duration(scalar val) noexcept; // Checks diff --git a/src/fvOptions/cellSetOption/cellSetOptionI.H b/src/fvOptions/cellSetOption/cellSetOptionI.H index da6b40d23c..3917f206b8 100644 --- a/src/fvOptions/cellSetOption/cellSetOptionI.H +++ b/src/fvOptions/cellSetOption/cellSetOptionI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,19 +28,19 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline Foam::scalar Foam::fv::cellSetOption::timeStart() const +inline Foam::scalar Foam::fv::cellSetOption::timeStart() const noexcept { return timeStart_; } -inline Foam::scalar Foam::fv::cellSetOption::duration() const +inline Foam::scalar Foam::fv::cellSetOption::duration() const noexcept { return duration_; } -inline bool Foam::fv::cellSetOption::inTimeLimits(const scalar time) const +inline bool Foam::fv::cellSetOption::inTimeLimits(const scalar timeValue) const { return ( @@ -53,40 +54,50 @@ inline bool Foam::fv::cellSetOption::inTimeLimits(const scalar time) const } -inline const Foam::fv::cellSetOption::selectionModeType& -Foam::fv::cellSetOption::selectionMode() const +inline Foam::fv::cellSetOption::selectionModeType +Foam::fv::cellSetOption::selectionMode() const noexcept { return selectionMode_; } -inline const Foam::word& Foam::fv::cellSetOption::cellSetName() const +inline bool Foam::fv::cellSetOption::useSubMesh() const noexcept +{ + return selectionMode_ != selectionModeType::smAll; +} + + +inline const Foam::word& Foam::fv::cellSetOption::cellSetName() const noexcept { return cellSetName_; } -inline Foam::scalar Foam::fv::cellSetOption::V() const +inline Foam::scalar Foam::fv::cellSetOption::V() const noexcept { return V_; } -inline const Foam::labelList& Foam::fv::cellSetOption::cells() const +inline const Foam::labelList& Foam::fv::cellSetOption::cells() const noexcept { return cells_; } -inline Foam::scalar& Foam::fv::cellSetOption::timeStart() +inline Foam::scalar Foam::fv::cellSetOption::timeStart(scalar val) noexcept { - return timeStart_; + scalar old(timeStart_); + timeStart_ = val; + return old; } -inline Foam::scalar& Foam::fv::cellSetOption::duration() +inline Foam::scalar Foam::fv::cellSetOption::duration(scalar val) noexcept { - return duration_; + scalar old(duration_); + duration_ = val; + return old; } diff --git a/src/fvOptions/corrections/limitTemperature/limitTemperature.C b/src/fvOptions/corrections/limitTemperature/limitTemperature.C index f47361f012..a96d5d697d 100644 --- a/src/fvOptions/corrections/limitTemperature/limitTemperature.C +++ b/src/fvOptions/corrections/limitTemperature/limitTemperature.C @@ -162,8 +162,8 @@ void Foam::fv::limitTemperature::correct(volScalarField& he) Info<< type() << " " << name_ << " Unlimited Tmax " << Tmax0 << nl << "Unlimited Tmin " << Tmin0 << endl; - // handle boundaries in the case of 'all' - if (selectionMode_ == smAll) + // Handle boundaries in the case of 'all' + if (!cellSetOption::useSubMesh()) { volScalarField::Boundary& bf = he.boundaryFieldRef(); diff --git a/src/fvOptions/corrections/limitVelocity/limitVelocity.C b/src/fvOptions/corrections/limitVelocity/limitVelocity.C index 37f6ccae19..2f8d1003ce 100644 --- a/src/fvOptions/corrections/limitVelocity/limitVelocity.C +++ b/src/fvOptions/corrections/limitVelocity/limitVelocity.C @@ -92,15 +92,11 @@ void Foam::fv::limitVelocity::correct(volVectorField& U) } } - // handle boundaries in the case of 'all' - if (selectionMode_ == smAll) + // Handle boundaries in the case of 'all' + if (!cellSetOption::useSubMesh()) { - volVectorField::Boundary& Ubf = U.boundaryFieldRef(); - - forAll(Ubf, patchi) + for (fvPatchVectorField& Up : U.boundaryFieldRef()) { - fvPatchVectorField& Up = Ubf[patchi]; - if (!Up.fixesValue()) { forAll(Up, facei) diff --git a/src/fvOptions/sources/derived/actuationDiskSource/actuationDiskSourceTemplates.C b/src/fvOptions/sources/derived/actuationDiskSource/actuationDiskSourceTemplates.C index fdd40cfe70..f51001a7b4 100644 --- a/src/fvOptions/sources/derived/actuationDiskSource/actuationDiskSourceTemplates.C +++ b/src/fvOptions/sources/derived/actuationDiskSource/actuationDiskSourceTemplates.C @@ -79,7 +79,7 @@ void Foam::fv::actuationDiskSource::calcFroudeMethod scalar rhoRef = 0.0; label szMonitorCells = monitorCells_.size(); - for (const auto& celli : monitorCells_) + for (const label celli : monitorCells_) { Uref += U[celli]; rhoRef = rhoRef + rho[celli]; @@ -150,7 +150,7 @@ void Foam::fv::actuationDiskSource::calcVariableScalingMethod scalar rhoRef = 0.0; label szMonitorCells = monitorCells_.size(); - for (const auto& celli : monitorCells_) + for (const label celli : monitorCells_) { Uref += U[celli]; rhoRef = rhoRef + rho[celli]; @@ -175,7 +175,7 @@ void Foam::fv::actuationDiskSource::calcVariableScalingMethod scalar rhoDisk = 0.0; scalar totalV = 0.0; - for (const auto& celli : cells_) + for (const label celli : cells_) { Udisk += U[celli]*cellsV[celli]; rhoDisk += rho[celli]*cellsV[celli]; diff --git a/src/fvOptions/sources/derived/radialActuationDiskSource/radialActuationDiskSourceTemplates.C b/src/fvOptions/sources/derived/radialActuationDiskSource/radialActuationDiskSourceTemplates.C index d686cde720..037c4ef820 100644 --- a/src/fvOptions/sources/derived/radialActuationDiskSource/radialActuationDiskSourceTemplates.C +++ b/src/fvOptions/sources/derived/radialActuationDiskSource/radialActuationDiskSourceTemplates.C @@ -76,7 +76,7 @@ addRadialActuationDiskAxialInertialResistance scalar rhoRef = 0.0; label szMonitorCells = monitorCells_.size(); - for (const auto& celli : monitorCells_) + for (const label celli : monitorCells_) { Uref += U[celli]; rhoRef = rhoRef + rho[celli]; diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C index 4c70b9bc15..0f3ade71f0 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C @@ -108,7 +108,6 @@ void Foam::fv::rotorDiskSource::checkData() } } - break; } default: