dlLibraryTable: Simplified and rationalised the handling of dynamic library loading
Rather than being tied to the Time class the dlLibraryTable libs is now a global variable in the Foam namespace which is accessable by any class needing to load dynamic libraries, in particular argList, Time and codeStream.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -331,8 +331,6 @@ Foam::Time::Time
|
||||
|
||||
objectRegistry(*this),
|
||||
|
||||
libs_(),
|
||||
|
||||
controlDict_
|
||||
(
|
||||
IOobject
|
||||
@ -368,7 +366,7 @@ Foam::Time::Time
|
||||
|
||||
functionObjects_(*this, enableFunctionObjects)
|
||||
{
|
||||
libs_.open(controlDict_, "libs");
|
||||
libs.open(controlDict_, "libs");
|
||||
|
||||
// Explicitly set read flags on objectRegistry so anything constructed
|
||||
// from it reads as well (e.g. fvSolution).
|
||||
@ -408,8 +406,6 @@ Foam::Time::Time
|
||||
|
||||
objectRegistry(*this),
|
||||
|
||||
libs_(),
|
||||
|
||||
controlDict_
|
||||
(
|
||||
IOobject
|
||||
@ -451,7 +447,7 @@ Foam::Time::Time
|
||||
: !args.optionFound("noFunctionObjects")
|
||||
)
|
||||
{
|
||||
libs_.open(controlDict_, "libs");
|
||||
libs.open(controlDict_, "libs");
|
||||
|
||||
// Explicitly set read flags on objectRegistry so anything constructed
|
||||
// from it reads as well (e.g. fvSolution).
|
||||
@ -491,8 +487,6 @@ Foam::Time::Time
|
||||
|
||||
objectRegistry(*this),
|
||||
|
||||
libs_(),
|
||||
|
||||
controlDict_
|
||||
(
|
||||
IOobject
|
||||
@ -529,7 +523,7 @@ Foam::Time::Time
|
||||
|
||||
functionObjects_(*this, enableFunctionObjects)
|
||||
{
|
||||
libs_.open(controlDict_, "libs");
|
||||
libs.open(controlDict_, "libs");
|
||||
|
||||
|
||||
// Explicitly set read flags on objectRegistry so anything constructed
|
||||
@ -572,8 +566,6 @@ Foam::Time::Time
|
||||
|
||||
objectRegistry(*this),
|
||||
|
||||
libs_(),
|
||||
|
||||
controlDict_
|
||||
(
|
||||
IOobject
|
||||
@ -607,7 +599,7 @@ Foam::Time::Time
|
||||
|
||||
functionObjects_(*this, enableFunctionObjects)
|
||||
{
|
||||
libs_.open(controlDict_, "libs");
|
||||
libs.open(controlDict_, "libs");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -76,10 +76,6 @@ class Time
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Any loaded dynamic libraries. Make sure to construct before
|
||||
// reading controlDict.
|
||||
dlLibraryTable libs_;
|
||||
|
||||
//- The controlDict
|
||||
unwatchedIOdictionary controlDict_;
|
||||
|
||||
@ -416,18 +412,6 @@ public:
|
||||
return functionObjects_;
|
||||
}
|
||||
|
||||
//- External access to the loaded libraries
|
||||
const dlLibraryTable& libs() const
|
||||
{
|
||||
return libs_;
|
||||
}
|
||||
|
||||
//- External access to the loaded libraries
|
||||
dlLibraryTable& libs()
|
||||
{
|
||||
return libs_;
|
||||
}
|
||||
|
||||
//- Return true if time currently being sub-cycled, otherwise false
|
||||
bool subCycling() const
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -70,11 +70,7 @@ Foam::dlLibraryTable& Foam::functionEntries::codeStream::libs
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
const baseIOdictionary& d = static_cast<const baseIOdictionary&>
|
||||
(
|
||||
dict.topDict()
|
||||
);
|
||||
return const_cast<Time&>(d.time()).libs();
|
||||
return Foam::libs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -54,9 +54,9 @@ void* Foam::codedBase::loadLibrary
|
||||
// avoid compilation by loading an existing library
|
||||
if (!libPath.empty())
|
||||
{
|
||||
if (libs().open(libPath, false))
|
||||
if (libs.open(libPath, false))
|
||||
{
|
||||
lib = libs().findLibrary(libPath);
|
||||
lib = libs.findLibrary(libPath);
|
||||
|
||||
// verify the loaded version and unload if needed
|
||||
if (lib)
|
||||
@ -92,7 +92,7 @@ void* Foam::codedBase::loadLibrary
|
||||
<< "from " << libPath << exit(FatalIOError);
|
||||
|
||||
lib = 0;
|
||||
if (!libs().close(libPath, false))
|
||||
if (!libs.close(libPath, false))
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
@ -124,7 +124,7 @@ void Foam::codedBase::unloadLibrary
|
||||
return;
|
||||
}
|
||||
|
||||
lib = libs().findLibrary(libPath);
|
||||
lib = libs.findLibrary(libPath);
|
||||
|
||||
if (!lib)
|
||||
{
|
||||
@ -154,7 +154,7 @@ void Foam::codedBase::unloadLibrary
|
||||
}
|
||||
}
|
||||
|
||||
if (!libs().close(libPath, false))
|
||||
if (!libs.close(libPath, false))
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
@ -306,7 +306,7 @@ void Foam::codedBase::updateLibrary
|
||||
|
||||
|
||||
// the correct library was already loaded => we are done
|
||||
if (libs().findLibrary(libPath))
|
||||
if (libs.findLibrary(libPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -88,9 +88,6 @@ protected:
|
||||
//- Update library as required
|
||||
void updateLibrary(const word& name) const;
|
||||
|
||||
//- Get the loaded dynamic libraries
|
||||
virtual dlLibraryTable& libs() const = 0;
|
||||
|
||||
//- Adapt the context for the current object
|
||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const = 0;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,6 @@ License
|
||||
|
||||
#include "dlLibraryTable.H"
|
||||
#include "OSspecific.H"
|
||||
#include "int.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -34,6 +33,8 @@ namespace Foam
|
||||
defineTypeNameAndDebug(dlLibraryTable, 0);
|
||||
}
|
||||
|
||||
Foam::dlLibraryTable Foam::libs;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -79,31 +80,31 @@ Foam::dlLibraryTable::~dlLibraryTable()
|
||||
|
||||
bool Foam::dlLibraryTable::open
|
||||
(
|
||||
const fileName& functionLibName,
|
||||
const fileName& libName,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
if (functionLibName.size())
|
||||
if (libName.size())
|
||||
{
|
||||
void* functionLibPtr = dlOpen
|
||||
void* libPtr = dlOpen
|
||||
(
|
||||
fileName(functionLibName).expand(),
|
||||
fileName(libName).expand(),
|
||||
verbose
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction
|
||||
<< "Opened " << functionLibName
|
||||
<< " resulting in handle " << uintptr_t(functionLibPtr) << endl;
|
||||
<< "Opened " << libName
|
||||
<< " resulting in handle " << uintptr_t(libPtr) << endl;
|
||||
}
|
||||
|
||||
if (!functionLibPtr)
|
||||
if (!libPtr)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "could not load " << functionLibName
|
||||
<< "could not load " << libName
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -111,8 +112,8 @@ bool Foam::dlLibraryTable::open
|
||||
}
|
||||
else
|
||||
{
|
||||
libPtrs_.append(functionLibPtr);
|
||||
libNames_.append(functionLibName);
|
||||
libPtrs_.append(libPtr);
|
||||
libNames_.append(libName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -123,71 +124,20 @@ bool Foam::dlLibraryTable::open
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dlLibraryTable::close
|
||||
bool Foam::dlLibraryTable::open
|
||||
(
|
||||
const fileName& functionLibName,
|
||||
const fileNameList& libNames,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
label index = -1;
|
||||
forAllReverse(libNames_, i)
|
||||
bool allOpened = !libNames.empty();
|
||||
|
||||
forAll(libNames, i)
|
||||
{
|
||||
if (libNames_[i] == functionLibName)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
allOpened = open(libNames[i], verbose) && allOpened;
|
||||
}
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction
|
||||
<< "Closing " << functionLibName
|
||||
<< " with handle " << uintptr_t(libPtrs_[index]) << endl;
|
||||
}
|
||||
|
||||
bool ok = dlClose(libPtrs_[index]);
|
||||
|
||||
libPtrs_[index] = nullptr;
|
||||
libNames_[index] = fileName::null;
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "could not close " << functionLibName
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void* Foam::dlLibraryTable::findLibrary(const fileName& functionLibName)
|
||||
{
|
||||
label index = -1;
|
||||
forAllReverse(libNames_, i)
|
||||
{
|
||||
if (libNames_[i] == functionLibName)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
return libPtrs_[index];
|
||||
}
|
||||
return nullptr;
|
||||
return allOpened;
|
||||
}
|
||||
|
||||
|
||||
@ -205,7 +155,7 @@ bool Foam::dlLibraryTable::open
|
||||
|
||||
forAll(libNames, i)
|
||||
{
|
||||
allOpened = dlLibraryTable::open(libNames[i]) && allOpened;
|
||||
allOpened = open(libNames[i]) && allOpened;
|
||||
}
|
||||
|
||||
return allOpened;
|
||||
@ -217,4 +167,72 @@ bool Foam::dlLibraryTable::open
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dlLibraryTable::close
|
||||
(
|
||||
const fileName& libName,
|
||||
const bool verbose
|
||||
)
|
||||
{
|
||||
label index = -1;
|
||||
forAllReverse(libNames_, i)
|
||||
{
|
||||
if (libNames_[i] == libName)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction
|
||||
<< "Closing " << libName
|
||||
<< " with handle " << uintptr_t(libPtrs_[index]) << endl;
|
||||
}
|
||||
|
||||
bool ok = dlClose(libPtrs_[index]);
|
||||
|
||||
libPtrs_[index] = nullptr;
|
||||
libNames_[index] = fileName::null;
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "could not close " << libName
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void* Foam::dlLibraryTable::findLibrary(const fileName& libName)
|
||||
{
|
||||
label index = -1;
|
||||
forAllReverse(libNames_, i)
|
||||
{
|
||||
if (libNames_[i] == libName)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
return libPtrs_[index];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -37,6 +37,7 @@ SourceFiles
|
||||
|
||||
#include "label.H"
|
||||
#include "DynamicList.H"
|
||||
#include "fileNameList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -51,8 +52,10 @@ class dlLibraryTable
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- List of pointers to the loaded dynamic libraries
|
||||
DynamicList<void*> libPtrs_;
|
||||
|
||||
//- List of names of the loaded dynamic libraries
|
||||
DynamicList<fileName> libNames_;
|
||||
|
||||
|
||||
@ -61,6 +64,7 @@ public:
|
||||
// Declare name of the class and its debug switch
|
||||
ClassName("dlLibraryTable");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
@ -81,13 +85,10 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Open the named library, optionally with warnings if problems occur
|
||||
bool open(const fileName& name, const bool verbose = true);
|
||||
bool open(const fileName& libName, const bool verbose = true);
|
||||
|
||||
//- Close the named library, optionally with warnings if problems occur
|
||||
bool close(const fileName& name, const bool verbose = true);
|
||||
|
||||
//- Find the handle of the named library
|
||||
void* findLibrary(const fileName& name);
|
||||
//- Open the named libraries, optionally with warnings if problems occur
|
||||
bool open(const fileNameList& libNames, const bool verbose = true);
|
||||
|
||||
//- Open all the libraries listed in the 'libsEntry' entry in the
|
||||
// given dictionary if present
|
||||
@ -104,6 +105,12 @@ public:
|
||||
const TablePtr& tablePtr
|
||||
);
|
||||
|
||||
//- Find the handle of the named library
|
||||
void* findLibrary(const fileName& libName);
|
||||
|
||||
//- Close the named library, optionally with warnings if problems occur
|
||||
bool close(const fileName& name, const bool verbose = true);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
@ -112,6 +119,10 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Table of loaded dynamic libraries
|
||||
extern dlLibraryTable libs;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -67,7 +67,7 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
|
||||
|
||||
if (dict.found("functionObjectLibs"))
|
||||
{
|
||||
const_cast<Time&>(runTime).libs().open
|
||||
libs.open
|
||||
(
|
||||
dict,
|
||||
"functionObjectLibs",
|
||||
@ -76,7 +76,7 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
|
||||
}
|
||||
else
|
||||
{
|
||||
const_cast<Time&>(runTime).libs().open
|
||||
libs.open
|
||||
(
|
||||
dict,
|
||||
"libs",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -748,7 +748,7 @@ bool Foam::functionObjectList::read()
|
||||
|
||||
const dictionary& functionsDict = entryPtr->dict();
|
||||
|
||||
const_cast<Time&>(time_).libs().open
|
||||
libs.open
|
||||
(
|
||||
functionsDict,
|
||||
"libs",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -100,13 +100,6 @@ const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dlLibraryTable& Foam::codedFixedValuePointPatchField<Type>::libs() const
|
||||
{
|
||||
return const_cast<dlLibraryTable&>(this->db().time().libs());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::codedFixedValuePointPatchField<Type>::prepare
|
||||
(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -91,8 +91,6 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class dynamicCode;
|
||||
class dynamicCodeContext;
|
||||
class IOdictionary;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -128,9 +126,6 @@ class codedFixedValuePointPatchField
|
||||
//- Set the rewrite vars controlling the Type
|
||||
static void setFieldTemplates(dynamicCode& dynCode);
|
||||
|
||||
//- Get the loaded dynamic libraries
|
||||
virtual dlLibraryTable& libs() const;
|
||||
|
||||
//- Adapt the context for the current object
|
||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,6 +36,7 @@ License
|
||||
#include "fileOperation.H"
|
||||
#include "fileOperationInitialise.H"
|
||||
#include "stringListOps.H"
|
||||
#include "dlLibraryTable.H"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
@ -306,14 +307,14 @@ bool Foam::argList::regroupArgv(int& argc, char**& argv)
|
||||
|
||||
// Note: we also re-write directly into args_
|
||||
// and use a second pass to sort out args/options
|
||||
for (int argI = 0; argI < argc; ++argI)
|
||||
for (int argi=0; argi<argc; argi++)
|
||||
{
|
||||
if (strcmp(argv[argI], "(") == 0)
|
||||
if (strcmp(argv[argi], "(") == 0)
|
||||
{
|
||||
++listDepth;
|
||||
tmpString += "(";
|
||||
}
|
||||
else if (strcmp(argv[argI], ")") == 0)
|
||||
else if (strcmp(argv[argi], ")") == 0)
|
||||
{
|
||||
if (listDepth)
|
||||
{
|
||||
@ -327,19 +328,19 @@ bool Foam::argList::regroupArgv(int& argc, char**& argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
args_[nArgs++] = argv[argI];
|
||||
args_[nArgs++] = argv[argi];
|
||||
}
|
||||
}
|
||||
else if (listDepth)
|
||||
{
|
||||
// Quote each string element
|
||||
tmpString += "\"";
|
||||
tmpString += argv[argI];
|
||||
tmpString += argv[argi];
|
||||
tmpString += "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
args_[nArgs++] = argv[argI];
|
||||
args_[nArgs++] = argv[argi];
|
||||
}
|
||||
}
|
||||
|
||||
@ -423,34 +424,22 @@ Foam::argList::argList
|
||||
args_(argc),
|
||||
options_(argc)
|
||||
{
|
||||
// Pre-load any libraries. Note that we cannot use dlLibraryTable here
|
||||
// Pre-load any libraries
|
||||
{
|
||||
const string libsString(getEnv("FOAM_LIBS"));
|
||||
if (!libsString.empty())
|
||||
{
|
||||
IStringStream is(libsString);
|
||||
const fileNameList libNames(is);
|
||||
//Info<< "Loading libraries " << libNames << endl;
|
||||
forAll(libNames, i)
|
||||
{
|
||||
dlOpen(libNames[i]);
|
||||
}
|
||||
libs.open(fileNameList((IStringStream(libsString))()));
|
||||
}
|
||||
for (int argI = 0; argI < argc; ++argI)
|
||||
|
||||
for (int argi=0; argi<argc; argi++)
|
||||
{
|
||||
if (argv[argI][0] == '-')
|
||||
if (argv[argi][0] == '-')
|
||||
{
|
||||
const char *optionName = &argv[argI][1];
|
||||
const char *optionName = &argv[argi][1];
|
||||
if (string(optionName) == "libs")
|
||||
{
|
||||
const string libsString(argv[argI+1]);
|
||||
IStringStream is(libsString);
|
||||
const fileNameList libNames(is);
|
||||
//Info<< "Loading libraries " << libNames << endl;
|
||||
forAll(libNames, i)
|
||||
{
|
||||
dlOpen(libNames[i]);
|
||||
}
|
||||
libs.open(fileNameList((IStringStream(argv[argi+1]))()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -459,14 +448,14 @@ Foam::argList::argList
|
||||
|
||||
// Check for fileHandler
|
||||
word handlerType(getEnv("FOAM_FILEHANDLER"));
|
||||
for (int argI = 0; argI < argc; ++argI)
|
||||
for (int argi=0; argi<argc; argi++)
|
||||
{
|
||||
if (argv[argI][0] == '-')
|
||||
if (argv[argi][0] == '-')
|
||||
{
|
||||
const char *optionName = &argv[argI][1];
|
||||
const char *optionName = &argv[argi][1];
|
||||
if (string(optionName) == "fileHandler")
|
||||
{
|
||||
handlerType = argv[argI+1];
|
||||
handlerType = argv[argi+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -487,11 +476,11 @@ Foam::argList::argList
|
||||
|
||||
// Check if this run is a parallel run by searching for any parallel option
|
||||
// If found call runPar which might filter argv
|
||||
for (int argI = 0; argI < argc; ++argI)
|
||||
for (int argi=0; argi<argc; argi++)
|
||||
{
|
||||
if (argv[argI][0] == '-')
|
||||
if (argv[argi][0] == '-')
|
||||
{
|
||||
const char *optionName = &argv[argI][1];
|
||||
const char *optionName = &argv[argi][1];
|
||||
|
||||
if (validParOptions.found(optionName))
|
||||
{
|
||||
@ -513,14 +502,14 @@ Foam::argList::argList
|
||||
int nArgs = 1;
|
||||
argListStr_ = args_[0];
|
||||
|
||||
for (int argI = 1; argI < args_.size(); ++argI)
|
||||
for (int argi=1; argi<args_.size(); argi++)
|
||||
{
|
||||
argListStr_ += ' ';
|
||||
argListStr_ += args_[argI];
|
||||
argListStr_ += args_[argi];
|
||||
|
||||
if (args_[argI][0] == '-')
|
||||
if (args_[argi][0] == '-')
|
||||
{
|
||||
const char *optionName = &args_[argI][1];
|
||||
const char *optionName = &args_[argi][1];
|
||||
|
||||
if
|
||||
(
|
||||
@ -534,8 +523,8 @@ Foam::argList::argList
|
||||
)
|
||||
)
|
||||
{
|
||||
++argI;
|
||||
if (argI >= args_.size())
|
||||
++argi;
|
||||
if (argi >= args_.size())
|
||||
{
|
||||
FatalError
|
||||
<<"Option '-" << optionName
|
||||
@ -545,8 +534,8 @@ Foam::argList::argList
|
||||
}
|
||||
|
||||
argListStr_ += ' ';
|
||||
argListStr_ += args_[argI];
|
||||
options_.insert(optionName, args_[argI]);
|
||||
argListStr_ += args_[argi];
|
||||
options_.insert(optionName, args_[argi]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -555,9 +544,9 @@ Foam::argList::argList
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nArgs != argI)
|
||||
if (nArgs != argi)
|
||||
{
|
||||
args_[nArgs] = args_[argI];
|
||||
args_[nArgs] = args_[argi];
|
||||
}
|
||||
++nArgs;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -297,7 +297,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
|
||||
controlDict.lookupOrDefault<word>("agglomerator", "faceAreaPair")
|
||||
);
|
||||
|
||||
const_cast<Time&>(mesh.thisDb().time()).libs().open
|
||||
libs.open
|
||||
(
|
||||
controlDict,
|
||||
"geometricGAMGAgglomerationLibs",
|
||||
@ -352,7 +352,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
|
||||
controlDict.lookupOrDefault<word>("agglomerator", "faceAreaPair")
|
||||
);
|
||||
|
||||
const_cast<Time&>(mesh.thisDb().time()).libs().open
|
||||
libs.open
|
||||
(
|
||||
controlDict,
|
||||
"algebraicGAMGAgglomerationLibs",
|
||||
@ -398,7 +398,7 @@ Foam::autoPtr<Foam::GAMGAgglomeration> Foam::GAMGAgglomeration::New
|
||||
controlDict.lookupOrDefault<word>("agglomerator", "faceAreaPair")
|
||||
);
|
||||
|
||||
const_cast<Time&>(mesh.thisDb().time()).libs().open
|
||||
libs.open
|
||||
(
|
||||
controlDict,
|
||||
"geometricGAMGAgglomerationLibs",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -40,7 +40,7 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
|
||||
|
||||
Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;
|
||||
|
||||
const_cast<Time&>(io.time()).libs().open
|
||||
libs.open
|
||||
(
|
||||
dict,
|
||||
"dynamicFvMeshLibs",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -79,7 +79,7 @@ Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::New
|
||||
|
||||
Info<< "Selecting motion solver: " << solverTypeName << endl;
|
||||
|
||||
const_cast<Time&>(mesh.time()).libs().open
|
||||
libs.open
|
||||
(
|
||||
solverDict,
|
||||
"motionSolverLibs",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -75,7 +75,7 @@ Foam::autoPtr<Foam::fv::option> Foam::fv::option::New
|
||||
Info<< indent
|
||||
<< "Selecting finite volume options model type " << modelType << endl;
|
||||
|
||||
const_cast<Time&>(mesh.time()).libs().open
|
||||
libs.open
|
||||
(
|
||||
coeffs,
|
||||
"libs",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -99,13 +99,6 @@ const Foam::IOdictionary& Foam::codedFixedValueFvPatchField<Type>::dict() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dlLibraryTable& Foam::codedFixedValueFvPatchField<Type>::libs() const
|
||||
{
|
||||
return const_cast<dlLibraryTable&>(this->db().time().libs());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::codedFixedValueFvPatchField<Type>::prepare
|
||||
(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -88,11 +88,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class dynamicCode;
|
||||
class dynamicCodeContext;
|
||||
class IOdictionary;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class codedFixedValueFvPatchField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -126,9 +121,6 @@ class codedFixedValueFvPatchField
|
||||
//- Set the rewrite vars controlling the Type
|
||||
static void setFieldTemplates(dynamicCode& dynCode);
|
||||
|
||||
//- Get the loaded dynamic libraries
|
||||
virtual dlLibraryTable& libs() const;
|
||||
|
||||
//- Adapt the context for the current object
|
||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -99,13 +99,6 @@ const Foam::IOdictionary& Foam::codedMixedFvPatchField<Type>::dict() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dlLibraryTable& Foam::codedMixedFvPatchField<Type>::libs() const
|
||||
{
|
||||
return const_cast<dlLibraryTable&>(this->db().time().libs());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::codedMixedFvPatchField<Type>::prepare
|
||||
(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -99,8 +99,6 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class dynamicCode;
|
||||
class dynamicCodeContext;
|
||||
class IOdictionary;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -136,9 +134,6 @@ class codedMixedFvPatchField
|
||||
//- Set the rewrite vars controlling the Type
|
||||
static void setFieldTemplates(dynamicCode& dynCode);
|
||||
|
||||
//- Get the loaded dynamic libraries
|
||||
virtual dlLibraryTable& libs() const;
|
||||
|
||||
//- Adapt the context for the current object
|
||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -78,7 +78,7 @@ void Foam::codedFunctionObject::prepare
|
||||
// Copy filtered H template
|
||||
dynCode.addCopyFile("functionObjectTemplate.H");
|
||||
|
||||
// Debugging: make BC verbose
|
||||
// Debugging: make verbose
|
||||
// dynCode.setFilterVariable("verbose", "true");
|
||||
// Info<<"compile " << name_ << " sha1: "
|
||||
// << context.sha1() << endl;
|
||||
@ -99,12 +99,6 @@ void Foam::codedFunctionObject::prepare
|
||||
}
|
||||
|
||||
|
||||
Foam::dlLibraryTable& Foam::codedFunctionObject::libs() const
|
||||
{
|
||||
return const_cast<Time&>(time_).libs();
|
||||
}
|
||||
|
||||
|
||||
Foam::string Foam::codedFunctionObject::description() const
|
||||
{
|
||||
return "functionObject " + name();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -113,9 +113,6 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Get the loaded dynamic libraries
|
||||
virtual dlLibraryTable& libs() const;
|
||||
|
||||
//- Adapt the context for the current object
|
||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -82,13 +82,6 @@ void Foam::fv::CodedSource<Type>::prepare
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dlLibraryTable& Foam::fv::CodedSource<Type>::libs() const
|
||||
{
|
||||
return const_cast<Time&>(mesh_.time()).libs();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::string Foam::fv::CodedSource<Type>::description() const
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -146,9 +146,6 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Get the loaded dynamic libraries
|
||||
virtual dlLibraryTable& libs() const;
|
||||
|
||||
//- Adapt the context for the current object
|
||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user