ENH: update faOptions handling to respect finite-area locations

- new locations
    * constant/finite-area/faOptions
    * system/finite-area/faOptions

- legacy locations are still supported
    * constant/faOptions
    * system/faOptions

TUT: update faOptions locations
This commit is contained in:
Mark Olesen
2025-10-02 12:34:27 +02:00
parent b913463d95
commit 19628b9576
16 changed files with 520 additions and 216 deletions

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.
@ -40,6 +40,17 @@ namespace Foam
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
bool Foam::fa::option::sameRegionNames(const word& name1, const word& name2)
{
const auto& a = polyMesh::regionName(name1);
const auto& b = polyMesh::regionName(name2);
return (a.empty() || b.empty() || (a == b));
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fa::option::resetApplied()

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.
@ -126,7 +126,10 @@ protected:
//- Applied flag list - corresponds to each fieldNames_ entry
List<bool> applied_;
//- Region name (finite-area)
//- The finite-area mesh name
word areaName_;
//- The model region name (finite-area)
word regionName_;
@ -246,50 +249,60 @@ public:
// Member Functions
// Access
//- Return const access to the source name
inline const word& name() const noexcept;
//- Return const access to the mesh database
inline const fvMesh& mesh() const noexcept;
//- Return dictionary
inline const dictionary& coeffs() const noexcept;
//- True if source is active
inline bool active() const noexcept;
//- Set the applied flag to true for field index fieldi
inline void setApplied(const label fieldi);
//- The region name
inline const word& regionName() const noexcept;
//- Return the region mesh database (demand-driven)
inline const faMesh& regionMesh() const;
//- Return volSurfaceMapping (demand-driven)
inline const volSurfaceMapping& vsm() const;
//- Compare the region names.
// Treats empty or polyMesh::defaultRegion as always matching
static bool sameRegionNames(const word& name1, const word& name2);
// Edit
// Access
//- Change source active flag, return previous value
inline bool active(const bool on) noexcept;
//- The source name
const word& name() const noexcept { return name_; }
//- Return const access to the mesh database
const fvMesh& mesh() const noexcept { return mesh_; }
//- Return dictionary
const dictionary& coeffs() const noexcept { return coeffs_; }
//- True if source is active
bool active() const noexcept { return active_; }
//- Set the applied flag to true for field index fieldi
inline void setApplied(const label fieldi);
//- The finite-area mesh name
const word& areaName() const noexcept { return areaName_; }
//- The model region name
const word& regionName() const noexcept { return regionName_; }
//- Return the region mesh database (demand-driven)
inline const faMesh& regionMesh() const;
//- Return volSurfaceMapping (demand-driven)
inline const volSurfaceMapping& vsm() const;
// Checks
// Edit
//- Is the source active?
virtual bool isActive();
//- Change source active flag, return previous value
inline bool active(bool on) noexcept;
//- Return index of field name if found in fieldNames list
virtual label applyToField(const word& fieldName) const;
//- Check that the source has been applied
virtual void checkApplied() const;
// Checks
//- Is the source active?
virtual bool isActive();
//- Return index of field name if found in fieldNames list
virtual label applyToField(const word& fieldName) const;
//- Check that the source has been applied
virtual void checkApplied() const;
// Member Functions
// Evaluation

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,31 +27,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::word& Foam::fa::option::name() const noexcept
{
return name_;
}
inline const Foam::fvMesh& Foam::fa::option::mesh() const noexcept
{
return mesh_;
}
inline const Foam::dictionary& Foam::fa::option::coeffs() const noexcept
{
return coeffs_;
}
inline bool Foam::fa::option::active() const noexcept
{
return active_;
}
inline bool Foam::fa::option::active(const bool on) noexcept
inline bool Foam::fa::option::active(bool on) noexcept
{
bool old(active_);
active_ = on;
@ -65,17 +41,11 @@ inline void Foam::fa::option::setApplied(const label fieldi)
}
inline const Foam::word& Foam::fa::option::regionName() const noexcept
{
return regionName_;
}
inline const Foam::faMesh& Foam::fa::option::regionMesh() const
{
if (!regionMeshPtr_)
{
regionMeshPtr_.reset(new faMesh(mesh_));
regionMeshPtr_.reset(new faMesh(areaName_, mesh_));
}
return *regionMeshPtr_;
}

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,17 +79,27 @@ void Foam::fa::optionList::checkApplied() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fa::optionList::optionList(const fvMesh& mesh)
Foam::fa::optionList::optionList
(
const fvMesh& mesh,
const word& defaultAreaName
)
:
PtrList<fa::option>(),
mesh_(mesh),
areaName_(defaultAreaName),
checkTimeIndex_(mesh_.time().startTimeIndex() + 2)
{}
Foam::fa::optionList::optionList(const fvMesh& mesh, const dictionary& dict)
Foam::fa::optionList::optionList
(
const fvMesh& mesh,
const dictionary& dict,
const word& defaultAreaName
)
:
Foam::fa::optionList(mesh)
Foam::fa::optionList(mesh, defaultAreaName)
{
reset(optionsDict(dict));
}

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.
@ -27,10 +27,11 @@ Class
Foam::fa::optionList
Description
List of finite volume options
List of finite-area options
SourceFile
optionList.C
faOptionList.C
faOptionList.txx
\*---------------------------------------------------------------------------*/
@ -76,6 +77,9 @@ protected:
//- Reference to the mesh database
const fvMesh& mesh_;
//- The finite-area mesh name
word areaName_;
//- Time index to check that all defined sources have been applied
label checkTimeIndex_;
@ -101,13 +105,6 @@ protected:
const dimensionSet& ds
);
//- No copy construct
optionList(const optionList&) = delete;
//- No copy assignment
void operator=(const optionList&) = delete;
public:
//- Runtime type information
@ -117,10 +114,27 @@ public:
// Constructors
//- Default construct from mesh
explicit optionList(const fvMesh& mesh);
explicit optionList
(
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);
//- Construct from mesh and dictionary
optionList(const fvMesh& mesh, const dictionary& dict);
optionList
(
const fvMesh& mesh,
const dictionary& dict,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);
//- No copy construct
optionList(const optionList&) = delete;
//- No copy assignment
void operator=(const optionList&) = delete;
//- Destructor
@ -129,6 +143,9 @@ public:
// Member Functions
//- The finite-area mesh name
const word& areaName() const noexcept { return areaName_; }
//- Reset the source list
void reset(const dictionary& dict);
@ -240,7 +257,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "faOptionListTemplates.C"
#include "faOptionList.txx"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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.
@ -27,6 +27,7 @@ License
#include "faOptions.H"
#include "faMesh.H"
#include "faMeshesRegistry.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -40,76 +41,188 @@ namespace Foam
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
Foam::IOobject Foam::fa::options::createIOobject
(
const fvMesh& mesh
) const
namespace
{
// Create IO object if dictionary is present
// - check finite-area locations
Foam::IOobject createIOobject
(
const Foam::polyMesh& mesh,
const Foam::word& baseName, // eg, faOptions
const Foam::word& areaName
)
{
using namespace Foam;
// eg, faOptions, faOptions.<area-name> etc
const word lookupName
(
IOobject::groupName(baseName, polyMesh::regionName(areaName))
);
IOobject io
(
typeName,
lookupName,
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
// located under finite-area
faMeshesRegistry::New(mesh).thisDb(),
IOobjectOption::MUST_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::REGISTER
);
if (io.typeHeaderOk<IOdictionary>(true))
{
Info<< "Creating finite area options from "
<< io.instance()/io.name() << nl
<< endl;
io.readOpt(IOobject::MUST_READ_IF_MODIFIED);
io.readOpt(IOobjectOption::READ_MODIFIED);
}
else
{
// Check if the faOptions file is in system
// Check if faOptions, faOptions.<area-name> file is in system
io.instance() = mesh.time().system();
if (io.typeHeaderOk<IOdictionary>(true))
{
Info<< "Creating finite area options from "
<< io.instance()/io.name() << nl
<< endl;
io.readOpt(IOobject::MUST_READ_IF_MODIFIED);
io.readOpt(IOobjectOption::READ_MODIFIED);
}
else
{
io.readOpt(IOobject::NO_READ);
io.readOpt(IOobjectOption::NO_READ);
}
}
if (!io.isAnyRead() && polyMesh::regionName(areaName).empty())
{
// Check legacy location (default area region only)
// - registered on polyMesh
IOobject legacy
(
baseName, // eg, faOptions
mesh.time().constant(),
mesh,
IOobjectOption::MUST_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::REGISTER
);
if (legacy.typeHeaderOk<IOdictionary>(true))
{
legacy.readOpt(IOobjectOption::READ_MODIFIED);
}
else
{
// Check if the faOptions file is in system
legacy.instance() = mesh.time().system();
if (legacy.typeHeaderOk<IOdictionary>(true))
{
legacy.readOpt(IOobjectOption::READ_MODIFIED);
}
else
{
legacy.readOpt(IOobjectOption::NO_READ);
}
}
if (legacy.isAnyRead())
{
Info<< "Creating finite-area options from "
<< legacy.instance()/legacy.name()
<< " (legacy location)" << nl << endl;
return legacy;
}
}
if (io.isAnyRead())
{
Info<< "Creating finite-area options from "
<< io.instance()/faMesh::prefix()/io.name() << nl << endl;
}
return io;
}
} // End anonymous namespace
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fa::options::options
(
const fvMesh& mesh
const fvMesh& mesh,
const IOobject& io,
const word& defaultAreaName
)
:
IOdictionary(createIOobject(mesh)),
optionList(mesh, *this)
IOdictionary(io),
fa::optionList(mesh, *this, defaultAreaName)
{}
Foam::fa::options& Foam::fa::options::New(const fvMesh& mesh)
Foam::fa::options::options
(
const fvMesh& mesh,
const word& defaultAreaName
)
:
IOdictionary(createIOobject(mesh, typeName, defaultAreaName)),
fa::optionList(mesh, *this, defaultAreaName)
{}
Foam::fa::options& Foam::fa::options::New
(
const fvMesh& mesh,
const word& defaultAreaName
)
{
options* ptr = mesh.thisDb().getObjectPtr<options>(typeName);
// eg, faOptions, faOptions.<area-name> etc
const word lookupName
(
IOobject::groupName(typeName, polyMesh::regionName(defaultAreaName))
);
// Registered under finite-area?
auto* ptr =
faMeshesRegistry::New(mesh).thisDb().getObjectPtr<fa::options>
(
lookupName
);
if (!ptr && polyMesh::regionName(defaultAreaName).empty())
{
// Legacy location?
// Registered under polyMesh. region0 area only!
ptr = mesh.thisDb().getObjectPtr<fa::options>(typeName);
if (ptr)
{
InfoInFunction
<< "Retrieved " << typeName
<< " from polyMesh " << mesh.name()
<< " (legacy location)" << endl;
}
}
if (!ptr)
{
DebugInFunction
<< "Constructing " << typeName
<< " for region " << mesh.name() << endl;
<< "Constructing " << lookupName
<< " for region " << mesh.name()
<< " : " << polyMesh::regionName(defaultAreaName) << endl;
ptr = new fa::options
(
mesh,
createIOobject(mesh, typeName, defaultAreaName),
defaultAreaName
);
ptr = new options(mesh);
regIOobject::store(ptr);
}
@ -121,7 +234,7 @@ bool Foam::fa::options::read()
{
if (IOdictionary::regIOobject::read())
{
optionList::read(*this);
fa::optionList::read(*this);
return true;
}

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.
@ -27,7 +27,27 @@ Class
Foam::fa::options
Description
Finite-area options
Finite-area options, which is an IOdictionary of values and
a fa::optionList
Possible file locations (default area region):
\verbatim
.
|-- constant/finite-area/faOptions
|-- system/finite-area/faOptions
|
|-- constant/faOptions (legacy location: OpenFOAM-v2506 and earlier)
|-- system/faOptions (legacy location: OpenFOAM-v2506 and earlier)
\endverbatim
Possible file locations (multi-region):
\verbatim
.
|-- constant/finite-area/faOptions.<area-name>
|-- system/finite-area/faOptions.<area-name>
\endverbatim
There are no legacy locations when using multiple area regions.
SourceFiles
faOptions.C
@ -39,7 +59,6 @@ SourceFiles
#include "faOptionList.H"
#include "IOdictionary.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,12 +74,30 @@ namespace fa
class options
:
public IOdictionary,
public optionList
public fa::optionList
{
// Private Member Functions
// Private Methods
//- Create IO object if dictionary is present
IOobject createIOobject(const fvMesh& mesh) const;
//- Construct with specified IOobject for the IOdictionary
//- (somewhat fragile)
options(const fvMesh& mesh, const IOobject& io, const word& areaName);
public:
//- Runtime information
ClassName("faOptions");
// Constructors
//- Construct from components with list of field names
explicit options
(
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);
//- No copy construct
options(const options&) = delete;
@ -69,20 +106,16 @@ class options
void operator=(const options&) = delete;
public:
// Declare name of the class and its debug switch
ClassName("faOptions");
// Constructors
//- Construct from components with list of field names
explicit options(const fvMesh& mesh);
// Factory Methods
//- Construct faOptions and register to database if not present
//- otherwise lookup and return
static options& New(const fvMesh& mesh);
static options& New
(
const fvMesh& mesh,
//! The expected finite-area mesh name
const word& defaultAreaName = word()
);
//- Destructor
@ -91,8 +124,10 @@ public:
// Member Functions
//- Inherit read from optionList
using optionList::read;
// Note: areaName() available from fa::optionList
//- Inherit read from fa::optionList
using fa::optionList::read;
//- Read dictionary
virtual bool read();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2024 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,29 +41,33 @@ namespace Foam
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
Foam::IOobject Foam::fv::options::createIOobject
(
const fvMesh& mesh
) const
namespace
{
// Create IO object if dictionary is present
Foam::IOobject createIOobject
(
const Foam::fvMesh& mesh,
const Foam::word& baseName // eg, fvOptions
)
{
using namespace Foam;
IOobject io
(
typeName,
baseName,
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
mesh.thisDb(),
IOobjectOption::MUST_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::REGISTER
);
if (io.typeHeaderOk<IOdictionary>(true))
{
Info<< "Creating finite volume options from "
<< io.instance()/io.name() << nl
<< endl;
io.readOpt(IOobject::MUST_READ_IF_MODIFIED);
io.readOpt(IOobjectOption::READ_MODIFIED);
}
else
{
@ -72,37 +76,53 @@ Foam::IOobject Foam::fv::options::createIOobject
if (io.typeHeaderOk<IOdictionary>(true))
{
Info<< "Creating finite volume options from "
<< io.instance()/io.name() << nl
<< endl;
io.readOpt(IOobject::MUST_READ_IF_MODIFIED);
io.readOpt(IOobjectOption::READ_MODIFIED);
}
else
{
io.readOpt(IOobject::NO_READ);
io.readOpt(IOobjectOption::NO_READ);
}
}
if (io.isAnyRead())
{
Info<< "Creating finite-volume options from "
<< io.instance()/io.name() << nl
<< endl;
}
return io;
}
} // End anonymous namespace
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::options::options
(
const fvMesh& mesh,
const IOobject& io
)
:
IOdictionary(io),
fv::optionList(mesh, *this)
{}
Foam::fv::options::options
(
const fvMesh& mesh
)
:
IOdictionary(createIOobject(mesh)),
optionList(mesh, *this)
IOdictionary(createIOobject(mesh, typeName)),
fv::optionList(mesh, *this)
{}
Foam::fv::options& Foam::fv::options::New(const fvMesh& mesh)
{
auto* ptr = mesh.thisDb().getObjectPtr<options>(typeName);
auto* ptr = mesh.thisDb().getObjectPtr<fv::options>(typeName);
if (!ptr)
{
@ -110,7 +130,7 @@ Foam::fv::options& Foam::fv::options::New(const fvMesh& mesh)
<< "Constructing " << typeName
<< " for region " << mesh.name() << nl;
ptr = new options(mesh);
ptr = new fv::options(mesh);
regIOobject::store(ptr);
}
@ -122,7 +142,7 @@ bool Foam::fv::options::read()
{
if (IOdictionary::regIOobject::read())
{
optionList::read(*this);
fv::optionList::read(*this);
return true;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,19 +28,33 @@ Class
Foam::fv::options
Description
Finite-volume options
Finite-volume options, which is an IOdictionary of values and
a fv::optionList
Possible file locations (default region):
\verbatim
.
|-- constant/fvOptions
|-- system/fvOptions
\endverbatim
Possible file locations (multi-region):
\verbatim
.
|-- constant/<region>/fvOptions
|-- system/<region>/fvOptions
\endverbatim
SourceFiles
options.C
fvOptions.C
\*---------------------------------------------------------------------------*/
#ifndef fv_options_H
#define fv_options_H
#ifndef Foam_fvOptions_H
#define Foam_fvOptions_H
#include "fvOptionList.H"
#include "IOdictionary.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,18 +70,13 @@ namespace fv
class options
:
public IOdictionary,
public optionList
public fv::optionList
{
// Private Member Functions
//- Create IO object if dictionary is present
IOobject createIOobject(const fvMesh& mesh) const;
//- No copy construct
options(const options&) = delete;
//- No copy assignment
void operator=(const options&) = delete;
//- Construct with specified IOobject for the IOdictionary
//- (somewhat fragile)
options(const fvMesh& mesh, const IOobject& io);
public:
@ -79,10 +88,19 @@ public:
// Constructors
//- Construct from components with list of field names
options(const fvMesh& mesh);
explicit options(const fvMesh& mesh);
//- No copy construct
options(const options&) = delete;
//- No copy assignment
void operator=(const options&) = delete;
// Factory Methods
//- Construct fvOptions and register to database if not present
// otherwise lookup and return
//- otherwise lookup and return
static options& New(const fvMesh& mesh);
@ -92,8 +110,8 @@ public:
// Member Functions
//- Inherit read from optionList
using optionList::read;
//- Inherit read from fv::optionList
using fv::optionList::read;
//- Read dictionary
virtual bool read();

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.
@ -27,9 +27,8 @@ License
#include "regionFaModel.H"
#include "faMesh.H"
#include "faMeshesRegistry.H"
#include "Time.H"
#include "mappedWallPolyPatch.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -44,13 +43,109 @@ namespace regionModels
const Foam::word
Foam::regionModels::regionFaModel::regionFaModelName("regionFaModel");
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace
{
// Return IOobject with name qualified with region and area names
Foam::IOobject createModelIOobject
(
const Foam::polyMesh& mesh,
// const Foam::word& baseName, <- always regionFaModelName
const Foam::word& regionName,
const Foam::word& areaName
)
{
using namespace Foam;
// Default: regionFaModel.<regionName>
word objName = IOobject::groupName
(
Foam::regionModels::regionFaModel::regionFaModelName,
regionName
);
// Append '.<area-name>' or nothing
objName.ext(polyMesh::regionName(areaName));
return IOobject
(
objName,
mesh.time().constant(),
faMeshesRegistry::New(mesh).thisDb(),
IOobjectOption::NO_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::REGISTER
);
}
// Return IOobject with name qualified with region and area names
Foam::IOobject createPropertiesIOobject
(
const Foam::polyMesh& mesh,
// const Foam::word& baseName, <- always regionFaModelName
const Foam::word& regionName,
const Foam::word& areaName
)
{
using namespace Foam;
const fileName uniformPath
(
word("uniform")
/ Foam::regionModels::regionFaModel::regionFaModelName
);
const word objName
(
IOobject::groupName
(
(regionName + "OutputProperties"),
polyMesh::regionName(areaName)
)
);
// NOTE (2025-10-01):
// Cannot hold the OutputProperties within
// - faMeshesRegistry::New(mesh).thisDb()
// since this produces a uniform path that we do not yet handle
//
// -> "<time>/finite-area/uniform/regionFaModel/<model-region>"
// vs: "<time>/uniform/regionFaModel/<model-region>"
//
// The difference being that we only look for 'uniform' at the
// first sub-level within the time directory when decomposing etc.
IOobject legacy
(
objName,
mesh.time().timeName(),
uniformPath/regionName,
// Not possible: faMeshesRegistry::New(mesh).thisDb(),
mesh, // Registered on volume mesh!
IOobjectOption::READ_IF_PRESENT,
IOobjectOption::NO_WRITE,
IOobjectOption::REGISTER
);
return legacy;
}
} // End anonymous namespace
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::regionModels::regionFaModel::constructMeshObjects()
{
regionMeshPtr_.reset
(
new faMesh(primaryMesh_)
new faMesh(areaName_, primaryMesh_)
);
}
@ -66,20 +161,16 @@ void Foam::regionModels::regionFaModel::initialise()
if (!outputPropertiesPtr_)
{
const fileName uniformPath(word("uniform")/regionFaModelName);
outputPropertiesPtr_.reset
(
new IOdictionary
(
IOobject
createPropertiesIOobject
(
regionName_ + "OutputProperties",
time_.timeName(),
uniformPath/regionName_,
primaryMesh_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
// regionFaModelName,
regionName_,
areaName_
)
)
);
@ -126,13 +217,12 @@ Foam::regionModels::regionFaModel::regionFaModel
:
IOdictionary
(
IOobject
createModelIOobject
(
IOobject::groupName(regionFaModelName, dict.get<word>("region")),
mesh.time().constant(),
mesh.time(),
IOobject::NO_READ,
IOobject::NO_WRITE
mesh,
// regionFaModelName,
dict.get<word>("region"),
dict.getOrDefault<word>("area", polyMesh::defaultRegion)
)
),
primaryMesh_(mesh),
@ -140,11 +230,9 @@ Foam::regionModels::regionFaModel::regionFaModel
active_(dict.get<Switch>("active")),
infoOutput_(false),
modelName_(modelName),
regionMeshPtr_(nullptr),
coeffs_(dict.subOrEmptyDict(modelName + "Coeffs")),
outputPropertiesPtr_(nullptr),
vsmPtr_(nullptr),
regionName_(dict.get<word>("region"))
areaName_(dict.getOrDefault<word>("area", polyMesh::defaultRegion)),
regionName_(dict.get<word>("region")),
coeffs_(dict.subOrEmptyDict(modelName + "Coeffs"))
{
constructMeshObjects();
initialise();
@ -163,7 +251,8 @@ void Foam::regionModels::regionFaModel::evolve()
if (active_)
{
Info<< "\nEvolving " << modelName_ << " for region "
<< regionMesh().name() << endl;
<< regionMesh().name() << " : "
<< polyMesh::regionName(areaName_) << endl;
preEvolveRegion();

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.
@ -55,6 +55,7 @@ Usage
\table
Property | Description | Type | Reqd | Deflt
region | Name of operand region | word | yes | -
area | Name of the finite-area mesh | word | no | region0
active | Flag to activate the model | bool | yes | -
infoOutput | Flag to activate information output | bool | no | false
\endtable
@ -117,6 +118,12 @@ protected:
//- Model name
const word modelName_;
//- The finite-area mesh name
word areaName_;
//- Region name
word regionName_;
//- Pointer to the region mesh database
autoPtr<faMesh> regionMeshPtr_;
@ -129,9 +136,6 @@ protected:
//- Volume/surface mapping
autoPtr<volSurfaceMapping> vsmPtr_;
//- Region name
word regionName_;
public:
@ -181,6 +185,9 @@ public:
//- Return the information flag
Switch infoOutput() const noexcept { return infoOutput_; }
//- The finite-area mesh name (extracted from dictionary)
const word& areaName() const noexcept { return areaName_; }
//- Return the model name
const word& modelName() const noexcept { return modelName_; }

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.
@ -34,7 +34,7 @@ inline const Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh() const
if (!regionMeshPtr_)
{
FatalErrorInFunction
<< "Region mesh not available"
<< "No finite-area mesh (" << areaName_ << ") available"
<< abort(FatalError);
}
@ -47,7 +47,7 @@ inline Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh()
if (!regionMeshPtr_)
{
FatalErrorInFunction
<< "Region mesh not available"
<< "No finite-area mesh (" << areaName_ << ") available"
<< abort(FatalError);
}
@ -64,6 +64,7 @@ Foam::regionModels::regionFaModel::outputProperties() const
<< "outputProperties dictionary not available"
<< abort(FatalError);
}
return *outputPropertiesPtr_;
}
@ -101,7 +102,7 @@ inline bool Foam::regionModels::regionFaModel::isRegionPatch
const label patchi
) const
{
return primaryPatchIDs().found(patchi);
return primaryPatchIDs().contains(patchi);
}