From 7fec15e3dcf63f7a130f2df9eb9e6cf67f1e7125 Mon Sep 17 00:00:00 2001 From: Hamidreza Norouzi Date: Sat, 25 Feb 2023 05:15:17 -0800 Subject: [PATCH] runtime dynamic link library and geometryPhasicFlow modification --- src/phasicFlow/CMakeLists.txt | 1 + .../systemControl/dynamicLinkLibs.cpp | 82 +++++++++++++++++++ .../systemControl/dynamicLinkLibs.hpp | 54 ++++++++++++ .../systemControl/systemControl.cpp | 2 + .../systemControl/systemControl.hpp | 6 ++ utilities/Utilities/CMakeLists.txt | 7 +- .../geometryPhasicFlow/Wall/Wall.cpp | 0 .../geometryPhasicFlow/Wall/Wall.hpp | 6 +- .../cuboidWall/cuboidWall.cpp | 0 .../cuboidWall/cuboidWall.hpp | 0 .../cylinderWall/cylinderWall.cpp | 1 + .../cylinderWall/cylinderWall.hpp | 0 .../planeWall/planeWall.cpp | 0 .../planeWall/planeWall.hpp | 0 .../geometryPhasicFlow/stlWall/stlWall.cpp | 0 .../geometryPhasicFlow/stlWall/stlWall.hpp | 0 utilities/Utilities/{ => vtkFile}/vtkFile.cpp | 0 utilities/Utilities/{ => vtkFile}/vtkFile.hpp | 0 utilities/geometryPhasicFlow/CMakeLists.txt | 5 -- .../geometryPhasicFlow/geometryPhasicFlow.cpp | 6 +- 20 files changed, 160 insertions(+), 10 deletions(-) create mode 100644 src/phasicFlow/repository/systemControl/dynamicLinkLibs.cpp create mode 100644 src/phasicFlow/repository/systemControl/dynamicLinkLibs.hpp rename utilities/{ => Utilities}/geometryPhasicFlow/Wall/Wall.cpp (100%) rename utilities/{ => Utilities}/geometryPhasicFlow/Wall/Wall.hpp (95%) rename utilities/{ => Utilities}/geometryPhasicFlow/cuboidWall/cuboidWall.cpp (100%) rename utilities/{ => Utilities}/geometryPhasicFlow/cuboidWall/cuboidWall.hpp (100%) rename utilities/{ => Utilities}/geometryPhasicFlow/cylinderWall/cylinderWall.cpp (93%) rename utilities/{ => Utilities}/geometryPhasicFlow/cylinderWall/cylinderWall.hpp (100%) rename utilities/{ => Utilities}/geometryPhasicFlow/planeWall/planeWall.cpp (100%) rename utilities/{ => Utilities}/geometryPhasicFlow/planeWall/planeWall.hpp (100%) rename utilities/{ => Utilities}/geometryPhasicFlow/stlWall/stlWall.cpp (100%) rename utilities/{ => Utilities}/geometryPhasicFlow/stlWall/stlWall.hpp (100%) rename utilities/Utilities/{ => vtkFile}/vtkFile.cpp (100%) rename utilities/Utilities/{ => vtkFile}/vtkFile.hpp (100%) diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt index 27f5944f..34103498 100644 --- a/src/phasicFlow/CMakeLists.txt +++ b/src/phasicFlow/CMakeLists.txt @@ -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 diff --git a/src/phasicFlow/repository/systemControl/dynamicLinkLibs.cpp b/src/phasicFlow/repository/systemControl/dynamicLinkLibs.cpp new file mode 100644 index 00000000..6004dd77 --- /dev/null +++ b/src/phasicFlow/repository/systemControl/dynamicLinkLibs.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 + +#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(libList); + } + + + REPORT(1)<< "libs are "<< greenText(libNames)< libs_; + + void* open(word libName); + +public: + + dynamicLinkLibs(const dictionary &dict, word libList = "libs"); + + ~dynamicLinkLibs(); + + + +}; + + +} // pFlow + + +#endif // __dynamicLinkLibs_hpp__ diff --git a/src/phasicFlow/repository/systemControl/systemControl.cpp b/src/phasicFlow/repository/systemControl/systemControl.cpp index 949b0e9d..eabde21a 100644 --- a/src/phasicFlow/repository/systemControl/systemControl.cpp +++ b/src/phasicFlow/repository/systemControl/systemControl.cpp @@ -135,6 +135,7 @@ pFlow::systemControl::systemControl true ) ), + libs_(settingsDict_), outFilePrecision_( settingsDict_.getValOrSet("outFilePrecision", static_cast(6)) ), @@ -205,6 +206,7 @@ pFlow::systemControl::systemControl( true ) ), + libs_(settingsDict_), Time_ ( this, diff --git a/src/phasicFlow/repository/systemControl/systemControl.hpp b/src/phasicFlow/repository/systemControl/systemControl.hpp index 7b25c436..4556ff40 100644 --- a/src/phasicFlow/repository/systemControl/systemControl.hpp +++ b/src/phasicFlow/repository/systemControl/systemControl.hpp @@ -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; diff --git a/utilities/Utilities/CMakeLists.txt b/utilities/Utilities/CMakeLists.txt index 44c0d092..8c5d4ff5 100644 --- a/utilities/Utilities/CMakeLists.txt +++ b/utilities/Utilities/CMakeLists.txt @@ -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) diff --git a/utilities/geometryPhasicFlow/Wall/Wall.cpp b/utilities/Utilities/geometryPhasicFlow/Wall/Wall.cpp similarity index 100% rename from utilities/geometryPhasicFlow/Wall/Wall.cpp rename to utilities/Utilities/geometryPhasicFlow/Wall/Wall.cpp diff --git a/utilities/geometryPhasicFlow/Wall/Wall.hpp b/utilities/Utilities/geometryPhasicFlow/Wall/Wall.hpp similarity index 95% rename from utilities/geometryPhasicFlow/Wall/Wall.hpp rename to utilities/Utilities/geometryPhasicFlow/Wall/Wall.hpp index b8296134..7cf3d0e8 100755 --- a/utilities/geometryPhasicFlow/Wall/Wall.hpp +++ b/utilities/Utilities/geometryPhasicFlow/Wall/Wall.hpp @@ -22,9 +22,9 @@ Licence: #ifndef __Wall_hpp__ #define __Wall_hpp__ +#include #include "virtualConstructor.hpp" -#include "Vectors.hpp" #include "dictionary.hpp" namespace pFlow @@ -42,7 +42,7 @@ class Wall { protected: - realx3x3Vector triangles_; + std::vector triangles_; word name_; @@ -79,7 +79,7 @@ public: //// - Methods // - - const realx3x3Vector& triangles()const + const auto& triangles()const { return triangles_; } diff --git a/utilities/geometryPhasicFlow/cuboidWall/cuboidWall.cpp b/utilities/Utilities/geometryPhasicFlow/cuboidWall/cuboidWall.cpp similarity index 100% rename from utilities/geometryPhasicFlow/cuboidWall/cuboidWall.cpp rename to utilities/Utilities/geometryPhasicFlow/cuboidWall/cuboidWall.cpp diff --git a/utilities/geometryPhasicFlow/cuboidWall/cuboidWall.hpp b/utilities/Utilities/geometryPhasicFlow/cuboidWall/cuboidWall.hpp similarity index 100% rename from utilities/geometryPhasicFlow/cuboidWall/cuboidWall.hpp rename to utilities/Utilities/geometryPhasicFlow/cuboidWall/cuboidWall.hpp diff --git a/utilities/geometryPhasicFlow/cylinderWall/cylinderWall.cpp b/utilities/Utilities/geometryPhasicFlow/cylinderWall/cylinderWall.cpp similarity index 93% rename from utilities/geometryPhasicFlow/cylinderWall/cylinderWall.cpp rename to utilities/Utilities/geometryPhasicFlow/cylinderWall/cylinderWall.cpp index 859c2811..db0b7987 100644 --- a/utilities/geometryPhasicFlow/cylinderWall/cylinderWall.cpp +++ b/utilities/Utilities/geometryPhasicFlow/cylinderWall/cylinderWall.cpp @@ -1,4 +1,5 @@ #include "cylinderWall.hpp" +#include "Vectors.hpp" #include "line.hpp" diff --git a/utilities/geometryPhasicFlow/cylinderWall/cylinderWall.hpp b/utilities/Utilities/geometryPhasicFlow/cylinderWall/cylinderWall.hpp similarity index 100% rename from utilities/geometryPhasicFlow/cylinderWall/cylinderWall.hpp rename to utilities/Utilities/geometryPhasicFlow/cylinderWall/cylinderWall.hpp diff --git a/utilities/geometryPhasicFlow/planeWall/planeWall.cpp b/utilities/Utilities/geometryPhasicFlow/planeWall/planeWall.cpp similarity index 100% rename from utilities/geometryPhasicFlow/planeWall/planeWall.cpp rename to utilities/Utilities/geometryPhasicFlow/planeWall/planeWall.cpp diff --git a/utilities/geometryPhasicFlow/planeWall/planeWall.hpp b/utilities/Utilities/geometryPhasicFlow/planeWall/planeWall.hpp similarity index 100% rename from utilities/geometryPhasicFlow/planeWall/planeWall.hpp rename to utilities/Utilities/geometryPhasicFlow/planeWall/planeWall.hpp diff --git a/utilities/geometryPhasicFlow/stlWall/stlWall.cpp b/utilities/Utilities/geometryPhasicFlow/stlWall/stlWall.cpp similarity index 100% rename from utilities/geometryPhasicFlow/stlWall/stlWall.cpp rename to utilities/Utilities/geometryPhasicFlow/stlWall/stlWall.cpp diff --git a/utilities/geometryPhasicFlow/stlWall/stlWall.hpp b/utilities/Utilities/geometryPhasicFlow/stlWall/stlWall.hpp similarity index 100% rename from utilities/geometryPhasicFlow/stlWall/stlWall.hpp rename to utilities/Utilities/geometryPhasicFlow/stlWall/stlWall.hpp diff --git a/utilities/Utilities/vtkFile.cpp b/utilities/Utilities/vtkFile/vtkFile.cpp similarity index 100% rename from utilities/Utilities/vtkFile.cpp rename to utilities/Utilities/vtkFile/vtkFile.cpp diff --git a/utilities/Utilities/vtkFile.hpp b/utilities/Utilities/vtkFile/vtkFile.hpp similarity index 100% rename from utilities/Utilities/vtkFile.hpp rename to utilities/Utilities/vtkFile/vtkFile.hpp diff --git a/utilities/geometryPhasicFlow/CMakeLists.txt b/utilities/geometryPhasicFlow/CMakeLists.txt index 1c875a2c..6fe0358e 100644 --- a/utilities/geometryPhasicFlow/CMakeLists.txt +++ b/utilities/geometryPhasicFlow/CMakeLists.txt @@ -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) diff --git a/utilities/geometryPhasicFlow/geometryPhasicFlow.cpp b/utilities/geometryPhasicFlow/geometryPhasicFlow.cpp index 72559853..f6967f92 100755 --- a/utilities/geometryPhasicFlow/geometryPhasicFlow.cpp +++ b/utilities/geometryPhasicFlow/geometryPhasicFlow.cpp @@ -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 "<