From d1b6a04292f9e7b5f3c6ae23822d0b803c8f22ed Mon Sep 17 00:00:00 2001 From: HRN Date: Fri, 24 May 2024 00:10:49 +0330 Subject: [PATCH 1/3] makeing beforeIteration step-wise for boundaryBase to implement non-bloking communications --- .../boundaries/boundaryBase/boundaryBase.hpp | 2 +- .../boundaries/boundaryExit/boundaryExit.cpp | 3 ++- .../boundaries/boundaryExit/boundaryExit.hpp | 2 +- .../structuredData/boundaries/boundaryList.cpp | 12 +++++++++++- .../boundaries/boundaryNone/boundaryNone.cpp | 1 + .../boundaries/boundaryNone/boundaryNone.hpp | 2 +- .../boundaries/boundaryPeriodic/boundaryPeriodic.cpp | 2 ++ .../boundaries/boundaryPeriodic/boundaryPeriodic.hpp | 2 +- .../boundaryReflective/boundaryReflective.cpp | 1 + .../boundaryReflective/boundaryReflective.hpp | 2 +- 10 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp b/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp index 978f674b..b1f8008a 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp @@ -339,7 +339,7 @@ public: virtual - bool beforeIteration(uint32 iterNum, real t, real dt) = 0 ; + bool beforeIteration(uint32 step, uint32 iterNum, real t, real dt) = 0 ; virtual bool iterate(uint32 iterNum, real t, real dt) = 0; diff --git a/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.cpp b/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.cpp index 9937433c..0f530418 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.cpp @@ -42,12 +42,13 @@ pFlow::boundaryExit::boundaryExit bool pFlow::boundaryExit::beforeIteration ( + uint32 step, uint32 iterNum, real t, real dt ) { - + if(step!= 2 )return true; if( !boundaryListUpdate(iterNum))return true; // nothing have to be done diff --git a/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.hpp b/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.hpp index f8aa61c5..b4763e26 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.hpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryExit/boundaryExit.hpp @@ -63,7 +63,7 @@ public: dictionary ); - bool beforeIteration(uint32 iterNum, real t, real dt) override; + bool beforeIteration(uint32 step, uint32 iterNum, real t, real dt) override; bool iterate(uint32 iterNum, real t, real dt) override; diff --git a/src/phasicFlow/structuredData/boundaries/boundaryList.cpp b/src/phasicFlow/structuredData/boundaries/boundaryList.cpp index 0e5ddfed..707e00ea 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryList.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryList.cpp @@ -172,7 +172,17 @@ pFlow::boundaryList::beforeIteration(uint32 iter, real t, real dt, bool force) for (auto bdry : *this) { - if (!bdry->beforeIteration(iter, t, dt)) + if (!bdry->beforeIteration(1, iter, t, dt)) + { + fatalErrorInFunction << "Error in beforeIteration in boundary " + << bdry->name() << endl; + return false; + } + } + + for (auto bdry : *this) + { + if (!bdry->beforeIteration(2, iter, t, dt)) { fatalErrorInFunction << "Error in beforeIteration in boundary " << bdry->name() << endl; diff --git a/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.cpp b/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.cpp index 327330dd..7f228562 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.cpp @@ -34,6 +34,7 @@ pFlow::boundaryNone::boundaryNone bool pFlow::boundaryNone::beforeIteration ( + uint32 step, uint32 iterNum, real t, real dt diff --git a/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.hpp b/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.hpp index 8e103d39..68ddf33f 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.hpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryNone/boundaryNone.hpp @@ -52,7 +52,7 @@ public: dictionary ); - bool beforeIteration(uint32 iterNum, real t, real dt) final; + bool beforeIteration(uint32 step, uint32 iterNum, real t, real dt) final; bool iterate(uint32 iterNum, real t, real dt) final; diff --git a/src/phasicFlow/structuredData/boundaries/boundaryPeriodic/boundaryPeriodic.cpp b/src/phasicFlow/structuredData/boundaries/boundaryPeriodic/boundaryPeriodic.cpp index cbdecf71..cf111eb5 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryPeriodic/boundaryPeriodic.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryPeriodic/boundaryPeriodic.cpp @@ -51,10 +51,12 @@ pFlow::realx3 pFlow::boundaryPeriodic::boundaryExtensionLength() const bool pFlow::boundaryPeriodic::beforeIteration( + uint32 step, uint32 iterNum, real t, real dt) { + if(step!=2)return true; // nothing have to be done if(empty()) { diff --git a/src/phasicFlow/structuredData/boundaries/boundaryPeriodic/boundaryPeriodic.hpp b/src/phasicFlow/structuredData/boundaries/boundaryPeriodic/boundaryPeriodic.hpp index 88983fa3..69b0413a 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryPeriodic/boundaryPeriodic.hpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryPeriodic/boundaryPeriodic.hpp @@ -64,7 +64,7 @@ public: //const plane& boundaryPlane()const override;*/ - bool beforeIteration(uint32 iterNum, real t, real dt) override; + bool beforeIteration(uint32 step, uint32 iterNum, real t, real dt) override; bool iterate(uint32 iterNum, real t, real dt) override; diff --git a/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.cpp b/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.cpp index 74ee4d75..8de9b74f 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.cpp @@ -46,6 +46,7 @@ pFlow::boundaryReflective::boundaryReflective } bool pFlow::boundaryReflective::beforeIteration( + uint32 step, uint32 iterNum, real t, real dt) diff --git a/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.hpp b/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.hpp index 43e1ce13..3f3bc64c 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.hpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.hpp @@ -59,7 +59,7 @@ public: dictionary ); - bool beforeIteration(uint32 iterNum, real t, real dt) override; + bool beforeIteration(uint32 step, uint32 iterNum, real t, real dt) override; bool iterate(uint32 iterNum, real t, real dt) override; From 32a2c20613b09aff311d77819d2d7477fe74fe01 Mon Sep 17 00:00:00 2001 From: HRN Date: Fri, 24 May 2024 20:50:53 +0330 Subject: [PATCH 2/3] for write to file binary MPI --- src/phasicFlow/repository/IOobject/IOobject.cpp | 2 ++ .../structuredData/boundaries/boundaryExit/boundaryExit.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/phasicFlow/repository/IOobject/IOobject.cpp b/src/phasicFlow/repository/IOobject/IOobject.cpp index 6fae2f0a..4442332f 100644 --- a/src/phasicFlow/repository/IOobject/IOobject.cpp +++ b/src/phasicFlow/repository/IOobject/IOobject.cpp @@ -126,6 +126,7 @@ bool pFlow::IOobject::writeObject() const { if(auto ptrOS = outStream(); ptrOS ) { + pOutput<<"Should write field "<name()<name()< Date: Fri, 24 May 2024 22:02:46 +0330 Subject: [PATCH 3/3] bug fix for binary file read when dealing with multiple Fields reading from a single file --- src/phasicFlow/containers/Field/Field.cpp | 19 +++++++++++++++---- src/phasicFlow/containers/Field/Field.hpp | 4 ++-- .../repository/IOobject/IOobject.cpp | 2 -- src/phasicFlow/triSurface/triSurface.cpp | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/phasicFlow/containers/Field/Field.cpp b/src/phasicFlow/containers/Field/Field.cpp index 335fbe49..10e14df8 100644 --- a/src/phasicFlow/containers/Field/Field.cpp +++ b/src/phasicFlow/containers/Field/Field.cpp @@ -21,13 +21,17 @@ Licence: template bool pFlow::Field::read ( - iIstream& is + iIstream& is, + bool resume ) { bool tokenFound = true; - tokenFound = is.findToken(fieldKey_); + if(resume) + tokenFound = is.findTokenResume(fieldKey_); + else + tokenFound = is.findToken(fieldKey_); if( !tokenFound ) { @@ -53,14 +57,21 @@ template bool pFlow::Field::read ( iIstream& is, - const IOPattern& iop + const IOPattern& iop, + bool resume ) { bool tokenFound = true; if(iop.thisProcReadData()) - tokenFound = is.findToken(fieldKey_); + { + if(resume) + tokenFound = is.findTokenResume(fieldKey_); + else + tokenFound = is.findToken(fieldKey_); + } + if( !tokenFound ) { diff --git a/src/phasicFlow/containers/Field/Field.hpp b/src/phasicFlow/containers/Field/Field.hpp index 738811bc..b38d3017 100644 --- a/src/phasicFlow/containers/Field/Field.hpp +++ b/src/phasicFlow/containers/Field/Field.hpp @@ -197,12 +197,12 @@ public: //// - IO operations - bool read(iIstream& is); + bool read(iIstream& is, bool resume = false); bool write(iOstream& os)const; - bool read(iIstream& is, const IOPattern& iop); + bool read(iIstream& is, const IOPattern& iop, bool resume = false); bool write(iOstream& os, const IOPattern& iop )const; diff --git a/src/phasicFlow/repository/IOobject/IOobject.cpp b/src/phasicFlow/repository/IOobject/IOobject.cpp index 4442332f..6fae2f0a 100644 --- a/src/phasicFlow/repository/IOobject/IOobject.cpp +++ b/src/phasicFlow/repository/IOobject/IOobject.cpp @@ -126,7 +126,6 @@ bool pFlow::IOobject::writeObject() const { if(auto ptrOS = outStream(); ptrOS ) { - pOutput<<"Should write field "<name()<name()<