runtime dynamic link library and geometryPhasicFlow modification
This commit is contained in:
parent
eef3906a7e
commit
7fec15e3dc
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
|
||||
set(SourceFiles
|
||||
vtkFile.cpp
|
||||
readFromTimeFolder.cpp
|
||||
readControlDict.cpp
|
||||
vtkFile/vtkFile.cpp
|
||||
geometryPhasicFlow/Wall/Wall.cpp
|
||||
geometryPhasicFlow/planeWall/planeWall.cpp
|
||||
geometryPhasicFlow/stlWall/stlWall.cpp
|
||||
geometryPhasicFlow/cylinderWall/cylinderWall.cpp
|
||||
geometryPhasicFlow/cuboidWall/cuboidWall.cpp
|
||||
)
|
||||
|
||||
set(link_libs Kokkos::kokkos phasicFlow Particles Geometry)
|
||||
|
|
|
@ -22,9 +22,9 @@ Licence:
|
|||
#ifndef __Wall_hpp__
|
||||
#define __Wall_hpp__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "virtualConstructor.hpp"
|
||||
#include "Vectors.hpp"
|
||||
#include "dictionary.hpp"
|
||||
|
||||
namespace pFlow
|
||||
|
@ -42,7 +42,7 @@ class Wall
|
|||
{
|
||||
protected:
|
||||
|
||||
realx3x3Vector triangles_;
|
||||
std::vector<realx3x3> triangles_;
|
||||
|
||||
word name_;
|
||||
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
//// - Methods
|
||||
|
||||
// -
|
||||
const realx3x3Vector& triangles()const
|
||||
const auto& triangles()const
|
||||
{
|
||||
return triangles_;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#include "cylinderWall.hpp"
|
||||
#include "Vectors.hpp"
|
||||
#include "line.hpp"
|
||||
|
||||
|
|
@ -1,11 +1,6 @@
|
|||
|
||||
set(source_files
|
||||
geometryPhasicFlow.cpp
|
||||
Wall/Wall.cpp
|
||||
planeWall/planeWall.cpp
|
||||
stlWall/stlWall.cpp
|
||||
cylinderWall/cylinderWall.cpp
|
||||
cuboidWall/cuboidWall.cpp
|
||||
)
|
||||
set(link_lib phasicFlow Geometry Kokkos::kokkos Utilities)
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ Licence:
|
|||
|
||||
#include "systemControl.hpp"
|
||||
#include "Wall.hpp"
|
||||
#include "Vectors.hpp"
|
||||
#include "multiTriSurface.hpp"
|
||||
#include "geometryMotion.hpp"
|
||||
#include "commandLine.hpp"
|
||||
|
@ -34,6 +35,7 @@ using pFlow::objectFile;
|
|||
using pFlow::wordVector;
|
||||
using pFlow::Wall;
|
||||
using pFlow::geometry;
|
||||
using pFlow::realx3x3Vector;
|
||||
using pFlow::multiTriSurface;
|
||||
using pFlow::commandLine;
|
||||
|
||||
|
@ -92,7 +94,9 @@ int main( int argc, char* argv[] )
|
|||
auto& wall = wallPtr();
|
||||
REPORT(1)<<"wall type is "<<greenText(wall.typeName())<<'\n'<<endREPORT;
|
||||
|
||||
surface.addTriSurface(wall.name(), wall.triangles());
|
||||
realx3x3Vector trinalges(wall.name());
|
||||
trinalges = wall.triangles();
|
||||
surface.addTriSurface(wall.name(), trinalges);
|
||||
materials.push_back(wall.materialName());
|
||||
motion.push_back(wall.motionName());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue