From f2e8e69899fc207112f5bb5c4c14f17fdd189144 Mon Sep 17 00:00:00 2001 From: Hamidreza Date: Thu, 24 Apr 2025 14:08:17 +0330 Subject: [PATCH] prime2 is added and readme update --- .../PostprocessOperationAverage.cpp | 38 ++- .../PostprocessOperationAverage.hpp | 7 + .../postprocessOperation.cpp | 58 ---- .../postprocessOperation.hpp | 11 +- .../postprocessOperationFunctions.hpp | 100 +++++++ src/PostprocessData/readme.md | 259 ++++++++++++++++-- .../sampleDictionary/postprocessDataDict | 108 +++----- 7 files changed, 407 insertions(+), 174 deletions(-) create mode 100644 src/PostprocessData/operation/postprocessOperation/postprocessOperationFunctions.hpp diff --git a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.cpp b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.cpp index 3ffbd5b8..15474667 100644 --- a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.cpp +++ b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.cpp @@ -77,6 +77,7 @@ pFlow::PostprocessOperationAverage::PostprocessOperationAverage } } + /// Performs weighted average of field values within each region bool pFlow::PostprocessOperationAverage::execute ( @@ -109,7 +110,7 @@ bool pFlow::PostprocessOperationAverage::execute allField) ); - if(calculateFluctuation2_) + if(calculateFluctuation2_()) { auto& processedRegField = processedRegFieldPtr_(); fluctuation2FieldPtr_ = makeUnique @@ -136,5 +137,40 @@ bool pFlow::PostprocessOperationAverage::execute } + return true; +} + +bool pFlow::PostprocessOperationAverage::write(const fileSystem &parDir) const +{ + if(! postprocessOperation::write(parDir)) + { + return false; + } + if(!calculateFluctuation2_()) + { + return true; + } + + auto ti = time().TimeInfo(); + + if(!os2Ptr_) + { + fileSystem path = parDir+( + processedFieldName()+"_prime2" + ".Start_" + ti.timeName()); + os2Ptr_ = makeUnique(path); + + regPoints().write(os2Ptr_()); + } + + + std::visit + ( + [&](auto&& arg)->bool + { + return writeField(os2Ptr_(), ti.t(), arg, threshold()); + }, + fluctuation2FieldPtr_() + ); + return true; } \ No newline at end of file diff --git a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.hpp b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.hpp index 6620d588..4d71d54f 100644 --- a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.hpp +++ b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.hpp @@ -150,6 +150,9 @@ private: uniquePtr fluctuation2FieldPtr_ = nullptr; + /// Pointer to the output stream for writing fluctuation2 results + mutable uniquePtr os2Ptr_ = nullptr; + public: TypeInfo("PostprocessOperation"); @@ -190,6 +193,10 @@ public: return processedRegFieldPtr_(); } + /// write to os stream + bool write(const fileSystem &parDir)const override; + + /// @brief Execute average operation on field values /// @param weights Weight factors for particles /// @return True if successful diff --git a/src/PostprocessData/operation/postprocessOperation/postprocessOperation.cpp b/src/PostprocessData/operation/postprocessOperation/postprocessOperation.cpp index e752f359..3eedd066 100644 --- a/src/PostprocessData/operation/postprocessOperation/postprocessOperation.cpp +++ b/src/PostprocessData/operation/postprocessOperation/postprocessOperation.cpp @@ -23,64 +23,6 @@ Licence: #include "regionPoints.hpp" #include "fieldsDataBase.hpp" -namespace pFlow -{ - -template -inline -bool writeField -( - iOstream& os, - timeValue t, - const regionField field, - uint32 threshold, - const T& defValue=T{} -) -{ - const auto& regPoints = field.regPoints(); - const uint32 n = field.size(); - os<= threshold) - { - if constexpr(std::is_same_v) - { - os<) - { - os << field[i].x() << ' ' << field[i].y() << ' ' << field[i].z() << ' ' << field[i].w() << tab; - } - else - { - os<) - { - os<) - { - os << defValue.x() << ' ' << defValue.y() << ' ' << defValue.z() << ' ' << defValue.w() << tab; - } - else - { - os<, regionField, and regionField are supported -/// in the postprocessOperation class. -using processedRegFieldType = std::variant - < - regionField, - regionField, - regionField - >; + /// - forward declaration class fieldsDataBase; diff --git a/src/PostprocessData/operation/postprocessOperation/postprocessOperationFunctions.hpp b/src/PostprocessData/operation/postprocessOperation/postprocessOperationFunctions.hpp new file mode 100644 index 00000000..82376fd1 --- /dev/null +++ b/src/PostprocessData/operation/postprocessOperation/postprocessOperationFunctions.hpp @@ -0,0 +1,100 @@ +/*------------------------------- 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 __postprocessOperationFunctions_hpp__ +#define __postprocessOperationFunctions_hpp__ + +#include + +#include "types.hpp" +#include "iOstream.hpp" +#include "regionField.hpp" + +namespace pFlow +{ + +/// Type alias for processed region field types. +/// Only regionField, regionField, and regionField are supported +/// in the postprocessOperation class. +using processedRegFieldType = std::variant +< + regionField, + regionField, + regionField +>; + + +template +inline +bool writeField +( + iOstream& os, + timeValue t, + const regionField field, + uint32 threshold, + const T& defValue=T{} +) +{ + const auto& regPoints = field.regPoints(); + const uint32 n = field.size(); + os<= threshold) + { + if constexpr(std::is_same_v) + { + os<) + { + os << field[i].x() << ' ' << field[i].y() << ' ' << field[i].z() << ' ' << field[i].w() << tab; + } + else + { + os<) + { + os<) + { + os << defValue.x() << ' ' << defValue.y() << ' ' << defValue.z() << ' ' << defValue.w() << tab; + } + else + { + os<