From 9dfe98eea2914b7455a9ba8742ba6d9cad501623 Mon Sep 17 00:00:00 2001 From: Hamidreza Norouzi Date: Mon, 5 Feb 2024 01:29:45 -0800 Subject: [PATCH] triSurfaceField refactored --- src/phasicFlow/CMakeLists.txt | 1 + src/phasicFlow/containers/Field/Field.hpp | 8 + .../triSurfaceField/triSurfaceField.cpp | 151 +++++++++++++++++- .../triSurfaceField/triSurfaceField.hpp | 121 ++++++-------- .../triSurfaceField/triSurfaceFields.cpp | 6 +- .../triSurfaceField/triSurfaceFields.hpp | 10 +- 6 files changed, 214 insertions(+), 83 deletions(-) diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt index e5a14d00..822f5cc6 100644 --- a/src/phasicFlow/CMakeLists.txt +++ b/src/phasicFlow/CMakeLists.txt @@ -55,6 +55,7 @@ containers/VectorHD/VectorSingles.cpp containers/Field/Fields.cpp containers/List/anyList/anyList.cpp containers/pointField/pointFields.cpp +containers/triSurfaceField/triSurfaceFields.cpp setFieldList/setFieldList.cpp setFieldList/setFieldEntry.cpp diff --git a/src/phasicFlow/containers/Field/Field.hpp b/src/phasicFlow/containers/Field/Field.hpp index 8c1ac98c..e1eb18c2 100644 --- a/src/phasicFlow/containers/Field/Field.hpp +++ b/src/phasicFlow/containers/Field/Field.hpp @@ -106,6 +106,14 @@ public: fieldKey_(fieldKey) {} + Field(const word& name, const word& fieldKey, size_t capacity, size_t len, const T& val) + : + VectorType(name, len, len, RESERVE()), + fieldKey_(fieldKey) + { + VectorType::fill(val); + } + /// Construct a field with name, fieldKey, capacity and len Field(const word& name, const word& fieldKey, size_t capacity, size_t len, RESERVE) : diff --git a/src/phasicFlow/containers/triSurfaceField/triSurfaceField.cpp b/src/phasicFlow/containers/triSurfaceField/triSurfaceField.cpp index 26830089..8ba0abf4 100644 --- a/src/phasicFlow/containers/triSurfaceField/triSurfaceField.cpp +++ b/src/phasicFlow/containers/triSurfaceField/triSurfaceField.cpp @@ -1,3 +1,4 @@ +#include "triSurfaceField.hpp" /*------------------------------- phasicFlow --------------------------------- O C enter of O O E ngineering and @@ -18,7 +19,153 @@ Licence: -----------------------------------------------------------------------------*/ -template class VectorField, class T, class MemorySpace> +template +pFlow::triSurfaceField::triSurfaceField +( + const objectFile& objf, + multiTriSurface& surface, + const T& defVal +) +: + triSurfaceField + ( + objf, + surface.owner(), + surface, + defVal + ) +{ + +} + +template +pFlow::triSurfaceField::triSurfaceField +( + const objectFile& objf, + repository* owner, + multiTriSurface& surface, + const T& defVal +) +: + IOobject + ( + objf, + IOPattern::AllProcessorsSimilar, + owner + ), + observer + ( + &surface, + message::Default() + ), + field_ + ( + objf.name(), + "value", + surface.capacity(), + surface.size(), + RESERVE() + ), + surface_(surface), + defaultValue_(defVal) +{ + if(IOobject::implyRead()) + { + REPORT(1)<< "Reading triSurfaceField "<< Green_Text(IOobject::name())<< + " from "< +pFlow::triSurfaceField::triSurfaceField +( + const objectFile &objf, + multiTriSurface &surface, + const T &val, + const T &defVal +) +: + triSurfaceField + ( + objf, + surface.owner(), + surface, + val, + defVal + ) +{} + +template +pFlow::triSurfaceField::triSurfaceField +( + const objectFile &objf, + repository *owner, + multiTriSurface &surface, + const T &val, + const T &defVal +) +: + IOobject + ( + objectFile + ( + objf.name(), + objf.localPath(), + objectFile::READ_NEVER, + objf.wFlag() + ), + IOPattern::AllProcessorsSimilar, + owner + ), + observer + ( + &surface, + message::Default() + ), + field_ + ( + objf.name(), + "value", + surface.capacity(), + surface.size(), + val + ), + surface_(surface), + defaultValue_(defVal) +{ +} + +template +bool pFlow::triSurfaceField::write +( + iOstream &is, + const IOPattern &iop +) const +{ + return field_.write(is, iop); +} + +template +bool pFlow::triSurfaceField::read +( + iIstream &is, + const IOPattern &iop +) +{ + return field_.read(is, iop); +} + +/*template class VectorField, class T, class MemorySpace> pFlow::triSurfaceField::triSurfaceField ( const triSurface& surface, @@ -116,4 +263,4 @@ bool pFlow::triSurfaceField::writeTriSurfaceField )const { return FieldType::write(os); -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp b/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp index 8dc2899b..37a17c38 100644 --- a/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp +++ b/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp @@ -22,7 +22,8 @@ Licence: #define __trieSurfaceField_hpp__ #include "Field.hpp" -#include "triSurface.hpp" +#include "multiTriSurface.hpp" +#include "observer.hpp" #include "error.hpp" @@ -30,119 +31,93 @@ namespace pFlow { -template class VectorField, class T, class MemorySpace=void> +template class triSurfaceField : - public eventObserver, - public Field + public IOobject, + public observer { public: - using triSurfaceFieldType = triSurfaceField; + using triSurfaceFieldType = triSurfaceField; - using FieldType = Field; + using FieldType = Field; using VectorType = typename FieldType::VectorType; - using iterator = typename FieldType::iterator; + using memory_space = typename FieldType::memory_space; - using constIterator = typename FieldType::constIterator; + using execution_space = typename FieldType::execution_space; - using reference = typename FieldType::reference; - - using constReference = typename FieldType::constReference; - - using valueType = typename FieldType::valueType; - - using pointer = typename FieldType::pointer; - - using constPointer = typename FieldType::constPointer; - -protected: +private: ////- data members - const triSurface& surface_; + + FieldType field_; + + const multiTriSurface& surface_; // - value when a new item is added to field - T defaultValue_; + T defaultValue_; public: // - type info - TypeInfoTemplateNV2("triSurfaceField", T, VectorType::memoerySpaceName()); + TypeInfoTemplate111("triSurfaceField", T, VectorType::memoerySpaceName()); //// CONSTRUCTORS // - construct a field from tirSurface and set defaultValue_ and field value to defVal - triSurfaceField( const triSurface& surface, const T& defVal, bool subscribe = true); + triSurfaceField( + const objectFile& objf, + multiTriSurface& surface, + const T& defVal); + + triSurfaceField( + const objectFile& objf, + repository* owner, + multiTriSurface& surface, + const T& defVal); // - construct from iIOEntity, tirSurface and a value - triSurfaceField( const triSurface& surface, const T& val, const T& defVal, bool subscribe = true); + triSurfaceField( + const objectFile& objf, + multiTriSurface& surface, + const T& val, + const T& defVal); - // - construct from another triSurfaceField - // subscribe to events if true - triSurfaceField( const triSurfaceField& src, bool subscribe); + triSurfaceField( + const objectFile& objf, + repository* owner, + multiTriSurface& surface, + const T& val, + const T& defVal); + ~triSurfaceField()override = default; - // - copy construct - triSurfaceField(const triSurfaceField& src); - - // - no move construct - triSurfaceField(triSurfaceField&& src) = delete; - - - // assignment, only assign the VectorField and preserve other parts of this - triSurfaceField& operator = (const triSurfaceField& rhs); - - // no move assignment - triSurfaceField& operator = (triSurfaceField&&) = delete; - - - inline uniquePtr clone() const - { - return makeUnique(*this); - } - - inline triSurfaceFieldType* clonePtr()const - { - return new triSurfaceFieldType(*this); - } + //// - Methods - inline const triSurface& surface()const { + inline + const auto& surface()const + { return surface_; } - auto getTriangleAccessor()const - { - return surface_.getTriangleAccessor(); - } - - bool update(const eventMessage& msg); - + //// - IO operations - bool readTriSurfacceField(iIstream& is); + bool write(iOstream& is, const IOPattern& iop)const override; - bool writeTriSurfaceField(iOstream& os)const; - - - bool read(iIstream& is) - { - return readTriSurfacceField(is); - } - - bool write(iOstream& os)const - { - return writeTriSurfaceField(os); - } + + bool read(iIstream& is, const IOPattern& iop) override; }; -template class VectorField, class T, class MemorySpace> +/*template class VectorField, class T, class MemorySpace> iIstream& operator >> (iIstream & is, triSurfaceField & tsF ) { if( !tsF.read(is)) @@ -168,7 +143,7 @@ iOstream& operator << (iOstream& os, const triSurfaceField; +template class pFlow::triSurfaceField; -template class pFlow::triSurfaceField; +/*template class pFlow::triSurfaceField; template class pFlow::triSurfaceField; @@ -31,4 +31,4 @@ template class pFlow::triSurfaceField; -template class pFlow::triSurfaceField; \ No newline at end of file +template class pFlow::triSurfaceField;*/ \ No newline at end of file diff --git a/src/phasicFlow/containers/triSurfaceField/triSurfaceFields.hpp b/src/phasicFlow/containers/triSurfaceField/triSurfaceFields.hpp index c3cd6bd9..cf3f6ffa 100644 --- a/src/phasicFlow/containers/triSurfaceField/triSurfaceFields.hpp +++ b/src/phasicFlow/containers/triSurfaceField/triSurfaceFields.hpp @@ -21,15 +21,15 @@ Licence: #ifndef __triSurfaceFields_hpp__ #define __triSurfaceFields_hpp__ -#include "VectorSingle.hpp" -#include "VectorDual.hpp" -#include "triSurfaceField.hpp" #include "types.hpp" +#include "VectorSingle.hpp" +#include "triSurfaceField.hpp" + namespace pFlow { -using realTriSurfaceField_D = triSurfaceField ; +/*using realTriSurfaceField_D = triSurfaceField ; using realTriSurfaceField_H = triSurfaceField ; @@ -52,7 +52,7 @@ using int8TriSurfaceField_H = triSurfaceField ; using int8TriSurfaceField_HD = triSurfaceField ; using int8TriSurfaceField = triSurfaceField> ; - +*/ }