This commit is contained in:
omid.khs
2023-03-06 16:47:18 +03:30
29 changed files with 293 additions and 85 deletions

View File

@ -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

View File

@ -139,10 +139,6 @@ public:
{
return true;
}
};

View File

@ -147,3 +147,20 @@ void pFlow::timeControl::setSaveTimeFolder(
}
}
bool pFlow::timeControl::operator ++(int)
{
if( reachedStopAt() ) return false;
// increament iteration number
currentIter_++;
currentTime_ += dt_;
if(screenReport())
{
REPORT(0)<<"Time (s): "<<cyanText( currentTimeWord() )<<endREPORT;
}
// switch outputToFile_ on/off
checkForOutputToFile();
return true;
}

View File

@ -182,23 +182,7 @@ public:
return true;
}
bool operator ++(int)
{
if( reachedStopAt() ) return false;
// increament iteration number
currentIter_++;
currentTime_ += dt_;
if(screenReport())
{
REPORT(0)<<"Time (s): "<<cyanText( currentTimeWord() )<<endREPORT;
}
// switch outputToFile_ on/off
checkForOutputToFile();
return true;
}
bool operator ++(int);
void setSaveTimeFolder(
bool saveToFile,

View 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;
}

View 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__

View File

@ -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,
@ -234,6 +236,7 @@ bool pFlow::systemControl::operator ++(int)
{
// skip writing to file for the first iteration
//output<< "time()++"<<endl;
auto finished = time()++;
writeToFileTimer_.start();
@ -256,12 +259,14 @@ bool pFlow::systemControl::operator ++(int)
}
writeToFileTimer_.end();
//output<< "after finalTime()"<<endl;
if( time().timersReportTime() &&
timersReport() )
{
timers_.write(output, true);
}
return finished;
}

View File

@ -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;