STYLE: consistent looping of patchSet entries

This commit is contained in:
Mark Olesen
2020-05-01 17:31:01 +02:00
parent 0680416b59
commit 2a24bab057
19 changed files with 136 additions and 161 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,7 +65,7 @@ bool Foam::functionObjects::Curle::calc()
dimensionedVector dfdt("dfdt", p.dimensions()*dimArea/dimTime, Zero);
for (auto patchi : patchSet_)
for (const label patchi : patchSet_)
{
dfdt.value() += sum(dpdtBf[patchi]*SfBf[patchi]);
}
@ -101,6 +101,7 @@ bool Foam::functionObjects::Curle::calc()
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::Curle::Curle
@ -121,19 +122,17 @@ Foam::functionObjects::Curle::Curle
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::Curle::~Curle()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::Curle::read(const dictionary& dict)
{
if (fieldExpression::read(dict))
{
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
patchSet_ =
mesh_.boundaryMesh().patchSet
(
dict.get<wordRes>("patches")
);
if (patchSet_.empty())
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,7 +106,7 @@ class Curle
:
public fieldExpression
{
// Private data
// Private Data
// Read from dictionary
@ -120,7 +120,12 @@ class Curle
dimensionedScalar c0_;
// Private Member Functions
protected:
// Protected Member Functions
//- Calculate acoustic pressure field and return true if successful
virtual bool calc();
//- No copy construct
Curle(const Curle&) = delete;
@ -129,12 +134,6 @@ class Curle
void operator=(const Curle&) = delete;
protected:
//- Calculate the acoustic pressure field and return true if successful
virtual bool calc();
public:
//- Runtime type information
@ -153,7 +152,7 @@ public:
//- Destructor
virtual ~Curle();
virtual ~Curle() = default;
// Member Functions

View File

@ -48,14 +48,13 @@ namespace functionObjects
const Foam::meshStructure&
Foam::functionObjects::columnAverage::meshAddressing(const polyMesh& mesh) const
{
if (!meshStructurePtr_.valid())
if (!meshStructurePtr_)
{
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
const labelList patchIDs(patchSet_.sortedToc());
// Count
label sz = 0;
for (const label patchi : patchIDs)
for (const label patchi : patchIDs_)
{
sz += pbm[patchi].size();
}
@ -63,7 +62,7 @@ Foam::functionObjects::columnAverage::meshAddressing(const polyMesh& mesh) const
// Fill
labelList meshFaces(sz);
sz = 0;
for (const label patchi : patchIDs)
for (const label patchi : patchIDs_)
{
label start = pbm[patchi].start();
label size = pbm[patchi].size();
@ -92,7 +91,7 @@ Foam::functionObjects::columnAverage::meshAddressing(const polyMesh& mesh) const
globalFaces_.set(new globalIndex(uip.size()));
globalEdges_.set(new globalIndex(uip.nEdges()));
globalPoints_.set(new globalIndex(uip.nPoints()));
meshStructurePtr_.set
meshStructurePtr_.reset
(
new meshStructure
(
@ -104,7 +103,8 @@ Foam::functionObjects::columnAverage::meshAddressing(const polyMesh& mesh) const
)
);
}
return meshStructurePtr_();
return *meshStructurePtr_;
}
@ -127,7 +127,7 @@ Foam::functionObjects::columnAverage::columnAverage
)
:
fvMeshFunctionObject(name, runTime, dict),
patchSet_(),
patchIDs_(),
fieldSet_(mesh_)
{
read(dict);
@ -140,7 +140,11 @@ bool Foam::functionObjects::columnAverage::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
patchIDs_ =
mesh_.boundaryMesh().patchSet
(
dict.get<wordRes>("patches")
).sortedToc();
fieldSet_.read(dict);

View File

@ -54,10 +54,10 @@ Usage
Where the entries comprise:
\table
Property | Description | Required | Default value
type | type name: fieldMinMax | yes |
patches | list of patches to collapse onto | yes |
fields | list of fields to process | yes |
Property | Description | Required | Default
type | type name: columnAverage | yes |
patches | list of patches to collapse onto | yes |
fields | list of fields to process | yes |
\endtable
See also
@ -96,8 +96,8 @@ class columnAverage
{
// Private Data
//- Patches on which to collapse the fields
labelHashSet patchSet_;
//- Patches on which to collapse the fields (in sorted order)
labelList patchIDs_;
//- Fields to collapse
volFieldSelection fieldSet_;
@ -134,7 +134,7 @@ public:
(
const word& name,
const Time& runTime,
const dictionary&
const dictionary& dict
);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -97,18 +97,9 @@ class ReynoldsAnalogy
:
public heatTransferCoeffModel
{
// Private Member Functions
//- No copy construct
ReynoldsAnalogy(const ReynoldsAnalogy&) = delete;
//- No copy assignment
void operator=(const ReynoldsAnalogy&) = delete;
protected:
// Protected data
// Protected Data
//- Name of velocity field
word UName_;
@ -143,6 +134,13 @@ protected:
virtual void htc(volScalarField& htc);
//- No copy construct
ReynoldsAnalogy(const ReynoldsAnalogy&) = delete;
//- No copy assignment
void operator=(const ReynoldsAnalogy&) = delete;
public:
//- Runtime type information

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,7 +26,6 @@ License
\*---------------------------------------------------------------------------*/
#include "fixedReferenceTemperature.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -47,7 +46,8 @@ namespace heatTransferCoeffModels
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::heatTransferCoeffModels::fixedReferenceTemperature::fixedReferenceTemperature
Foam::heatTransferCoeffModels::fixedReferenceTemperature::
fixedReferenceTemperature
(
const dictionary& dict,
const fvMesh& mesh,
@ -90,9 +90,8 @@ void Foam::heatTransferCoeffModels::fixedReferenceTemperature::htc
const scalar eps = ROOTVSMALL;
volScalarField::Boundary& htcBf = htc.boundaryFieldRef();
forAllConstIters(patchSet_, iter)
for (const label patchi : patchSet_)
{
label patchi = iter.key();
htcBf[patchi] = qBf[patchi]/(TRef_ - Tbf[patchi] + eps);
}
}

View File

@ -49,10 +49,10 @@ Usage
Where the entries comprise:
\table
Property | Description | Required | Default value
type | type name: heatTransferCoeff | yes |
htcModel | selected htc model | yes |
TRef | reference temperature | yes |
Property | Description | Required | Default
type | type name: heatTransferCoeff | yes |
htcModel | selected htc model | yes |
TRef | reference temperature | yes |
\endtable
SourceFiles
@ -83,20 +83,11 @@ class fixedReferenceTemperature
:
public heatTransferCoeffModel
{
// Private Member Functions
//- No copy construct
fixedReferenceTemperature(const fixedReferenceTemperature&) = delete;
//- No copy assignment
void operator=(const fixedReferenceTemperature&) = delete;
protected:
// Protected data
// Protected Data
//- Reference tempetaure
//- Reference temperature
scalar TRef_;
@ -105,6 +96,12 @@ protected:
//- Set the heat transfer coefficient
virtual void htc(volScalarField& htc);
//- No copy construct
fixedReferenceTemperature(const fixedReferenceTemperature&) = delete;
//- No copy assignment
void operator=(const fixedReferenceTemperature&) = delete;
public:

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,7 +85,7 @@ Foam::heatTransferCoeffModel::q() const
const volScalarField& alpha(thermo.alpha());
const volScalarField::Boundary& alphabf = alpha.boundaryField();
for (label patchi : patchSet_)
for (const label patchi : patchSet_)
{
q[patchi] = alphabf[patchi]*hebf[patchi].snGrad();
}
@ -98,10 +98,12 @@ Foam::heatTransferCoeffModel::q() const
}
// Add radiative heat flux contribution if present
if (mesh_.foundObject<volScalarField>(qrName_))
const volScalarField* qrPtr = mesh_.cfindObject<volScalarField>(qrName_);
if (qrPtr)
{
const volScalarField& qr = mesh_.lookupObject<volScalarField>(qrName_);
const volScalarField::Boundary& qrbf = qr.boundaryField();
const volScalarField::Boundary& qrbf = qrPtr->boundaryField();
for (const label patchi : patchSet_)
{
@ -123,8 +125,8 @@ Foam::heatTransferCoeffModel::heatTransferCoeffModel
)
:
mesh_(mesh),
TName_(TName),
patchSet_(),
TName_(TName),
qrName_("qr")
{}
@ -133,7 +135,11 @@ Foam::heatTransferCoeffModel::heatTransferCoeffModel
bool Foam::heatTransferCoeffModel::read(const dictionary& dict)
{
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
patchSet_ =
mesh_.boundaryMesh().patchSet
(
dict.get<wordRes>("patches")
);
dict.readIfPresent("qr", qrName_);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,6 +55,7 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class fvMesh;
/*---------------------------------------------------------------------------*\
@ -63,8 +64,29 @@ class fvMesh;
class heatTransferCoeffModel
{
protected:
// Private Member Functions
// Protected Data
//- Mesh reference
const fvMesh& mesh_;
//- Optional list of (wall) patches to process
labelHashSet patchSet_;
//- Temperature name
const word TName_;
//- Name of radiative heat flux name, default = qr
word qrName_;
// Protected Member Functions
tmp<FieldField<Field, scalar>> q() const;
//- Set the heat transfer coefficient
virtual void htc(volScalarField& htc) = 0;
//- No copy construct
heatTransferCoeffModel(const heatTransferCoeffModel&) = delete;
@ -73,24 +95,6 @@ class heatTransferCoeffModel
void operator=(const heatTransferCoeffModel&) = delete;
protected:
// Protected data
const fvMesh& mesh_;
const word TName_;
labelHashSet patchSet_;
word qrName_;
tmp<FieldField<Field, scalar>> q() const;
//- Set the heat transfer coefficient
virtual void htc(volScalarField& htc) = 0;
public:
//- Runtime type information

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,7 +26,6 @@ License
\*---------------------------------------------------------------------------*/
#include "localReferenceTemperature.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -45,6 +44,7 @@ namespace heatTransferCoeffModels
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::heatTransferCoeffModels::localReferenceTemperature::
@ -83,9 +83,9 @@ void Foam::heatTransferCoeffModels::localReferenceTemperature::htc
const scalar eps = ROOTVSMALL;
volScalarField::Boundary& htcBf = htc.boundaryFieldRef();
forAllConstIters(patchSet_, iter)
for (const label patchi : patchSet_)
{
label patchi = iter.key();
const scalarField Tc(Tbf[patchi].patchInternalField());
htcBf[patchi] = qBf[patchi]/(Tc - Tbf[patchi] + eps);
}

View File

@ -256,14 +256,6 @@ Foam::functionObjects::nearWallFields::nearWallFields
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::nearWallFields::~nearWallFields()
{
DebugInFunction << endl;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::nearWallFields::read(const dictionary& dict)
@ -272,7 +264,12 @@ bool Foam::functionObjects::nearWallFields::read(const dictionary& dict)
dict.readEntry("fields", fieldSet_);
dict.readEntry("distance", distance_);
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
patchSet_ =
mesh_.boundaryMesh().patchSet
(
dict.get<wordRes>("patches")
);
// Clear out any previously loaded fields

View File

@ -106,7 +106,7 @@ class nearWallFields
{
protected:
// Protected member data
// Protected Member Data
// Read from dictionary
@ -176,8 +176,6 @@ protected:
) const;
private:
//- No copy construct
nearWallFields(const nearWallFields&) = delete;
@ -203,13 +201,13 @@ public:
//- Destructor
virtual ~nearWallFields();
virtual ~nearWallFields() = default;
// Member Functions
//- Read the controls
virtual bool read(const dictionary&);
virtual bool read(const dictionary& dict);
//- Calculate the near-wall fields
virtual bool execute();

View File

@ -75,26 +75,21 @@ void Foam::functionObjects::wallHeatFlux::calcHeatFlux
const volScalarField::Boundary& alphaBf = alpha.boundaryField();
forAll(wallHeatFluxBf, patchi)
for (const label patchi : patchSet_)
{
if (!wallHeatFluxBf[patchi].coupled())
{
wallHeatFluxBf[patchi] = alphaBf[patchi]*heBf[patchi].snGrad();
}
wallHeatFluxBf[patchi] = alphaBf[patchi]*heBf[patchi].snGrad();
}
if (foundObject<volScalarField>(qrName_))
const auto* qrPtr = cfindObject<volScalarField>(qrName_);
if (qrPtr)
{
const volScalarField& qr = lookupObject<volScalarField>(qrName_);
const volScalarField::Boundary& radHeatFluxBf = qrPtr->boundaryField();
const volScalarField::Boundary& radHeatFluxBf = qr.boundaryField();
forAll(wallHeatFluxBf, patchi)
for (const label patchi : patchSet_)
{
if (!wallHeatFluxBf[patchi].coupled())
{
wallHeatFluxBf[patchi] -= radHeatFluxBf[patchi];
}
wallHeatFluxBf[patchi] -= radHeatFluxBf[patchi];
}
}
}
@ -139,12 +134,6 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::wallHeatFlux::~wallHeatFlux()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::wallHeatFlux::read(const dictionary& dict)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,7 +52,7 @@ Usage
Where the entries comprise:
\table
Property | Description | Required | Default value
Property | Description | Required | Default
type | type name: wallHeatFlux | yes |
patches | list of patches to process | no | all wall patches
qr | name of radiative heat flux field | no | qr
@ -94,12 +94,11 @@ class wallHeatFlux
public fvMeshFunctionObject,
public writeFile
{
protected:
// Protected data
// Protected Data
//- Optional list of patches to process
//- Optional list of wall patches to process
labelHashSet patchSet_;
//- Name of radiative heat flux name, default = qr
@ -120,9 +119,7 @@ protected:
);
private:
// Private member functions
// Protected Member Functions
//- No copy construct
wallHeatFlux(const wallHeatFlux&) = delete;
@ -149,13 +146,13 @@ public:
//- Destructor
virtual ~wallHeatFlux();
virtual ~wallHeatFlux() = default;
// Member Functions
//- Read the wallHeatFlux data
virtual bool read(const dictionary&);
virtual bool read(const dictionary& dict);
//- Calculate the wall heat-flux
virtual bool execute();

View File

@ -118,12 +118,6 @@ Foam::functionObjects::wallShearStress::wallShearStress
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::wallShearStress::~wallShearStress()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)

View File

@ -107,7 +107,7 @@ class wallShearStress
protected:
// Protected data
// Protected Data
//- Optional list of patches to process
labelHashSet patchSet_;
@ -125,11 +125,6 @@ protected:
volVectorField& shearStress
);
private:
// Private member functions
//- No copy construct
wallShearStress(const wallShearStress&) = delete;
@ -155,7 +150,7 @@ public:
//- Destructor
virtual ~wallShearStress();
virtual ~wallShearStress() = default;
// Member Functions

View File

@ -813,9 +813,11 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
directForceDensity_ = dict.lookupOrDefault("directForceDensity", false);
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
patchSet_ = pbm.patchSet(dict.get<wordRes>("patches"));
patchSet_ =
mesh_.boundaryMesh().patchSet
(
dict.get<wordRes>("patches")
);
if (directForceDensity_)
{

View File

@ -119,10 +119,7 @@ class rigidBodyMeshMotionSolver
// Private Member Functions
//- No copy construct
rigidBodyMeshMotionSolver
(
const rigidBodyMeshMotionSolver&
) = delete;
rigidBodyMeshMotionSolver(const rigidBodyMeshMotionSolver&) = delete;
//- No copy assignment
void operator=(const rigidBodyMeshMotionSolver&) = delete;