From 9de1fa2dc74796931839c3b285e28023a41f9dd6 Mon Sep 17 00:00:00 2001 From: Hamidreza Date: Mon, 21 Apr 2025 00:13:54 +0330 Subject: [PATCH] postprocessPhasicFlow is now updated with new postprocessData auxFunction. It now uses postprocessDataDict. --- .../fieldsDataBase/fieldsDataBase.cpp | 125 ++++++-- .../fieldsDataBase/fieldsDataBase.hpp | 109 ++++--- .../fieldsDataBaseTemplates.cpp | 30 ++ .../simulationFieldsDataBase.cpp | 29 +- .../simulationFieldsDataBase.hpp | 13 +- .../postprocessData/postprocessData.cpp | 41 +-- .../postprocessData/postprocessData.hpp | 30 +- src/phasicFlow/CMakeLists.txt | 1 + src/phasicFlow/ranges/combinedRange.hpp | 36 +++ src/phasicFlow/ranges/intervalRange.hpp | 9 + src/phasicFlow/ranges/stridedRange.hpp | 25 +- .../repository/systemControl/timeFolder.cpp | 131 +++++++++ .../repository/systemControl/timeFolder.hpp | 84 ++++-- utilities/pFlowToVTK/pFlowToVTK.cpp | 12 +- .../postprocessPhasicFlow/CMakeLists.txt | 17 +- .../postprocessPhasicFlow/IncludeMask.hpp | 263 ----------------- .../postprocessPhasicFlow/IncludeMasks.cpp | 80 ------ .../postprocessPhasicFlow/ProcessField.hpp | 179 ------------ .../postprocessPhasicFlow/ProcessFields.cpp | 33 --- .../postprocessPhasicFlow/cellMapper.cpp | 91 ------ .../postprocessPhasicFlow/cellMapper.hpp | 137 --------- .../postprocessPhasicFlow/countField.cpp | 94 ------ .../postprocessPhasicFlow/countField.hpp | 102 ------- .../postprocessPhasicFlow/countFields.cpp | 53 ---- .../postprocessPhasicFlow/countFields.hpp | 77 ----- .../postprocessPhasicFlow/fieldOperations.hpp | 112 -------- .../postprocessPhasicFlow/includeMask.cpp | 108 ------- .../postprocessPhasicFlow/includeMask.hpp | 109 ------- .../postprocessPhasicFlow/pointRectCell.hpp | 142 --------- .../postSimulationFieldsDataBase.cpp | 271 ++++++++++++++++++ .../postSimulationFieldsDataBase.hpp | 97 +++++++ .../postprocessPhasicFlow/postprocess.cpp | 156 ---------- .../postprocessPhasicFlow/postprocess.hpp | 100 ------- .../postprocessPhasicFlow.cpp | 123 ++++---- .../postprocessPhasicFlow/processField.cpp | 132 --------- .../postprocessPhasicFlow/processField.hpp | 180 ------------ .../postprocessPhasicFlow/rectMeshField.hpp | 212 -------------- .../rectMeshFieldToVTK.hpp | 98 ------- .../postprocessPhasicFlow/rectMeshFields.hpp | 45 --- .../postprocessPhasicFlow/rectangleMesh.cpp | 52 ---- .../postprocessPhasicFlow/rectangleMesh.hpp | 174 ----------- 41 files changed, 1000 insertions(+), 2912 deletions(-) create mode 100644 src/phasicFlow/repository/systemControl/timeFolder.cpp delete mode 100644 utilities/postprocessPhasicFlow/IncludeMask.hpp delete mode 100644 utilities/postprocessPhasicFlow/IncludeMasks.cpp delete mode 100644 utilities/postprocessPhasicFlow/ProcessField.hpp delete mode 100644 utilities/postprocessPhasicFlow/ProcessFields.cpp delete mode 100644 utilities/postprocessPhasicFlow/cellMapper.cpp delete mode 100644 utilities/postprocessPhasicFlow/cellMapper.hpp delete mode 100644 utilities/postprocessPhasicFlow/countField.cpp delete mode 100644 utilities/postprocessPhasicFlow/countField.hpp delete mode 100644 utilities/postprocessPhasicFlow/countFields.cpp delete mode 100644 utilities/postprocessPhasicFlow/countFields.hpp delete mode 100644 utilities/postprocessPhasicFlow/fieldOperations.hpp delete mode 100644 utilities/postprocessPhasicFlow/includeMask.cpp delete mode 100644 utilities/postprocessPhasicFlow/includeMask.hpp delete mode 100644 utilities/postprocessPhasicFlow/pointRectCell.hpp create mode 100644 utilities/postprocessPhasicFlow/postSimulationFieldsDataBase/postSimulationFieldsDataBase.cpp create mode 100644 utilities/postprocessPhasicFlow/postSimulationFieldsDataBase/postSimulationFieldsDataBase.hpp delete mode 100644 utilities/postprocessPhasicFlow/postprocess.cpp delete mode 100644 utilities/postprocessPhasicFlow/postprocess.hpp delete mode 100644 utilities/postprocessPhasicFlow/processField.cpp delete mode 100644 utilities/postprocessPhasicFlow/processField.hpp delete mode 100644 utilities/postprocessPhasicFlow/rectMeshField.hpp delete mode 100644 utilities/postprocessPhasicFlow/rectMeshFieldToVTK.hpp delete mode 100644 utilities/postprocessPhasicFlow/rectMeshFields.hpp delete mode 100644 utilities/postprocessPhasicFlow/rectangleMesh.cpp delete mode 100644 utilities/postprocessPhasicFlow/rectangleMesh.hpp diff --git a/src/PostprocessData/fieldsDataBase/fieldsDataBase.cpp b/src/PostprocessData/fieldsDataBase/fieldsDataBase.cpp index 2ea4e81b..51a533b4 100644 --- a/src/PostprocessData/fieldsDataBase/fieldsDataBase.cpp +++ b/src/PostprocessData/fieldsDataBase/fieldsDataBase.cpp @@ -24,7 +24,7 @@ Licence: #include "systemControl.hpp" #include "fieldsDataBase.hpp" #include "fieldFunctions.hpp" - +#include "dictionary.hpp" namespace pFlow { @@ -38,19 +38,6 @@ bool pFlow::fieldsDataBase::loadPointStructureToTime() return false; } -pFlow::word pFlow::fieldsDataBase::getPointFieldType(const word &name) const -{ - word pfType = time_.lookupObjectTypeName(name); - word type, space; - if(!pointFieldGetType(pfType, type, space)) - { - fatalErrorInFunction - <<"Error in retriving the type of pointField " - << pfType< pFlow::fieldsDataBase::createOrGetOne(bool forceUpdate) field.size()); } +pFlow::span pFlow::fieldsDataBase::createOrGetMass(bool forceUpdate) +{ + const word fName = "mass"; + + bool shouldUpdate = checkForUpdate(fName, forceUpdate); + + if(shouldUpdate) + { + const auto index = updateFieldUint32("shapeIndex", true); + const auto ms = getShape().mass(); + + FieldTypeHost massField + ( + fName, + "value", + pointFieldSize() + ); + + for(uint32 i=0; i< massField.size(); i++) + { + massField[i] = ms[index[i]]; + } + + allFields_.emplaceBackOrReplace> + ( + fName, + std::move(massField) + ); + } + + auto& field = allFields_.getObject>(fName); + return span( + field.data(), + field.size()); +} + +pFlow::span pFlow::fieldsDataBase::createOrGetI(bool forceUpdate) +{ + const word fName = "I"; + + bool shouldUpdate = checkForUpdate(fName, forceUpdate); + + if(shouldUpdate) + { + const auto index = updateFieldUint32("shapeIndex", true); + const auto Is = getShape().Inertia(); + + FieldTypeHost IField + ( + fName, + "value", + pointFieldSize() + ); + + for(uint32 i=0; i< IField.size(); i++) + { + IField[i] = Is[index[i]]; + } + + allFields_.emplaceBackOrReplace> + ( + fName, + std::move(IField) + ); + } + + auto& field = allFields_.getObject>(fName); + return span( + field.data(), + field.size()); +} + bool pFlow::fieldsDataBase::findFunction( const word &compoundFieldName, word &fieldName, @@ -399,11 +458,35 @@ bool pFlow::fieldsDataBase::inputOutputType return false; } -pFlow::fieldsDataBase::fieldsDataBase(systemControl& control, bool inSimulation) +pFlow::fieldsDataBase::fieldsDataBase +( + systemControl& control, + const dictionary& postDict, + bool inSimulation, + timeValue startTime +) : time_(control.time()), inSimulation_(inSimulation) -{} +{ + if(!inSimulation_) + { + shapeType_ = postDict.getValOrSet("shapeType", ""); + + if(shapeType_.empty()) + { + WARNING + << "shapeType is not set in dictionary: " + << postDict.globalName() + << " and you may need to set for some postprocess operations"< - pFlow::fieldsDataBase::create(systemControl& control, bool inSimulation) + pFlow::fieldsDataBase::create +( + systemControl& control, + const dictionary& postDict, + bool inSimulation, + timeValue startTime +) { word dbType; if(inSimulation) @@ -823,7 +912,7 @@ pFlow::uniquePtr if( boolvCtorSelector_.search(dbType) ) { auto objPtr = - boolvCtorSelector_[dbType](control, inSimulation); + boolvCtorSelector_[dbType](control, postDict, inSimulation, startTime); return objPtr; } else diff --git a/src/PostprocessData/fieldsDataBase/fieldsDataBase.hpp b/src/PostprocessData/fieldsDataBase/fieldsDataBase.hpp index ec8c577e..6af3f2f9 100644 --- a/src/PostprocessData/fieldsDataBase/fieldsDataBase.hpp +++ b/src/PostprocessData/fieldsDataBase/fieldsDataBase.hpp @@ -33,6 +33,7 @@ Licence: namespace pFlow { +class dictionary; class systemControl; class Time; @@ -83,16 +84,9 @@ private: /// Flag indicating if we're in simulation mode bool inSimulation_ = false; -protected: + word shapeType_; - /// Map of reserved field names with their corresponding types - static const inline std::map reservedFieldNames_ - { - {"position", "realx3"}, - {"one", "real"}, - {"volume", "real"}, - {"density", "real"} - }; +protected: /// check if pointField name exists in Time or time folder virtual @@ -104,12 +98,28 @@ protected: virtual bool loadPointStructureToTime()=0; + + virtual + const shape& getShape() const= 0; + + const word& shapeTypeName()const + { + return shapeType_; + } /// get the type name of the pointField in the Time object - word getPointFieldType(const word& name)const; + virtual + word getPointFieldType(const word& name)const = 0; /// Checks if a field needs to be updated based on capture time bool checkForUpdate(const word& compoundName, bool forceUpdate = false); + + /// @brief return the size of pointStructure + uint32 pointFieldSize() + { + auto s = updatePoints(); + return s.size(); + } template span updateField(const word& name, bool forceUpdate = false); @@ -125,6 +135,21 @@ protected: span createOrGetOne(bool forceUpdate=false); + span createOrGetMass(bool forceUpdate=false); + + span createOrGetI(bool forceUpdate=false); + + /// Map of reserved field names with their corresponding types + static const inline std::map reservedFieldNames_ + { + {"position", "realx3"}, + {"one", "real"}, + {"volume", "real"}, + {"density", "real"}, + {"mass", "real"}, + {"I", "real"} + }; + static bool findFunction( const word& compoundFieldName, @@ -137,25 +162,7 @@ protected: const word& inputType, word& outputType); - -protected: - // - protected member functions - - - virtual - bool checkTimeFolder(const word& fieldName) const = 0; - - virtual - const shape& getShape() const= 0; - - - /// @brief return the size of pointStructure - uint32 pointFieldSize() - { - auto s = updatePoints(); - return s.size(); - } public: @@ -165,7 +172,11 @@ public: // - constructors - fieldsDataBase(systemControl& control, bool inSimulation); + fieldsDataBase( + systemControl& control, + const dictionary& postDict, + bool inSimulation, + timeValue startTime); /// no copy constructor fieldsDataBase(const fieldsDataBase&) = delete; @@ -186,8 +197,13 @@ public: ( fieldsDataBase, bool, - (systemControl& control, bool inSimulation), - (control, inSimulation) + ( + systemControl& control, + const dictionary& postDict, + bool inSimulation, + timeValue startTime + ), + (control, postDict, inSimulation, startTime) ); @@ -260,14 +276,39 @@ public: virtual const pointStructure& pStruct()const = 0; + + /// Get the next avaiable time folder after the current time folder + /// This is only used for post-simulation processing + virtual + timeValue getNextTimeFolder()const + { + return -1.0; + } + /// Sets the current folder to the next time folder. + /// This is used only for post-simulation processing + /// @returns the time value of the next folder. virtual - void resetTimeFolder() = 0; - + timeValue setToNextTimeFolder() + { + return -1.0; + } + + /// Skips the next time folder. + /// This is used only for post-simulation processing + /// @returns the time value of the skipped folder + virtual + timeValue skipNextTimeFolder() + { + return -1.0; + } + static uniquePtr create( systemControl& control, - bool inSimulation); + const dictionary& postDict, + bool inSimulation, + timeValue startTime); }; } // namespace pFlow diff --git a/src/PostprocessData/fieldsDataBase/fieldsDataBaseTemplates.cpp b/src/PostprocessData/fieldsDataBase/fieldsDataBaseTemplates.cpp index a36eb95c..b473e8c8 100644 --- a/src/PostprocessData/fieldsDataBase/fieldsDataBaseTemplates.cpp +++ b/src/PostprocessData/fieldsDataBase/fieldsDataBaseTemplates.cpp @@ -116,6 +116,36 @@ pFlow::span pFlow::fieldsDataBase::updateReservedField fatalExit; } } + else if( name == "mass") + { + if constexpr( std::same_as) + { + return createOrGetMass(forceUpdate); + } + else + { + fatalErrorInFunction + << "This type: " + << getTypeName() + <<" is not supported for field mass."<) + { + return createOrGetI(forceUpdate); + } + else + { + fatalErrorInFunction + << "This type: " + << getTypeName() + <<" is not supported for field I."<) diff --git a/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.cpp b/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.cpp index 312f8e51..9348037a 100644 --- a/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.cpp +++ b/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.cpp @@ -24,23 +24,35 @@ bool pFlow::simulationFieldsDataBase::loadPointStructureToTime() return time().lookupObjectName(pointStructureFile__); } -bool pFlow::simulationFieldsDataBase::checkTimeFolder(const word &fieldName) const -{ - return true; -} const pFlow::shape& pFlow::simulationFieldsDataBase::getShape() const { return shape_; } +pFlow::word pFlow::simulationFieldsDataBase::getPointFieldType(const word &name) const +{ + word pfType = time().lookupObjectTypeName(name); + word type, space; + if(!pointFieldGetType(pfType, type, space)) + { + fatalErrorInFunction + <<"Error in retriving the type of pointField " + << pfType<(*control.caseSetup().lookupObjectPtr(shapeFile__)) @@ -57,6 +69,3 @@ const pFlow::pointStructure &pFlow::simulationFieldsDataBase::pStruct() const ); } -void pFlow::simulationFieldsDataBase::resetTimeFolder() -{ -} diff --git a/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.hpp b/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.hpp index d7ea7f50..de1d5b51 100644 --- a/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.hpp +++ b/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.hpp @@ -38,6 +38,7 @@ protected: /// check if pointField name exists in Time or time folder bool pointFieldNameExists(const word& name)const override; + /// Loads a pointField with a given name to the Time object. /// For simulation, it just checks if the name exists @@ -47,15 +48,19 @@ protected: /// For simulation, it just checks if the name exists bool loadPointStructureToTime() override; - bool checkTimeFolder(const word& fieldName) const override; - const shape& getShape() const override; + + word getPointFieldType(const word& name)const override; public: TypeInfo("fieldsDataBase"); - simulationFieldsDataBase(systemControl& control, bool inSimulation); + simulationFieldsDataBase( + systemControl& control, + const dictionary& postDict, + bool inSimulation, + timeValue startTime); ~simulationFieldsDataBase() override = default; @@ -68,8 +73,6 @@ public: const pointStructure& pStruct()const override; - void resetTimeFolder() override; - }; diff --git a/src/PostprocessData/postprocessData/postprocessData.cpp b/src/PostprocessData/postprocessData/postprocessData.cpp index dc1dc479..02afc48e 100644 --- a/src/PostprocessData/postprocessData/postprocessData.cpp +++ b/src/PostprocessData/postprocessData/postprocessData.cpp @@ -22,22 +22,18 @@ Licence: #include "List.hpp" #include "systemControl.hpp" #include "postprocessData.hpp" -#include "fileDictionary.hpp" #include "postprocessGlobals.hpp" #include "postprocessComponent.hpp" -pFlow::postprocessData::postprocessData(const systemControl &control) +pFlow::postprocessData::postprocessData +( + const systemControl &control, + timeValue startTime +) : auxFunctions(control), + inSimulation_(startTime<0.0?true:false), time_(control.time()), - fieldsDataBasePtr_ - ( - fieldsDataBase::create - ( - const_cast(control), - true - ) - ), dict_ ( objectFile @@ -59,6 +55,15 @@ pFlow::postprocessData::postprocessData(const systemControl &control) <<" This feature is disabled in the current run."<(control), + dict_, + inSimulation_, + startTime + ); + activeInSimulation_ = dict_.getValOrSet( "activeInSimulation", @@ -80,12 +85,6 @@ pFlow::postprocessData::postprocessData(const systemControl &control) control.time().saveInterval(), "execution"); } - - shapeType_ = dict_.getValOrSet - ( - "shapeType", - word("sphere") - ); componentsDictsPtr_ = makeUnique(readDictList("components", dict_)); @@ -105,10 +104,10 @@ bool pFlow::postprocessData::execute() for(auto& component:postprocesses_) { - if(!component->execute(ti)) + if(!component->execute(ti, !inSimulation_) ) { fatalErrorInFunction - <<"Error occured in executing postprocess component: " + <<"Error occurred in executing postprocess component: " <name()<write(postProcessGlobals::defaultDir__/component->name())) { fatalErrorInFunction @@ -135,3 +135,8 @@ bool pFlow::postprocessData::write() const } return true; } + +void pFlow::postprocessData::setOutputDirectory(const fileSystem &path) const +{ + postProcessGlobals::defaultDir__ = path; +} diff --git a/src/PostprocessData/postprocessData/postprocessData.hpp b/src/PostprocessData/postprocessData/postprocessData.hpp index e2223116..04ae6188 100644 --- a/src/PostprocessData/postprocessData/postprocessData.hpp +++ b/src/PostprocessData/postprocessData/postprocessData.hpp @@ -20,14 +20,14 @@ Licence: #ifndef __postprocessData_hpp__ #define __postprocessData_hpp__ -#include "auxFunctions.hpp" #include "Logical.hpp" #include "ListPtr.hpp" #include "fileDictionary.hpp" -#include "baseTimeControl.hpp" +#include "dictionaryList.hpp" +#include "auxFunctions.hpp" #include "fieldsDataBase.hpp" #include "postprocessComponent.hpp" -#include "dictionaryList.hpp" + namespace pFlow { @@ -36,6 +36,7 @@ class systemControl; class Time; class timeInfo; + /** * @class postprocessData * @brief An interface class for handling post-processing of simulation data. @@ -47,7 +48,11 @@ class postprocessData : public auxFunctions { - /// Indicates if a post-processing is active during simulatoin + /// Indicates if this is post-processing during simulation or + /// post-simulation + bool inSimulation_; + + /// Indicates if a post-processing is active during simulation Logical activeInSimulation_{false}; /// a list of active post-process components @@ -62,9 +67,6 @@ class postprocessData /// file dictionary that is constructed from the file (postProcessDataDict) fileDictionary dict_; - /// name of the shape for use in the time of postprocess after simulation - word shapeType_; - /// list of dictionaries for postprocess components uniquePtr componentsDictsPtr_ = nullptr; @@ -79,7 +81,7 @@ public: /// this constructor is used when postprocesing is active /// during simulation. /// @param control const reference to systemControl - postprocessData(const systemControl& control); + postprocessData(const systemControl& control, timeValue startTime = -1.0); ~postprocessData()override = default; @@ -92,11 +94,19 @@ public: bool execute() override; - - bool write()const override; + fieldsDataBase& database() + { + return fieldsDataBasePtr_(); + } + const fieldsDataBase& database()const + { + return fieldsDataBasePtr_(); + } + + void setOutputDirectory(const fileSystem& path)const; }; } // namespace pFlow diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt index c8a697ea..db66642e 100644 --- a/src/phasicFlow/CMakeLists.txt +++ b/src/phasicFlow/CMakeLists.txt @@ -49,6 +49,7 @@ repository/Time/baseTimeControl.cpp repository/systemControl/systemControl.cpp repository/systemControl/auxFunctions/auxFunctions.cpp repository/systemControl/dynamicLinkLibs.cpp +repository/systemControl/timeFolder.cpp commandLine/commandLine.cpp diff --git a/src/phasicFlow/ranges/combinedRange.hpp b/src/phasicFlow/ranges/combinedRange.hpp index d01b3b5d..a5533eb5 100644 --- a/src/phasicFlow/ranges/combinedRange.hpp +++ b/src/phasicFlow/ranges/combinedRange.hpp @@ -128,6 +128,42 @@ public: return false; } + T minVal()const + { + T m = largestPositive(); + for(const auto& sr:sRanges_) + { + m = min(m, sr.begin()); + } + for(const auto& iR:iRanges_) + { + m = min(m, iR.begin()); + } + for(const auto& i:individuals_) + { + m = min(m, i); + } + return m; + } + + T maxVal()const + { + T m = largestNegative(); + for(const auto& sr:sRanges_) + { + m = max(m, sr.begin()); + } + for(const auto& iR:iRanges_) + { + m = max(m, iR.begin()); + } + for(const auto& i:individuals_) + { + m = max(m, i); + } + return m; + } + bool isMember(T val)const { for(auto& sR:sRanges_) diff --git a/src/phasicFlow/ranges/intervalRange.hpp b/src/phasicFlow/ranges/intervalRange.hpp index 0108713d..ab33c574 100644 --- a/src/phasicFlow/ranges/intervalRange.hpp +++ b/src/phasicFlow/ranges/intervalRange.hpp @@ -68,6 +68,15 @@ public: } } + T begin()const + { + return begin_; + } + + T end()const + { + return end_; + } inline bool isMember(T val)const diff --git a/src/phasicFlow/ranges/stridedRange.hpp b/src/phasicFlow/ranges/stridedRange.hpp index 31f671d9..a813aefe 100644 --- a/src/phasicFlow/ranges/stridedRange.hpp +++ b/src/phasicFlow/ranges/stridedRange.hpp @@ -30,6 +30,25 @@ Licence: namespace pFlow { +template +constexpr T getEpsilon() +{ + return 0; +} + +template<> +constexpr float getEpsilon() +{ + return 10*std::numeric_limits::epsilon(); +} + +template<> +constexpr double getEpsilon() +{ + return 10*std::numeric_limits::epsilon(); +} + + template class stridedRange @@ -107,7 +126,7 @@ public: } inline - bool isMember(T val, T epsilon = 0)const + bool isMember(T val, T epsilon = getEpsilon())const { if(!isInRange(val)) return false; @@ -151,7 +170,7 @@ public: template<> inline -bool stridedRange::isMember(float val, float epsilon)const +bool stridedRange::isMember(float val, float epsilon )const { if(!isInRange(val)) return false; @@ -171,7 +190,7 @@ bool stridedRange::isMember(float val, float epsilon)const template<> inline -bool stridedRange::isMember(double val, double epsilon)const +bool stridedRange::isMember(double val, double epsilon )const { /*if(!isInRange(val)) return false; if(const double dist = val-begin_; abs(remainder(dist,stride_)<= epsilon)) return true; diff --git a/src/phasicFlow/repository/systemControl/timeFolder.cpp b/src/phasicFlow/repository/systemControl/timeFolder.cpp new file mode 100644 index 00000000..ae5f1623 --- /dev/null +++ b/src/phasicFlow/repository/systemControl/timeFolder.cpp @@ -0,0 +1,131 @@ +/*------------------------------- 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 "timeFolder.hpp" +#include "vocabs.hpp" + + +bool pFlow::timeFolder::validateForPointStructure() +{ + std::erase_if + ( + folders_, + [this](const auto& folder) + { + return !containsPointStructure(folder.second); + } + ); + return true; +} + +bool pFlow::timeFolder::validFieldFile(const fileSystem &filePath) const +{ + IOfileHeader fieldHeader( + objectFile( + filePath.fileName(), + filePath.dirPath(), + objectFile::READ_ALWAYS, + objectFile::WRITE_NEVER) + ); + return fieldHeader.headerOk(true); +} + +bool pFlow::timeFolder::validFieldFile +( + const fileSystem &filePath, + word &fieldName, + word &objectType +) const +{ + IOfileHeader fieldHeader( + objectFile( + filePath.fileName(), + filePath.dirPath(), + objectFile::READ_ALWAYS, + objectFile::WRITE_NEVER) + ); + + if(!fieldHeader.headerOk(true)) + { + return false; + } + else + { + fieldName = fieldHeader.objectName(); + objectType = fieldHeader.objectType(); + return true; + } +} + +pFlow::timeFolder::timeFolder +( + const systemControl& control, + bool pointStructureOnly +) +: + timeFolder(control.path(), pointStructureOnly) +{} + + +pFlow::timeFolder::timeFolder +( + const fileSystem& path, + bool pointStructureOnly +) +: + folders_(getTimeFolders(path)), + currentFolder_(folders_.begin()) +{ + if(pointStructureOnly) + { + validateForPointStructure(); + } + currentFolder_ = folders_.begin(); +} + +bool pFlow::timeFolder::containsPointStructure(const fileSystem &dirPath) const +{ + auto files = containingFiles(dirPath); + for (const auto &file : files) + { + if (file.fileName() == pointStructureFile__) + { + return validFieldFile(file); + } + } + return false; +} + +pFlow::Map pFlow::timeFolder::currentFolderFiles() const +{ + Map fileList; + if( folders_.empty()) return fileList; + + auto files = containingFiles(folder()); + word name, objectType; + for (const auto &file : files) + { + if(validFieldFile(file, name, objectType)) + { + fileList.insertIf(name, objectType); + } + } + return fileList; +} diff --git a/src/phasicFlow/repository/systemControl/timeFolder.hpp b/src/phasicFlow/repository/systemControl/timeFolder.hpp index 15c01e4e..bad231af 100644 --- a/src/phasicFlow/repository/systemControl/timeFolder.hpp +++ b/src/phasicFlow/repository/systemControl/timeFolder.hpp @@ -27,38 +27,55 @@ Licence: namespace pFlow { -Map getTimeFolders(const fileSystem& path); +Map getTimeFolders(const fileSystem& path); class timeFolder { - using timeList = Map; + using timeList = Map; + protected: timeList folders_; timeList::iterator currentFolder_; - + bool validateForPointStructure(); + + bool validFieldFile(const fileSystem& filePath)const; + + bool validFieldFile( + const fileSystem& filePath, + word& fieldName, + word& objectType)const; + public: - timeFolder(const systemControl& control ) - : - timeFolder(control.path()) - {} - - timeFolder(const fileSystem& path) - : - folders_(getTimeFolders(path)), - currentFolder_(folders_.begin()) + timeFolder(const systemControl& control, bool pointStructureOnly = false ); + + timeFolder(const fileSystem& path, bool pointStructureOnly = false); + + inline + bool empty()const { - + return folders_.empty(); } - real time()const + inline + timeValue currentTime()const { + if(folders_.empty()) return -1; return currentFolder_->first; } + inline + timeValue nextTime()const + { + auto next = currentFolder_; + next++; + if(next == folders_.end()) return -1; + return next->first; + } + fileSystem folder()const { return currentFolder_->second; @@ -81,6 +98,27 @@ public: return !finished(); } + bool setTime(timeValue upto) + { + timeList::iterator orgFolder = currentFolder_; + + rewind(); + + while(!finished()) + { + auto t = currentTime(); + if( equal(upto, t) || t>upto) + { + return true; + } + (*this)++; + } + + currentFolder_ = orgFolder; + + return false; + } + explicit operator bool()const { return !finished(); @@ -102,30 +140,38 @@ public: return false; } - real startTime()const + timeValue startTime()const { + if(folders_.empty()) return -1; auto [t,f] = *folders_.begin(); return t; } - real endTime()const + timeValue endTime()const { + if(folders_.empty()) return -1; auto [t,f] = *(--folders_.end()); return t; } + + bool containsPointStructure(const fileSystem& dirPath)const; + + /// Get the list of files in the current folder + /// the first element is file name and the second is the objectType + Map currentFolderFiles()const; }; inline -Map getTimeFolders(const fileSystem& path) +Map getTimeFolders(const fileSystem& path) { - Map tFolders; + Map tFolders; auto subDirs = subDirectories(path); for(auto& subD: subDirs) { auto timeName = tailName(subD.wordPath(), '/'); - real TIME; + timeValue TIME; if( auto success = readReal(timeName, TIME); success) { if(!tFolders.insertIf(TIME, subD)) diff --git a/utilities/pFlowToVTK/pFlowToVTK.cpp b/utilities/pFlowToVTK/pFlowToVTK.cpp index 919c66d9..8f3a2f24 100755 --- a/utilities/pFlowToVTK/pFlowToVTK.cpp +++ b/utilities/pFlowToVTK/pFlowToVTK.cpp @@ -149,10 +149,10 @@ int main(int argc, char** argv ) pFlow::wordList surfNames; do { - Control.time().setTime(folders.time()); - if( !validRange.isMember( folders.time() ) )continue; + Control.time().setTime(folders.currentTime()); + if( !validRange.isMember( folders.currentTime() ) )continue; - pFlow::output<< "time: " << Cyan_Text( folders.time() )<<" s" <(0.0)), + !pFlow::equal(folders.currentTime(),static_cast(0.0)), fileName ) ) @@ -197,7 +197,7 @@ int main(int argc, char** argv ) } } - timeSeries.addTimeFile("particles", folders.time(), fileName); + timeSeries.addTimeFile("particles", folders.currentTime(), fileName); } diff --git a/utilities/postprocessPhasicFlow/CMakeLists.txt b/utilities/postprocessPhasicFlow/CMakeLists.txt index ad3f3d5c..0813a49b 100644 --- a/utilities/postprocessPhasicFlow/CMakeLists.txt +++ b/utilities/postprocessPhasicFlow/CMakeLists.txt @@ -1,16 +1,9 @@ -set(source_files -cellMapper.cpp -rectangleMesh.cpp -countField.cpp -countFields.cpp -postprocess.cpp -processField.cpp -ProcessFields.cpp -includeMask.cpp -IncludeMasks.cpp -postprocessPhasicFlow.cpp +set(source_files + + postprocessPhasicFlow.cpp + postSimulationFieldsDataBase/postSimulationFieldsDataBase.cpp ) -set(link_lib phasicFlow Interaction Kokkos::kokkos Utilities) +set(link_lib phasicFlow PostprocessData Kokkos::kokkos Utilities) pFlow_make_executable_install(postprocessPhasicFlow source_files link_lib) diff --git a/utilities/postprocessPhasicFlow/IncludeMask.hpp b/utilities/postprocessPhasicFlow/IncludeMask.hpp deleted file mode 100644 index c56001de..00000000 --- a/utilities/postprocessPhasicFlow/IncludeMask.hpp +++ /dev/null @@ -1,263 +0,0 @@ -/*------------------------------- 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 __IncludeMask_hpp__ -#define __IncludeMask_hpp__ - - -#include "includeMask.hpp" - -namespace pFlow -{ - - -template -struct greaterThanOp -{ - TypeInfoNV("greaterThan"); - - inline - bool operator()(const T &compVal, const T &val) const { - return val > compVal; } -}; - -template -struct greaterThanEqOp -{ - TypeInfoNV("greaterThanEq"); - - inline - bool operator()(const T &compVal, const T &val) const { - return val >= compVal; } -}; - -template -struct lessThanOp -{ - TypeInfoNV("lessThan"); - - inline - bool operator()(const T &compVal, const T &val) const { - return val < compVal; } -}; - -template -struct lessThanEqOp -{ - TypeInfoNV("lessThanEq"); - - inline - bool operator()(const T &compVal, const T &val) const { - return val <= compVal; } -}; - -template -struct equalOp -{ - TypeInfoNV("equal"); - - inline - bool operator()(const T &compVal, const T &val) const { - return equal(val , compVal); } -}; - - -template -struct betweenOp -{ - TypeInfoNV("between"); - - inline - bool operator()(const T &compVal1, const T &compVal2 ,const T &val) const { - return val>compVal1 && val -struct betweenEqOp -{ - TypeInfoNV("betweenEq"); - - inline - bool operator()(const T &compVal1, const T &compVal2 ,const T &val) const { - return val>=compVal1 && val<=compVal2; } -}; - -template -struct allOp -{ - TypeInfoNV("all"); - - inline - bool operator()() const {return true; } -}; - - - -template class Operator> -class compareOne -{ -public: - - using opertorType = Operator; - -protected: - T compValue_{}; - opertorType operator_{}; -public: - - TypeInfoNV(Operator::TYPENAME()); - - compareOne(const dictionary& dict) - : - compValue_(dict.getVal("value")) - {} - - bool operator()(const T& value)const - { - return operator_(compValue_, value); - } -}; - -template class Operator> -class compareTwo -{ -public: - using opertorType = Operator; -protected: - T compValue1_; - T compValue2_; - opertorType operator_{}; -public: - - TypeInfoNV(opertorType::TYPENAME()); - - compareTwo(const dictionary& dict) - : - compValue1_(dict.getVal("value1")), - compValue2_(dict.getVal("value2")) - {} - - bool operator()(const T& value)const - { - return operator_(compValue1_, compValue2_, value); - } -}; - -template -class compareZero -{ -protected: - Operator operator_{}; -public: - - TypeInfoNV(Operator::TYPENAME()); - compareZero(const dictionary& dict); - - bool operator()(const T& value) const - { - return operator_(); - } -}; - -template -class IncludeMask -: - public includeMask -{ -protected: - - Operator operator_; - - uniquePtr> fieldPtr_; - - hostViewType1D field_; -public: - - TypeInfoTemplate12("IncludeMask", T, Operator); - - IncludeMask( - const dictionary& dict, - const word& opType, - readFromTimeFolder& timeFolder) - : - includeMask(dict, opType, timeFolder), - operator_(dict), - fieldPtr_(timeFolder.readPointField_H(this->fieldName())), - field_(fieldPtr_().hostView()) - { - } - - add_vCtor( - includeMask, - IncludeMask, - dictionary); - - bool isIncluded(int32 n)const override - { - return operator_(field_[n]); - } - - uint32 size()const override - { - return field_.size(); - } - -}; - - -template -class IncludeMask> -: - public includeMask -{ -public: - TypeInfoTemplate12("IncludeMask", T, allOp); - - IncludeMask( - const dictionary& dict, - const word& opType, - readFromTimeFolder& timeFolder) - : - includeMask(dict, opType, timeFolder) - {} - - add_vCtor( - includeMask, - IncludeMask, - dictionary); - - bool isIncluded(int32 n)const override - { - return true; - } - - uint32 size()const override - { - return 0; - } -}; - - -} // pFlow - -#endif //__IncludeMask_hpp__ - - diff --git a/utilities/postprocessPhasicFlow/IncludeMasks.cpp b/utilities/postprocessPhasicFlow/IncludeMasks.cpp deleted file mode 100644 index 4b644f99..00000000 --- a/utilities/postprocessPhasicFlow/IncludeMasks.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/*------------------------------- 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 "IncludeMask.hpp" - -// real -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask>; - -// realx3 -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask>; - -// int32 -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask>; - -// in64 -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask >; -template class pFlow::IncludeMask >; - -template class pFlow::IncludeMask>; - - -template class pFlow::IncludeMask>; diff --git a/utilities/postprocessPhasicFlow/ProcessField.hpp b/utilities/postprocessPhasicFlow/ProcessField.hpp deleted file mode 100644 index 01841ebc..00000000 --- a/utilities/postprocessPhasicFlow/ProcessField.hpp +++ /dev/null @@ -1,179 +0,0 @@ -/*------------------------------- 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 __ProcessField_hpp__ -#define __ProcessField_hpp__ - - -#include "processField.hpp" -#include "rectMeshFields.hpp" -#include "twoPartEntry.hpp" -#include "fieldOperations.hpp" -#include "rectMeshFieldToVTK.hpp" - -namespace pFlow -{ - - -template -class ProcessField -: - public processField -{ - -protected: - - uniquePtr> field_; - - - rectMeshField_H processedField_; - -public: - - TypeInfoTemplate11("ProcessField", T); - - ProcessField( - const dictionary& dict, - pointRectCell& pToCell, - repository& rep) - : - processField(dict, pToCell, rep), - field_( - this->isUniform()? - timeFolder().createUniformPointField_H(this->fieldName(), getUniformValue(), false ): - timeFolder().readPointField_H(this->fieldName()) - ), - processedField_ - ( - mesh(), - processedFieldName(), - T{} - ) - { - - } - - add_vCtor( - processField, - ProcessField, - dictionary); - - - T getUniformValue()const - { - const dataEntry& entry = dict().dataEntryRef("field"); - twoPartEntry tpEntry(entry); - return tpEntry.secondPartVal(); - } - - virtual bool process() override - { - - const includeMask& incMask = includeMask_(); - - auto numeratorPtr = sumMaksOp( field_() , this->pointToCell(), incMask); - uniquePtr> denomeratorPtr; - - if(operation() == "sum") - { - denomeratorPtr = makeUnique>(this->mesh(), static_cast(1.0)); - - }else if(operation() == "average") - { - - pointField_H oneFld( - objectFile - ( - "oneField", - "", - objectFile::READ_NEVER, - objectFile::WRITE_NEVER - ), - const_cast(field_().pStruct()), - static_cast(1.0), - static_cast(1.0) - ); - - denomeratorPtr = sumOp(oneFld, this->pointToCell()); - - }else if(operation() == "averageMask") - { - //pointField_H oneFld(field_().pStruct(), static_cast(1.0), static_cast(1.0)); - pointField_H oneFld( - objectFile - ( - "oneField", - "", - objectFile::READ_NEVER, - objectFile::WRITE_NEVER - ), - const_cast(field_().pStruct()), - static_cast(1.0), - static_cast(1.0) - ); - - denomeratorPtr = sumMaksOp(oneFld, this->pointToCell(), incMask); - - } - else - { - fatalErrorInFunction<<"operation is not known: "<< operation()<mesh().nx(); i++ ) - { - for(int32 j=0; jmesh().ny(); j++ ) - { - for(int32 k=0; kmesh().nz(); k++ ) - { - if( pointToCell().nPointInCell(i,j,k)>= threshold() ) - { - processedField_(i,j,k) = numerator(i,j,k)/denomerator(i,j,k); - } - else - { - processedField_(i,j,k) = T{}; - } - } - } - } - - - return true; - } - - - bool writeToVTK(iOstream& os)const override - { - return convertRectMeshField(os, processedField_); - } - -}; - - -} // pFlow - - - -#endif //__ProcessField_hpp__ diff --git a/utilities/postprocessPhasicFlow/ProcessFields.cpp b/utilities/postprocessPhasicFlow/ProcessFields.cpp deleted file mode 100644 index 31969b57..00000000 --- a/utilities/postprocessPhasicFlow/ProcessFields.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/*------------------------------- 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 "ProcessField.hpp" - - -template class pFlow::ProcessField; - -template class pFlow::ProcessField; - -template class pFlow::ProcessField; - -template class pFlow::ProcessField; - -template class pFlow::ProcessField; - diff --git a/utilities/postprocessPhasicFlow/cellMapper.cpp b/utilities/postprocessPhasicFlow/cellMapper.cpp deleted file mode 100644 index 2e5de875..00000000 --- a/utilities/postprocessPhasicFlow/cellMapper.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/*------------------------------- 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 "cellMapper.hpp" -//#include "cellMapperKernels.hpp" -#include "streams.hpp" - - -void pFlow::cellMapper::allocateArrays(rangeU32 nextRng) -{ - checkAllocateNext(nextRng); - nullifyNext(nextRng); - reallocFill(head_, domainCells_.nx(), domainCells_.ny(), domainCells_.nz(), NoPos); -} - -void pFlow::cellMapper::checkAllocateNext(rangeU32 nextRng) -{ - - auto newCap = nextRng.end(); - - if( nextCapacity_ < newCap) - { - nextCapacity_ = newCap; - reallocNoInit(next_, nextCapacity_); - } -} - -void pFlow::cellMapper::nullifyHead() -{ - fill(head_, NoPos); -} - -void pFlow::cellMapper::nullifyNext(rangeU32 nextRng) -{ - fill(next_, nextRng, NoPos); -} - -pFlow::cellMapper::cellMapper( - const rectangleMesh& rectMesh, - const hostViewType1D& pointPos, - const pFlagTypeHost& flags -) -: - domainCells_(rectMesh) -{ - - allocateArrays(flags.activeRange()); -} - -bool pFlow::cellMapper::build -( - const hostViewType1D& pointPos, - const pFlagTypeHost & flags -) -{ - auto aRange = flags.activeRange(); - - checkAllocateNext(aRange); - nullifyHead(); - nullifyNext(aRange); - int32x3 ind; - for(uint32 i=aRange.start(); i; - - using NextType = hostViewType1D; - - - static constexpr uint32 NoPos = 0xFFFFFFFF; - - class CellIterator - { - private: - HeadType head_; - - NextType next_; - - public: - - CellIterator(const HeadType& head, const NextType& next) - : - head_(head), - next_(next) - {} - - static constexpr uint32 NoPos = 0xFFFFFFFF; - - INLINE_FUNCTION_H - int32x3 numCells()const { - return int32x3(head_.extent(0), head_.extent(1), head_.extent(2));} - - INLINE_FUNCTION_H - uint32 start(int32 i, int32 j, int32 k)const { - return head_(i,j,k); } - - INLINE_FUNCTION_H - uint32 getNext(uint32 n)const { - if(n == NoPos ) return NoPos; - return next_(n); } - - INLINE_FUNCTION_H - uint32 next(uint32 n)const{ - return next_(n);} - }; - -private: - - const rectangleMesh& domainCells_; - - HeadType head_{"NBS::head",1,1,1}; - - NextType next_{"NBS::next", 1}; - - uint32 nextCapacity_ = 0; - - void allocateArrays(rangeU32 nextRng); - - void checkAllocateNext(rangeU32 nextRng); - - void nullifyHead(); - - void nullifyNext(rangeU32 nextRng); - -public: - - TypeInfoNV("cellMapper"); - - - cellMapper( - const rectangleMesh& rectMesh, - const hostViewType1D& pointPos, - const pFlagTypeHost& flags); - - INLINE_FUNCTION_HD - cellMapper(const cellMapper&) = default; - - INLINE_FUNCTION_HD - cellMapper(cellMapper&&) = default; - - INLINE_FUNCTION_HD - cellMapper& operator = (const cellMapper&) = default; - - INLINE_FUNCTION_HD - cellMapper& operator = (cellMapper&&) = default; - - INLINE_FUNCTION_HD - ~cellMapper()=default; - - //// - Methods - - auto getCellIterator()const - { - return CellIterator(head_, next_); - } - - - bool build( - const hostViewType1D& pointPos, - const pFlagTypeHost& flags); -}; - -} // pFlow - -#endif // __cellMapper_hpp__ \ No newline at end of file diff --git a/utilities/postprocessPhasicFlow/countField.cpp b/utilities/postprocessPhasicFlow/countField.cpp deleted file mode 100644 index 634e9418..00000000 --- a/utilities/postprocessPhasicFlow/countField.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/*------------------------------- 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 "countField.hpp" -#include "repository.hpp" -#include "twoPartEntry.hpp" - -bool pFlow::countField::getFieldType( - const dictionary& dict, - readFromTimeFolder& timeFolder, - word& fieldName, - word& fieldType) -{ - if(dict.containsDataEntry("field")) - { - const dataEntry& entry = dict.dataEntryRef("field"); - - if( isTwoPartEntry(entry)) - { - twoPartEntry tpEntry(entry); - fieldName = "uniformField"; - fieldType = tpEntry.firstPart(); - } - else - { - fieldName = dict.getVal("field"); - if( !timeFolder.pointFieldFileGetType(fieldName, fieldType) ) - { - fatalErrorInFunction<<"error in reading field type from file "<< fieldName<< - "in folder "<< timeFolder.path()<("includeMask"); - - auto& incDict = dict_.subDictOrCreate(includeMaskType+"Info"); - - includeMask_ = includeMask::create(incDict, includeMaskType, timeFolder_); - -} - - -bool pFlow::countField::process(uint32& countedValue) -{ - auto& incMask = includeMask_(); - - countedValue = 0; - uint32 n = incMask.size(); - - for(uint32 i=0; i includeMask_ = nullptr; - - bool static getFieldType( - const dictionary& dict, - readFromTimeFolder& timeFolder, - word& fieldName, - word& fieldType); - -public: - - TypeInfo("countField"); - - countField(const dictionary& dict, repository& rep); - - - auto& dict() - { - return dict_; - } - - const auto& dict()const - { - return dict_; - } - - auto& timeFolderRepository() - { - return timeFolder_.db(); - } - - - auto& timeFolder() - { - return timeFolder_; - } - - word variableName()const - { - return dict_.name(); - } - - // requires a class to read pointField from timefolder - bool process(uint32& countedValue); - - - - //virtual bool writeToFile(iOstream& is) const = 0; - - /*static - uniquePtr create( - const dictionary& dict, - repository& rep);*/ -}; - - -} - - -#endif //__countField_hpp__ \ No newline at end of file diff --git a/utilities/postprocessPhasicFlow/countFields.cpp b/utilities/postprocessPhasicFlow/countFields.cpp deleted file mode 100644 index d4b3d6d8..00000000 --- a/utilities/postprocessPhasicFlow/countFields.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/*------------------------------- 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 "countFields.hpp" -#include "countField.hpp" -#include "repository.hpp" -#include "includeMask.hpp" - - -pFlow::countFields::countFields(const dictionary& dict) -: - dict_(dict), - variableNames_(dict.dictionaryKeywords()), - countedValues_(variableNames_.size(), 0u) -{ - -} - - -bool pFlow::countFields::process(repository& rep) -{ - uint32List counted; - - for(const auto& name: variableNames_) - { - const dictionary& varDict = dict_.subDict(name); - uint32 count; - countField cField(varDict, rep); - cField.process(count); - counted.push_back(count); - } - - countedValues_ = counted; - - return true; -} diff --git a/utilities/postprocessPhasicFlow/countFields.hpp b/utilities/postprocessPhasicFlow/countFields.hpp deleted file mode 100644 index 86ba2c63..00000000 --- a/utilities/postprocessPhasicFlow/countFields.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/*------------------------------- 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 __countFields_hpp__ -#define __countFields_hpp__ - - -#include "dictionary.hpp" - - -namespace pFlow -{ - - -class repository; - -class countFields -{ -protected: - - dictionary dict_; - - wordList variableNames_; - - uint32List countedValues_; - -public: - - TypeInfo("countFields"); - - countFields(const dictionary& dict); - - auto& dict() - { - return dict_; - } - - const auto& dict()const - { - return dict_; - } - - const wordList& variableNames()const - { - return variableNames_; - } - const uint32List& countedValues()const - { - return countedValues_; - } - - // requires a class to read pointField from timefolder - bool process(repository& rep); - -}; - - -} - - -#endif //__countFields_hpp__ \ No newline at end of file diff --git a/utilities/postprocessPhasicFlow/fieldOperations.hpp b/utilities/postprocessPhasicFlow/fieldOperations.hpp deleted file mode 100644 index 80eb82f8..00000000 --- a/utilities/postprocessPhasicFlow/fieldOperations.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/*------------------------------- 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 __fieldOperations_hpp__ -#define __fieldOperations_hpp__ - -#include "rectMeshFields.hpp" -#include "pointFields.hpp" -#include "pointRectCell.hpp" -#include "includeMask.hpp" - -namespace pFlow -{ - - -template -uniquePtr> sumOp( pointField_H& field, pointRectCell& pointToCell) -{ - // create field - auto& mesh = pointToCell.mesh(); - auto iterator = pointToCell.getCellIterator(); - auto f = field.deviceView(); - - auto resultsPtr = makeUnique>(mesh, T(0)); - auto& results = resultsPtr(); - for(int32 i=0; i -uniquePtr> sumMaksOp( pointField_H& field, pointRectCell& pointToCell, const incMask& mask) -{ - // create field - auto& mesh = pointToCell.mesh(); - auto iterator = pointToCell.getCellIterator(); - auto f = field.deviceView(); - - auto resultsPtr = makeUnique>(mesh, T(0)); - auto& results = resultsPtr(); - - for(int32 i=0; i("field", "none"); - - if(fName == "none") - { - fType = "int8"; - } - else - { - if( !timeFolder.pointFieldFileGetType(fName, fType) ) - { - fatalErrorInFunction<<"error in reading field type from file "<< fName<< - "in folder "<< timeFolder.path()< pFlow::includeMask::create( - const dictionary& dict, - const word& opType, - readFromTimeFolder& timeFolder) -{ - - word fType, fName; - if(!getFieldType(dict, timeFolder, fName, fType)) - { - fatalExit; - return nullptr; - } - - word method = angleBracketsNames2("IncludeMask", fType, opType); - - if( dictionaryvCtorSelector_.search(method) ) - { - auto objPtr = - dictionaryvCtorSelector_[method] - (dict, opType, timeFolder); - REPORT(2)<< dict.name()<< " with model "< create( - const dictionary& dict, - const word& opType, - readFromTimeFolder& timeFolder); - -}; - - - -} // pFlow - -#endif //__IncludeMask_hpp__ - - diff --git a/utilities/postprocessPhasicFlow/pointRectCell.hpp b/utilities/postprocessPhasicFlow/pointRectCell.hpp deleted file mode 100644 index 764cab4a..00000000 --- a/utilities/postprocessPhasicFlow/pointRectCell.hpp +++ /dev/null @@ -1,142 +0,0 @@ -/*------------------------------- 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 __pointRectCell_hpp__ -#define __pointRectCell_hpp__ - -#include "cellMapper.hpp" -#include "rectMeshFields.hpp" -#include "pointStructure.hpp" - -namespace pFlow -{ - - -class pointRectCell -{ -public: - - using mapType = cellMapper; - - //using memory_space = typename mapType::memory_space; - -protected: - - repository& processedRepository_; - - rectangleMesh mesh_; - - const pointStructure& pStruct_; - - hostViewType1D pointPosition_; - - mapType map_; - - int32RectMeshField_H nPointInCell_; - -public: - - pointRectCell( - const dictionary& dictMesh, - const pointStructure& pStruct, - repository& rep) - : - processedRepository_(rep), - mesh_ - ( - dictMesh, - &rep - ), - pStruct_(pStruct), - pointPosition_(pStruct_.pointPosition().hostViewAll()), - map_ - ( - mesh_, - pointPosition_, - pStruct_.activePointsMaskHost() - ), - nPointInCell_(mesh_,"nPointInCell", 0) - { - - mapPOints(); - } - - auto& mesh() - { - return mesh_; - } - - const auto& mesh()const - { - return mesh_; - } - - auto& processedRepository() - { - return processedRepository_; - } - - void mapPOints() - { - auto points = pStruct_.pointPositionHost(); - auto activeMask = pStruct_.activePointsMaskHost(); - - map_.build(points, activeMask); - - auto iterator = map_.getCellIterator(); - - for(int32 i=0; isecond == "real") + { + allPointFields_.push_back + ( + makeUnique> + ( + objectFile + ( + name, + allValidFolders_.folder(), + objectFile::READ_ALWAYS, + objectFile::WRITE_NEVER + ), + pStructPtr_(), + 0.0 + ) + ); + } + else if(iter->second=="realx3") + { + allPointFields_.push_back + ( + makeUnique> + ( + objectFile + ( + name, + allValidFolders_.folder(), + objectFile::READ_ALWAYS, + objectFile::WRITE_NEVER + ), + pStructPtr_(), + 0.0 + ) + ); + } + else if(iter->second=="realx4") + { + allPointFields_.push_back + ( + makeUnique> + ( + objectFile + ( + name, + allValidFolders_.folder(), + objectFile::READ_ALWAYS, + objectFile::WRITE_NEVER + ), + pStructPtr_(), + 0.0 + ) + ); + } + else if(iter->second == "uint32") + { + allPointFields_.push_back + ( + makeUnique> + ( + objectFile + ( + name, + allValidFolders_.folder(), + objectFile::READ_ALWAYS, + objectFile::WRITE_NEVER + ), + pStructPtr_(), + 0u + ) + ); + } + else + { + fatalErrorInFunction + <<"Field "<second<(control_, 0.0005); + } + return true; +} + +const pFlow::shape &pFlow::postSimulationFieldsDataBase::getShape() const +{ + if(!shapePtr_) + { + word shapeType = shapeTypeName(); + if(shapeType.empty()) + { + fatalErrorInFunction + << "shapeType is not set in the postprocess dictionary"<(pFlow::propertyFile__, control_.caseSetup().path()); + shapePtr_ = shape::create(shapeType, pFlow::shapeFile__, &control_.caseSetup(), propertyPtr_()); + } + return shapePtr_(); +} + +pFlow::word pFlow::postSimulationFieldsDataBase::getPointFieldType(const word &name) const +{ + if(auto [iter, success]=currentFileFields_.findIf(name); success) + { + return iter->second; + } + else + { + fatalErrorInFunction + <<"Field "< currentFileFields_; + + uniquePtr pStructPtr_ = nullptr; + + ListPtr allPointFields_; + + mutable uniquePtr shapePtr_ = nullptr; + + mutable uniquePtr propertyPtr_ = nullptr; + + bool setToCurrentFolder(); + +protected: + + bool pointFieldNameExists(const word& name)const override; + + bool loadPointFieldToTime(const word& name) override; + + bool loadPointStructureToTime(); + + const shape& getShape() const override; + + word getPointFieldType(const word& name)const override; + +public: + + TypeInfo("fieldsDataBase"); + + postSimulationFieldsDataBase( + systemControl& control, + const dictionary& postDict, + bool inSimulation, + timeValue startTime); + + ~postSimulationFieldsDataBase() override = default; + + add_vCtor + ( + fieldsDataBase, + postSimulationFieldsDataBase, + bool + ); + + const pointStructure& pStruct()const override; + + timeValue getNextTimeFolder()const override; + + timeValue setToNextTimeFolder() override; + + timeValue skipNextTimeFolder() override; + +}; + +} // namespace pFlow + +#endif // __postSimulationFieldsDataBase_hpp__ diff --git a/utilities/postprocessPhasicFlow/postprocess.cpp b/utilities/postprocessPhasicFlow/postprocess.cpp deleted file mode 100644 index fd9076f3..00000000 --- a/utilities/postprocessPhasicFlow/postprocess.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/*------------------------------- 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 "postprocess.hpp" -#include "timeFolder.hpp" -#include "pointStructure.hpp" -#include "countFields.hpp" -#include "vocabs.hpp" -#include "vtkFile.hpp" - -pFlow::postprocess::postprocess(systemControl& control) -: - control_(control), - dict_(postprocessFile__, control_.settings().path()+postprocessFile__) -{ - REPORT(1)<<"Reading numberBased dictionary ..."<( - dict_.subDict("rectMesh"), - pStruct, - control_.time()); - - // first numberbased dict - - processedFields_.clear(); - for(word& dictName:numberBasedDictNames_) - { - auto fieldDict = dict_.subDict("numberBased").subDict(dictName); - auto ppFieldPtr = processField::create( - fieldDict, - pointToCell_(), - control_.time()); - - if(!ppFieldPtr->process()) - { - fatalExit; - } - - processedFields_.push_back( ppFieldPtr.release() ); - output<mesh().writeToVtk(vtk()); - - ForAll( i, processedFields_) - { - - if( !processedFields_[i].writeToVTK(vtk())) - { - - fatalErrorInFunction<<"error in writing "<< processedFields_[i].processedFieldName()<< - "to vtk file\n"; - return false; - } - } - - return true; -} diff --git a/utilities/postprocessPhasicFlow/postprocess.hpp b/utilities/postprocessPhasicFlow/postprocess.hpp deleted file mode 100644 index 05ef0053..00000000 --- a/utilities/postprocessPhasicFlow/postprocess.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/*------------------------------- 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 __postprocess_hpp__ -#define __postprocess_hpp__ - - -#include "MapPtr.hpp" -#include "systemControl.hpp" -#include "pointRectCell.hpp" -#include "processField.hpp" - - -namespace pFlow -{ - -class timeFolder; - - -class postprocess -{ -protected: - - systemControl& control_; - - dictionary dict_; - - wordList numberBasedDictNames_; - - wordList weightBasedDictNames_; - - wordList countDictNames_; - - List countedVariableNamesList_; - - List countedVairablesLists_; - - uniquePtr timeFolderReposiory_ {nullptr}; - - uniquePtr pointToCell_ {nullptr}; - - //uniquePtr processedRepository_ {nullptr}; - - ListPtr processedFields_; - - real time_=0.0; - - //orderedMapPtr timeFolderRepositories_; - - - Logical saveTimes{"No"}; - - Logical saveTimeFolders{"No"}; - - - auto& timeFolderReposiory() - { - return timeFolderReposiory_(); - } - -public: - - postprocess(systemControl& control); - - - - bool processTimeFolder(real time, const word& tName, const fileSystem& localFolder); - - bool processTimeFolder(const timeFolder& tFolder); - - - bool writeToVTK(fileSystem path, word bName)const; - - -}; - - - -} - - - -#endif //__postprocess_hpp__ diff --git a/utilities/postprocessPhasicFlow/postprocessPhasicFlow.cpp b/utilities/postprocessPhasicFlow/postprocessPhasicFlow.cpp index 49762836..792876f2 100644 --- a/utilities/postprocessPhasicFlow/postprocessPhasicFlow.cpp +++ b/utilities/postprocessPhasicFlow/postprocessPhasicFlow.cpp @@ -18,103 +18,130 @@ Licence: -----------------------------------------------------------------------------*/ -#include "KokkosUtilities.hpp" #include "systemControl.hpp" -#include "timeFolder.hpp" +#include "Vectors.hpp" #include "commandLine.hpp" -#include "ranges.hpp" #include "readControlDict.hpp" -#include "postprocess.hpp" - -using pFlow::word; -using pFlow::wordVector; -using pFlow::wordList; -using pFlow::commandLine; -using pFlow::timeFolder; -using pFlow::output; -using pFlow::endl; - - +#include "postprocessData.hpp" +#include "postprocessGlobals.hpp" int main(int argc, char** argv ) { - word outFolder = (pFlow::CWD()/word("VTK/postprocess")).wordPath(); + pFlow::word outFolder = (pFlow::CWD()/pFlow::postProcessGlobals::defaultRelDir__).wordPath(); - commandLine cmds( + pFlow::commandLine cmds( "postprocessPhasicFlow", "post-process fields in time folders based on the input file " - "settings/postprocessDict and convetes the results into vtk file format."); + "settings/postprocessDataDict."); + + pFlow::wordVector times; + + pFlow::word description = "path to output folder of postprocess data: ./" + + pFlow::postProcessGlobals::defaultRelDir__; - wordVector times; - cmds.addOption("-o,--out-folder", outFolder, - "path to output folder of VTK/postprocess", + description, "path"); cmds.addOption( "-t,--time", times.vectorField(), - "a space separated lits of time folders, or a strided range begin:stride:end, or an interval begin:end", + "a SPACE separated lits of time folders, " + "or a strided range ::, or an interval :", " "); bool withZeroFolder = false; - cmds.addOption( + cmds.add_flag( "-z, --zeroFolder", withZeroFolder, - "Do NOT exclude zero folder from processing time folders"); + "include zero folder into processing time folders"); bool isCoupling = false; if(!cmds.parse(argc, argv)) return 0; #include "initialize_Control.hpp" - - - - // time folders in case - timeFolder folders(Control); - // time in command line - pFlow::realCombinedRange validRange; + pFlow::combinedRange validRange; + if( cmds.count("--time") ) { - if(!validRange.addRanges(times)){ - fatalExit; } + if(!validRange.addRanges(times)) + { + fatalExit; + } + if(withZeroFolder) + validRange.addIndividual(0.0); } else { - validRange.addIntervalRange(folders.startTime(), folders.endTime()); + if(withZeroFolder) + validRange.addIntervalRange(0.0, 1.0e+15); + else + validRange.addIntervalRange(1.0e-7, 1.0e+15); } - pFlow::fileSystem destFolder = pFlow::fileSystem(outFolder); + pFlow::timeValue nextTime = validRange.minVal(); - pFlow::postprocess post(Control); + if(nextTime <0.0) + { + fatalError + <<"Invalid time range in the command line. " + <<"your input range is: " + <=0.0) { - if( !validRange.isMember( folders.time() ) ) + if( !folderSkipped ) { - continue; - } - - if( !withZeroFolder && pFlow::equal(folders.time() , pFlow::zero))continue; + if(!postprocess.execute()) + { + fatalError + <<"Error occured in executing postprocessing...."<("operation")), - includeMaskType_(dict.getVal("includeMask")), - threshold_(dict.getValOrSetMax("threshold", 1)) -{ - - if(!processField::getFieldType( - dict_, - timeFolder_, - fieldName_, - fieldType_) ) - { - fatalExit; - } - - auto& incDict = dict_.subDictOrCreate(includeMaskType_+"Info"); - - includeMask_ = includeMask::create(incDict, includeMaskType_, timeFolder_); - -} - -bool pFlow::processField::getFieldType( - const dictionary& dict, - readFromTimeFolder& timeFolder, - word& fieldName, - word& fieldType) -{ - if(dict.containsDataEntry("field")) - { - const dataEntry& entry = dict.dataEntryRef("field"); - - if( isTwoPartEntry(entry)) - { - twoPartEntry tpEntry(entry); - fieldName = "uniformField"; - fieldType = tpEntry.firstPart(); - } - else - { - fieldName = dict.getVal("field"); - if( !timeFolder.pointFieldFileGetType(fieldName, fieldType) ) - { - fatalErrorInFunction<<"error in reading field type from file "<< fieldName<< - "in folder "<< timeFolder.path()< -pFlow::processField::create( - const dictionary& dict, - pointRectCell& pToCell, - repository& rep) -{ - - word fName, fType; - readFromTimeFolder timeFolder(rep); - if(!getFieldType(dict, timeFolder, fName, fType)) - { - fatalExit; - return nullptr; - } - - auto method = angleBracketsNames("ProcessField", fType); - - if( dictionaryvCtorSelector_.search(method) ) - { - auto objPtr = - dictionaryvCtorSelector_[method] - (dict, pToCell, rep); - REPORT(2)<<"Processing/creating " << Yellow_Text(dict.name())<< " with model "< includeMask_ = nullptr; - - bool static getFieldType( - const dictionary& dict, - readFromTimeFolder& timeFolder, - word& fieldName, - word& fieldType); - -public: - - TypeInfo("processField"); - - processField(const dictionary& dict, pointRectCell& pToCell, repository& rep); - - virtual ~processField() = default; - - create_vCtor( - processField, - dictionary, - (const dictionary& dict, - pointRectCell& pToCell, - repository& rep), - (dict, pToCell, rep) ); - - - const auto& mesh()const - { - return pointToCell_.mesh(); - } - - auto& mesh() - { - return pointToCell_.mesh(); - } - - const auto& pointToCell()const - { - return pointToCell_; - } - - auto& pointToCell() - { - return pointToCell_; - } - - auto& dict() - { - return dict_; - } - - const auto& dict()const - { - return dict_; - } - - auto& timeFolderRepository() - { - return timeFolder_.db(); - } - - auto& processedRepository() - { - return pointToCell_.processedRepository(); - } - - const word& fieldType()const - { - return fieldType_; - } - - const word& fieldName()const - { - return fieldName_; - } - - bool isUniform()const - { - return fieldName_ == "uniformField"; - } - - const word& operation()const - { - return operation_; - } - - auto& timeFolder() - { - return timeFolder_; - } - - const word& includeMaskType()const - { - return includeMaskType_; - } - - auto threshold()const - { - return threshold_; - } - - const word& processedFieldName()const - { - return processedFieldName_; - } - - // requires a class to read pointField from timefolder - virtual bool process() = 0; - - virtual bool writeToVTK(iOstream& is) const = 0; - - static - uniquePtr create( - const dictionary& dict, - pointRectCell& pToCell, - repository& rep); -}; - - -} - - -#endif //__processField_hpp__ \ No newline at end of file diff --git a/utilities/postprocessPhasicFlow/rectMeshField.hpp b/utilities/postprocessPhasicFlow/rectMeshField.hpp deleted file mode 100644 index 1da71d05..00000000 --- a/utilities/postprocessPhasicFlow/rectMeshField.hpp +++ /dev/null @@ -1,212 +0,0 @@ -/*------------------------------- 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 __rectMeshField_hpp__ -#define __rectMeshField_hpp__ - -#include "rectangleMesh.hpp" -#include "ViewAlgorithms.hpp" - -namespace pFlow -{ - -template -class rectMeshField -: - public IOobject -{ -public: - - using viewType = ViewType3D; - - using memory_space = typename viewType::memory_space; - -protected: - - const rectangleMesh* mesh_; - - word name_="noName"; - - viewType field_; - - T defaultValue_{}; - - constexpr static inline const char* memoerySpaceName() - { - return memory_space::name(); - } - -public: - - - TypeInfoTemplateNV111("rectMeshField", T, memoerySpaceName()); - - rectMeshField(rectangleMesh& mesh, const word& name ,const T& defVal) - : - IOobject( - objectFile - ( - name, - "", - objectFile::READ_NEVER, - objectFile::WRITE_NEVER - ), - IOPattern::MasterProcessorOnly, - nullptr - ), - mesh_(&mesh), - name_(name), - field_("reactMeshField."+name, mesh_->nx(), mesh_->ny(), mesh_->nz()), - defaultValue_(defVal) - { - this->fill(defaultValue_); - } - - rectMeshField(rectangleMesh& mesh, const T& defVal) - : - IOobject( - objectFile - ( - "noName", - "", - objectFile::READ_NEVER, - objectFile::WRITE_NEVER - ), - IOPattern::MasterProcessorOnly, - nullptr - ), - mesh_(&mesh), - name_("noName"), - field_("reactMeshField.noName", mesh_->nx(), mesh_->ny(), mesh_->nz()), - defaultValue_(defVal) - { - this->fill(defaultValue_); - } - - rectMeshField(const rectMeshField&) = default; - - rectMeshField& operator = (const rectMeshField&) = default; - - rectMeshField(rectMeshField&&) = default; - - rectMeshField& operator =(rectMeshField&&) = default; - - - inline uniquePtr clone() const - { - return makeUnique(*this); - } - - inline rectMeshField* clonePtr()const - { - return new rectMeshField(*this); - } - - INLINE_FUNCTION_H - const word& name()const - { - return name_; - } - - INLINE_FUNCTION_HD - int64 size()const - { - return mesh_->size(); - } - - auto nx()const - { - return mesh_->nx(); - } - - auto ny()const - { - return mesh_->ny(); - } - - auto nz()const - { - return mesh_->nz(); - } - - const auto& mesh() - { - return *mesh_; - } - - INLINE_FUNCTION_HD - real cellVol()const - { - return mesh_->cellVol(); - } - - INLINE_FUNCTION_HD - T& operator()(int32 i, int32 j, int32 k) - { - return field_(i,j,k); - } - - INLINE_FUNCTION_HD - const T& operator()(int32 i, int32 j, int32 k)const - { - return field_(i,j,k); - } - - void fill(T val) - { - pFlow::fill( - field_, - val - ); - } - - - bool write(iOstream& is, const IOPattern& iop)const override - { - notImplementedFunction; - return true; - } - - bool read(iIstream& is, const IOPattern& iop) override - { - notImplementedFunction; - return true; - } - - bool read(iIstream& is) - { - notImplementedFunction; - return true; - } - - bool write(iOstream& os)const - { - notImplementedFunction; - return true; - } - -}; - - - -} - - -#endif // __rectMeshField_hpp__ diff --git a/utilities/postprocessPhasicFlow/rectMeshFieldToVTK.hpp b/utilities/postprocessPhasicFlow/rectMeshFieldToVTK.hpp deleted file mode 100644 index d0d951b5..00000000 --- a/utilities/postprocessPhasicFlow/rectMeshFieldToVTK.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/*------------------------------- 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 __rectMeshFieldToVTK_hpp__ -#define __rectMeshFieldToVTK_hpp__ - - -namespace pFlow -{ - -template -bool convertRectMeshField(iOstream& os, const rectMeshField_H& field) -{ - fatalErrorInFunction<< "this type is not supported "<< - field.typeName()< -bool convertRectMeshField(iOstream& os, const rectMeshField_H& field) -{ - - os<<"FIELD FieldData 1 " << field.name() << " 1 "<< field.size() << " float\n"; - for(int32 k=0; k -bool convertRectMeshField(iOstream& os, const rectMeshField_H& field) -{ - - os<<"FIELD FieldData 1 " << field.name() << " 3 "<< field.size() << " float\n"; - for(int32 k=0; k -bool convertRectMeshField(iOstream& os, const rectMeshField_H& field) -{ - - os<<"FIELD FieldData 1 " << field.name() << " 1 "<< field.size() << " int\n"; - for(int32 k=0; k -using rectMeshField_H = rectMeshField; - -using int8RectMeshField_H = rectMeshField; - -using int32RectMeshField_H = rectMeshField; - -using int64RectMeshField_H = rectMeshField; - -using realRectMeshField_H = rectMeshField; - -using realx3RectMeshField_H = rectMeshField; - -} - - -#endif // __rectMeshFields_hpp__ diff --git a/utilities/postprocessPhasicFlow/rectangleMesh.cpp b/utilities/postprocessPhasicFlow/rectangleMesh.cpp deleted file mode 100644 index 804b20c9..00000000 --- a/utilities/postprocessPhasicFlow/rectangleMesh.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "rectangleMesh.hpp" - - -pFlow::rectangleMesh::rectangleMesh -( - const box& mshBox, - int32 nx, - int32 ny, - int32 nz, - repository* rep -) -: - IOobject( - objectFile - ( - "rectMesh", - "", - objectFile::READ_NEVER, - objectFile::WRITE_NEVER - ), - IOPattern::MasterProcessorOnly, - rep - ), - meshBox_(mshBox), - numCells_(nx, ny, nz) -{ - if(mshBox.minPoint()>= mshBox.maxPoint()) - { - fatalErrorInFunction<<"Lower corner point of mesh "<("nx"), - dict.getVal("ny"), - dict.getVal("nz"), - rep - ) -{ - -} diff --git a/utilities/postprocessPhasicFlow/rectangleMesh.hpp b/utilities/postprocessPhasicFlow/rectangleMesh.hpp deleted file mode 100644 index b13272b1..00000000 --- a/utilities/postprocessPhasicFlow/rectangleMesh.hpp +++ /dev/null @@ -1,174 +0,0 @@ -/*------------------------------- 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 __rectangleMesh_hpp__ -#define __rectangleMesh_hpp__ - -#include "types.hpp" -#include "error.hpp" -#include "box.hpp" -#include "IOobject.hpp" - -class repository; - -namespace pFlow -{ - -class rectangleMesh -: - public IOobject -{ -private: - - box meshBox_; - - int32x3 numCells_; - - realx3 dx_; - -public: - - TypeInfo("rectangleMesh"); - - rectangleMesh( - const box& mshBox, - int32 nx, - int32 ny, - int32 nz, - repository* rep); - - rectangleMesh(const dictionary & dict, repository* rep); - - - rectangleMesh(const rectangleMesh&) = default; - - - rectangleMesh& operator = (const rectangleMesh&) = default; - - rectangleMesh(rectangleMesh&&) = default; - - - rectangleMesh& operator = (rectangleMesh&&) = default; - - ~rectangleMesh() override = default; - - int64 size()const - { - return numCells_.x_*numCells_.y_*numCells_.z_; - } - - int32 nx()const - { - return numCells_.x(); - } - - int32 ny()const - { - return numCells_.y(); - } - - int32 nz()const - { - return numCells_.z(); - } - - real cellVol()const - { - return dx_.x_*dx_.y_*dx_.z_; - } - - realx3 minPoint()const - { - return meshBox_.minPoint(); - } - - realx3 maxPoint()const - { - return meshBox_.maxPoint(); - } - - inline - bool isInsideIndex(const realx3 p, int32x3 & ind )const - { - if(meshBox_.isInside(p)) - { - ind = (p - meshBox_.minPoint())/dx_ ; - return true; - } - else - { - return false; - } - } - - bool write(iOstream& is, const IOPattern& iop)const override - { - notImplementedFunction; - return true; - } - - bool read(iIstream& is, const IOPattern& iop) override - { - notImplementedFunction; - return true; - } - - bool writeToVtk(iOstream& os)const - { - os<<"DATASET RECTILINEAR_GRID"<minPoint(); - auto [dx, dy, dz] = dx_; - - os<<"X_COORDINATES "<< nx()+1 <<" float\n"; - for(int32 i=0; i