diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7b403304..e912cc93 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,3 +13,5 @@ add_subdirectory(Interaction) add_subdirectory(MotionModel) +add_subdirectory(PostprocessData) + diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt index eb50c1a7..c8a697ea 100644 --- a/src/phasicFlow/CMakeLists.txt +++ b/src/phasicFlow/CMakeLists.txt @@ -47,6 +47,7 @@ repository/Time/Time.cpp repository/Time/timeControl.cpp repository/Time/baseTimeControl.cpp repository/systemControl/systemControl.cpp +repository/systemControl/auxFunctions/auxFunctions.cpp repository/systemControl/dynamicLinkLibs.cpp commandLine/commandLine.cpp diff --git a/src/phasicFlow/containers/List/anyList/anyList.hpp b/src/phasicFlow/containers/List/anyList/anyList.hpp index 91a93360..b720a783 100644 --- a/src/phasicFlow/containers/List/anyList/anyList.hpp +++ b/src/phasicFlow/containers/List/anyList/anyList.hpp @@ -79,6 +79,27 @@ public: /// List of varibales names const wordList& names()const; + template + void emplaceBackOrReplace(const word& name, Args&&... args) + { + if( contains(name)) + { + int32 i = names_.findi(name); + types_[i] = getTypeName(); + anyList_.pos(i)->reset(); + anyList_.pos(i)-> emplace(std::forward(args)...); + } + else + { + names_.push_back(name); + types_.push_back(getTypeName()); + anyList_.emplace_back( + std::in_place_type, + std::forward(args)...); + } + + } + /// Create variable using constructor in-place template reference emplaceBack(const word& name, Args&&... args) diff --git a/src/phasicFlow/dictionary/dictionaryList.hpp b/src/phasicFlow/dictionary/dictionaryList.hpp new file mode 100644 index 00000000..d47e891e --- /dev/null +++ b/src/phasicFlow/dictionary/dictionaryList.hpp @@ -0,0 +1,114 @@ +/*------------------------------- 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 __dictionaryList_hpp__ +#define __dictionaryList_hpp__ + +#include "List.hpp" +#include "dictionary.hpp" + + +namespace pFlow +{ + +class dictionaryList +: + public List +{ +private: + + const dictionary& parrent_; + + word name_; + + +public: + + TypeInfoNV("dictionaryList"); + + dictionaryList(const word& name, const dictionary& parrent) + : + List(), + parrent_(parrent), + name_(name) + {} + + dictionaryList(const dictionaryList&) = default; + + dictionaryList(dictionaryList&&) = default; + + dictionaryList& operator = (const dictionaryList&) = default; + + dictionaryList& operator = (dictionaryList&&) = default; + + ~dictionaryList() = default; + + const word& name()const + { + return name_; + } + + const word globalName()const + { + return parrent_.globalName(); + } + + List& dicts() + { + return *this; + } + + const List& dicts()const + { + return *this; + } + + const dictionary& parrent()const + { + return parrent_; + } + +}; + +inline +dictionaryList readDictList(const word& name, const dictionary& dict) +{ + if(!dict.containsDataEntry(name)) + { + fatalErrorInFunction + <<"data entry: "<< name + <<" does not exist in dictionary "<< dict.globalName()<>(name); + for(auto& d:dicts) + { + allDicts.emplace_back(d.name(), dict, d); + } + + return allDicts; +} + +} + + + +#endif \ No newline at end of file diff --git a/src/phasicFlow/globals/vocabs.hpp b/src/phasicFlow/globals/vocabs.hpp index 9cb2c5bd..33844862 100755 --- a/src/phasicFlow/globals/vocabs.hpp +++ b/src/phasicFlow/globals/vocabs.hpp @@ -47,6 +47,7 @@ const inline char* const contactSearchFile__ = "contactSearch"; const inline char* const propertyFile__ = "interaction"; const inline char* const interactionFile__ = "interaction"; const inline char* const postprocessFile__ = "postprocessDict"; +const inline char* const postprocessDataFiel__ = "postprocessDataDict"; const inline char* const uniform__ = "uniform"; const inline char* const nonUniform__ = "nonUniform"; diff --git a/src/phasicFlow/repository/Time/baseTimeControl.cpp b/src/phasicFlow/repository/Time/baseTimeControl.cpp index b3bba368..c4a83327 100644 --- a/src/phasicFlow/repository/Time/baseTimeControl.cpp +++ b/src/phasicFlow/repository/Time/baseTimeControl.cpp @@ -21,14 +21,24 @@ Licence: #include "baseTimeControl.hpp" #include "timeInfo.hpp" -pFlow::baseTimeControl::baseTimeControl +void pFlow::baseTimeControl::setTimeControl ( - const dictionary &dict, - const word& intervalPrefix, - timeValue defStartTime + timeValue startTime, + timeValue endTime, + timeValue interval, + const word &intervalPrefix ) -: - intervalPrefix_(intervalPrefix) +{ + isTimeStep_ = false; + intervalPrefix_ = intervalPrefix; + rRange_ = stridedRange(startTime, endTime, interval); +} + +pFlow::baseTimeControl::baseTimeControl( + const dictionary &dict, + const word &intervalPrefix, + timeValue defStartTime) + : intervalPrefix_(intervalPrefix) { auto tControl = dict.getVal("timeControl"); if(tControl == "timeStep") @@ -119,6 +129,24 @@ pFlow::baseTimeControl::baseTimeControl(int32 start, int32 end, int32 stride, co { } +pFlow::baseTimeControl::baseTimeControl +( + timeValue start, + timeValue end, + timeValue stride, + const word &intervalPrefix +) +: + isTimeStep_(false), + rRange_( + start, end, stride + ), + intervalPrefix_( + intervalPrefix.size()==0uL? word("interval"): intervalPrefix+"Interval" + ) +{ +} + bool pFlow::baseTimeControl::eventTime(uint32 iter, timeValue t, timeValue dt) const { if(isTimeStep_) diff --git a/src/phasicFlow/repository/Time/baseTimeControl.hpp b/src/phasicFlow/repository/Time/baseTimeControl.hpp index f49d97be..8e9dd62f 100644 --- a/src/phasicFlow/repository/Time/baseTimeControl.hpp +++ b/src/phasicFlow/repository/Time/baseTimeControl.hpp @@ -32,13 +32,21 @@ class baseTimeControl { private: - bool isTimeStep_; + bool isTimeStep_; - int32StridedRagne iRange_; + int32StridedRagne iRange_; - stridedRange rRange_; + stridedRange rRange_; - const word intervalPrefix_; + word intervalPrefix_; + +protected: + + void setTimeControl( + timeValue startTime, + timeValue endTime, + timeValue interval, + const word& intervalPrefix); public: @@ -59,8 +67,33 @@ public: int32 end, int32 stride, const word& intervalPrefix = "" + ); + + baseTimeControl( + timeValue start, + timeValue end, + timeValue stride, + const word& intervalPrefix = "" ); + baseTimeControl( + const baseTimeControl& other + ) = default; + + baseTimeControl( + baseTimeControl&& other + ) = default; + + baseTimeControl& operator=( + const baseTimeControl& other + ) = default; + + baseTimeControl& operator=( + baseTimeControl&& other + ) = default; + + ~baseTimeControl() = default; + inline bool isTimeStep() const { return isTimeStep_; diff --git a/src/phasicFlow/repository/Time/timeControl.hpp b/src/phasicFlow/repository/Time/timeControl.hpp index 065b3777..dc2bb80b 100644 --- a/src/phasicFlow/repository/Time/timeControl.hpp +++ b/src/phasicFlow/repository/Time/timeControl.hpp @@ -120,6 +120,16 @@ public: return startTime_; } + timeValue endTime()const + { + return endTime_; + } + + timeValue saveInterval()const + { + return saveInterval_; + } + word timeName()const; timeValue currentTime() const diff --git a/src/phasicFlow/repository/Time/timeInfo.hpp b/src/phasicFlow/repository/Time/timeInfo.hpp index fc759614..ee0cff61 100644 --- a/src/phasicFlow/repository/Time/timeInfo.hpp +++ b/src/phasicFlow/repository/Time/timeInfo.hpp @@ -106,6 +106,12 @@ public: return real2FixedStripZeros(currentTime_, presicion_); } + inline + word prevTimeName()const + { + return real2FixedStripZeros( max(currentTime_-dt_, timeValue(0)), presicion_); + } + static uint32 precision() { diff --git a/src/phasicFlow/repository/systemControl/auxFunctions/auxFunctions.cpp b/src/phasicFlow/repository/systemControl/auxFunctions/auxFunctions.cpp new file mode 100644 index 00000000..8214a3c2 --- /dev/null +++ b/src/phasicFlow/repository/systemControl/auxFunctions/auxFunctions.cpp @@ -0,0 +1,56 @@ +/*------------------------------- 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 "auxFunctions.hpp" +#include "systemControl.hpp" + + +pFlow::uniquePtr + pFlow::auxFunctions::create(const systemControl& control) +{ + const auto& setDict = control.settingsDict(); + + if( !setDict.containsDataEntry("auxFunctions")) + { + return nullptr; + } + + word func = setDict.getVal("auxFunctions"); + + if( systemControlvCtorSelector_.search(func) ) + { + REPORT(1)<<"Creating auxiliary function "<< Green_Text(func)<< " ..."< create(const systemControl& control); + +}; + +} // namespace pFlow + +#endif \ No newline at end of file diff --git a/src/phasicFlow/repository/systemControl/systemControl.cpp b/src/phasicFlow/repository/systemControl/systemControl.cpp index 75109c71..4c9ae2f0 100644 --- a/src/phasicFlow/repository/systemControl/systemControl.cpp +++ b/src/phasicFlow/repository/systemControl/systemControl.cpp @@ -25,6 +25,8 @@ Licence: #include "types.hpp" #include "vocabs.hpp" +inline static bool axuFunctionsInitialized__ = false; + bool pFlow::systemControl::readIncludeExclue(const dictionary& dict) { if (dict.containsDataEntry("includeObjects")) @@ -187,6 +189,18 @@ bool pFlow::systemControl::operator++(int) { auto toContinue = time()++; + if(!axuFunctionsInitialized__) + { + auxFunctions_ = auxFunctions::create(*this); + axuFunctionsInitialized__ = true; + } + + if(auxFunctions_) + { + auxFunctions_().execute(); + auxFunctions_().write(); + } + if (toContinue) { writeToFileTimer_.start(); @@ -221,3 +235,5 @@ bool pFlow::systemControl::operator++(int) return toContinue; } + + diff --git a/src/phasicFlow/repository/systemControl/systemControl.hpp b/src/phasicFlow/repository/systemControl/systemControl.hpp index 94d3b939..0e9f8988 100644 --- a/src/phasicFlow/repository/systemControl/systemControl.hpp +++ b/src/phasicFlow/repository/systemControl/systemControl.hpp @@ -34,10 +34,13 @@ Licence: #include "Timers.hpp" #include "dynamicLinkLibs.hpp" #include "Set.hpp" +#include "auxFunctions.hpp" + namespace pFlow { + class systemControl : public repository @@ -83,6 +86,7 @@ protected: wordSet excludeList_; + uniquePtr auxFunctions_ = nullptr; bool readIncludeExclue(const dictionary& dict); diff --git a/src/phasicFlow/smartPointers/uniquePtr.hpp b/src/phasicFlow/smartPointers/uniquePtr.hpp index c28490c7..23e7f3a6 100644 --- a/src/phasicFlow/smartPointers/uniquePtr.hpp +++ b/src/phasicFlow/smartPointers/uniquePtr.hpp @@ -38,15 +38,16 @@ namespace pFlow template< - typename T + typename T, + typename Deleter = std::default_delete > class uniquePtr : - public std::unique_ptr + public std::unique_ptr { public: - using uniquePtrType = std::unique_ptr; + using uniquePtrType = std::unique_ptr; // using base constructors using uniquePtrType::unique_ptr; diff --git a/src/phasicFlow/structuredData/sphere/sphere.hpp b/src/phasicFlow/structuredData/sphere/sphere.hpp index 21b20d1c..2586723c 100644 --- a/src/phasicFlow/structuredData/sphere/sphere.hpp +++ b/src/phasicFlow/structuredData/sphere/sphere.hpp @@ -105,6 +105,12 @@ public: return sqrt(radius2_); } + INLINE_FUNCTION_HD + real volume()const + { + return 4.0/3.0* Pi * pow(radius(),3.0); + } + //// - IO operation FUNCTION_H bool read(iIstream & is);