ENH: finite-area region support to all faOptions and regionFaModels

- for a non-default mesh region, corresponding files:

     system/finite-area/faOptions.<name>
     system/finite-area/<name>/faSchemes, etc

  if the entries within the faOptions dictionary happen to contain an
  "area" entry and it conflicts with what is expected, it will be
  rejected when creating the list of options, which helps avoid
  unexpected behaviour and simplifies overall handling.
This commit is contained in:
Mark Olesen
2025-10-06 16:06:55 +02:00
parent 19628b9576
commit b25147a4f8
20 changed files with 235 additions and 103 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2022-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,10 +53,11 @@ Foam::fa::limitHeight::limitHeight
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
const word& defaultAreaName
)
:
faceSetOption(name, modelType, dict, mesh),
fa::faceSetOption(name, modelType, dict, mesh, defaultAreaName),
hName_("h"),
max_(0) // overwritten later
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2022-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -69,8 +69,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef fa_limitHeight_H
#define fa_limitHeight_H
#ifndef Foam_fa_limitHeight_H
#define Foam_fa_limitHeight_H
#include "faceSetOption.H"
@ -87,7 +87,7 @@ namespace fa
class limitHeight
:
public faceSetOption
public fa::faceSetOption
{
protected:
@ -100,15 +100,6 @@ protected:
scalar max_;
// Protected Member Functions
//- No copy construct
limitHeight(const limitHeight&) = delete;
//- No copy assignment
void operator=(const limitHeight&) = delete;
public:
//- Runtime type information
@ -123,9 +114,17 @@ public:
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);
//- No copy construct
limitHeight(const limitHeight&) = delete;
//- No copy assignment
void operator=(const limitHeight&) = delete;
//- Destructor
virtual ~limitHeight() = default;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,15 +52,16 @@ Foam::fa::limitVelocity::limitVelocity
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
const word& defaultAreaName
)
:
faceSetOption(name, modelType, dict, mesh),
fa::faceSetOption(name, modelType, dict, mesh, defaultAreaName),
UName_(coeffs_.getOrDefault<word>("U", "U")),
max_(coeffs_.get<scalar>("max"))
{
fieldNames_.setSize(1, UName_);
applied_.setSize(1, false);
fieldNames_.resize(1, UName_);
applied_.resize(1, false);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -110,7 +110,9 @@ public:
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);
//- No copy construct

View File

@ -67,7 +67,8 @@ Foam::fa::option::option
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
const word& defaultAreaName
)
:
name_(name),
@ -75,15 +76,28 @@ Foam::fa::option::option
mesh_(mesh),
dict_(dict),
coeffs_(dict.optionalSubDict(modelType + "Coeffs")),
fieldNames_(),
applied_(),
areaName_(defaultAreaName),
regionName_(dict.get<word>("region")),
regionMeshPtr_(nullptr),
vsmPtr_(nullptr),
active_(dict.getOrDefault("active", true)),
log(true)
{
Log << incrIndent << indent << "Source: " << name_ << endl << decrIndent;
if (dict.readIfPresent("area", areaName_))
{
if (!sameRegionNames(areaName_, defaultAreaName))
{
// Produce a large warning message
IOWarningInFunction(dict) << nl
<< "The faOption option \"" << name
<< "\" has conflicting area specifications!" << nl
<< " expected : " << defaultAreaName << nl
<< " found : " << areaName_ << nl;
}
}
Log << incrIndent << indent << "Source: " << name_
<< " [" << polyMesh::regionName(areaName_) << ']' << endl
<< decrIndent;
}
@ -93,13 +107,24 @@ Foam::autoPtr<Foam::fa::option> Foam::fa::option::New
(
const word& name,
const dictionary& coeffs,
const fvMesh& mesh
const fvMesh& mesh,
const word& defaultAreaName
)
{
const word modelType(coeffs.get<word>("type"));
word areaName(defaultAreaName);
coeffs.readIfPresent("area", areaName);
Info<< indent
<< "Selecting finite area options type " << modelType << endl;
<< "Selecting finite-area option, type " << modelType
<< " [" << polyMesh::regionName(areaName) << ']';
if (!sameRegionNames(areaName, defaultAreaName))
{
Info<< " != " << defaultAreaName << nl;
}
Info<< endl;
mesh.time().libs().open
(
@ -121,7 +146,10 @@ Foam::autoPtr<Foam::fa::option> Foam::fa::option::New
) << exit(FatalIOError);
}
return autoPtr<fa::option>(ctorPtr(name, modelType, coeffs, mesh));
return autoPtr<fa::option>
(
ctorPtr(name, modelType, coeffs, mesh, areaName)
);
}

View File

@ -40,6 +40,9 @@ Usage
// Mandatory entries (runtime modifiable)
region <regionName>;
// Optional entry (unmodifiable)
area <areaName>;
// Optional entries (unmodifiable/runtime modifiable)
<faOption>Coeffs
{
@ -56,6 +59,7 @@ Usage
\table
Property | Description | Type | Reqd | Dflt
type | Name of operand faOption | word | yes | -
area | Name of finite-area mesh | word | no | region0
region | Name of operand region | word | yes | -
\<faOption\>Coeffs | Dictionary containing settings of <!--
--> the selected faOption settings | dictionary | no | -
@ -174,9 +178,10 @@ public:
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
const word& areaName
),
(name, modelType, dict, mesh)
(name, modelType, dict, mesh, areaName)
);
@ -188,7 +193,9 @@ public:
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);
//- Return clone
@ -205,28 +212,33 @@ public:
//- Reference to the mesh
const fvMesh& mesh_;
//- Name
//- The option name
const word& name_;
//- The default area name
const word& area_;
public:
iNew
(
const fvMesh& mesh,
const word& name
)
const word& name,
const word& defaultAreaName
) noexcept
:
mesh_(mesh),
name_(name)
name_(name),
area_(defaultAreaName)
{}
autoPtr<option> operator()(Istream& is) const
{
const dictionary dict(is);
return autoPtr<option>
return autoPtr<fa::option>
(
option::New(name_, dict, mesh_)
fa::option::New(name_, dict, mesh_, area_)
);
}
};
@ -239,7 +251,9 @@ public:
(
const word& name,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);

View File

@ -109,31 +109,92 @@ Foam::fa::optionList::optionList
void Foam::fa::optionList::reset(const dictionary& dict)
{
// Count number of active faOptions
// Count number of possible faOptions
label count = 0;
for (const entry& dEntry : dict)
// Reject sub-dictionary entries that have an "area" entry that
// conflicts with the expected name
const word& expectedName = polyMesh::regionName(areaName_);
const auto accept = [&](const dictionary& d)
{
if (dEntry.isDict())
if (expectedName.empty())
{
++count;
return true;
}
else if (auto* is = d.findStream("area", keyType::LITERAL))
{
const auto& tok = is->front();
return
(
tok.isStringType()
&& fa::option::sameRegionNames(expectedName, tok.stringToken())
);
}
else
{
return true;
}
};
for (const entry& e : dict)
{
if (const auto* dictptr = e.dictPtr())
{
if (!accept(*dictptr))
{
// Produce a conspicuous warning message
auto& err = IOWarningInFunction(*dictptr) << nl
<< incrIndent
<< indent
<< "Ignoring faOption entry: " << e.keyword() << nl
<< indent << "which has an inconsistent 'area' entry." << nl
<< indent << nl
<< incrIndent
<< indent << "expected : " << expectedName << nl
<< indent << "found : ";
if (auto* is = dictptr->findStream("area", keyType::LITERAL))
{
err << is->front();
}
err << decrIndent << nl << nl
<< indent
<< "It is either located in the wrong faOptions" << nl
<< indent
<< "or the 'area' entry should be removed." << nl
<< decrIndent << nl << endl;
}
else
{
++count;
}
}
}
this->resize(count);
this->resize_null(count);
count = 0;
for (const entry& dEntry : dict)
{
if (dEntry.isDict())
{
const word& name = dEntry.keyword();
const dictionary& sourceDict = dEntry.dict();
this->set
(
count++,
option::New(name, sourceDict, mesh_)
);
for (const entry& e : dict)
{
if (const auto* dictptr = e.dictPtr())
{
if (accept(*dictptr))
{
const word& name = e.keyword();
const auto& coeffs = *dictptr;
this->set
(
count++,
fa::option::New(name, coeffs, mesh_, areaName_)
);
}
}
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -116,9 +116,13 @@ void Foam::fa::faceSetOption::setArea()
// Set area information
scalar sumArea = 0;
for (const label facei : faces_)
{
sumArea += regionMesh().S()[facei];
const auto& meshAreas = regionMesh().S();
for (const label facei : faces_)
{
sumArea += meshAreas[facei];
}
}
reduce(sumArea, sumOp<scalar>());
@ -291,10 +295,11 @@ Foam::fa::faceSetOption::faceSetOption
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
const word& defaultAreaName
)
:
fa::option(name, modelType, dict, mesh),
fa::option(name, modelType, dict, mesh, defaultAreaName),
timeStart_(-1),
duration_(0),
selectionMode_(selectionModeTypeNames_.get("selectionMode", coeffs_)),

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -187,7 +187,9 @@ public:
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -51,10 +51,11 @@ Foam::fa::contactHeatFluxSource::contactHeatFluxSource
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
const word& defaultAreaName
)
:
fa::faceSetOption(sourceName, modelType, dict, mesh),
fa::faceSetOption(sourceName, modelType, dict, mesh, defaultAreaName),
TName_(dict.getOrDefault<word>("T", "T")),
TprimaryName_(dict.get<word>("Tprimary")),
Tprimary_(mesh_.lookupObject<volScalarField>(TprimaryName_)),

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -79,10 +79,8 @@ SourceFiles
#ifndef Foam_fa_contactHeatFluxSource_H
#define Foam_fa_contactHeatFluxSource_H
#include "faOption.H"
#include "Function1.H"
#include "PtrList.H"
#include "areaFields.H"
#include "PtrList.H"
#include "faceSetOption.H"
#include "temperatureCoupledBase.H"
@ -171,7 +169,9 @@ public:
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);
//- No copy construct

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,10 +50,11 @@ Foam::fa::externalFileSource::externalFileSource
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& m
const fvMesh& m,
const word& defaultAreaName
)
:
fa::faceSetOption(sourceName, modelType, dict, m),
fa::faceSetOption(sourceName, modelType, dict, m, defaultAreaName),
fieldName_(dict.get<word>("fieldName")),
tableName_(dict.get<word>("tableName")),
pExt_

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -72,10 +72,9 @@ SourceFiles
#ifndef Foam_fa_externalFileSource_H
#define Foam_fa_externalFileSource_H
#include "faOption.H"
#include "areaFields.H"
#include "faceSetOption.H"
#include "MappedFile.H"
#include "faceSetOption.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -130,7 +129,9 @@ public:
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);
//- No copy construct

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,10 +65,11 @@ Foam::fa::externalHeatFluxSource::externalHeatFluxSource
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& m
const fvMesh& m,
const word& defaultAreaName
)
:
fa::faceSetOption(sourceName, modelType, dict, m),
fa::faceSetOption(sourceName, modelType, dict, m, defaultAreaName),
mode_(operationModeNames.get("mode", dict)),
TName_(dict.getOrDefault<word>("T", "T")),
Q_(nullptr),

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -117,9 +117,8 @@ SourceFiles
#ifndef Foam_fa_externalHeatFluxSource_H
#define Foam_fa_externalHeatFluxSource_H
#include "faOption.H"
#include "Function1.H"
#include "areaFields.H"
#include "Function1.H"
#include "faceSetOption.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -193,7 +192,9 @@ public:
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);
//- No copy construct

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,10 +49,11 @@ Foam::fa::jouleHeatingSource::jouleHeatingSource
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& m
const fvMesh& m,
const word& defaultAreaName
)
:
fa::faceSetOption(sourceName, modelType, dict, m),
fa::faceSetOption(sourceName, modelType, dict, m, defaultAreaName),
TName_(dict.getOrDefault<word>("T", "T")),
V_
(

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -138,9 +138,8 @@ SourceFiles
#ifndef Foam_fa_jouleHeatingSource_H
#define Foam_fa_jouleHeatingSource_H
#include "faOption.H"
#include "Function1.H"
#include "areaFields.H"
#include "Function1.H"
#include "faceSetOption.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -212,7 +211,9 @@ public:
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);
//- No copy construct

View File

@ -198,15 +198,19 @@ liquidFilmBase::liquidFilmBase
dimensionedScalar(dimPressure, Zero)
),
addedMassTotal_(0),
faOptions_(Foam::fa::options::New(primaryMesh()))
faOptions_
(
Foam::fa::options::New(primaryMesh(), regionFaModel::areaName())
)
{
const areaVectorField& ns = regionMesh().faceAreaNormals();
gn_ = g_ & ns;
if (!faOptions_.optionList::size())
if (faOptions_.optionList::empty())
{
Info << "No finite area options present" << endl;
Info<< "No finite area options present for area : "
<< polyMesh::regionName(regionFaModel::areaName()) << endl;
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -64,11 +64,15 @@ thermalShellModel::thermalShellModel
),
regionMesh()
),
faOptions_(Foam::fa::options::New(primaryMesh()))
faOptions_
(
Foam::fa::options::New(primaryMesh(), regionFaModel::areaName())
)
{
if (faOptions_.optionList::empty())
{
Info << "No finite area options present" << endl;
Info<< "No finite area options present for area : "
<< polyMesh::regionName(regionFaModel::areaName()) << endl;
}
}

View File

@ -78,11 +78,15 @@ vibrationShellModel::vibrationShellModel
solid_(dict.subDict("solid"), solidProperties::MECHANICAL),
pName_(dict.get<word>("p")),
pa_(mesh.lookupObject<volScalarField>(pName_)),
faOptions_(Foam::fa::options::New(mesh))
faOptions_
(
Foam::fa::options::New(mesh, regionFaModel::areaName())
)
{
if (faOptions_.optionList::empty())
{
Info << "No finite area options present" << endl;
Info<< "No finite area options present for area : "
<< polyMesh::regionName(regionFaModel::areaName()) << endl;
}
}