ENH: functionObjects: add optional flag to suppress warnings for missing patches

This commit is contained in:
Kutalmis Bercin 2024-09-12 16:30:03 +01:00
parent 1d6396dd3f
commit bacb35a4df
18 changed files with 77 additions and 18 deletions

View File

@ -67,7 +67,8 @@ Foam::functionObjects::Curle::Curle
c0_(0),
rawFilePtrs_(),
inputSurface_(),
surfaceWriterPtr_(nullptr)
surfaceWriterPtr_(nullptr),
warnOnNoPatch_(true)
{
read(dict);
}
@ -85,8 +86,10 @@ bool Foam::functionObjects::Curle::read(const dictionary& dict)
}
dict.readIfPresent("p", pName_);
dict.readIfPresent("warnOnNoPatch", warnOnNoPatch_);
patchIDs_ = pbm.patchSet(dict.get<wordRes>("patches")).sortedToc();
patchIDs_ =
pbm.patchSet(dict.get<wordRes>("patches"), warnOnNoPatch_).sortedToc();
if (patchIDs_.empty())
{

View File

@ -181,6 +181,9 @@ class Curle
//- Ouput surface when sampling a surface
autoPtr<surfaceWriter> surfaceWriterPtr_;
//- Flag to suppress warnings for missing patches
bool warnOnNoPatch_;
public:

View File

@ -122,6 +122,7 @@ Foam::binModel::binModel
mesh_(mesh),
decomposePatchValues_(false),
cumulative_(false),
warnOnNoPatch_(true),
coordSysPtr_(nullptr),
nBin_(1)
{}
@ -138,8 +139,11 @@ bool Foam::binModel::read(const dictionary& dict)
return false;
}
dict.readIfPresent("warnOnNoPatch", warnOnNoPatch_);
// Can also use pbm.indices(), but no warnings...
patchIDs_ = pbm.patchSet(dict.get<wordRes>("patches")).sortedToc();
patchIDs_ =
pbm.patchSet(dict.get<wordRes>("patches"), warnOnNoPatch_).sortedToc();
fieldNames_ = dict.get<wordHashSet>("fields").sortedToc();
wordRes zoneNames;

View File

@ -77,6 +77,9 @@ protected:
//- increasing distance in binning direction
bool cumulative_;
//- Flag to suppress warnings for missing patches
bool warnOnNoPatch_;
//- Local coordinate system of bins
autoPtr<coordinateSystem> coordSysPtr_;

View File

@ -128,7 +128,8 @@ Foam::functionObjects::columnAverage::columnAverage
:
fvMeshFunctionObject(name, runTime, dict),
patchIDs_(),
fieldSet_(mesh_)
fieldSet_(mesh_),
warnOnNoPatch_(true)
{
read(dict);
}
@ -140,10 +141,13 @@ bool Foam::functionObjects::columnAverage::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
dict.readIfPresent("warnOnNoPatch", warnOnNoPatch_);
patchIDs_ =
mesh_.boundaryMesh().patchSet
(
dict.get<wordRes>("patches")
dict.get<wordRes>("patches"),
warnOnNoPatch_
).sortedToc();
fieldSet_.read(dict);

View File

@ -132,6 +132,9 @@ class columnAverage
mutable autoPtr<globalIndex> globalPoints_;
mutable autoPtr<meshStructure> meshStructurePtr_;
//- Flag to suppress warnings for missing patches
bool warnOnNoPatch_;
// Private Member Functions

View File

@ -51,7 +51,8 @@ Foam::heatTransferCoeffModel::heatTransferCoeffModel
:
mesh_(mesh),
TName_(TName),
qrName_("qr")
qrName_("qr"),
warnOnNoPatch_(true)
{}
@ -150,8 +151,10 @@ bool Foam::heatTransferCoeffModel::read(const dictionary& dict)
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
dict.readIfPresent("qr", qrName_);
dict.readIfPresent("warnOnNoPatch", warnOnNoPatch_);
patchIDs_ = pbm.patchSet(dict.get<wordRes>("patches")).sortedToc();
patchIDs_ =
pbm.patchSet(dict.get<wordRes>("patches"), warnOnNoPatch_).sortedToc();
return true;
}

View File

@ -76,6 +76,9 @@ protected:
//- Name of radiative heat flux field
word qrName_;
//- Flag to suppress warnings for missing patches
bool warnOnNoPatch_;
// Protected Member Functions

View File

@ -245,7 +245,8 @@ Foam::functionObjects::nearWallFields::nearWallFields
)
:
fvMeshFunctionObject(name, runTime, dict),
fieldSet_()
fieldSet_(),
warnOnNoPatch_(true)
{
read(dict);
}
@ -261,9 +262,11 @@ bool Foam::functionObjects::nearWallFields::read(const dictionary& dict)
dict.readEntry("fields", fieldSet_);
dict.readEntry("distance", distance_);
dict.readIfPresent("warnOnNoPatch", warnOnNoPatch_);
// Can also use pbm.indices(), but no warnings...
patchIDs_ = pbm.patchSet(dict.get<wordRes>("patches")).sortedToc();
patchIDs_ =
pbm.patchSet(dict.get<wordRes>("patches"), warnOnNoPatch_).sortedToc();
// Clear out any previously loaded fields

View File

@ -134,6 +134,9 @@ protected:
//- From resulting back to original field
HashTable<word> reverseFieldMap_;
//- Flag to suppress warnings for missing patches
bool warnOnNoPatch_;
// Calculated addressing

View File

@ -206,7 +206,10 @@ Foam::functionObjects::regionSizeDistribution::findPatchRegions
labelHashSet patchRegions(2*regions.nRegions());
labelHashSet patchSet(mesh_.boundaryMesh().patchSet(patchNames_));
labelHashSet patchSet
(
mesh_.boundaryMesh().patchSet(patchNames_, warnOnNoPatch_)
);
for (const label patchi : patchSet)
{
@ -369,7 +372,8 @@ Foam::functionObjects::regionSizeDistribution::regionSizeDistribution
writeFile(obr_, name),
alphaName_(dict.get<word>("field")),
patchNames_(dict.get<wordRes>("patches")),
isoPlanes_(dict.getOrDefault("isoPlanes", false))
isoPlanes_(dict.getOrDefault("isoPlanes", false)),
warnOnNoPatch_(true)
{
read(dict);
}
@ -416,6 +420,8 @@ bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict)
direction_.normalise();
}
dict.readIfPresent("warnOnNoPatch", warnOnNoPatch_);
return true;
}

View File

@ -249,6 +249,9 @@ class regionSizeDistribution
//- Switch to enable iso-planes sampling
bool isoPlanes_;
//- Flag to suppress warnings for missing patches
bool warnOnNoPatch_;
// Private Member Functions

View File

@ -106,7 +106,8 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux
:
fvMeshFunctionObject(name, runTime, dict),
writeFile(obr_, name, typeName, dict),
qrName_("qr")
qrName_("qr"),
warnOnNoPatch_(true)
{
read(dict);
@ -144,12 +145,13 @@ bool Foam::functionObjects::wallHeatFlux::read(const dictionary& dict)
writeFile::read(dict);
dict.readIfPresent("qr", qrName_);
dict.readIfPresent("warnOnNoPatch", warnOnNoPatch_);
wordRes patchNames;
labelHashSet patchSet;
if (dict.readIfPresent("patches", patchNames) && !patchNames.empty())
{
patchSet = pbm.patchSet(patchNames);
patchSet = pbm.patchSet(patchNames, warnOnNoPatch_);
}
labelHashSet allWalls(pbm.findPatchIDs<wallPolyPatch>());

View File

@ -123,6 +123,9 @@ protected:
//- Name of radiative heat flux name
word qrName_;
//- Flag to suppress warnings for missing patches
bool warnOnNoPatch_;
// Protected Member Functions

View File

@ -90,7 +90,8 @@ Foam::functionObjects::wallShearStress::wallShearStress
:
fvMeshFunctionObject(name, runTime, dict),
writeFile(mesh_, name, typeName, dict),
writeFields_(true) // May change in the future
writeFields_(true), // May change in the future
warnOnNoPatch_(true)
{
read(dict);
@ -127,6 +128,7 @@ bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
writeFields_ = true; // May change in the future
dict.readIfPresent("writeFields", writeFields_);
dict.readIfPresent("warnOnNoPatch", warnOnNoPatch_);
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
@ -134,7 +136,7 @@ bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
labelHashSet patchSet;
if (dict.readIfPresent("patches", patchNames) && !patchNames.empty())
{
patchSet = pbm.patchSet(patchNames);
patchSet = pbm.patchSet(patchNames, warnOnNoPatch_);
}
labelHashSet allWalls(pbm.findPatchIDs<wallPolyPatch>());

View File

@ -133,6 +133,9 @@ class wallShearStress
//- Write the shear stress field ?
bool writeFields_;
//- Flag to suppress warnings for missing patches
bool warnOnNoPatch_;
protected:

View File

@ -550,7 +550,8 @@ Foam::functionObjects::forces::forces
directForceDensity_(false),
porosity_(false),
writeFields_(false),
initialised_(false)
initialised_(false),
warnOnNoPatch_(true)
{
if (readFields)
{
@ -589,7 +590,8 @@ Foam::functionObjects::forces::forces
directForceDensity_(false),
porosity_(false),
writeFields_(false),
initialised_(false)
initialised_(false),
warnOnNoPatch_(true)
{
if (readFields)
{
@ -613,10 +615,13 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
initialised_ = false;
dict.readIfPresent("warnOnNoPatch", warnOnNoPatch_);
Info<< type() << ' ' << name() << ':' << endl;
// Can also use pbm.indices(), but no warnings...
patchIDs_ = pbm.patchSet(dict.get<wordRes>("patches")).sortedToc();
patchIDs_ =
pbm.patchSet(dict.get<wordRes>("patches"), warnOnNoPatch_).sortedToc();
dict.readIfPresent("directForceDensity", directForceDensity_);
if (directForceDensity_)

View File

@ -264,6 +264,9 @@ protected:
//- Flag of initialisation (internal)
bool initialised_;
//- Flag to suppress warnings for missing patches
bool warnOnNoPatch_;
// Protected Member Functions