diff --git a/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.C index 767538191..7fd73adec 100644 --- a/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.C @@ -431,6 +431,21 @@ Foam::autoPtr Foam::decompositionMethod::New const dictionary& decompositionDict ) { + // HR 11.02.18: Library table is member of runtime (like in + // vanilla). Therefore need runtime here and we get it by + // traversing to the top of the dict in the hope that it is + // an IOdictionary. + const dictionary& topDict = decompositionDict.topDict(); + if (isA(topDict)) + { + Time& time = const_cast + ( + reinterpret_cast(topDict) + ); + + loadExternalLibraries(time); + } + word methodName(decompositionDict.lookup("method")); Info<< "Selecting decompositionMethod " << methodName << endl; @@ -461,6 +476,8 @@ Foam::autoPtr Foam::decompositionMethod::New const polyMesh& mesh ) { + loadExternalLibraries(const_cast(mesh.time())); + word methodName(decompositionDict.lookup("method")); Info<< "Selecting decompositionMethod " @@ -487,6 +504,29 @@ Foam::autoPtr Foam::decompositionMethod::New } +void Foam::decompositionMethod::loadExternalLibraries(Time& time) +{ + wordList libNames(3); + libNames[0]=word("scotchDecomp"); + libNames[1]=word("metisDecomp"); + libNames[2]=word("parMetisDecomp"); + + forAll(libNames,i) + { + const word libName("lib"+libNames[i]+".so"); + + if(!time.libs().open(libName)) + { + WarningIn("decompositionMethod::loadExternalLibraries()") + << "Loading of decomposition library " << libName + << " unsuccesful. Some decomposition methods may not be " + << " available" + << endl; + } + } +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::labelList Foam::decompositionMethod::decompose diff --git a/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.H b/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.H index ef329ebe3..7a04c74d3 100644 --- a/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.H +++ b/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.H @@ -113,6 +113,10 @@ private: //- Disallow default bitwise assignment void operator=(const decompositionMethod&); + //- Load missing libraries to avoid compile-time linking to external dependencies + // Temporary hack: to be resolved by Henrik Rusche. HJ, 15/May/2018 + static void loadExternalLibraries(Time& time); + public: