mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-12 16:26:23 +00:00
runtime dynamic link library and geometryPhasicFlow modification
This commit is contained in:
@ -38,6 +38,7 @@ Timer/Timers.cpp
|
||||
repository/Time/Time.cpp
|
||||
repository/Time/timeControl.cpp
|
||||
repository/systemControl/systemControl.cpp
|
||||
repository/systemControl/dynamicLinkLibs.cpp
|
||||
repository/repository/repository.cpp
|
||||
repository/IOobject/objectFile.cpp
|
||||
repository/IOobject/IOobject.cpp
|
||||
|
82
src/phasicFlow/repository/systemControl/dynamicLinkLibs.cpp
Normal file
82
src/phasicFlow/repository/systemControl/dynamicLinkLibs.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C): www.cemf.ir
|
||||
email: hamid.r.norouzi AT gmail.com
|
||||
------------------------------------------------------------------------------
|
||||
Licence:
|
||||
This file is part of phasicFlow code. It is a free software for simulating
|
||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||
the terms of GNU General Public License v3 or any other later versions.
|
||||
|
||||
phasicFlow is distributed to help others in their research in the field of
|
||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "dynamicLinkLibs.hpp"
|
||||
#include "List.hpp"
|
||||
#include "streams.hpp"
|
||||
|
||||
|
||||
pFlow::dynamicLinkLibs::dynamicLinkLibs(
|
||||
const dictionary &dict,
|
||||
word libList)
|
||||
{
|
||||
|
||||
wordList libNames;
|
||||
if(dict.containsDataEntry(libList))
|
||||
{
|
||||
libNames = dict.getVal<wordList>(libList);
|
||||
}
|
||||
|
||||
|
||||
REPORT(1)<< "libs are "<< greenText(libNames)<<endREPORT;
|
||||
|
||||
for(auto libName:libNames)
|
||||
{
|
||||
auto* hndl = open(libName);
|
||||
|
||||
if(hndl)
|
||||
{
|
||||
libs_.insertIf(libName, hndl);
|
||||
}
|
||||
else
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pFlow::dynamicLinkLibs::~dynamicLinkLibs()
|
||||
{
|
||||
for(auto &lib:libs_)
|
||||
{
|
||||
if( lib.second && dlclose(lib.second) != 0)
|
||||
{
|
||||
warningInFunction<< "could not close lib "<<lib.first<<endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void* pFlow::dynamicLinkLibs::open(word libName)
|
||||
{
|
||||
REPORT(2)<<"Loading "<< greenText(libName)<<endREPORT;
|
||||
|
||||
void* handle = dlopen(libName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
|
||||
|
||||
if(!handle)
|
||||
{
|
||||
warningInFunction<< "could not open lib "<< libName<<endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
54
src/phasicFlow/repository/systemControl/dynamicLinkLibs.hpp
Normal file
54
src/phasicFlow/repository/systemControl/dynamicLinkLibs.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C): www.cemf.ir
|
||||
email: hamid.r.norouzi AT gmail.com
|
||||
------------------------------------------------------------------------------
|
||||
Licence:
|
||||
This file is part of phasicFlow code. It is a free software for simulating
|
||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||
the terms of GNU General Public License v3 or any other later versions.
|
||||
|
||||
phasicFlow is distributed to help others in their research in the field of
|
||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __dynamicLinkLibs_hpp__
|
||||
#define __dynamicLinkLibs_hpp__
|
||||
|
||||
|
||||
#include "hashMap.hpp"
|
||||
#include "dictionary.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
class dynamicLinkLibs
|
||||
{
|
||||
protected:
|
||||
|
||||
wordHashMap<void*> libs_;
|
||||
|
||||
void* open(word libName);
|
||||
|
||||
public:
|
||||
|
||||
dynamicLinkLibs(const dictionary &dict, word libList = "libs");
|
||||
|
||||
~dynamicLinkLibs();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
#endif // __dynamicLinkLibs_hpp__
|
@ -135,6 +135,7 @@ pFlow::systemControl::systemControl
|
||||
true
|
||||
)
|
||||
),
|
||||
libs_(settingsDict_),
|
||||
outFilePrecision_(
|
||||
settingsDict_.getValOrSet("outFilePrecision", static_cast<size_t>(6))
|
||||
),
|
||||
@ -205,6 +206,7 @@ pFlow::systemControl::systemControl(
|
||||
true
|
||||
)
|
||||
),
|
||||
libs_(settingsDict_),
|
||||
Time_
|
||||
(
|
||||
this,
|
||||
|
@ -33,6 +33,7 @@ Licence:
|
||||
#include "dictionary.hpp"
|
||||
#include "box.hpp"
|
||||
#include "Timers.hpp"
|
||||
#include "dynamicLinkLibs.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
@ -49,6 +50,8 @@ protected:
|
||||
// - path to top-level folder
|
||||
const fileSystem topLevelFolder_;
|
||||
|
||||
|
||||
|
||||
// - settings folder repository
|
||||
repository settings_;
|
||||
|
||||
@ -58,6 +61,9 @@ protected:
|
||||
// - settingsDict fileDictionary
|
||||
dictionary& settingsDict_;
|
||||
|
||||
// - extra libs to be loaded
|
||||
dynamicLinkLibs libs_;
|
||||
|
||||
// - precision for writing to file
|
||||
size_t outFilePrecision_ = 6;
|
||||
|
||||
|
Reference in New Issue
Block a user