From 0096856c982e4254b8d7a7857b0eaabfa0bb5279 Mon Sep 17 00:00:00 2001 From: Hamidreza Norouzi Date: Fri, 19 Jan 2024 22:31:08 -0800 Subject: [PATCH] Field class and pointStructure modified and tested --- src/phasicFlow/CMakeLists.txt | 3 +- src/phasicFlow/Kokkos/KokkosUtilities.hpp | 1 + src/phasicFlow/containers/Field/Field.cpp | 162 ++++++++---- src/phasicFlow/containers/Field/Field.hpp | 56 ++--- src/phasicFlow/containers/Field/Fields.cpp | 56 +---- src/phasicFlow/containers/Field/Fields.hpp | 43 ++-- src/phasicFlow/containers/Vector/Vector.cpp | 4 +- src/phasicFlow/containers/Vector/Vector.hpp | 234 +++++++++--------- src/phasicFlow/containers/Vector/Vectors.cpp | 18 -- .../containers/Vector/stdVectorHelper.hpp | 37 ++- .../containers/VectorHD/VectorSingle.cpp | 17 ++ .../containers/VectorHD/VectorSingle.hpp | 61 +++-- .../containers/VectorHD/VectorSingles.cpp | 38 +++ .../containers/pointField/internalField.cpp | 34 ++- .../containers/pointField/internalField.hpp | 28 ++- .../containers/pointField/pointField.cpp | 230 ++++++++++------- .../containers/pointField/pointField.hpp | 17 +- .../containers/pointField/pointFields.cpp | 13 +- .../containers/pointField/pointFields.hpp | 9 +- src/phasicFlow/containers/span/span.hpp | 60 ++--- src/phasicFlow/dictionary/fileDictionary.cpp | 2 +- .../repository/IOobject/IOobject.cpp | 12 +- .../repository/IOobject/IOobject.hpp | 8 +- .../repository/repository/repository.cpp | 2 +- .../streams/dataIO/createDataIO.hpp | 20 ++ src/phasicFlow/streams/dataIO/dataIO.hpp | 67 ++++- src/phasicFlow/streams/dataIO/dataIOMPI.hpp | 97 ++++++++ .../streams/dataIO/dataIORegular.hpp | 20 ++ .../streams/dataIO/dataIOTemplate.cpp | 225 ++++++++++------- .../boundaries/boundaryBase/boundaryBase.hpp | 8 +- .../domain/simulationDomain.hpp | 2 +- .../pointStructure/internalPoints.cpp | 98 ++++++-- .../pointStructure/internalPoints.hpp | 30 ++- .../pointStructure/pointStructure.cpp | 63 +++-- .../pointStructure/pointStructure.hpp | 27 +- 35 files changed, 1162 insertions(+), 640 deletions(-) create mode 100644 src/phasicFlow/containers/VectorHD/VectorSingles.cpp create mode 100644 src/phasicFlow/streams/dataIO/dataIOMPI.hpp diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt index 5024be68..952be63b 100644 --- a/src/phasicFlow/CMakeLists.txt +++ b/src/phasicFlow/CMakeLists.txt @@ -35,9 +35,10 @@ dictionary/entry/dataEntry.cpp dictionary/twoPartEntry/twoPartEntry.cpp containers/Vector/Vectors.cpp +containers/VectorHD/VectorSingles.cpp containers/Field/Fields.cpp containers/List/anyList/anyList.cpp -containers/pointField/pointFields.cpp +#containers/pointField/pointFields.cpp #setFieldList/setFieldList.cpp #setFieldList/setFieldEntry.cpp diff --git a/src/phasicFlow/Kokkos/KokkosUtilities.hpp b/src/phasicFlow/Kokkos/KokkosUtilities.hpp index b44a467d..6d1c7f46 100644 --- a/src/phasicFlow/Kokkos/KokkosUtilities.hpp +++ b/src/phasicFlow/Kokkos/KokkosUtilities.hpp @@ -26,6 +26,7 @@ Licence: #include "pFlowMacros.hpp" #include "types.hpp" #include "span.hpp" +#include "dataIO.hpp" #include "iOstream.hpp" namespace pFlow diff --git a/src/phasicFlow/containers/Field/Field.cpp b/src/phasicFlow/containers/Field/Field.cpp index 93b72c20..dd4506e4 100644 --- a/src/phasicFlow/containers/Field/Field.cpp +++ b/src/phasicFlow/containers/Field/Field.cpp @@ -18,6 +18,116 @@ Licence: -----------------------------------------------------------------------------*/ +template +bool pFlow::Field::read +( + iIstream& is +) +{ + + bool tokenFound = true; + + tokenFound = is.findToken(fieldKey_); + + if( !tokenFound ) + { + ioErrorInFile( is.name(), is.lineNumber() ) << + " error in searching for filedkey " << fieldKey_<name()< +bool pFlow::Field::read +( + iIstream& is, + const IOPattern& iop +) +{ + + bool tokenFound = true; + + if(iop.thisProcReadData()) + tokenFound = is.findToken(fieldKey_); + + if( !tokenFound ) + { + ioErrorInFile( is.name(), is.lineNumber() ) << + " error in searching for filedkey " << fieldKey_<name()< +bool pFlow::Field::write +( + iOstream& os +)const +{ + + os.writeWordKeyword(fieldKey_)< +bool pFlow::Field::write +( + iOstream& os, + const IOPattern& iop +)const +{ + + if(iop.thisProcWriteData()) + os.writeWordKeyword(fieldKey_)< class VectorField, class T, class PropType> bool pFlow::Field::readUniform ( @@ -179,55 +289,3 @@ bool pFlow::Field::writeField(iOstream& os)const return true; }*/ - - -template class VectorField, class T, class PropType> -bool pFlow::Field::read -( - iIstream& is, - const IOPattern& iop -) -{ - - bool tokenFound = true; - - if(iop.thisProcReadData()) - tokenFound = is.findToken(fieldKey_); - - if( !tokenFound ) - { - ioErrorInFile( is.name(), is.lineNumber() ) << - " error in searching for filedkey " << fieldKey_<name()< class VectorField, class T, class PropType> -bool pFlow::Field::write( - iOstream& os, - const IOPattern& iop)const -{ - - os.writeWordKeyword(fieldKey_)< class VectorField, class T, class PropType=void> +template class Field : - public VectorField + public VectorSingle { public: - - using VectorType = VectorField; + using VectorType = VectorSingle; - using FieldType = Field; + using FieldType = Field; - using iterator = typename VectorType::iterator; + using FieldTypeHost = Field; - using const_iterator = typename VectorType::const_iterator; + using memory_space = typename VectorType::memory_space; - using reference = typename VectorType::reference; + using execution_space = typename VectorType::execution_space; + + using iterator = typename VectorType::iterator; + + using const_iterator = typename VectorType::const_iterator; + + using reference = typename VectorType::reference; - using const_reference = typename VectorType::const_reference; + using const_reference = typename VectorType::const_reference; - using value_type = typename VectorType::value_type; + using value_type = typename VectorType::value_type; - using pointer = typename VectorType::pointer; + using pointer = typename VectorType::pointer; - using const_pointer = typename VectorType::const_pointer; + using const_pointer = typename VectorType::const_pointer; -protected: +private: static const inline word FKey = "value"; const word fieldKey_ = FKey; - /*bool readUniform( iIstream& is, size_t len, bool readLength = true); - - bool readNonUniform( iIstream& is, size_t len);*/ - public: /// type info @@ -91,7 +89,6 @@ public: VectorType(name), fieldKey_(fieldKey) {} - /// Construct a field with name and fieldKey and specified len Field(const word& name, const word& fieldKey, size_t len) @@ -189,15 +186,12 @@ public: } //// - IO operations - /*bool readField(iIstream& is, const size_t len, bool resume, bool readLength = true); + bool read(iIstream& is); - bool readField(iIstream& is, bool resume ); + bool write(iOstream& os)const; - - bool writeField(iOstream& os)const;*/ - bool read(iIstream& is, const IOPattern& iop); @@ -206,8 +200,8 @@ public: }; -template class VectorField, class T, class PropType> -inline iIstream& operator >> (iIstream & is, Field & ifld ) +template +inline iIstream& operator >> (iIstream & is, Field & ifld ) { if( !ifld.read(is, IOPattern::MasterProcessorOnly) ) { @@ -217,8 +211,8 @@ inline iIstream& operator >> (iIstream & is, Field & i return is; } -template class VectorField, class T, class PropType> -inline iOstream& operator << (iOstream& os, const Field& ofld ) +template +inline iOstream& operator << (iOstream& os, const Field& ofld ) { if( !ofld.write(os, IOPattern::AllProcessorsDifferent) ) diff --git a/src/phasicFlow/containers/Field/Fields.cpp b/src/phasicFlow/containers/Field/Fields.cpp index e43c4330..55337632 100644 --- a/src/phasicFlow/containers/Field/Fields.cpp +++ b/src/phasicFlow/containers/Field/Fields.cpp @@ -21,61 +21,17 @@ Licence: #include "Fields.hpp" -template class pFlow::Field; +template class pFlow::Field; -/*template class pFlow::Field; +template class pFlow::Field; -template class pFlow::Field; +template class pFlow::Field; -template class pFlow::Field; +template class pFlow::Field; -template class pFlow::Field; +template class pFlow::Field; -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; - -template class pFlow::Field; +template class pFlow::Field; -template class pFlow::Field>;*/ - diff --git a/src/phasicFlow/containers/Field/Fields.hpp b/src/phasicFlow/containers/Field/Fields.hpp index 411bedf7..abe589fe 100644 --- a/src/phasicFlow/containers/Field/Fields.hpp +++ b/src/phasicFlow/containers/Field/Fields.hpp @@ -30,44 +30,44 @@ Licence: namespace pFlow { -using int8Field_D = Field; +using int8Field_D = Field; -using int8Field_H = Field; +using int8Field_H = Field; -using int32Field_D = Field; +using int32Field_D = Field; -using int32Field_H = Field; +using int32Field_H = Field; -using int64Field_D = Field; +using int64Field_D = Field; -using int64Field_H = Field; +using int64Field_H = Field; -using uint8Field_D = Field; +using uint8Field_D = Field; -using uint8Field_H = Field; +using uint8Field_H = Field; -using uint32Field_D = Field; +using uint32Field_D = Field; -using uint32Field_H = Field; +using uint32Field_H = Field; -using uint64Field_D = Field; +using uint64Field_D = Field; -using uint64Field_H = Field ; +using uint64Field_H = Field ; -using realField_D = Field; +using realField_D = Field; -using realField_H = Field ; +using realField_H = Field ; -using realx3Field_D = Field; +using realx3Field_D = Field; -using realx3Field_H = Field; +using realx3Field_H = Field; -using realx3x3Field_D = Field; +using realx3x3Field_D = Field; -using realx3x3Field_H = Field; +using realx3x3Field_H = Field; // - no typedef on device (since word does not compile on CUDA) -using wordField_H = Field; +using wordField_H = Field; // host device fields @@ -93,11 +93,6 @@ using int64x3Field_HD = Field; using realx3x3Field_HD = Field;*/ - -using wordField = Field>; - - - } diff --git a/src/phasicFlow/containers/Vector/Vector.cpp b/src/phasicFlow/containers/Vector/Vector.cpp index e17ce7a8..ec729fc2 100644 --- a/src/phasicFlow/containers/Vector/Vector.cpp +++ b/src/phasicFlow/containers/Vector/Vector.cpp @@ -19,7 +19,7 @@ Licence: -----------------------------------------------------------------------------*/ -template +/*template bool pFlow::Vector::readVector ( iIstream& is, @@ -38,7 +38,7 @@ bool pFlow::Vector::writeVector ) const { return writeStdVector(os, vectorField(), iop); -} +}*/ /*template bool pFlow::Vector::deleteElement_sorted diff --git a/src/phasicFlow/containers/Vector/Vector.hpp b/src/phasicFlow/containers/Vector/Vector.hpp index fa7cabb6..32d2f115 100644 --- a/src/phasicFlow/containers/Vector/Vector.hpp +++ b/src/phasicFlow/containers/Vector/Vector.hpp @@ -59,27 +59,27 @@ class Vector { public: - typedef Vector VectorType; + using VectorType = Vector; - typedef typename std::vector vectorType; + using vectorType = typename std::vector; - typedef typename vectorType::iterator iterator; + using iterator = typename vectorType::iterator; - typedef typename vectorType::const_iterator const_iterator; + using const_iterator = typename vectorType::const_iterator; - typedef typename vectorType::reference reference; + using reference = typename vectorType::reference; - typedef typename vectorType::const_reference const_reference; + using const_reference = typename vectorType::const_reference; - typedef T value_type; + using value_type = T; - typedef T* pointer; + using pointer = T *; - typedef const T* const_pointer; + using const_pointer = const T *; - typedef typename std::initializer_list init_list; + using init_list = typename std::initializer_list; -protected: +private: // - name of the vector word name_; @@ -105,21 +105,24 @@ public: /// Empty Vector with a name - inline Vector(const word& name) + inline + explicit Vector(const word& name) : name_(name) {} /// Vector with specified length and name - inline Vector(const word& name, size_t len) + inline + Vector(const word& name, size_t len) : vectorType(len), name_(name) {} /// Vector with name, length and value - inline Vector(const word& name, size_t len, const T& val) + inline + Vector(const word& name, size_t len, const T& val) : Vector(name, len) { @@ -136,7 +139,8 @@ public: /// Vector from name and initializer list - inline Vector(const word& name, const init_list &l) + inline + Vector(const word& name, const init_list &l) : vectorType(l), name_(name) @@ -162,7 +166,7 @@ public: inline Vector(const VectorType& src) = default; /// Copy from src with a new name - inline Vector(const word name, const Vector& src): + inline Vector(const word& name, const Vector& src): vectorType(src), name_(name) {} @@ -178,10 +182,10 @@ public: } /// Move construct - inline Vector( VectorType && mv) = default; + Vector( VectorType && mv) noexcept= default; /// Move assignment - inline VectorType& operator=( VectorType && mv) = default; + VectorType& operator=( VectorType && mv)noexcept = default; /// Scalar assignment inline void operator=(const T& val) @@ -190,10 +194,8 @@ public: } /// Destructor - inline ~Vector() - { - vectorType::clear(); - } + ~Vector() = default; + /// Clone as a uniquePtr inline uniquePtr clone() const @@ -204,7 +206,8 @@ public: /// Clone as a pointer inline VectorType* clonePtr()const { - return new VectorType(*this); + uniquePtr Ptr = makeUnique(*this); + return Ptr.release(); } @@ -283,6 +286,99 @@ public: vectorType::reserve(cap); } + // - fill the whole content of vector, [begin, end), with val + void fill( const T& val); + + inline + auto getSpan() + { + return span(this->data(), this->size()); + } + + inline + auto getSpan()const + { + return span(const_cast(this->data()), this->size()); + } + + static constexpr bool isHostAccessible() + { + return isHostAccessible_; + } + + void operator +=( const T& val); + void operator -=( const T& val); + void operator *=( const T& val); + void operator /=( const T& val); + + void operator +=( const VectorType& v ); + void operator -=( const VectorType& v ); + void operator /=( const VectorType& v ); + void operator *=( const VectorType& v ); + + VectorType operator -()const; + + bool read(iIstream& is) + { + return readStdVector(is, vectorField()); + } + bool write(iOstream& os) + { + return writeStdVector(os, vectorField()); + } + + bool read(iIstream& is, const IOPattern& iop) + { + return readStdVector(is, vectorField(), iop); + } + + bool write(iOstream& os, const IOPattern& iop)const + { + return writeStdVector(os, vectorField(), iop); + } + + static + constexpr const char* memoerySpaceName() + { + return "std"; + } +}; + + +template +inline iIstream& operator >> (iIstream & is, Vector & ivec ) +{ + if( !ivec.read(is) ) + { + ioErrorInFile (is.name(), is.lineNumber()); + fatalExit; + } + return is; +} + +template +inline iOstream& operator << (iOstream& os, const Vector& ovec ) +{ + if( !ovec.write(os) ) + { + ioErrorInFile(os.name(), os.lineNumber()); + fatalExit; + } + return os; +} + + +} // pFlow + + +#include "VectorI.hpp" +#include "Vector.cpp" +#include "VectorMath.hpp" +#include "VectorAlgorithm.hpp" + +#endif + + /*// - delete elemens of vector based on sorted indices // return false if out of range @@ -317,94 +413,4 @@ public: // - set or insert a new element into the vecor // return false if it fails - inline bool insertSetElement(int32 idx, const T& val);*/ - - // - fill the whole content of vector, [begin, end), with val - inline void fill( const T& val); - - inline - auto getSpan() - { - return span(this->data(), this->size()); - } - - inline - auto getSpan()const - { - return span(const_cast(this->data()), this->size()); - } - - static constexpr bool isHostAccessible() - { - return isHostAccessible_; - } - - - - inline void operator +=( const T& val); - inline void operator -=( const T& val); - inline void operator *=( const T& val); - inline void operator /=( const T& val); - - inline void operator +=( const VectorType& v ); - inline void operator -=( const VectorType& v ); - inline void operator /=( const VectorType& v ); - inline void operator *=( const VectorType& v ); - - inline VectorType operator -()const; - - /// Read vector (assume ASCII in input) - bool readVector(iIstream& is, const IOPattern& iop); - - /// write vector - bool writeVector(iOstream& os, const IOPattern& iop) const; - - bool read(iIstream& is, const IOPattern& iop) - { - return readVector(is, iop); - } - - bool write(iOstream& os, const IOPattern& iop)const - { - return writeVector(os, iop); - } - - constexpr static inline const char* memoerySpaceName() - { - return "std"; - } -}; - - -template -inline iIstream& operator >> (iIstream & is, Vector & ivec ) -{ - if( !ivec.readVector(is, IOPattern::MasterProcessorOnly) ) - { - ioErrorInFile (is.name(), is.lineNumber()); - fatalExit; - } - return is; -} - -template -inline iOstream& operator << (iOstream& os, const Vector& ovec ) -{ - if( !ovec.writeVector(os, IOPattern::AllProcessorsDifferent) ) - { - ioErrorInFile(os.name(), os.lineNumber()); - fatalExit; - } - return os; -} - - -} // pFlow - - -#include "VectorI.hpp" -#include "Vector.cpp" -#include "VectorMath.hpp" -#include "VectorAlgorithm.hpp" - -#endif + inline bool insertSetElement(int32 idx, const T& val);*/ \ No newline at end of file diff --git a/src/phasicFlow/containers/Vector/Vectors.cpp b/src/phasicFlow/containers/Vector/Vectors.cpp index 8db0fb40..d8f2dc05 100644 --- a/src/phasicFlow/containers/Vector/Vectors.cpp +++ b/src/phasicFlow/containers/Vector/Vectors.cpp @@ -20,22 +20,4 @@ Licence: #include "Vectors.hpp" -// instantiation just for numeral types - -/*template class pFlow::Vector; - -template class pFlow::Vector; - -template class pFlow::Vector; - -template class pFlow::Vector; - -template class pFlow::Vector; - -template class pFlow::Vector;*/ - - - - - diff --git a/src/phasicFlow/containers/Vector/stdVectorHelper.hpp b/src/phasicFlow/containers/Vector/stdVectorHelper.hpp index 584d07c6..60a71873 100644 --- a/src/phasicFlow/containers/Vector/stdVectorHelper.hpp +++ b/src/phasicFlow/containers/Vector/stdVectorHelper.hpp @@ -48,12 +48,20 @@ public: template using vecAllocator = std::allocator; +template +inline +bool writeSpan( + iOstream& os, + span sp) +{ + return writeDataAsciiBinary(os, sp); +} template inline bool writeSpan( iOstream& os, - const span& sp, + span sp, const IOPattern& iop) { @@ -73,6 +81,17 @@ bool writeSpan( return true; } +template +bool writeStdVector +( + iOstream& os, + const std::vector& vec +) +{ + auto sp = makeSpan(vec); + return writeSpan(os, sp); +} + template bool writeStdVector ( @@ -85,6 +104,18 @@ bool writeStdVector return writeSpan(os, sp, iop); } +template +bool readStdVector +( + iIstream& is, + std::vector& vec +) +{ + + return readDataAsciiBinary(is, vec); + +} + template bool readStdVector ( @@ -113,7 +144,7 @@ bool readStdVector template iOstream& operator<<( iOstream& os, const std::vector& vec) { - if(!writeStdVector(os, vec, IOPattern::AllProcessorsDifferent)) + if(!writeStdVector(os, vec)) { fatalErrorInFunction; fatalExit; @@ -125,7 +156,7 @@ iOstream& operator<<( iOstream& os, const std::vector& vec) template iIstream& operator>>(iIstream& is, std::vector& vec) { - if( !readStdVector(is,vec, IOPattern::MasterProcessorOnly)) + if( !readStdVector(is,vec)) { fatalErrorInFunction; fatalExit; diff --git a/src/phasicFlow/containers/VectorHD/VectorSingle.cpp b/src/phasicFlow/containers/VectorHD/VectorSingle.cpp index 18b053e6..6b0789b1 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingle.cpp +++ b/src/phasicFlow/containers/VectorHD/VectorSingle.cpp @@ -403,6 +403,23 @@ void pFlow::VectorSingle::assign { assign(src, src.capacity()); } +template +INLINE_FUNCTION_H +void pFlow::VectorSingle::assign(const VectorTypeHost& src) +{ + uint32 srcSize = src.size(); + uint32 srcCap = src.capacity(); + + if(srcCap != capacity()) + { + reallocateCapacitySize(srcCap, srcSize); + } + else + { + setSize(srcSize); + } + copy(deviceVector(), src.hostVector()); +} template INLINE_FUNCTION_H diff --git a/src/phasicFlow/containers/VectorHD/VectorSingle.hpp b/src/phasicFlow/containers/VectorHD/VectorSingle.hpp index 1b34604b..0876e6e5 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingle.hpp +++ b/src/phasicFlow/containers/VectorHD/VectorSingle.hpp @@ -24,12 +24,11 @@ Licence: #include "globalSettings.hpp" #include "phasicFlowKokkos.hpp" -#include "types.hpp" +#include "stdVectorHelper.hpp" #include "error.hpp" #include "indexContainer.hpp" #include "streams.hpp" -#include "span.hpp" -#include "dataIO.hpp" + #ifndef __RESERVE__ @@ -53,6 +52,8 @@ public: using VectorType = VectorSingle; + using VectorTypeHost = VectorSingle; + using iterator = T*; using const_iterator = const T*; @@ -77,7 +78,7 @@ public: using execution_space = typename viewType::execution_space; -protected: +private: // - Data members @@ -136,7 +137,7 @@ public: VectorSingle(); /// Empty vector with a name (capacity = 2) - VectorSingle(const word& name); + explicit VectorSingle(const word& name); /// Vector with name and size n VectorSingle(const word& name, uint32 n); @@ -271,6 +272,12 @@ public: /// The capacity of *this becomes the capacity of src. INLINE_FUNCTION_H void assign(const std::vector& src); + + /// Assign source vector from host side. + /// The size of *this becomes the size of src. + /// The capacity of *this becomes the capacity of src. + INLINE_FUNCTION_H + void assign(const VectorTypeHost& src); INLINE_FUNCTION_H auto getSpan(); @@ -291,7 +298,7 @@ public: /// resize if necessary and works on host accessible vector. template INLINE_FUNCTION_H - typename std::enable_if::type + typename std::enable_if_t push_back(const T& val) { auto n = changeSize(size_+1); @@ -360,7 +367,19 @@ public: //// - IO operations - /// Read vector from stream (ASCII) + /// Read vector from stream + FUNCTION_H + bool read(iIstream& is) + { + std::vector vecFromFile; + if(! readStdVector(is, vecFromFile)) return false; + + this->assign(vecFromFile); + + return true; + } + + /// Read vector from stream FUNCTION_H bool read(iIstream& is, const IOPattern& iop) { @@ -383,6 +402,16 @@ public: } + FUNCTION_H + bool write(iOstream& os)const + { + auto hVec = hostVector(); + auto sp = span( const_cast(hVec.data()), hVec.size()); + + return writeSpan(os, sp); + + } + template FUNCTION_H bool write(iOstream& os, const IOPattern& iop, const HostMask& mask)const @@ -408,19 +437,21 @@ public: return writeSpan(os, sp, iop); } - /// Name of the memory space - constexpr static inline - const char* memoerySpaceName() - { - return memory_space::name(); - } + + + /// Name of the memory space + static + constexpr const char* memoerySpaceName() + { + return memory_space::name(); + } }; // class VectorSingle template inline iIstream& operator >> (iIstream & is, VectorSingle & ivec ) { - if( !ivec.read(is, IOPattern::MasterProcessorOnly ) ) + if( !ivec.read(is) ) { ioErrorInFile (is.name(), is.lineNumber()); fatalExit; @@ -432,7 +463,7 @@ template inline iOstream& operator << (iOstream& os, const VectorSingle& ovec ) { - if( !ovec.write(os, IOPattern::AllProcessorsDifferent) ) + if( !ovec.write(os) ) { ioErrorInFile(os.name(), os.lineNumber()); fatalExit; diff --git a/src/phasicFlow/containers/VectorHD/VectorSingles.cpp b/src/phasicFlow/containers/VectorHD/VectorSingles.cpp new file mode 100644 index 00000000..c856b7c1 --- /dev/null +++ b/src/phasicFlow/containers/VectorHD/VectorSingles.cpp @@ -0,0 +1,38 @@ +/*------------------------------- 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 "VectorSingles.hpp" + + +template class Kokkos::View; +template class pFlow::VectorSingle; + +template class Kokkos::View; +template class pFlow::VectorSingle; + +template class Kokkos::View; +template class pFlow::VectorSingle; + +template class Kokkos::View; +template class pFlow::VectorSingle; + +template class Kokkos::View; +template class pFlow::VectorSingle; + diff --git a/src/phasicFlow/containers/pointField/internalField.cpp b/src/phasicFlow/containers/pointField/internalField.cpp index 6759e38e..b3c23431 100644 --- a/src/phasicFlow/containers/pointField/internalField.cpp +++ b/src/phasicFlow/containers/pointField/internalField.cpp @@ -28,7 +28,7 @@ pFlow::internalField::internalField observer ( &internal, - message::CAP_CHANGED+message::ITEM_INSERT+message::ITEM_REARRANGE+message::ITEM_DELETE + defaultMessage_ ), field_ ( @@ -41,10 +41,36 @@ pFlow::internalField::internalField internalPoints_(internal) {} - template class VectorField, class T, class MemorySpace> -pFlow::hostViewType1D - pFlow::internalField::activeValuesHost()const +pFlow::internalField::internalField +( + const word &name, + const internalPoints &internal, + const T &val +) +: + observer + ( + &internal, + defaultMessage_ + ), + field_ + ( + name, + "ineternalField", + internal.capacity(), + internal.size(), + RESERVE() + ), + internalPoints_(internal) +{ + field_.fill(val); +} + + +template