ENH: additional tests in {cell,face}SetOption

- useSubMesh() - name as per fvMeshSubsetProxy.
  Setter methods take a parameter instead of direct access.
This commit is contained in:
Mark Olesen 2021-10-27 17:06:23 +02:00
parent f5058bca90
commit 3d3d287452
13 changed files with 118 additions and 100 deletions

View File

@ -440,7 +440,7 @@ int main(int argc, char *argv[])
autoPtr<topoSetSource> 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
(

View File

@ -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)

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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)

View File

@ -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

View File

@ -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;
}

View File

@ -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();

View File

@ -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)

View File

@ -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];

View File

@ -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];

View File

@ -108,7 +108,6 @@ void Foam::fv::rotorDiskSource::checkData()
}
}
break;
}
default: