functionObject,fvModel,fvConstraint: Added automatic library loading

If the libs entry is not provided and the name of the library containing the
functionObject, fvModel or fvConstraint corresponds to the type specified the
corresponding library is automatically loaded, e.g. to apply the
VoFTurbulenceDamping fvModel to an incompressibleVoF simulation the following
will load the libVoFTurbulenceDamping.so library automatically and instantiate
the fvModel:

turbulenceDamping
{
    type            VoFTurbulenceDamping;

    delta           1e-4;
}
This commit is contained in:
Henry Weller
2023-06-01 20:31:16 +01:00
parent 2561212f56
commit 0b8c17d8c1
33 changed files with 132 additions and 143 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -65,32 +65,34 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
Info<< "Selecting function " << functionType << endl;
}
if (dict.found("functionObjectLibs"))
if
(
!dictionaryConstructorTablePtr_
|| dictionaryConstructorTablePtr_->find(functionType)
== dictionaryConstructorTablePtr_->end()
)
{
libs.open
if
(
dict,
"functionObjectLibs",
dictionaryConstructorTablePtr_
);
}
else
{
libs.open
(
dict,
"libs",
dictionaryConstructorTablePtr_
);
}
!libs.open
(
dict,
"libs",
dictionaryConstructorTablePtr_
)
)
{
libs.open("lib" + functionType.remove(':') + ".so", false);
}
if (!dictionaryConstructorTablePtr_)
{
FatalErrorInFunction
<< "Unknown function type "
<< functionType << nl << nl
<< "Table of functionObjects is empty"
<< exit(FatalError);
if (!dictionaryConstructorTablePtr_)
{
FatalErrorInFunction
<< "Unknown function type "
<< functionType << nl << nl
<< "Table of functionObjects is empty"
<< exit(FatalError);
}
}
dictionaryConstructorTable::iterator cstrIter =