diff --git a/DEMSystems/domainDistribute/domainDistribute.cpp b/DEMSystems/domainDistribute/domainDistribute.cpp index b888f2d6..b6985243 100644 --- a/DEMSystems/domainDistribute/domainDistribute.cpp +++ b/DEMSystems/domainDistribute/domainDistribute.cpp @@ -52,11 +52,13 @@ bool pFlow::domainDistribute::locateParticles( range activeRange = mask.activeRange(); + for(int32 di=0; di return nullptr; } +bool pFlow::geometry::beforeIteration() +{ + this->zeroForce(); + return true; +} + + +bool pFlow::geometry::afterIteration() +{ + + auto Force = contactForceWall_.deviceVectorAll(); + auto area = triSurface_.area().deviceVectorAll(); + auto stress = stressWall_.deviceVectorAll(); + auto numTri =triSurface_.size(); + + + Kokkos::parallel_for( + "geometry::calculateStress", + numTri, + LAMBDA_HD(int32 i){ + stress[i] = Force[i]/area[i]; + }); + Kokkos::fence(); + return true; + +} + pFlow::uniquePtr pFlow::geometry::create( systemControl& control, diff --git a/src/Geometry/geometry/geometry.hpp b/src/Geometry/geometry/geometry.hpp index acc40dfd..a8296700 100644 --- a/src/Geometry/geometry/geometry.hpp +++ b/src/Geometry/geometry/geometry.hpp @@ -34,51 +34,68 @@ Licence: namespace pFlow { + +/** + * Base class for geometry for managing tri-surfaces, geometry motion, + * and surface physical properties. + * + */ class geometry : public demGeometry { protected: - const property& wallProperty_; + // - Protected members - // - this object is owned by geometryRepository_ - repository& geometryRepository_; + /// Const reference to physical property of materials + const property& wallProperty_; - // all triangles of walls - multiTriSurface& triSurface_; + /// Repository to store geometry data at each simulation moment + repository& geometryRepository_; - // - wordField& motionComponentName_; + /// All triangles in the set of wall surfaces + multiTriSurface& triSurface_; - // - wordField& materialName_; + /// The name of motion component of each wall surface + wordField& motionComponentName_; + + /// Material name of each wall surface + wordField& materialName_; - int8TriSurfaceField_D& propertyId_; + /// Property id of each triangle in the set of wall surfaces + int8TriSurfaceField_D& propertyId_; - realx3TriSurfaceField_D& contactForceWall_; + /// Contact force on each triangle in the set of wall surfaces + realx3TriSurfaceField_D& contactForceWall_; - realx3TriSurfaceField_D& stressWall_; + /// Stress on ech triangle in the set of wall surfaces + realx3TriSurfaceField_D& stressWall_; - bool findPropertyId(); + // - Protected member functions + + /// Find property id of each triangle based on the supplied material name + /// and the surface wall that the triangle belongs to. + bool findPropertyId(); - void zeroForce() - { - contactForceWall_.fill(zero3); - } + /// Initialize contact force to zero + void zeroForce() + { + contactForceWall_.fill(zero3); + } public: - // - type info + /// Type info TypeInfo("geometry"); - //// - Constructors + // - Constructors - // - empty + /// Construct from controlSystem and property, for reading from file geometry(systemControl& control, const property& prop); - // - from components + /// Construct from components geometry(systemControl& control, const property& prop, const multiTriSurface& triSurface, @@ -86,6 +103,8 @@ public: const wordVector& propName ); + /// Construct from components and dictionary that contains + /// motionModel geometry(systemControl& control, const property& prop, const dictionary& dict, @@ -93,9 +112,10 @@ public: const wordVector& motionCompName, const wordVector& propName); - + /// Destructor virtual ~geometry() = default; + /// Virtual constructor create_vCtor ( geometry, @@ -107,6 +127,7 @@ public: (control, prop) ); + /// Virtual constructor create_vCtor ( geometry, @@ -120,141 +141,141 @@ public: (control, prop, dict, triSurface, motionCompName, propName) ); - ////- Methods + //- Methods + /// Size of tri-surface inline auto size()const { return triSurface_.size(); } + /// Number of points in the set of surface walls inline auto numPoints()const { return triSurface_.numPoints(); } + /// Number of triangles in the set of surface walls inline auto numTriangles()const { return size(); } + /// Access to the points inline const auto& points()const { return triSurface_.points(); } + /// Access to the vertices inline const auto& vertices()const { return triSurface_.vertices(); } + /// Obtain an object for accessing triangles inline auto getTriangleAccessor()const { return triSurface_.getTriangleAccessor(); } + /// Surface inline auto& surface() { return triSurface_; } + /// Surface inline const auto& surface()const { return triSurface_; } + /// Access to contact force inline realx3TriSurfaceField_D& contactForceWall() { return contactForceWall_; } + /// Access to contact force inline const realx3TriSurfaceField_D& contactForceWall() const { return contactForceWall_; } + /// Access to property inline const auto& wallProperty()const { return wallProperty_; } - // owner repository + /// Owner repository inline const repository& owner()const { return geometryRepository_; } + /// Owner repository inline repository& owner() { return geometryRepository_; } + /// Path to the repository folder inline auto path() { return owner().path(); } + /// The name of motion model virtual word motionModelTypeName()const = 0; + /// Motion model index of triangles virtual const int8Vector_HD& triMotionIndex() const =0; + /// Motion model index of points virtual const int8Vector_HD& pointMotionIndex()const = 0; + /// Property ide of triangles const int8TriSurfaceField_D& propertyId() const { return propertyId_; } - bool beforeIteration() override { - - this->zeroForce(); - return true; - - } + /// Operations before each iteration + bool beforeIteration() override; - bool afterIteration() override { - - auto Force = contactForceWall_.deviceVectorAll(); - auto area = triSurface_.area().deviceVectorAll(); - auto stress = stressWall_.deviceVectorAll(); - auto numTri =triSurface_.size(); - + /// Operations after each iteration + bool afterIteration() override; - Kokkos::parallel_for( - "geometry::calculateStress", - numTri, - LAMBDA_HD(int32 i){ - stress[i] = Force[i]/area[i]; - }); - Kokkos::fence(); - return true; - - } + //- IO + /// write bool write()const { return owner().write(); } - // static + //- Static members static - uniquePtr create(systemControl& control, const property& prop); + uniquePtr create(systemControl& control, const property& prop); static - uniquePtr create( + uniquePtr create( systemControl& control, const property& prop, const dictionary& dict, diff --git a/src/Geometry/geometryMotion/geometryMotion.cpp b/src/Geometry/geometryMotion/geometryMotion.cpp index 60401f91..ece859df 100644 --- a/src/Geometry/geometryMotion/geometryMotion.cpp +++ b/src/Geometry/geometryMotion/geometryMotion.cpp @@ -18,38 +18,6 @@ Licence: -----------------------------------------------------------------------------*/ -template -bool pFlow::geometryMotion::moveGeometry() -{ - - real dt = this->dt(); - real t = this->currentTime(); - - auto pointMIndex= pointMotionIndex_.deviceVector(); - auto mModel = motionModel_.getModel(t); - realx3* points = triSurface_.pointsData_D(); - auto numPoints = triSurface_.numPoints(); - - - Kokkos::parallel_for( - "geometryMotion::movePoints", - numPoints, - LAMBDA_HD(int32 i){ - auto newPos = mModel.transferPoint(pointMIndex[i], points[i], dt); - points[i] = newPos; - }); - - Kokkos::fence(); - - // move the motion components - motionModel_.move(t,dt); - - // end of calculations - moveGeomTimer_.end(); - - return true; -} - template bool pFlow::geometryMotion::findMotionIndex() { @@ -88,6 +56,7 @@ bool pFlow::geometryMotion::findMotionIndex() return true; } + template pFlow::geometryMotion::geometryMotion ( @@ -180,6 +149,13 @@ pFlow::geometryMotion::geometryMotion findMotionIndex(); } +template +bool pFlow::geometryMotion::beforeIteration() +{ + geometry::beforeIteration(); + return true; +} + template bool pFlow::geometryMotion::iterate() { @@ -189,5 +165,44 @@ bool pFlow::geometryMotion::iterate() moveGeometry(); moveGeomTimer_.end(); } + return true; +} + +template +bool pFlow::geometryMotion::afterIteration() +{ + geometry::afterIteration(); + return true; +} + +template +bool pFlow::geometryMotion::moveGeometry() +{ + + real dt = this->dt(); + real t = this->currentTime(); + + auto pointMIndex= pointMotionIndex_.deviceVector(); + auto mModel = motionModel_.getModel(t); + realx3* points = triSurface_.pointsData_D(); + auto numPoints = triSurface_.numPoints(); + + + Kokkos::parallel_for( + "geometryMotion::movePoints", + numPoints, + LAMBDA_HD(int32 i){ + auto newPos = mModel.transferPoint(pointMIndex[i], points[i], dt); + points[i] = newPos; + }); + + Kokkos::fence(); + + // move the motion components + motionModel_.move(t,dt); + + // end of calculations + moveGeomTimer_.end(); + return true; } \ No newline at end of file diff --git a/src/Geometry/geometryMotion/geometryMotion.hpp b/src/Geometry/geometryMotion/geometryMotion.hpp index 2175fca8..cf47c613 100644 --- a/src/Geometry/geometryMotion/geometryMotion.hpp +++ b/src/Geometry/geometryMotion/geometryMotion.hpp @@ -17,8 +17,6 @@ Licence: implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -----------------------------------------------------------------------------*/ - - #ifndef __geometryMotion_hpp__ #define __geometryMotion_hpp__ @@ -29,7 +27,11 @@ Licence: namespace pFlow { - +/** + * A class that represent surfaces in the simulation and moves surfaces + * based on the MotionModelType. MotionModelType can be any motion model. + * + */ template class geometryMotion : @@ -41,34 +43,34 @@ public: protected: - + /// Ref to motion model MotionModel& motionModel_; - // motion indext mapped on each surface + /// motion indext mapped on each surface int32Vector_HD motionIndex_; - // motion index mapped on each triangle + /// motion index mapped on each triangle int8Vector_HD triMotionIndex_; /// motion index mapped on each point int8Vector_HD pointMotionIndex_; - // timer for moveGeometry + /// timer for moveGeometry Timer moveGeomTimer_; - + /// determine the motion index of each triangle bool findMotionIndex(); public: - // type info + /// Type info TypeInfoTemplate("geometry", MotionModel); - //// - Constructors + // - Constructors geometryMotion(systemControl& control, const property& prop); - // construct from components + geometryMotion( systemControl& control, const property& prop, @@ -77,17 +79,16 @@ public: const wordVector& propName, const MotionModel& motionModel); - // - construct from components and dictionary that contains - // motionModel + /// Construct from components and dictionary that contains + /// motionModel geometryMotion(systemControl& control, const property& prop, const dictionary& dict, const multiTriSurface& triSurface, const wordVector& motionCompName, const wordVector& propName); - - + /// Add virtual constructor add_vCtor ( geometry, @@ -95,6 +96,7 @@ public: systemControl ); + /// Add virtual constructor add_vCtor ( geometry, @@ -102,48 +104,47 @@ public: dictionary ); - //// - Methods + // - Methods - auto getModel(real t)const - { - return motionModel_.getModel(t); - } + /// Obtain motion model at time t + auto getModel(real t)const + { + return motionModel_.getModel(t); + } - word motionModelTypeName()const override - { - return motionModel_.typeName(); - } + /// TypeName / TypeInfo of motion model + word motionModelTypeName()const override + { + return motionModel_.typeName(); + } - const int8Vector_HD& triMotionIndex()const override - { - return triMotionIndex_; - } + /// Access to motion model index of triangles + const int8Vector_HD& triMotionIndex()const override + { + return triMotionIndex_; + } - const int8Vector_HD& pointMotionIndex()const override - { - return pointMotionIndex_; - } + /// Access to motion model index of points + const int8Vector_HD& pointMotionIndex()const override + { + return pointMotionIndex_; + } - // - iterate - bool beforeIteration() override { - geometry::beforeIteration(); - return true; - } + /// Operations before each iteration + bool beforeIteration() override; - bool iterate() override ; + /// Iterate geometry one time step + bool iterate() override ; - bool afterIteration() override { - geometry::afterIteration(); - return true; - } + /// Operations after each iteration + bool afterIteration() override; - - bool moveGeometry(); + /// Move geometry + bool moveGeometry(); }; - -} +} // pFlow #include "geometryMotion.cpp" diff --git a/src/Particles/CMakeLists.txt b/src/Particles/CMakeLists.txt index 09257ef9..9c23631f 100644 --- a/src/Particles/CMakeLists.txt +++ b/src/Particles/CMakeLists.txt @@ -2,6 +2,7 @@ set(SourceFiles dynamicPointStructure/dynamicPointStructure.cpp particles/particles.cpp +particles/particleIdHandler.cpp SphereParticles/sphereShape/sphereShape.cpp SphereParticles/sphereParticles/sphereParticles.cpp Insertion/shapeMixture/shapeMixture.cpp diff --git a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp index f4908782..cfa0ea80 100644 --- a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp +++ b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp @@ -77,7 +77,7 @@ bool pFlow::sphereParticles::initializeParticles() 0, static_cast(shapeName_.size())); - return insertSphereParticles(shapeName_, indices); + return insertSphereParticles(shapeName_, indices, false); } @@ -119,11 +119,11 @@ bool pFlow::sphereParticles::iterate() accelerationTimer_.end(); intCorrectTimer_.start(); - //INFO<<"before correct dyn "<dt(), accelertion_); - //INFO<<"after correct dyn "<dt(), rVelocity_, rAcceleration_); - //INFO<<"after correct rvel "<> getFieldObjectList()const override; diff --git a/src/Particles/particles/particleIdHandler.cpp b/src/Particles/particles/particleIdHandler.cpp new file mode 100644 index 00000000..71dec22a --- /dev/null +++ b/src/Particles/particles/particleIdHandler.cpp @@ -0,0 +1,58 @@ +/*------------------------------- 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 "particleIdHandler.hpp" + + + +pFlow::particleIdHandler::particleIdHandler(int32PointField_HD & id) +{ + int32 maxID = maxActive(id); + + if( maxID != -1 && id.size() == 0 ) + { + nextId_ = 0; + } + else if( maxID == -1 && id.size()>0 ) + { + + nextId_ = 0; + id.modifyOnHost(); + + ForAll(i,id) + { + if(id.isActive(i)) + { + id[i] = getNextId(); + } + } + + id.syncViews(); + } + else if( maxID >= static_cast(id.size()) ) + { + nextId_ = maxID + 1; + } + else + { + nextId_ = id.size(); + } +} + diff --git a/src/Particles/particles/particleIdHandler.hpp b/src/Particles/particles/particleIdHandler.hpp index abe708b4..d93e6b1f 100644 --- a/src/Particles/particles/particleIdHandler.hpp +++ b/src/Particles/particles/particleIdHandler.hpp @@ -32,39 +32,8 @@ class particleIdHandler protected: int32 nextId_=0; public: - particleIdHandler(int32PointField_HD & id) - { - int32 maxID = maxActive(id); - - if( maxID != -1 && id.size() == 0 ) - { - nextId_ = 0; - } - else if( maxID == -1 && id.size()>0 ) - { - nextId_ = 0; - id.modifyOnHost(); - - ForAll(i,id) - { - if(id.isActive(i)) - { - id[i] = getNextId(); - } - } - - id.syncViews(); - } - else if( maxID >= static_cast(id.size()) ) - { - nextId_ = maxID + 1; - } - else - { - nextId_ = id.size(); - } - } - + particleIdHandler(int32PointField_HD & id); + int32 getNextId() { return nextId_++; diff --git a/src/Particles/particles/particles.cpp b/src/Particles/particles/particles.cpp index ae6e89c1..d5c3bb45 100644 --- a/src/Particles/particles/particles.cpp +++ b/src/Particles/particles/particles.cpp @@ -150,6 +150,35 @@ pFlow::particles::particles } +bool pFlow::particles::beforeIteration() +{ + auto domain = this->control().domain(); + + auto numMarked = dynPointStruct_.markDeleteOutOfBox(domain); + + if(time_.sortTime()) + { + real min_dx, max_dx; + boundingSphereMinMax(min_dx, max_dx); + Timer t; + t.start(); + REPORT(0)<<"Performing morton sorting on particles ...."<zeroForce(); + this->zeroTorque(); + + return true; +} + pFlow::uniquePtr> pFlow::particles::getFieldObjectList()const { diff --git a/src/Particles/particles/particles.hpp b/src/Particles/particles/particles.hpp index 0cfcdf57..7b207c50 100644 --- a/src/Particles/particles/particles.hpp +++ b/src/Particles/particles/particles.hpp @@ -241,21 +241,7 @@ public: return shapeName_; } - bool beforeIteration() override - { - auto domain = this->control().domain(); - - auto numMarked = dynPointStruct_.markDeleteOutOfBox(domain); - /*if(numMarked) - { - output<<"\nNumber of deleted points/particles that are out of domain box: "<zeroForce(); - this->zeroTorque(); - - return true; - } + bool beforeIteration() override; virtual bool insertParticles diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt index 34103498..b6b68815 100644 --- a/src/phasicFlow/CMakeLists.txt +++ b/src/phasicFlow/CMakeLists.txt @@ -45,12 +45,14 @@ repository/IOobject/IOobject.cpp repository/IOobject/IOfileHeader.cpp structuredData/box/box.cpp +structuredData/cells/cells.cpp structuredData/cylinder/cylinder.cpp structuredData/sphere/sphere.cpp structuredData/iBox/iBoxs.cpp structuredData/line/line.cpp structuredData/zAxis/zAxis.cpp structuredData/pointStructure/pointStructure.cpp +structuredData/pointStructure/mortonIndexing.cpp structuredData/pointStructure/selectors/pStructSelector/pStructSelector.cpp structuredData/pointStructure/selectors/selectBox/selectBox.cpp structuredData/pointStructure/selectors/selectRange/selectRange.cpp diff --git a/src/phasicFlow/Kokkos/KokkosTypes.hpp b/src/phasicFlow/Kokkos/KokkosTypes.hpp index b378124d..4f59872f 100644 --- a/src/phasicFlow/Kokkos/KokkosTypes.hpp +++ b/src/phasicFlow/Kokkos/KokkosTypes.hpp @@ -26,6 +26,8 @@ Licence: #include #include +#include "iOstream.hpp" + namespace pFlow { @@ -51,9 +53,12 @@ using DefaultExecutionSpace = Kokkos::DefaultExecutionSpace; template using kPair = Kokkos::pair; -using range = kPair; +template + using kRange = kPair; -using range64 = kPair; +using range = kRange; + +using range64 = kRange; template using ViewTypeScalar = Kokkos::View; @@ -132,6 +137,13 @@ using deviceAtomicViewType3D = T***, Kokkos::MemoryTraits::value?0:Kokkos::Atomic>>; +template +iOstream& operator <<(iOstream& os, const kRange& rng) +{ + os<<"["<(pFirst, numElems, static_cast(0)); - sort(pFirst, numElems, compare); + fillSequence(pFirst, numElems, static_cast(0)); + sort(pFirst, numElems, compare); } diff --git a/src/phasicFlow/containers/Field/Field.cpp b/src/phasicFlow/containers/Field/Field.cpp index 2acd3fb0..5569ea9b 100644 --- a/src/phasicFlow/containers/Field/Field.cpp +++ b/src/phasicFlow/containers/Field/Field.cpp @@ -82,11 +82,8 @@ bool pFlow::Field::readNonUniform return false; } - this->clear(); - VectorType::read(is); - + VectorType::readVector(is, flen); is.readEndStatement("readField"); - if( this->size() != flen ) { ioErrorInFile( is.name(), is.lineNumber() ) << @@ -94,6 +91,7 @@ bool pFlow::Field::readNonUniform this->size() << " elements in file "<< is.name() <::readField ( iIstream& is, const size_t len, + bool resume, bool readLength ) { - if( !is.findToken(fieldKey_) ) + + bool tokenFound; + if( resume ) + tokenFound = is.findTokenResume(fieldKey_); + else + tokenFound = is.findToken(fieldKey_); + + if( !tokenFound ) { ioErrorInFile( is.name(), is.lineNumber() ) << " error in searching for filedkey " << fieldKey_<::readField template class VectorField, class T, class PropType> bool pFlow::Field::readField ( - iIstream& is + iIstream& is, + bool resume ) { - return readField(is, 0, true); + return readField(is, 0, resume ,true); } template class VectorField, class T, class PropType> bool pFlow::Field::writeField(iOstream& os)const { + os.writeWordKeyword(fieldKey_) << nonUniform__<size()< class VectorField, class T, class PropType> inline iIstream& operator >> (iIstream & is, Field & ifld ) { - if( !ifld.readField(is) ) + if( !ifld.readField(is, false) ) { ioErrorInFile (is.name(), is.lineNumber()); fatalExit; diff --git a/src/phasicFlow/containers/Vector/Vector.cpp b/src/phasicFlow/containers/Vector/Vector.cpp index f979f5f3..7c0c9db3 100644 --- a/src/phasicFlow/containers/Vector/Vector.cpp +++ b/src/phasicFlow/containers/Vector/Vector.cpp @@ -28,59 +28,70 @@ pFlow::Vector::Vector(iIstream& is) template bool pFlow::Vector::readVector ( - iIstream& is + iIstream& is, + size_t len ) { - this->clear(); + - is.fatalCheck(FUNCTION_NAME); - - token firstToken(is); - - T val{}; - if( firstToken.isPunctuation() ) // start of vector + if(is.isBinary() && !std::is_same_v) { - if(firstToken != token::BEGIN_LIST) + this->resize(len); + is.read(reinterpret_cast(this->data()), this->size()*sizeof(T)); + } + else + { + this->clear(); + is.fatalCheck(FUNCTION_NAME); + + token firstToken(is); + + T val{}; + if( firstToken.isPunctuation() ) // start of vector + { + if(firstToken != token::BEGIN_LIST) + { + warningInFunction + << "expected token "<< token::BEGIN_LIST + << " but found "<< firstToken ; + return false; + + } + + token lastToken(is); + + + is.fatalCheck(FUNCTION_NAME); + + while + ( !( + lastToken.isPunctuation() + && lastToken == token::END_LIST + + ) + ) + { + + is.putBack(lastToken); + + is >> val; + this->push_back(val); + + is >> lastToken; + is.fatalCheck(FUNCTION_NAME); + } + + } else { warningInFunction << "expected token "<< token::BEGIN_LIST << " but found "<< firstToken ; return false; - } - - token lastToken(is); - - - is.fatalCheck(FUNCTION_NAME); - - while - ( !( - lastToken.isPunctuation() - && lastToken == token::END_LIST - - ) - ) - { - - is.putBack(lastToken); - - is >> val; - this->push_back(val); - - is >> lastToken; - is.fatalCheck(FUNCTION_NAME); - } - - } else - { - warningInFunction - << "expected token "<< token::BEGIN_LIST - << " but found "<< firstToken ; - return false; - } + + return true; } @@ -91,30 +102,35 @@ bool pFlow::Vector::writeVector iOstream& os ) const { - - - auto len = size(); - auto stride = getVectorStride(len); - // start of - os << token::BEGIN_LIST; - label i = 0; - while( i) + { + os.write(reinterpret_cast(this->data()), this->size()*sizeof(T)); + } + else { - os << this->operator[](i++); - for(label j=0; joperator[](i++); + + os << this->operator[](i++); + for(label j=0; joperator[](i++); + } + + if(i::deleteElement return false; } +template +void pFlow::Vector::sortItems( + const int32IndexContainer& indices) +{ + if(indices.size() == 0) + { + this->resize(0); + return; + } + size_t newSize = indices.size(); + auto hIndices = indices.hostView(); + VectorType sortedVec(name(), capacity(), newSize, RESERVE()); + + ForAll(i, hIndices) + { + sortedVec[i] = vectorType::operator[](i); + } + *this = std::move(sortedVec); +} + template bool pFlow::Vector::insertSetElement( const int32IndexContainer& indices, diff --git a/src/phasicFlow/containers/Vector/Vector.hpp b/src/phasicFlow/containers/Vector/Vector.hpp index c0b1f17a..c8d354ee 100644 --- a/src/phasicFlow/containers/Vector/Vector.hpp +++ b/src/phasicFlow/containers/Vector/Vector.hpp @@ -291,6 +291,8 @@ public: return *this; } + + const word& name()const { return name_; @@ -323,6 +325,9 @@ public: // return false if out of range bool deleteElement(label index); + /// Sort elements based on the indices + void sortItems(const int32IndexContainer& indices); + // - set or insert new elements into the vector // return false if it fails bool insertSetElement(const int32IndexContainer& indices, const T& val); @@ -369,9 +374,7 @@ public: // from iIstream and free size Vector(iIstream& is); - //bool readVector(iIstream & is, size_t len); - - bool readVector(iIstream& is); + bool readVector(iIstream& is, size_t len=0); bool writeVector(iOstream& os) const; diff --git a/src/phasicFlow/containers/VectorHD/VectorDual.hpp b/src/phasicFlow/containers/VectorHD/VectorDual.hpp index a5310bd7..aa39549e 100644 --- a/src/phasicFlow/containers/VectorHD/VectorDual.hpp +++ b/src/phasicFlow/containers/VectorHD/VectorDual.hpp @@ -128,7 +128,7 @@ protected: // use actualCap = true only for reserve INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false) { - if(n >= capacity_ ) + if(n > capacity_ ) { if(actualCap) capacity_ = n; @@ -545,6 +545,36 @@ public: return true; } + INLINE_FUNCTION_H + void sortItems(const int32IndexContainer& indices) + { + if(indices.size() == 0) + { + setSize(0); + return; + } + size_t newSize = indices.size(); + + deviceViewType sortedView("sortedView", newSize); + auto dVec = deviceVectorAll(); + + auto d_indices = indices.deviceView(); + + Kokkos::parallel_for( + "sortItems", + newSize, + LAMBDA_HD(int32 i){ + sortedView[i] = dVec[d_indices[i]]; + } + ); + + Kokkos::fence(); + setSize(newSize); + copy(deviceVector(), sortedView); + modifyOnDevice(); + syncViews(); + } + INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer& indices, const T& val) { @@ -744,7 +774,11 @@ public: syncToHost(); modifyOnHost(); - if(size_ == capacity_) changeSize(capacity_); + if(size_ == capacity_) + { + changeSize(evalCapacity(capacity_), true); + + } data()[size_++] = val; subViewsUpdated_ = false; @@ -898,16 +932,24 @@ public: //// - IO operations FUNCTION_H - bool read(iIstream& is) + bool readVector( + iIstream& is, + size_t len=0) { Vector vecFromFile; - if( !vecFromFile.read(is) ) return false; + if( !vecFromFile.readVector(is,len) ) return false; this->assign(vecFromFile); return true; } + FUNCTION_H + bool read(iIstream& is) + { + return readVector(is); + } + FUNCTION_H bool write(iOstream& os) const { diff --git a/src/phasicFlow/containers/VectorHD/VectorSingle.hpp b/src/phasicFlow/containers/VectorHD/VectorSingle.hpp index ab6df542..e0d14127 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingle.hpp +++ b/src/phasicFlow/containers/VectorHD/VectorSingle.hpp @@ -28,6 +28,8 @@ Licence: #include "Vector.hpp" #include "indexContainer.hpp" +#include "streams.hpp" + #include "KokkosTypes.hpp" #include "ViewAlgorithms.hpp" @@ -106,7 +108,7 @@ protected: // use actualCap = true only for reserve INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false) { - if(n >= capacity_ ) + if(n > capacity_ ) { if(actualCap) capacity_ = n; @@ -556,6 +558,41 @@ public: return false; } + INLINE_FUNCTION_H + void sortItems(const int32IndexContainer& indices) + { + if(indices.size() == 0) + { + setSize(0); + return; + } + + size_t newSize = indices.size(); + viewType sortedView("sortedView", newSize); + + using policy = Kokkos::RangePolicy< + execution_space, + Kokkos::IndexType >; + + auto d_indices = indices.deviceView(); + auto d_view = view_; + Kokkos::parallel_for( + "sortItems", + newSize, + LAMBDA_HD(int32 i){ + sortedView(i) = d_view(d_indices(i)); + }); + + Kokkos::fence(); + + setSize(newSize); + + copy(deviceVector(), sortedView); + + return; + + } + INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer& indices, const Vector& vals) { @@ -565,7 +602,8 @@ public: if(indices.size() != vals.size())return false; auto maxInd = indices.max(); - + /*output<<"maxInd "<< maxInd<empty() || maxInd > size()-1 ) { resize(maxInd+1); @@ -707,7 +745,10 @@ public: void>::type push_back(const T& val) { - if(size_ == capacity_) changeSize(capacity_); + if(size_ == capacity_) + { + changeSize(evalCapacity(capacity_), true); + } data()[size_++] = val; subViewUpdated_ = false; } @@ -789,16 +830,24 @@ public: //// - IO operations FUNCTION_H - bool read(iIstream& is) + bool readVector( + iIstream& is, + size_t len=0) { Vector vecFromFile; - if( !vecFromFile.read(is) ) return false; + if( !vecFromFile.readVector(is,len) ) return false; this->assign(vecFromFile); return true; } + FUNCTION_H + bool read(iIstream& is) + { + return readVector(is); + } + FUNCTION_H bool write(iOstream& os)const { diff --git a/src/phasicFlow/containers/indexContainer/indexContainer.cpp b/src/phasicFlow/containers/indexContainer/indexContainer.cpp index 15d717b2..744f45a9 100644 --- a/src/phasicFlow/containers/indexContainer/indexContainer.cpp +++ b/src/phasicFlow/containers/indexContainer/indexContainer.cpp @@ -18,4 +18,7 @@ Licence: -----------------------------------------------------------------------------*/ -#include "indexContainer.hpp" \ No newline at end of file +#include "indexContainer.hpp" + + +template class pFlow::indexContainer; \ No newline at end of file diff --git a/src/phasicFlow/containers/indexContainer/indexContainer.hpp b/src/phasicFlow/containers/indexContainer/indexContainer.hpp index 14e88726..7b517a5a 100644 --- a/src/phasicFlow/containers/indexContainer/indexContainer.hpp +++ b/src/phasicFlow/containers/indexContainer/indexContainer.hpp @@ -43,6 +43,10 @@ public: // - viewType of data on host using HostViewType = typename DualViewType::t_host; + using HostType = typename HostViewType::device_type; + + using DeviceType = typename DeviceViewType::device_type; + template class IndexAccessor { @@ -99,7 +103,11 @@ public: indexContainer(const indexContainer&) = default; - indexContainer& operator = (const indexContainer&) = default; + indexContainer& operator = (const indexContainer&) = default; + + indexContainer(indexContainer&&) = default; + + indexContainer& operator = (indexContainer&&) = default; ~indexContainer() = default; @@ -150,6 +158,16 @@ public: return views_.d_view; } + HostViewType& hostView() + { + return views_.h_view; + } + + DeviceViewType& deviceView() + { + return views_.d_view; + } + auto indicesHost()const { return IndexAccessor(views_.h_view); @@ -157,7 +175,45 @@ public: auto indicesDevice()const { - return IndexAccessor(views_.d_veiw); + return IndexAccessor(views_.d_view); + } + + void modifyOnHost() + { + views_.modify_host(); + } + + void modifyOnDevice() + { + views_.modify_device(); + } + + void syncViews() + { + bool findMinMax = false; + if(views_.template need_sync()) + { + Kokkos::deep_copy(views_.d_view, views_.h_view); + findMinMax = true; + } + else if(views_.template need_sync()) + { + Kokkos::deep_copy(views_.h_view, views_.d_view); + findMinMax = true; + } + + if(findMinMax) + { + min_ = pFlow::min(views_.d_view, 0, size_); + max_ = pFlow::max(views_.d_view, 0, size_); + } + } + + size_t setSize(size_t ns) + { + auto tmp = size_; + size_ = ns; + return tmp; } }; diff --git a/src/phasicFlow/containers/pointField/pointField.cpp b/src/phasicFlow/containers/pointField/pointField.cpp index 41c5230b..bc0a62e0 100644 --- a/src/phasicFlow/containers/pointField/pointField.cpp +++ b/src/phasicFlow/containers/pointField/pointField.cpp @@ -123,6 +123,13 @@ bool pFlow::pointField::update(const eventMessage& //Vector vals( newElems.size(), defaultValue_); return this->insertSetElement(newElems, defaultValue_); } + + if(msg.isRearranged()) + { + auto sortedIndex = pStruct().mortonSortedIndex(); + this->sortItems(sortedIndex); + return true; + } return true; } diff --git a/src/phasicFlow/repository/IOobject/IOfileHeader.cpp b/src/phasicFlow/repository/IOobject/IOfileHeader.cpp index a30daa8e..2aae5642 100644 --- a/src/phasicFlow/repository/IOobject/IOfileHeader.cpp +++ b/src/phasicFlow/repository/IOobject/IOfileHeader.cpp @@ -24,22 +24,24 @@ Licence: pFlow::uniquePtr pFlow::IOfileHeader::inStream()const { if( fileExist() ) - return makeUnique(path()); + return makeUnique(path(), inFileBinary()); else return nullptr; } pFlow::uniquePtr pFlow::IOfileHeader::outStream()const { - auto osPtr = makeUnique(path()); - if(osPtr && owner_) - { + + auto osPtr = makeUnique(path(), outFileBinary()); + + if(osPtr && owner_) + { auto outPrecision = owner_->outFilePrecision(); osPtr->precision(outPrecision); - } + } - return osPtr; + return osPtr; } pFlow::IOfileHeader::IOfileHeader @@ -68,6 +70,19 @@ pFlow::fileSystem pFlow::IOfileHeader::path() const return f; } +bool pFlow::IOfileHeader::outFileBinary()const +{ + if(owner_) + return owner_->outFileBinary(); + else + return false; +} + +bool pFlow::IOfileHeader::inFileBinary()const +{ + return toUpper(fileFormat_) == "BINARY"; +} + bool pFlow::IOfileHeader::headerOk(bool silent) { if(!fileExist()) @@ -130,6 +145,15 @@ bool pFlow::IOfileHeader::writeHeader(iOstream& os, const word& typeName) const os.writeWordEntry("objectName", name() ); os.fatalCheck("writing objectName"); + word fileFormat; + if(outFileBinary()) + fileFormat = "Binary"; + else + fileFormat = "ASCII"; + + os.writeWordEntry("fileFormat", fileFormat); + os.fatalCheck("writing fileFormat"); + writeSeparator(os); return true; } @@ -164,6 +188,18 @@ bool pFlow::IOfileHeader::readHeader(iIstream& is, bool silent) return false; } + + if( !is.findTokenAndNextSilent("fileFormat", fileFormat_) ) + { + if(!silent) + { + warningInFunction << + "cannot find/error in reading fileFormat in file "<< + is.name()<("writeFormat", "ASCII")); + + if(wF == "ASCII") + outFormatBinary_ = false; + else if(wF == "BINARY") + outFormatBinary_ = true; + else + { + fatalErrorInFunction<< + "Invalid writeFormat in file "<< dict.name()<(1.0)) ) - { checkForOutputToFile(); } @@ -95,6 +103,15 @@ pFlow::timeControl::timeControl( ( startTime_, dict.getValOrSet("timersReportInterval", 0.04) + ), + performSorting_ + ( + dict.getValOrSet("performSorting", Logical("No")) + ), + sortingInterval_ + ( + startTime_, + dict.getValOrSet("sortingInterval", static_cast(1.0)) ) { checkForOutputToFile(); @@ -160,6 +177,11 @@ bool pFlow::timeControl::timersReportTime()const return timersReportInterval_.isMember(currentTime_, dt_); } +bool pFlow::timeControl::sortTime()const +{ + return performSorting_()&&sortingInterval_.isMember(currentTime_,dt_); +} + void pFlow::timeControl::setSaveTimeFolder( bool saveToFile, const word& timeName) diff --git a/src/phasicFlow/repository/Time/timeControl.hpp b/src/phasicFlow/repository/Time/timeControl.hpp index b3ac5c1b..9503d8ea 100644 --- a/src/phasicFlow/repository/Time/timeControl.hpp +++ b/src/phasicFlow/repository/Time/timeControl.hpp @@ -74,9 +74,13 @@ protected: real writeTime_ = 0; // for managedExternamly - realStridedRange timersReportInterval_; + realStridedRange timersReportInterval_; - int32StridedRagne screenReportInterval_ ={0,100}; + Logical performSorting_; + + realStridedRange sortingInterval_; + + int32StridedRagne screenReportInterval_ ={0,100}; bool outputToFile_ = false; @@ -164,6 +168,8 @@ public: } bool timersReportTime()const; + + bool sortTime()const; bool setOutputToFile(real writeTime, const word& timeName) { diff --git a/src/phasicFlow/repository/repository/repository.hpp b/src/phasicFlow/repository/repository/repository.hpp index ae9c059d..b257e692 100644 --- a/src/phasicFlow/repository/repository/repository.hpp +++ b/src/phasicFlow/repository/repository/repository.hpp @@ -204,7 +204,15 @@ public: // list of repository names in this repository wordList repositoryNames()const; + //// - IO operations + virtual bool outFileBinary()const + { + if(owner_) + return owner_->outFileBinary(); + else + return false; + } virtual bool write(bool verbose = false) const; }; diff --git a/src/phasicFlow/streams/Fstream/fileStream.cpp b/src/phasicFlow/streams/Fstream/fileStream.cpp index 3a39783a..8edf2d3a 100755 --- a/src/phasicFlow/streams/Fstream/fileStream.cpp +++ b/src/phasicFlow/streams/Fstream/fileStream.cpp @@ -24,7 +24,7 @@ Licence: #include "fileStream.hpp" #include "error.hpp" - +#include "streams.hpp" void pFlow::fileStream::openInFile ( @@ -39,7 +39,12 @@ void pFlow::fileStream::openInFile fatalExit; } - inStream_ = makeUnique( path.wordPath(), std::ios_base::in); + if(binary_) + inStream_ = makeUnique( + path.wordPath(), std::ios_base::in | std::ios_base::binary); + else + inStream_ = makeUnique( + path.wordPath(), std::ios_base::in); if( !inStream_->is_open()) { @@ -66,7 +71,15 @@ void pFlow::fileStream::openOutFile dir.createDirs(); } - outStream_ = makeUnique< std::ofstream>(path.wordPath(), std::ios_base::out); + if(binary_) + { + outStream_ = makeUnique< std::ofstream>( + path.wordPath(), std::ios_base::out| std::ios::binary); + } + else + outStream_ = makeUnique< std::ofstream>( + path.wordPath(), std::ios_base::out); + if(!outStream_->is_open()) { @@ -92,11 +105,13 @@ void pFlow::fileStream::close() pFlow::fileStream::fileStream ( const fileSystem& path, - bool outStream + bool outStream, + bool binary ) : inStream_(nullptr), - outStream_(nullptr) + outStream_(nullptr), + binary_(binary) { if(outStream) diff --git a/src/phasicFlow/streams/Fstream/fileStream.hpp b/src/phasicFlow/streams/Fstream/fileStream.hpp index 560da9ee..8804200c 100755 --- a/src/phasicFlow/streams/Fstream/fileStream.hpp +++ b/src/phasicFlow/streams/Fstream/fileStream.hpp @@ -43,6 +43,8 @@ protected: // - out file stream uniquePtr outStream_; + bool binary_ = false; + // - open input file void openInFile(const fileSystem& path); @@ -56,7 +58,7 @@ public: // - Constructors - fileStream( const fileSystem& path, bool outStream = false); + fileStream( const fileSystem& path, bool outStream = false, bool binary = false); fileStream(const fileStream&)= delete; diff --git a/src/phasicFlow/streams/Fstream/iFstream.cpp b/src/phasicFlow/streams/Fstream/iFstream.cpp index 09008735..2eb0a4fe 100755 --- a/src/phasicFlow/streams/Fstream/iFstream.cpp +++ b/src/phasicFlow/streams/Fstream/iFstream.cpp @@ -24,9 +24,17 @@ Licence: #include "iFstream.hpp" -pFlow::iFstream::iFstream (const fileSystem& path) +pFlow::iFstream::iFstream +( + const fileSystem& path, + bool binary) : - fileStream(path), - Istream( fileStream::inStream(), path.wordPath()) + fileStream(path, false, binary), + Istream + ( + fileStream::inStream(), + path.wordPath(), + (binary)? BINARY : ASCII + ) { } \ No newline at end of file diff --git a/src/phasicFlow/streams/Fstream/iFstream.hpp b/src/phasicFlow/streams/Fstream/iFstream.hpp index 253a4a36..a37baf81 100755 --- a/src/phasicFlow/streams/Fstream/iFstream.hpp +++ b/src/phasicFlow/streams/Fstream/iFstream.hpp @@ -40,7 +40,7 @@ class iFstream public: // - Constructor - iFstream (const fileSystem& path); + iFstream (const fileSystem& path, bool binary = false); // no copy constructor iFstream( const iFstream& src) = delete; diff --git a/src/phasicFlow/streams/Fstream/oFstream.cpp b/src/phasicFlow/streams/Fstream/oFstream.cpp index 3d1cbe9a..5e975843 100755 --- a/src/phasicFlow/streams/Fstream/oFstream.cpp +++ b/src/phasicFlow/streams/Fstream/oFstream.cpp @@ -24,11 +24,13 @@ Licence: #include "oFstream.hpp" -pFlow::oFstream::oFstream (const fileSystem& path) +pFlow::oFstream::oFstream (const fileSystem& path, bool binary) : - fileStream(path, true), - Ostream( fileStream::outStream(), path.wordPath()) -{ - - -} \ No newline at end of file + fileStream(path, true, binary), + Ostream + ( + fileStream::outStream(), + path.wordPath(), + (binary)? BINARY : ASCII + ) +{} \ No newline at end of file diff --git a/src/phasicFlow/streams/Fstream/oFstream.hpp b/src/phasicFlow/streams/Fstream/oFstream.hpp index 2a25e5de..0fa6d86d 100755 --- a/src/phasicFlow/streams/Fstream/oFstream.hpp +++ b/src/phasicFlow/streams/Fstream/oFstream.hpp @@ -41,7 +41,7 @@ class oFstream public: // Constructor - oFstream (const fileSystem& path); + oFstream (const fileSystem& path, bool binary = false); // no copy constructor oFstream( const oFstream& src) = delete; diff --git a/src/phasicFlow/streams/Stream/Istream.cpp b/src/phasicFlow/streams/Stream/Istream.cpp index 748ae06f..06e3a4ed 100755 --- a/src/phasicFlow/streams/Stream/Istream.cpp +++ b/src/phasicFlow/streams/Stream/Istream.cpp @@ -307,10 +307,11 @@ pFlow::Istream& pFlow::Istream::readVariable(word& str) pFlow::Istream::Istream ( std::istream& is, - const word& streamName + const word& streamName, + writeFormat wf ) : - iIstream(), + iIstream(wf), name_(streamName), is_(is) { @@ -846,6 +847,26 @@ pFlow::iIstream& pFlow::Istream::read(double& val) return *this; } +pFlow::iIstream& pFlow::Istream::read +( + char* buffer, + std::streamsize count +) +{ + if ( !isBinary() ) + { + fatalErrorInFunction<<"stream format is not binray. Stream name is "<< + name()<<'\n'; + fatalExit; + } + + readBegin("binaryBlock"); + is_.read(buffer, count); + readEnd("binaryBlock"); + + setState(is_.rdstate()); + return *this; +} void pFlow::Istream::rewind() { diff --git a/src/phasicFlow/streams/Stream/Istream.hpp b/src/phasicFlow/streams/Stream/Istream.hpp index a65d080b..ae2bcab8 100755 --- a/src/phasicFlow/streams/Stream/Istream.hpp +++ b/src/phasicFlow/streams/Stream/Istream.hpp @@ -65,8 +65,7 @@ public: //- Construct wrapper around std::istream, set stream status - Istream( std::istream& is, const word& streamName); - + Istream( std::istream& is, const word& streamName, writeFormat wf = ASCII); //- Destructor virtual ~Istream() = default; @@ -150,6 +149,8 @@ public: //- Read a double virtual iIstream& read(double& val) override; + iIstream& read(char* buffer, std::streamsize count) override; + //- Rewind the stream so that it may be read again virtual void rewind(); diff --git a/src/phasicFlow/streams/Stream/Ostream.cpp b/src/phasicFlow/streams/Stream/Ostream.cpp index 75e4f477..51f2f28d 100755 --- a/src/phasicFlow/streams/Stream/Ostream.cpp +++ b/src/phasicFlow/streams/Stream/Ostream.cpp @@ -28,10 +28,11 @@ Licence: pFlow::Ostream::Ostream ( std::ostream& os, - const word& streamName + const word& streamName, + writeFormat wF ) : - iOstream(), + iOstream(wF), name_(streamName), os_(os) { @@ -230,6 +231,29 @@ pFlow::iOstream& pFlow::Ostream::write(const double val) return *this; } +pFlow::iOstream& pFlow::Ostream::write +( + const char* binaryData, + std::streamsize count +) +{ + if ( !isBinary() ) + { + fatalErrorInFunction<<"stream format is not binray. Stream name is "<< + name()<<'\n'; + fatalExit; + } + + os_ << token::BEGIN_LIST; + os_.write(binaryData, count); + os_ << token::END_LIST; + + setState(os_.rdstate()); + + return *this; +} + + void pFlow::Ostream::indent() diff --git a/src/phasicFlow/streams/Stream/Ostream.hpp b/src/phasicFlow/streams/Stream/Ostream.hpp index e34c521b..727b65e4 100755 --- a/src/phasicFlow/streams/Stream/Ostream.hpp +++ b/src/phasicFlow/streams/Stream/Ostream.hpp @@ -46,7 +46,7 @@ public: // Constructors - Ostream ( std::ostream& os, const word& streamName); + Ostream ( std::ostream& os, const word& streamName, writeFormat wf = ASCII); //- no copy construct Ostream(const Ostream&) = delete; @@ -75,79 +75,80 @@ public: //- Write token to stream or otherwise handle it. // return false if the token type was not handled by this method - virtual bool write(const token& tok)override; + bool write(const token& tok)override; //- Write character - virtual iOstream& write(const char c)override; + iOstream& write(const char c)override; //- Write character string - virtual iOstream& write(const char* str)override; + iOstream& write(const char* str)override; //- Write word - virtual iOstream& write(const word& str)override; + iOstream& write(const word& str)override; //- Write std::string surrounded by quotes. // Optional write without quotes. - virtual iOstream& writeQuoted ( const word& str, const bool quoted=true )override; + iOstream& writeQuoted ( const word& str, const bool quoted=true ) override; //- Write int64 - virtual iOstream& write(const int64 val) override; + iOstream& write(const int64 val) override; //- Write int32 - virtual iOstream& write(const int32 val) override; - + iOstream& write(const int32 val) override; //- Write label - virtual iOstream& write(const label val) override; + iOstream& write(const label val) override; //- Write uint32 - virtual iOstream& write(const uint32 val) override; + iOstream& write(const uint32 val) override; //- Write uint16 - virtual iOstream& write(const uint16 val) override; + iOstream& write(const uint16 val) override; //- Write float - virtual iOstream& write(const float val) override; + iOstream& write(const float val) override; //- Write double - virtual iOstream& write(const double val) override; + iOstream& write(const double val) override; + + /// Write a block of binray data + iOstream& write(const char* binaryData, std::streamsize count) override; //- Add indentation characters - virtual void indent(); - + void indent() override; //- Set stream flags - virtual ios_base::fmtflags flags(const ios_base::fmtflags f); + ios_base::fmtflags flags(const ios_base::fmtflags f) override; //- Flush stream - virtual void flush(); + void flush() override; //- Add newline and flush stream - virtual void endl(); + void endl() override; //- Get the current padding character - virtual char fill() const; + char fill() const override; //- Set padding character for formatted field up to field width // \return previous padding character - virtual char fill(const char fillch); + char fill(const char fillch) override; //- Get width of output field - virtual int width() const; + int width() const override; //- Set width of output field // \return previous width - virtual int width(const int w); + int width(const int w) override; //- Get precision of output field - virtual int precision() const; + int precision() const override; //- Set precision of output field // return old precision - virtual int precision(const int p); + int precision(const int p) override; //- Access to underlying std::ostream - virtual std::ostream& stdStream() + virtual std::ostream& stdStream() { return os_; } diff --git a/src/phasicFlow/streams/TStream/iTstream.cpp b/src/phasicFlow/streams/TStream/iTstream.cpp index 28e7cf6c..d5f6ab2a 100755 --- a/src/phasicFlow/streams/TStream/iTstream.cpp +++ b/src/phasicFlow/streams/TStream/iTstream.cpp @@ -302,7 +302,15 @@ pFlow::iIstream& pFlow::iTstream::read return *this; } - +pFlow::iIstream& pFlow::iTstream::read +( + char* buffer, + std::streamsize count +) +{ + notImplementedFunction; + return *this; +} void pFlow::iTstream::rewind() { diff --git a/src/phasicFlow/streams/TStream/iTstream.hpp b/src/phasicFlow/streams/TStream/iTstream.hpp index 8b2fecd8..eb77f94e 100755 --- a/src/phasicFlow/streams/TStream/iTstream.hpp +++ b/src/phasicFlow/streams/TStream/iTstream.hpp @@ -123,6 +123,8 @@ public: //- Read a doubleScalar virtual iIstream& read(double&) override; + iIstream& read(char* buffer, std::streamsize count) override; + // - Rewind the stream so that it may be read again virtual void rewind(); diff --git a/src/phasicFlow/streams/TStream/oTstream.cpp b/src/phasicFlow/streams/TStream/oTstream.cpp index a3a67911..5f158545 100755 --- a/src/phasicFlow/streams/TStream/oTstream.cpp +++ b/src/phasicFlow/streams/TStream/oTstream.cpp @@ -148,6 +148,15 @@ pFlow::iOstream& pFlow::oTstream::write(const double val) return *this; } +pFlow::iOstream& pFlow::oTstream::write +( + const char* binaryData, + std::streamsize count +) +{ + notImplementedFunction; + return *this; +} void pFlow::oTstream::append(const token& tok) diff --git a/src/phasicFlow/streams/TStream/oTstream.hpp b/src/phasicFlow/streams/TStream/oTstream.hpp index 12d60322..92b37f60 100755 --- a/src/phasicFlow/streams/TStream/oTstream.hpp +++ b/src/phasicFlow/streams/TStream/oTstream.hpp @@ -102,6 +102,11 @@ public: //- Write double virtual iOstream& write(const double val) override; + /// Write a block of binray data + iOstream& write( + const char* binaryData, + std::streamsize count) override; + // - append token to the stream virtual void append(const token& tok); diff --git a/src/phasicFlow/streams/iStream/IOstream.hpp b/src/phasicFlow/streams/iStream/IOstream.hpp index e44b394c..046aa1f0 100644 --- a/src/phasicFlow/streams/iStream/IOstream.hpp +++ b/src/phasicFlow/streams/iStream/IOstream.hpp @@ -50,226 +50,260 @@ public: enum streamAccess : char { - CLOSED = 0, //!< stream is not open - OPENED //!< stream is open + CLOSED = 0, /// stream is not open + OPENED /// stream is open }; + enum writeFormat: char + { + ASCII = 0, + BINARY + }; - //- Default precision + /// Default precision, only works for ASCII static unsigned int precision_; protected: - //- Name for any generic stream - normally treat as readonly + /// Name for any generic stream - normally treat as readonly static word staticName_; + /// Is stream open or closed streamAccess openClosed_; + /// write format + writeFormat writeFormat_ = ASCII; + + /// state ios_base::iostate ioState_; - //- The file line + /// The file line int32 lineNumber_; - // Protected Member Functions + //- Protected Member Functions - //- Set stream opened - void setOpened() - { - openClosed_ = OPENED; - } + /// Set stream opened + void setOpened() + { + openClosed_ = OPENED; + } - //- Set stream closed - void setClosed() - { - openClosed_ = CLOSED; - } + /// Set stream closed + void setClosed() + { + openClosed_ = CLOSED; + } - //- Set stream state - void setState(ios_base::iostate state) - { - ioState_ = state; - } + /// Set stream state + void setState(ios_base::iostate state) + { + ioState_ = state; + } - //- Set stream to be good - void setGood() - { - ioState_ = ios_base::iostate(0); - } + void setWriteFormat(writeFormat wF) + { + writeFormat_ = wF; + } + /// Set stream to be good + void setGood() + { + ioState_ = ios_base::iostate(0); + } public: - // Constructors - explicit IOstream(): - openClosed_(CLOSED), - ioState_(ios_base::iostate(0)), - lineNumber_(0) - { - setBad(); - } + //- Constructors - IOstream(const IOstream&) = default; + /// Default + explicit IOstream(): + openClosed_(CLOSED), + writeFormat_(ASCII), + ioState_(ios_base::iostate(0)), + lineNumber_(0) + { + setBad(); + } - //- Destructor - virtual ~IOstream() = default; - - - //// Member Functions + /// Construct and set write format + explicit IOstream(writeFormat wF): + openClosed_(CLOSED), + writeFormat_(wF), + ioState_(ios_base::iostate(0)), + lineNumber_(0) + { + setBad(); + } - //- Return the name of the stream - virtual const word& name() const; + /// Copy + IOstream(const IOstream&) = default; - //- Return non-const access to the name of the stream - virtual word& name(); + /// Destructor + virtual ~IOstream() = default; + + + //- Member Functions - //- Check IOstream status for given operation. - // Print IOstream state or generate a FatalIOError - // when an error has occurred. - // The base implementation is a fatalCheck - virtual bool check(const char* operation) const; + /// Return the name of the stream + virtual const word& name() const; - //- Check IOstream status for given operation. - // Generate a FatalIOError when an error has occurred. - bool fatalCheck(const char* operation) const; + /// Return non-const access to the name of the stream + virtual word& name(); - //- Return true if stream has been opened - bool opened() const - { - return openClosed_ == OPENED; - } + /// Check IOstream status for given operation. + /// Print IOstream state or generate a FatalIOError + /// when an error has occurred. + /// The base implementation is a fatalCheck + virtual bool check(const char* operation) const; - //- Return true if stream is closed - bool closed() const - { - return openClosed_ == CLOSED; - } + /// Check IOstream status for given operation. + /// Generate a FatalIOError when an error has occurred. + bool fatalCheck(const char* operation) const; - //- Return true if next operation might succeed - bool good() const - { - return ioState_ == 0; - } + /// Return true if stream has been opened + bool opened() const + { + return openClosed_ == OPENED; + } - //- Return true if end of input seen - bool eof() const - { - return ioState_ & ios_base::eofbit; - } + /// Return true if stream is closed + bool closed() const + { + return openClosed_ == CLOSED; + } - //- Return true if next operation will fail - bool fail() const - { - return ioState_ & (ios_base::badbit | ios_base::failbit); - } + /// Return true if stream format is binray + bool isBinary()const + { + return writeFormat_ == BINARY; + } - //- Return true if stream is corrupted - bool bad() const - { - return ioState_ & ios_base::badbit; - } + /// Return true if next operation might succeed + bool good() const + { + return ioState_ == 0; + } - //- Return true if the stream has not failed - explicit operator bool() const - { - return !fail(); - } + /// Return true if end of input seen + bool eof() const + { + return ioState_ & ios_base::eofbit; + } - //- Return true if the stream has failed - bool operator!() const - { - return fail(); - } + /// Return true if next operation will fail + bool fail() const + { + return ioState_ & (ios_base::badbit | ios_base::failbit); + } - - //- Const access to the current stream line number - int32 lineNumber() const - { - return lineNumber_; - } + /// Return true if stream is corrupted + bool bad() const + { + return ioState_ & ios_base::badbit; + } - //- Non-const access to the current stream line number - int32& lineNumber() - { - return lineNumber_; - } + /// Return true if the stream has not failed + explicit operator bool() const + { + return !fail(); + } - //- Set the stream line number - // \return the previous value - int32 lineNumber(const int32 num) - { - const int32 old(lineNumber_); - lineNumber_ = num; - return old; - } + /// Return true if the stream has failed + bool operator!() const + { + return fail(); + } - //- Return flags of stream - virtual ios_base::fmtflags flags() const = 0; + + /// Const access to the current stream line number + int32 lineNumber() const + { + return lineNumber_; + } - //- Return the default precision - static unsigned int defaultPrecision() - { - return precision_; - } + /// Non-const access to the current stream line number + int32& lineNumber() + { + return lineNumber_; + } - //- Reset the default precision - // \return the previous value - static unsigned int defaultPrecision(unsigned int prec) - { - unsigned int old(precision_); - precision_ = prec; - return old; - } + /// Set the stream line number + /// return the previous value + int32 lineNumber(const int32 num) + { + const int32 old(lineNumber_); + lineNumber_ = num; + return old; + } - //- Set stream to have reached eof - void setEof() - { - ioState_ |= ios_base::eofbit; - } + /// Return flags of stream + virtual ios_base::fmtflags flags() const = 0; - //- Set stream to have failed - void setFail() - { - ioState_ |= ios_base::failbit; - } + /// Return the default precision + static unsigned int defaultPrecision() + { + return precision_; + } - //- Set stream to be bad - void setBad() - { - ioState_ |= ios_base::badbit; - } + /// Reset the default precision + /// return the previous value + static unsigned int defaultPrecision(unsigned int prec) + { + unsigned int old(precision_); + precision_ = prec; + return old; + } - //- Set flags of stream - virtual ios_base::fmtflags flags(const ios_base::fmtflags f) = 0; + /// Set stream to have reached eof + void setEof() + { + ioState_ |= ios_base::eofbit; + } - //- Set flags of stream - ios_base::fmtflags setf(const ios_base::fmtflags f) - { - return flags(flags() | f); - } + /// Set stream to have failed + void setFail() + { + ioState_ |= ios_base::failbit; + } - //- Set flags of given field of stream - ios_base::fmtflags setf - ( - const ios_base::fmtflags f, - const ios_base::fmtflags mask - ) - { - return flags((flags() & ~mask) | (f & mask)); - } + /// Set stream to be bad + void setBad() + { + ioState_ |= ios_base::badbit; + } - //- Unset flags of stream - void unsetf(const ios_base::fmtflags f) - { - flags(flags() & ~f); - } + /// Set flags of stream + virtual ios_base::fmtflags flags(const ios_base::fmtflags f) = 0; + + /// Set flags of stream + ios_base::fmtflags setf(const ios_base::fmtflags f) + { + return flags(flags() | f); + } + + /// Set flags of given field of stream + ios_base::fmtflags setf + ( + const ios_base::fmtflags f, + const ios_base::fmtflags mask + ) + { + return flags((flags() & ~mask) | (f & mask)); + } + + /// Unset flags of stream + void unsetf(const ios_base::fmtflags f) + { + flags(flags() & ~f); + } }; // end of IOstream -//- An IOstream manipulator +/// An IOstream manipulator typedef IOstream& (*IOstreamManip)(IOstream&); inline IOstream& dec(IOstream& io) diff --git a/src/phasicFlow/streams/iStream/iIstream.cpp b/src/phasicFlow/streams/iStream/iIstream.cpp index 7877bd58..96849244 100755 --- a/src/phasicFlow/streams/iStream/iIstream.cpp +++ b/src/phasicFlow/streams/iStream/iIstream.cpp @@ -60,6 +60,11 @@ bool pFlow::iIstream::peekBack(token& tok) bool pFlow::iIstream::findToken( const word & w ) { rewind(); + return findTokenResume(w); +} + +bool pFlow::iIstream::findTokenResume(const word& w) +{ token next; bool isFirstToken = true; @@ -74,8 +79,6 @@ bool pFlow::iIstream::findToken( const word & w ) return false; } - - if( next.isWord() && isFirstToken) { if(next.wordToken() == w ) return true; @@ -93,6 +96,11 @@ bool pFlow::iIstream::findToken( const word & w ) bool pFlow::iIstream::findTokenSilent( const word & w, int32 limitLine ) { rewind(); + return findTokenResumeSilent(w,limitLine); +} + +bool pFlow::iIstream::findTokenResumeSilent( const word & w, int32 limitLine ) +{ token next; bool isFirstToken = true; @@ -115,7 +123,7 @@ bool pFlow::iIstream::findTokenSilent( const word & w, int32 limitLine ) isFirstToken = false; } - return false; + return false; } bool pFlow::iIstream::findTokenAndNext diff --git a/src/phasicFlow/streams/iStream/iIstream.hpp b/src/phasicFlow/streams/iStream/iIstream.hpp index a3618127..cf32961b 100755 --- a/src/phasicFlow/streams/iStream/iIstream.hpp +++ b/src/phasicFlow/streams/iStream/iIstream.hpp @@ -53,6 +53,11 @@ public: putBack_(false) {} + iIstream(writeFormat wf): + IOstream(wf), + putBack_(false) + {} + // - Copy construct iIstream(const iIstream&) = default; @@ -122,6 +127,8 @@ public: //- Read a doubleScalar virtual iIstream& read(double&) = 0; + virtual iIstream& read(char* buffer, std::streamsize count) =0; + //- Rewind the stream so that it may be read again virtual void rewind() = 0; @@ -132,10 +139,18 @@ public: // - search for all tokesn and find the first word token tbat matchs w virtual bool findToken( const word & w ); + /// search for all tokesn after the current file position + /// and find the first word token tbat matchs w + virtual bool findTokenResume(const word& w); + // - search for all tokesn and find the first word token that matchs virtual bool findTokenSilent( const word & w, int32 limitLine = 100 ); + /// search for all tokesn after the current file position + /// and find the first word token tbat matchs w + virtual bool findTokenResumeSilent( const word & w, int32 limitLine = 100 ); + // - search for all tokens and find the first word token and also next word token // chekck if it is eneded with end statement ; virtual bool findTokenAndNext( const word& w, word& nextW, bool checkEndStatement = true); diff --git a/src/phasicFlow/streams/iStream/iOstream.hpp b/src/phasicFlow/streams/iStream/iOstream.hpp index 59f00768..6c083a9b 100644 --- a/src/phasicFlow/streams/iStream/iOstream.hpp +++ b/src/phasicFlow/streams/iStream/iOstream.hpp @@ -58,219 +58,227 @@ protected: // Protected Data - //- Indentation of the entry from the start of the keyword + /// Indentation of the entry from the start of the keyword static constexpr const unsigned short entryIndentation_ = 16; - //- Number of spaces per indent level + /// Number of spaces per indent level unsigned short indentSize_ = 4; - //- Current indent level + /// Current indent level unsigned short indentLevel_ = 0; public: - // Constructor - explicit iOstream() - {} + // Constructors - //- Copy construct - iOstream(const iOstream&) = default; + /// Default + explicit iOstream() + {} - //- Destructor - virtual ~iOstream() = default; + /// Construct from writeFormat + explicit iOstream(writeFormat wF): + IOstream(wF) + {} + + /// Copy construct + iOstream(const iOstream&) = default; + + /// Destructor + virtual ~iOstream() = default; - // Write Functions + /// Write Functions - //- Write token to stream or otherwise handle it. - // \return false if the token type was not handled by this method - virtual bool write(const token& tok) = 0; + /// Write token to stream or otherwise handle it. + /// return false if the token type was not handled by this method + virtual bool write(const token& tok) = 0; - //- Write character - virtual iOstream& write(const char c) = 0; + /// Write character + virtual iOstream& write(const char c) = 0; - //- Write character string - virtual iOstream& write(const char* str) = 0; + /// Write character string + virtual iOstream& write(const char* str) = 0; - //- Write word - virtual iOstream& write(const word& str) = 0; + /// Write word + virtual iOstream& write(const word& str) = 0; + /// Write std::string surrounded by quotes. + /// Optional write without quotes. + virtual iOstream& writeQuoted + ( + const word& str, + const bool quoted=true + ) = 0; + + /// Write int64 + virtual iOstream& write(const int64 val) = 0; - //- Write std::string surrounded by quotes. - // Optional write without quotes. - virtual iOstream& writeQuoted - ( - const word& str, - const bool quoted=true - ) = 0; + /// Write int32 + virtual iOstream& write(const int32 val) = 0; + /// Write label + virtual iOstream& write(const label val) = 0; + + /// Write uint32 + virtual iOstream& write(const uint32 val) = 0; + + /// Write uint16 + virtual iOstream& write(const uint16 val) = 0; + + /// Write float + virtual iOstream& write(const float val) = 0; + + /// Write double + virtual iOstream& write(const double val) = 0; + + /// Write a block of binray data + virtual iOstream& write(const char* binaryData, std::streamsize count) = 0; + - //- Write int64 - virtual iOstream& write(const int64 val) = 0; + // - Indent - //- Write int32 - virtual iOstream& write(const int32 val) = 0; + /// Add indentation characters + virtual void indent() = 0; - //- Write label - virtual iOstream& write(const label val) = 0; + /// Return indent level + unsigned short indentSize() const + { + return indentSize_; + } - //- Write uint32 - virtual iOstream& write(const uint32 val) = 0; + /// Access to indent size + unsigned short& indentSize() + { + return indentSize_; + } - //- Write uint16 - virtual iOstream& write(const uint16 val) = 0; + /// Return indent level + unsigned short indentLevel() const + { + return indentLevel_; + } - //- Write float - virtual iOstream& write(const float val) = 0; + /// Access to indent level + unsigned short& indentLevel() + { + return indentLevel_; + } - //- Write double - virtual iOstream& write(const double val) = 0; - + /// Increment the indent level + void incrIndent() + { + ++indentLevel_; + } + /// Decrement the indent level + void decrIndent(); + + //- Punctuations - //- Add indentation characters - virtual void indent() = 0; + /// Write begin block group with a name + /// Increments indentation, adds newline. + virtual iOstream& beginBlock(const word& kw); - //- Return indent level - unsigned short indentSize() const - { - return indentSize_; - } + /// Write begin block group without a name + /// Increments indentation, adds newline. + virtual iOstream& beginBlock(); - //- Access to indent size - unsigned short& indentSize() - { - return indentSize_; - } + /// Write end block group + /// Decrements indentation, adds newline. + virtual iOstream& endBlock(); - //- Return indent level - unsigned short indentLevel() const - { - return indentLevel_; - } + /// Write begin list "(" + virtual iOstream& beginList(); - //- Access to indent level - unsigned short& indentLevel() - { - return indentLevel_; - } + /// Write begin list with keyword "kw (" + virtual iOstream& beginList(const word& kw); - //- Increment the indent level - void incrIndent() - { - ++indentLevel_; - } + /// Write end list ")" + virtual iOstream& endList(); - //- Decrement the indent level - void decrIndent(); + /// Write begin list "[" + virtual iOstream& beginSquare(); - + /// Write begin list with keyword "kw [" + virtual iOstream& beginSquare(const word& kw); - - //- Write begin block group with a name - // Increments indentation, adds newline. - virtual iOstream& beginBlock(const word& kw); + /// Write end list "]" + virtual iOstream& endSquare(); - //- Write begin block group without a name - // Increments indentation, adds newline. - virtual iOstream& beginBlock(); + /// Write end entry (';') followed by newline. + virtual iOstream& endEntry(); - //- Write end block group - // Decrements indentation, adds newline. - virtual iOstream& endBlock(); + /// Write a newLine to stream + virtual iOstream& newLine(); - //- Write begin list "(" - virtual iOstream& beginList(); + /// Write space to stream + virtual iOstream& space(int32 n=1); - //- Write begin list with keyword "kw (" - virtual iOstream& beginList(const word& kw); + /// Write the keyword followed by an appropriate indentation + virtual iOstream& writeWordKeyword(const word& kw); - //- Write end list ")" - virtual iOstream& endList(); - - //- Write begin list "[" - virtual iOstream& beginSquare(); - - //- Write begin list with keyword "kw [" - virtual iOstream& beginSquare(const word& kw); - - //- Write end list "]" - virtual iOstream& endSquare(); - - //- Write end entry (';') followed by newline. - virtual iOstream& endEntry(); - - //- Write a newLine to stream - virtual iOstream& newLine(); - - //- Write space to stream - virtual iOstream& space(int32 n=1); - - - //- Write the keyword followed by an appropriate indentation - virtual iOstream& writeWordKeyword(const word& kw); - - //- Write a keyword/value entry. - template - iOstream& writeWordEntry(const word& key, const T& value) - { - writeWordKeyword(key) << value; - return endEntry(); - } - - //// Stream state functions - - //- Flush stream - virtual void flush() = 0; - - //- Add newline and flush stream - virtual void endl() = 0; - - //- Get padding character - virtual char fill() const = 0; - - //- Set padding character for formatted field up to field width - virtual char fill(const char fillch) = 0; - - //- Get width of output field - virtual int width() const = 0; - - //- Set width of output field (and return old width) - virtual int width(const int w) = 0; - - //- Get precision of output field - virtual int precision() const = 0; - - //- Set precision of output field (and return old precision) - virtual int precision(const int p) = 0; + /// Write a keyword/value entry. + template + iOstream& writeWordEntry(const word& key, const T& value) + { + writeWordKeyword(key) << value; + return endEntry(); + } - // Member Operators + //- Stream state functions - //- Return a non-const reference to const iOstream - // Needed for write functions where the stream argument is temporary: - // e.g. thing thisThing(OFstream("thingFileName")()); - iOstream& operator()() const - { - return const_cast(*this); - } + /// Flush stream + virtual void flush() = 0; + + /// Add newline and flush stream + virtual void endl() = 0; + + /// Get padding character + virtual char fill() const = 0; + + /// Set padding character for formatted field up to field width + virtual char fill(const char fillch) = 0; + + /// Get width of output field + virtual int width() const = 0; + + /// Set width of output field (and return old width) + virtual int width(const int w) = 0; + + /// Get precision of output field + virtual int precision() const = 0; + + /// Set precision of output field (and return old precision) + virtual int precision(const int p) = 0; + + + //- Member Operators + + /// Return a non-const reference to const iOstream + /// Needed for write functions where the stream argument is temporary: + /// e.g. thing thisThing(OFstream("thingFileName")()); + iOstream& operator()() const + { + return const_cast(*this); + } }; -//- An iOstream manipulator +/// An iOstream manipulator typedef iOstream& (*iOstreamManip)(iOstream&); -//- operator<< handling for manipulators without arguments +/// operator<< handling for manipulators without arguments inline iOstream& operator<<(iOstream& os, iOstreamManip f) { return f(os); } -//- operator<< handling for manipulators without arguments +/// operator<< handling for manipulators without arguments inline iOstream& operator<<(iOstream& os, IOstreamManip f) { f(os); @@ -278,21 +286,21 @@ inline iOstream& operator<<(iOstream& os, IOstreamManip f) } -//- Indent stream +/// Indent stream inline iOstream& indent(iOstream& os) { os.indent(); return os; } -//- Increment the indent level +/// Increment the indent level inline iOstream& incrIndent(iOstream& os) { os.incrIndent(); return os; } -//- Decrement the indent level +/// Decrement the indent level inline iOstream& decrIndent(iOstream& os) { os.decrIndent(); @@ -300,7 +308,7 @@ inline iOstream& decrIndent(iOstream& os) } -//- Flush stream +/// Flush stream inline iOstream& flush(iOstream& os) { os.flush(); @@ -308,7 +316,7 @@ inline iOstream& flush(iOstream& os) } -//- Add newline and flush stream +/// Add newline and flush stream inline iOstream& endl(iOstream& os) { os.endl(); @@ -316,7 +324,7 @@ inline iOstream& endl(iOstream& os) } -//- Write begin block group without a name +/// Write begin block group without a name // Increments indentation, adds newline. inline iOstream& beginBlock(iOstream& os) { @@ -325,7 +333,7 @@ inline iOstream& beginBlock(iOstream& os) } -//- Write end block group +/// Write end block group // Decrements indentation, adds newline. inline iOstream& endBlock(iOstream& os) { @@ -334,7 +342,7 @@ inline iOstream& endBlock(iOstream& os) } -//- Write end entry (';') followed by newline. +/// Write end entry (';') followed by newline. inline iOstream& endEntry(iOstream& os) { os.endEntry(); diff --git a/src/phasicFlow/structuredData/cells/cells.cpp b/src/phasicFlow/structuredData/cells/cells.cpp new file mode 100644 index 00000000..bf5b2d2a --- /dev/null +++ b/src/phasicFlow/structuredData/cells/cells.cpp @@ -0,0 +1,21 @@ +/*------------------------------- 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 "cells.hpp" \ No newline at end of file diff --git a/src/phasicFlow/structuredData/cells/cells.hpp b/src/phasicFlow/structuredData/cells/cells.hpp new file mode 100644 index 00000000..c77b1a69 --- /dev/null +++ b/src/phasicFlow/structuredData/cells/cells.hpp @@ -0,0 +1,259 @@ +/*------------------------------- 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 __cells_hpp__ +#define __cells_hpp__ + + +#include "types.hpp" +#include "box.hpp" + +namespace pFlow +{ + +template +class cells +{ +public: + + using CellType = triple; + +protected: + + // - domain + box domain_{realx3(0.0), realx3(1.0)}; + + // - cell size + realx3 cellSize_{1,1,1}; + + CellType numCells_{1,1,1}; + + + // - protected methods + INLINE_FUNCTION_H + void calculate() + { + numCells_ = (domain_.maxPoint()-domain_.minPoint())/cellSize_ + realx3(1.0); + numCells_ = max( numCells_ , CellType(static_cast(1)) ); + } + +public: + + INLINE_FUNCTION_HD + cells() + {} + + INLINE_FUNCTION_H + cells(const box& domain, real cellSize) + : + domain_(domain), + cellSize_(cellSize) + { + calculate(); + } + + + INLINE_FUNCTION_H + cells(const box& domain, int32 nx, int32 ny, int32 nz) + : + domain_(domain), + cellSize_( + (domain_.maxPoint() - domain_.minPoint())/realx3(nx, ny, nz) + ), + numCells_(nx, ny, nz) + {} + + INLINE_FUNCTION_HD + cells(const cells&) = default; + + INLINE_FUNCTION_HD + cells& operator = (const cells&) = default; + + INLINE_FUNCTION_HD + cells(cells &&) = default; + + INLINE_FUNCTION_HD + cells& operator=(cells&&) = default; + + cells getCells()const + { + return *this; + } + + INLINE_FUNCTION_H + void setCellSize(real cellSize) + { + cellSize_ = cellSize; + calculate(); + } + + INLINE_FUNCTION_H + void setCellSize(realx3 cellSize) + { + cellSize_ = cellSize; + calculate(); + } + + INLINE_FUNCTION_HD + realx3 cellSize()const + { + return cellSize_; + } + + INLINE_FUNCTION_HD + const CellType& numCells()const + { + return numCells_; + } + + INLINE_FUNCTION_HD + indexType nx()const + { + return numCells_.x(); + } + + INLINE_FUNCTION_HD + indexType ny()const + { + return numCells_.y(); + } + + INLINE_FUNCTION_HD + indexType nz()const + { + return numCells_.z(); + } + + INLINE_FUNCTION_HD + int64 totalCells()const + { + return static_cast(numCells_.x())* + static_cast(numCells_.y())* + static_cast(numCells_.z()); + } + + const auto& domain()const + { + return domain_; + } + + INLINE_FUNCTION_HD + CellType pointIndex(const realx3& p)const + { + return CellType( (p - domain_.minPoint())/cellSize_ ); + } + + INLINE_FUNCTION_HD + bool pointIndexInDomain(const realx3 p, CellType& index)const + { + if( !domain_.isInside(p) ) return false; + + index = this->pointIndex(p); + return true; + } + + INLINE_FUNCTION_HD + bool inDomain(const realx3& p)const + { + return domain_.isInside(p); + } + + INLINE_FUNCTION_HD + bool isInRange(const CellType& cell)const + { + if(cell.x()<0)return false; + if(cell.y()<0)return false; + if(cell.z()<0)return false; + if(cell.x()>numCells_.x()-1) return false; + if(cell.y()>numCells_.y()-1) return false; + if(cell.z()>numCells_.z()-1) return false; + return true; + } + + INLINE_FUNCTION_HD + bool isInRange(indexType i, indexType j, indexType k)const + { + if(i<0)return false; + if(j<0)return false; + if(k<0)return false; + if(i>numCells_.x()-1) return false; + if(j>numCells_.y()-1) return false; + if(k>numCells_.z()-1) return false; + return true; + } + + INLINE_FUNCTION_HD + void extendBox( + const CellType& p1, + const CellType& p2, + const CellType& p3, + indexType extent, + CellType& minP, + CellType& maxP)const + { + minP = min( min( p1, p2), p3)-extent; + maxP = max( max( p1, p2), p3)+extent; + + minP = bound(minP); + maxP = bound(maxP); + } + + INLINE_FUNCTION_HD + void extendBox( + const realx3& p1, + const realx3& p2, + const realx3& p3, + real extent, + realx3& minP, + realx3& maxP)const + { + minP = min(min(p1,p2),p3) - extent*cellSize_ ; + maxP = max(max(p1,p2),p3) + extent*cellSize_ ; + + minP = bound(minP); + maxP = bound(maxP); + } + + INLINE_FUNCTION_HD + CellType bound(CellType p)const + { + return CellType( + min( numCells_.x()-1, max(0,p.x())), + min( numCells_.y()-1, max(0,p.y())), + min( numCells_.z()-1, max(0,p.z())) + ); + } + + INLINE_FUNCTION_HD + realx3 bound(realx3 p)const + { + return realx3( + min( domain_.maxPoint().x(), max(domain_.minPoint().x(),p.x())), + min( domain_.maxPoint().y(), max(domain_.minPoint().y(),p.y())), + min( domain_.maxPoint().z(), max(domain_.minPoint().z(),p.z())) + ); + } +}; + + +} + + +#endif diff --git a/src/phasicFlow/structuredData/pointStructure/mortonIndexing.cpp b/src/phasicFlow/structuredData/pointStructure/mortonIndexing.cpp new file mode 100644 index 00000000..63969747 --- /dev/null +++ b/src/phasicFlow/structuredData/pointStructure/mortonIndexing.cpp @@ -0,0 +1,82 @@ +/*------------------------------- 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 "mortonIndexing.hpp" +#include "cells.hpp" + +#include "streams.hpp" + +bool pFlow::getSortedIndex( + box boundingBox, + real dx, + range activeRange, + ViewType1D pos, + ViewType1D flag, + int32IndexContainer& sortedIndex) +{ + + // obtain the morton code of the particles + cells allCells( boundingBox, dx); + int32IndexContainer index(activeRange.first, activeRange.second); + + ViewType1D mortonCode("mortonCode", activeRange.second); + + output<<"before first kernel"<>; + int32 numActive = 0; + Kokkos::parallel_reduce + ( + "mortonIndexing::getIndex::morton", + rpMorton(activeRange.first, activeRange.second), + LAMBDA_HD(int32 i, int32& sumToUpdate){ + if( flag[i] == 1 ) // active point + { + auto cellInd = allCells.pointIndex(pos[i]); + mortonCode[i] = xyzToMortonCode64(cellInd.x(), cellInd.y(), cellInd.z()); + sumToUpdate++; + }else + { + mortonCode[i] = xyzToMortonCode64 + ( + static_cast(-1), + static_cast(-1), + static_cast(-1) + ); + } + }, + numActive + ); + + permuteSort( + mortonCode, + activeRange.first, + activeRange.second, + index.deviceView(), + 0 ); + index.modifyOnDevice(); + index.setSize(numActive); + index.syncViews(); + + sortedIndex = index; + + return true; +} \ No newline at end of file diff --git a/src/phasicFlow/structuredData/pointStructure/mortonIndexing.hpp b/src/phasicFlow/structuredData/pointStructure/mortonIndexing.hpp new file mode 100644 index 00000000..9ccdc83e --- /dev/null +++ b/src/phasicFlow/structuredData/pointStructure/mortonIndexing.hpp @@ -0,0 +1,88 @@ +/*------------------------------- 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 __mortonIndexing_hpp__ +#define __mortonIndexing_hpp__ + +#include "types.hpp" +#include "box.hpp" +#include "indexContainer.hpp" + +namespace pFlow +{ + +bool getSortedIndex( + box boundingBox, + real dx, + range activeRange, + ViewType1D pos, + ViewType1D flag, + int32IndexContainer& sortedIndex); + + +INLINE_FUNCTION_HD +uint64_t splitBy3(const uint64_t val){ + uint64_t x = val; + x = (x | x << 32) & 0x1f00000000ffff; + x = (x | x << 16) & 0x1f0000ff0000ff; + x = (x | x << 8) & 0x100f00f00f00f00f; + x = (x | x << 4) & 0x10c30c30c30c30c3; + x = (x | x << 2) & 0x1249249249249249; + return x; +} + +INLINE_FUNCTION_HD +uint64_t xyzToMortonCode64(uint64_t x, uint64_t y, uint64_t z) +{ + return splitBy3(x) | (splitBy3(y) << 1) | (splitBy3(z) << 2); +} + + +INLINE_FUNCTION_HD +uint64_t getThirdBits(uint64_t x) +{ + x = x & 0x9249249249249249; + x = (x | (x >> 2)) & 0x30c30c30c30c30c3; + x = (x | (x >> 4)) & 0xf00f00f00f00f00f; + x = (x | (x >> 8)) & 0x00ff0000ff0000ff; + x = (x | (x >> 16)) & 0xffff00000000ffff; + x = (x | (x >> 32)) & 0x00000000ffffffff; + return x; + +} + +INLINE_FUNCTION_HD +void mortonCode64Toxyz(uint64_t morton, uint64_t& x, uint64_t& y, uint64_t& z) +{ + x = getThirdBits(morton); + y = getThirdBits(morton >> 1); + z = getThirdBits(morton >> 2); +} + +struct indexMorton +{ + size_t morton; + size_t index; +}; + + +} + +#endif //__mortonIndexing_hpp__ diff --git a/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp b/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp index 6a21e808..f3f38e5b 100644 --- a/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp +++ b/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp @@ -24,7 +24,8 @@ Licence: #include "setFieldList.hpp" #include "error.hpp" #include "iOstream.hpp" -#include "Time.hpp" +//#include "Time.hpp" +#include "mortonIndexing.hpp" FUNCTION_H bool pFlow::pointStructure::evaluatePointStructure() @@ -83,6 +84,7 @@ pFlow::uniquePtr return makeUnique( activeRange_.second, activeRange_.second+numNewPoints); + } // second, check if there is space at the beginning @@ -230,6 +232,55 @@ bool pFlow::pointStructure::allActive()const return numActivePoints_ == numPoints_; } +FUNCTION_H +bool pFlow::pointStructure::mortonSortPoints(const box& domain, real dx) +{ + if( !getSortedIndex( + domain, + dx, + activeRange_, + pointPosition_.deviceVectorAll(), + pointFlag_.deviceVectorAll(), + mortonSortedIndex_) ) + { + fatalErrorInFunction<<"failed to perform morton sorting!"<(mortonSortedIndex_.size())}; + numActivePoints_ = mortonSortedIndex_.size(); + + eventMessage msg(eventMessage::REARRANGE); + + if(oldSize != size() ) + { + msg.add(eventMessage::SIZE_CHANGED); + } + + if(oldCapacity != capacity()) + { + msg.add(eventMessage::CAP_CHANGED); + } + + if( oldRange != activeRange_) + { + msg.add(eventMessage::RANGE_CHANGED); + } + + // notify all the registered objects except the exclusionList + if( !this->notify(msg) ) return false; + + return true; +} FUNCTION_H size_t pFlow::pointStructure::markDeleteOutOfBox(const box& domain) @@ -305,7 +356,6 @@ pFlow::uniquePtr pFlow::pointStructure::insertPoints ) { - auto numNew = pos.size(); if( numNew==0) { @@ -334,8 +384,6 @@ pFlow::uniquePtr pFlow::pointStructure::insertPoints static_cast(PointFlag::ACTIVE)) )return nullptr; - - setNumMaxPoints(); auto minInd = newPointsPtr().min(); auto maxInd = newPointsPtr().max(); @@ -360,8 +408,8 @@ pFlow::uniquePtr pFlow::pointStructure::insertPoints } // changes the active rage based on the new inserted points - activeRange_ = { min(activeRange_.first, minInd ), - max(activeRange_.second, maxInd+1)}; + activeRange_ = { static_cast(min(activeRange_.first, minInd )), + static_cast(max(activeRange_.second, maxInd+1))}; numActivePoints_ += numNew; @@ -401,7 +449,7 @@ bool pFlow::pointStructure::readPointStructure return false; } - if(! pointFlag_.read(is)) + if(! pointFlag_.read(is, true)) { ioErrorInFile(is.name(), is.lineNumber())<< "Error in reading pointFlag in pointStructure \n"; diff --git a/src/phasicFlow/structuredData/pointStructure/pointStructure.hpp b/src/phasicFlow/structuredData/pointStructure/pointStructure.hpp index 4f53f2ce..be70072d 100644 --- a/src/phasicFlow/structuredData/pointStructure/pointStructure.hpp +++ b/src/phasicFlow/structuredData/pointStructure/pointStructure.hpp @@ -163,8 +163,11 @@ protected: // index range of active points (half-open range) range activeRange_; - // - index vector for points to be inserted - int32IndexContainer tobeInsertedIndex_; + /// Index vector for points to be inserted + int32IndexContainer tobeInsertedIndex_; + + /// Sorted index of particles based on morton code + int32IndexContainer mortonSortedIndex_; //// - protected methods @@ -298,6 +301,10 @@ public: FUNCTION_H virtual bool updateForDelete(); + + FUNCTION_H + virtual bool mortonSortPoints(const box& domain, real dx); + /////////////////////////////////////////////////////////////////////////////////////////////////// // - const access to points to be newly inserted @@ -320,6 +327,13 @@ public: } + FUNCTION_H + auto mortonSortedIndex()const + { + return mortonSortedIndex_; + } + + // - update data structure by inserting/setting new points // Notifies all the fields in the registered list of data structure // and exclude the fields that re in the exclusionList diff --git a/src/phasicFlow/structuredData/trisurfaceStructure/multiTriSurface.cpp b/src/phasicFlow/structuredData/trisurfaceStructure/multiTriSurface.cpp index 4e3af48b..fe37308c 100644 --- a/src/phasicFlow/structuredData/trisurfaceStructure/multiTriSurface.cpp +++ b/src/phasicFlow/structuredData/trisurfaceStructure/multiTriSurface.cpp @@ -214,14 +214,12 @@ bool pFlow::multiTriSurface::readMultiTriSurface { if( !readTriSurface(is) )return false; - is >> lastPointIndex_; - if(!is.check(FUNCTION_NAME) ) return false; + // from current position + if(!lastPointIndex_.read(is, true)) return false; - is >> lastVertexIndex_; - if(!is.check(FUNCTION_NAME) ) return false; + if(!lastVertexIndex_.read(is, true) ) return false; - is >> surfaceNames_; - if( !is.check(FUNCTION_NAME)) return false; + if( !surfaceNames_.read(is, true)) return false; calculateVars(); diff --git a/src/phasicFlow/structuredData/trisurfaceStructure/triSurface.cpp b/src/phasicFlow/structuredData/trisurfaceStructure/triSurface.cpp index eb292aa8..ff23104b 100644 --- a/src/phasicFlow/structuredData/trisurfaceStructure/triSurface.cpp +++ b/src/phasicFlow/structuredData/trisurfaceStructure/triSurface.cpp @@ -193,14 +193,16 @@ bool pFlow::triSurface::readTriSurface ) { + std::cout<<"triSurface file is binary "<< is.isBinary()<> points_; - is.fatalCheck(FUNCTION_NAME); - - is >> vertices_; - is.fatalCheck(FUNCTION_NAME); - + // from start of file + if(!points_.read(is)) return false; + + // from the current position + if(!vertices_.read(is, true)) return false; + if( !check() ) { ioErrorInFile( is.name(), is.lineNumber() ) << diff --git a/tutorials/iterateGeometry/inclinedScrewConveyor/caseSetup/interaction b/tutorials/iterateGeometry/inclinedScrewConveyor/caseSetup/interaction index 45fe8f50..d3100ba3 100755 --- a/tutorials/iterateGeometry/inclinedScrewConveyor/caseSetup/interaction +++ b/tutorials/iterateGeometry/inclinedScrewConveyor/caseSetup/interaction @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName interaction; objectType dicrionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ materials (wallMat); // a list of materials names densities (1000.0); // density of materials [kg/m3] diff --git a/tutorials/iterateGeometry/inclinedScrewConveyor/settings/geometryDict b/tutorials/iterateGeometry/inclinedScrewConveyor/settings/geometryDict index cb16a115..a2a373d5 100644 --- a/tutorials/iterateGeometry/inclinedScrewConveyor/settings/geometryDict +++ b/tutorials/iterateGeometry/inclinedScrewConveyor/settings/geometryDict @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName geometryDict; objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // motion model: rotating object around an axis motionModel rotatingAxisMotion; diff --git a/tutorials/iterateGeometry/inclinedScrewConveyor/settings/settingsDict b/tutorials/iterateGeometry/inclinedScrewConveyor/settings/settingsDict index 48c5fed2..c4307d71 100644 --- a/tutorials/iterateGeometry/inclinedScrewConveyor/settings/settingsDict +++ b/tutorials/iterateGeometry/inclinedScrewConveyor/settings/settingsDict @@ -4,6 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName settingsDict; objectType dictionary;; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ run inclinedScrewConveyor; @@ -31,6 +33,8 @@ domain integrationMethod AdamsBashforth2; // integration method +writeFormat ascii; + timersReport Yes; // report timers? timersReportInterval 0.01; // time interval for reporting timers diff --git a/tutorials/postprocessPhasicFlow/segregation/caseSetup/interaction b/tutorials/postprocessPhasicFlow/segregation/caseSetup/interaction index a95b6075..43943550 100755 --- a/tutorials/postprocessPhasicFlow/segregation/caseSetup/interaction +++ b/tutorials/postprocessPhasicFlow/segregation/caseSetup/interaction @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName interaction; objectType dicrionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ materials (prop1); // a list of materials names densities (1000.0); // density of materials [kg/m3] diff --git a/tutorials/postprocessPhasicFlow/segregation/caseSetup/particleInsertion b/tutorials/postprocessPhasicFlow/segregation/caseSetup/particleInsertion index eec7b7f9..76835952 100755 --- a/tutorials/postprocessPhasicFlow/segregation/caseSetup/particleInsertion +++ b/tutorials/postprocessPhasicFlow/segregation/caseSetup/particleInsertion @@ -2,10 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName particleInsertion; objectType dicrionary; - +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ active no; // is insertion active? diff --git a/tutorials/postprocessPhasicFlow/segregation/caseSetup/sphereShape b/tutorials/postprocessPhasicFlow/segregation/caseSetup/sphereShape index 15060c08..ffe420d8 100755 --- a/tutorials/postprocessPhasicFlow/segregation/caseSetup/sphereShape +++ b/tutorials/postprocessPhasicFlow/segregation/caseSetup/sphereShape @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName sphereDict; objectType sphereShape; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ names (smallSphere largeSphere); // names of shapes diameters (0.003 0.005); // diameter of shapes diff --git a/tutorials/postprocessPhasicFlow/segregation/settings/geometryDict b/tutorials/postprocessPhasicFlow/segregation/settings/geometryDict index 7a2667f7..46d4025b 100644 --- a/tutorials/postprocessPhasicFlow/segregation/settings/geometryDict +++ b/tutorials/postprocessPhasicFlow/segregation/settings/geometryDict @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName geometryDict; objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // motion model: rotating object around an axis motionModel rotatingAxisMotion; diff --git a/tutorials/postprocessPhasicFlow/segregation/settings/particlesDict b/tutorials/postprocessPhasicFlow/segregation/settings/particlesDict index 2dcd1599..e32d8182 100644 --- a/tutorials/postprocessPhasicFlow/segregation/settings/particlesDict +++ b/tutorials/postprocessPhasicFlow/segregation/settings/particlesDict @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName particlesDict; objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // positions particles positionParticles diff --git a/tutorials/postprocessPhasicFlow/segregation/settings/postprocessDict b/tutorials/postprocessPhasicFlow/segregation/settings/postprocessDict index 10ac3c80..d065122a 100644 --- a/tutorials/postprocessPhasicFlow/segregation/settings/postprocessDict +++ b/tutorials/postprocessPhasicFlow/segregation/settings/postprocessDict @@ -4,6 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName postprocessDict; objectType dictionary;; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ rectMesh { diff --git a/tutorials/postprocessPhasicFlow/segregation/settings/settingsDict b/tutorials/postprocessPhasicFlow/segregation/settings/settingsDict index e6e2d9b9..b5d3129b 100644 --- a/tutorials/postprocessPhasicFlow/segregation/settings/settingsDict +++ b/tutorials/postprocessPhasicFlow/segregation/settings/settingsDict @@ -4,6 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName settingsDict; objectType dictionary;; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ run rotatingDrumSmall; @@ -31,6 +33,8 @@ domain integrationMethod AdamsBashforth2; // integration method +writeFormat ascii; + timersReport Yes; // report timers? timersReportInterval 0.01; // time interval for reporting timers diff --git a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/interaction b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/interaction index f01b3196..fc7dc5a1 100644 --- a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/interaction +++ b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/interaction @@ -4,7 +4,9 @@ \* ------------------------------------------------------------------------- */ objectName interaction; objectType dicrionary; -/*----------------------------------------------------------------------------*/ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ + // a list of materials names materials (lightMat heavyMat wallMat); // density of materials [kg/m3] diff --git a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/particleInsertion b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/particleInsertion index 68712a02..86ecbdd9 100644 --- a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/particleInsertion +++ b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/particleInsertion @@ -4,6 +4,7 @@ \* ------------------------------------------------------------------------- */ objectName particleInsertion; objectType dicrionary; +fileFormat ASCII; /*---------------------------------------------------------------------------*/ // is insertion active? diff --git a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/sphereShape b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/sphereShape index 714e1b9a..c9960912 100644 --- a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/sphereShape +++ b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/caseSetup/sphereShape @@ -4,7 +4,9 @@ \* ------------------------------------------------------------------------- */ objectName sphereDict; objectType sphereShape; +fileFormat ASCII; /*---------------------------------------------------------------------------*/ + // names of shapes names (smallSphere largeSphere); // diameter of shapes (m) diff --git a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/geometryDict b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/geometryDict index bb372bce..5485c307 100644 --- a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/geometryDict +++ b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/geometryDict @@ -4,7 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName geometryDict; objectType dictionary; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // motion model: all surfaces are fixed motionModel rotatingAxisMotion; diff --git a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/particlesDict b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/particlesDict index 4be2a5c3..6e03ca5d 100644 --- a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/particlesDict +++ b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/particlesDict @@ -4,7 +4,9 @@ \* ------------------------------------------------------------------------- */ objectName particlesDict; objectType dictionary; +fileFormat ASCII; /*---------------------------------------------------------------------------*/ + setFields { defaultValue diff --git a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/settingsDict b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/settingsDict index 5216b07c..2fffee5b 100644 --- a/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/settingsDict +++ b/tutorials/sphereGranFlow/RotatingDrumWithBaffles/settings/settingsDict @@ -2,24 +2,30 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName settingsDict; -objectType dictionary;; +objectType dictionary; +fileFormat ASCII; /*---------------------------------------------------------------------------*/ + run RotatingDrumwithBaffles; // time step for integration (s) - dt 0.00001; +dt 0.00001; + // start time for simulation - startTime 0; +startTime 0; + // end time for simulation - endTime 10; +endTime 10; + // time interval for saving the simulation - saveInterval 0.05; +saveInterval 0.05; + // maximum number of digits for time folder - timePrecision 6; +timePrecision 6; + // gravity vector (m/s2) - g (0 -9.8 0); +g (0 -9.8 0); /*Simulation domain*/ /* Every particles that goes outside this domain is deleted.*/ @@ -28,9 +34,15 @@ domain min (-0.328 0.095 -0.025); max (-0.068 0.355 0.125); } + // integration method - integrationMethod AdamsBashforth3; +integrationMethod AdamsBashforth3; + +// binary or ascii for saving data +writeFormat ascii; + // report timers? - timersReport Yes; +timersReport Yes; + // time interval for reporting timers - timersReportInterval 0.01; +timersReportInterval 0.01; diff --git a/tutorials/sphereGranFlow/V-blender/caseSetup/interaction b/tutorials/sphereGranFlow/V-blender/caseSetup/interaction index 1b9d0835..709fe23e 100644 --- a/tutorials/sphereGranFlow/V-blender/caseSetup/interaction +++ b/tutorials/sphereGranFlow/V-blender/caseSetup/interaction @@ -4,7 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName interaction; objectType dicrionary; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // a list of materials names materials (wallMat lightMat); diff --git a/tutorials/sphereGranFlow/V-blender/caseSetup/particleInsertion b/tutorials/sphereGranFlow/V-blender/caseSetup/particleInsertion index 3515f535..682830c5 100644 --- a/tutorials/sphereGranFlow/V-blender/caseSetup/particleInsertion +++ b/tutorials/sphereGranFlow/V-blender/caseSetup/particleInsertion @@ -4,7 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName particleInsertion; objectType dicrionary; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // is insertion active? active yes; diff --git a/tutorials/sphereGranFlow/V-blender/caseSetup/sphereShape b/tutorials/sphereGranFlow/V-blender/caseSetup/sphereShape index b09f3164..71a9880d 100644 --- a/tutorials/sphereGranFlow/V-blender/caseSetup/sphereShape +++ b/tutorials/sphereGranFlow/V-blender/caseSetup/sphereShape @@ -4,7 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName sphereDict; objectType sphereShape; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // names of particles names (smallSphere largeSphere); diff --git a/tutorials/sphereGranFlow/V-blender/settings/geometryDict b/tutorials/sphereGranFlow/V-blender/settings/geometryDict index 74fd0455..bbb9bfea 100644 --- a/tutorials/sphereGranFlow/V-blender/settings/geometryDict +++ b/tutorials/sphereGranFlow/V-blender/settings/geometryDict @@ -4,7 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName geometryDict; objectType dictionary; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // motion model: rotating object around an axis motionModel rotatingAxisMotion; diff --git a/tutorials/sphereGranFlow/V-blender/settings/particlesDict b/tutorials/sphereGranFlow/V-blender/settings/particlesDict index 9cee31d8..20f0f595 100644 --- a/tutorials/sphereGranFlow/V-blender/settings/particlesDict +++ b/tutorials/sphereGranFlow/V-blender/settings/particlesDict @@ -4,7 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName particlesDict; objectType dictionary; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ setFields { diff --git a/tutorials/sphereGranFlow/V-blender/settings/settingsDict b/tutorials/sphereGranFlow/V-blender/settings/settingsDict index 46692780..4dab1980 100644 --- a/tutorials/sphereGranFlow/V-blender/settings/settingsDict +++ b/tutorials/sphereGranFlow/V-blender/settings/settingsDict @@ -4,7 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName settingsDict; objectType dictionary; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ run rotatingVblender; @@ -40,6 +41,8 @@ domain // integration method integrationMethod AdamsBashforth2; +writeFormat ascii; + // report timers? timersReport Yes; diff --git a/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/interaction b/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/interaction index 5e5909e9..79aef8f9 100755 --- a/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/interaction +++ b/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/interaction @@ -2,9 +2,11 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ +objectName interaction; +objectType dicrionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ -objectName interaction; -objectType dicrionary; materials (prop1); // a list of materials names densities (1000.0); // density of materials [kg/m3] diff --git a/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/particleInsertion b/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/particleInsertion index eec7b7f9..dbbc4709 100755 --- a/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/particleInsertion +++ b/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/particleInsertion @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - -objectName particleInsertion; -objectType dicrionary; +objectName particleInsertion; +objectType dicrionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ active no; // is insertion active? diff --git a/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/sphereShape b/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/sphereShape index 15060c08..ffe420d8 100755 --- a/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/sphereShape +++ b/tutorials/sphereGranFlow/binarySystemOfParticles/caseSetup/sphereShape @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName sphereDict; objectType sphereShape; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ names (smallSphere largeSphere); // names of shapes diameters (0.003 0.005); // diameter of shapes diff --git a/tutorials/sphereGranFlow/binarySystemOfParticles/settings/geometryDict b/tutorials/sphereGranFlow/binarySystemOfParticles/settings/geometryDict index 7a2667f7..46d4025b 100644 --- a/tutorials/sphereGranFlow/binarySystemOfParticles/settings/geometryDict +++ b/tutorials/sphereGranFlow/binarySystemOfParticles/settings/geometryDict @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName geometryDict; objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // motion model: rotating object around an axis motionModel rotatingAxisMotion; diff --git a/tutorials/sphereGranFlow/binarySystemOfParticles/settings/particlesDict b/tutorials/sphereGranFlow/binarySystemOfParticles/settings/particlesDict index 71a463fd..f53fb9b6 100644 --- a/tutorials/sphereGranFlow/binarySystemOfParticles/settings/particlesDict +++ b/tutorials/sphereGranFlow/binarySystemOfParticles/settings/particlesDict @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName particlesDict; objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // positions particles positionParticles diff --git a/tutorials/sphereGranFlow/binarySystemOfParticles/settings/settingsDict b/tutorials/sphereGranFlow/binarySystemOfParticles/settings/settingsDict index 5e633b90..3df9af04 100644 --- a/tutorials/sphereGranFlow/binarySystemOfParticles/settings/settingsDict +++ b/tutorials/sphereGranFlow/binarySystemOfParticles/settings/settingsDict @@ -3,7 +3,10 @@ | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ objectName settingsDict; -objectType dictionary;; +objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ + run binarySystemofParticles; @@ -31,6 +34,8 @@ domain integrationMethod AdamsBashforth2; // integration method +writeFormat ascii; + timersReport Yes; // report timers? timersReportInterval 0.01; // time interval for reporting timers diff --git a/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/interaction b/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/interaction index cea5227c..de2272e8 100755 --- a/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/interaction +++ b/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/interaction @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName interaction; objectType dicrionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ materials (lightMat heavyMat wallMat); // a list of materials names densities (1000 1500.0 2500); // density of materials [kg/m3] diff --git a/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/particleInsertion b/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/particleInsertion index 97cf663d..ff00abb0 100755 --- a/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/particleInsertion +++ b/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/particleInsertion @@ -2,10 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName particleInsertion; objectType dicrionary; - +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ active yes; // is insertion active? diff --git a/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/sphereShape b/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/sphereShape index db80a19f..749d1f0c 100755 --- a/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/sphereShape +++ b/tutorials/sphereGranFlow/layeredSiloFilling/caseSetup/sphereShape @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName sphereDict; objectType sphereShape; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ names (lightSphere heavySphere); // names of shapes diameters (0.007 0.007); // diameter of shapes diff --git a/tutorials/sphereGranFlow/layeredSiloFilling/settings/geometryDict b/tutorials/sphereGranFlow/layeredSiloFilling/settings/geometryDict index b3d427d3..fa71f7ba 100644 --- a/tutorials/sphereGranFlow/layeredSiloFilling/settings/geometryDict +++ b/tutorials/sphereGranFlow/layeredSiloFilling/settings/geometryDict @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName geometryDict; objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // motion model: all surfaces are fixed motionModel fixedWall; diff --git a/tutorials/sphereGranFlow/layeredSiloFilling/settings/particlesDict b/tutorials/sphereGranFlow/layeredSiloFilling/settings/particlesDict index fa3edaf3..8e014c06 100644 --- a/tutorials/sphereGranFlow/layeredSiloFilling/settings/particlesDict +++ b/tutorials/sphereGranFlow/layeredSiloFilling/settings/particlesDict @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName particlesDict; objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ setFields { diff --git a/tutorials/sphereGranFlow/layeredSiloFilling/settings/settingsDict b/tutorials/sphereGranFlow/layeredSiloFilling/settings/settingsDict index eb08a1d3..6f19dd6e 100644 --- a/tutorials/sphereGranFlow/layeredSiloFilling/settings/settingsDict +++ b/tutorials/sphereGranFlow/layeredSiloFilling/settings/settingsDict @@ -3,7 +3,9 @@ | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ objectName settingsDict; -objectType dictionary;; +objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ run layerdSiloFilling; @@ -31,6 +33,8 @@ domain integrationMethod AdamsBashforth3; // integration method +writeFormat ascii; + timersReport Yes; // report timers? timersReportInterval 0.01; // time interval for reporting timers diff --git a/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/interaction b/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/interaction index 5b063862..3a744122 100755 --- a/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/interaction +++ b/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/interaction @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName interaction; objectType dicrionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ materials (glassMat wallMat); // a list of materials names densities (2500.0 2500); // density of materials [kg/m3] diff --git a/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/particleInsertion b/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/particleInsertion index eec7b7f9..76835952 100755 --- a/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/particleInsertion +++ b/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/particleInsertion @@ -2,10 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName particleInsertion; objectType dicrionary; - +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ active no; // is insertion active? diff --git a/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/sphereShape b/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/sphereShape index eab9b617..fc596f2a 100755 --- a/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/sphereShape +++ b/tutorials/sphereGranFlow/rotatingDrumMedium/caseSetup/sphereShape @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName sphereDict; objectType sphereShape; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ names (glassBead); // names of shapes diameters (0.003); // diameter of shapes diff --git a/tutorials/sphereGranFlow/rotatingDrumMedium/settings/geometryDict b/tutorials/sphereGranFlow/rotatingDrumMedium/settings/geometryDict index 862c60df..b2c6fa26 100644 --- a/tutorials/sphereGranFlow/rotatingDrumMedium/settings/geometryDict +++ b/tutorials/sphereGranFlow/rotatingDrumMedium/settings/geometryDict @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName geometryDict; objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // motion model: rotating object around an axis motionModel rotatingAxisMotion; diff --git a/tutorials/sphereGranFlow/rotatingDrumMedium/settings/particlesDict b/tutorials/sphereGranFlow/rotatingDrumMedium/settings/particlesDict index f6437a4d..e6e5c7eb 100644 --- a/tutorials/sphereGranFlow/rotatingDrumMedium/settings/particlesDict +++ b/tutorials/sphereGranFlow/rotatingDrumMedium/settings/particlesDict @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName particlesDict; objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ setFields { diff --git a/tutorials/sphereGranFlow/rotatingDrumMedium/settings/settingsDict b/tutorials/sphereGranFlow/rotatingDrumMedium/settings/settingsDict index f8d59407..aedf2a89 100644 --- a/tutorials/sphereGranFlow/rotatingDrumMedium/settings/settingsDict +++ b/tutorials/sphereGranFlow/rotatingDrumMedium/settings/settingsDict @@ -4,6 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName settingsDict; objectType dictionary;; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ run rotatingDrumMedium; @@ -31,6 +33,8 @@ domain integrationMethod AdamsBashforth3; // integration method +writeFormat binary; + timersReport Yes; // report timers? timersReportInterval 0.01; // time interval for reporting timers diff --git a/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/interaction b/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/interaction index 292d4722..32800a5c 100755 --- a/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/interaction +++ b/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/interaction @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName interaction; objectType dicrionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ materials (prop1); // a list of materials names densities (1000.0); // density of materials [kg/m3] diff --git a/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/particleInsertion b/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/particleInsertion index eec7b7f9..76835952 100755 --- a/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/particleInsertion +++ b/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/particleInsertion @@ -2,10 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName particleInsertion; objectType dicrionary; - +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ active no; // is insertion active? diff --git a/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/sphereShape b/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/sphereShape index 72192393..7a87b7ad 100755 --- a/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/sphereShape +++ b/tutorials/sphereGranFlow/rotatingDrumSmall/caseSetup/sphereShape @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName sphereDict; objectType sphereShape; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ names (sphere1); // names of shapes diameters (0.004); // diameter of shapes diff --git a/tutorials/sphereGranFlow/rotatingDrumSmall/settings/geometryDict b/tutorials/sphereGranFlow/rotatingDrumSmall/settings/geometryDict index 7a2667f7..46d4025b 100644 --- a/tutorials/sphereGranFlow/rotatingDrumSmall/settings/geometryDict +++ b/tutorials/sphereGranFlow/rotatingDrumSmall/settings/geometryDict @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName geometryDict; objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // motion model: rotating object around an axis motionModel rotatingAxisMotion; diff --git a/tutorials/sphereGranFlow/rotatingDrumSmall/settings/particlesDict b/tutorials/sphereGranFlow/rotatingDrumSmall/settings/particlesDict index 261f6910..4ad57c22 100644 --- a/tutorials/sphereGranFlow/rotatingDrumSmall/settings/particlesDict +++ b/tutorials/sphereGranFlow/rotatingDrumSmall/settings/particlesDict @@ -2,9 +2,10 @@ | phasicFlow File | | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ - objectName particlesDict; objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ setFields { diff --git a/tutorials/sphereGranFlow/rotatingDrumSmall/settings/settingsDict b/tutorials/sphereGranFlow/rotatingDrumSmall/settings/settingsDict index dc202f23..7611fd2b 100644 --- a/tutorials/sphereGranFlow/rotatingDrumSmall/settings/settingsDict +++ b/tutorials/sphereGranFlow/rotatingDrumSmall/settings/settingsDict @@ -3,7 +3,9 @@ | copyright: www.cemf.ir | \* ------------------------------------------------------------------------- */ objectName settingsDict; -objectType dictionary;; +objectType dictionary; +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ run rotatingDrumSmall; @@ -31,6 +33,8 @@ domain integrationMethod AdamsBashforth2; // integration method +writeFormat ascii; + timersReport Yes; // report timers? timersReportInterval 0.01; // time interval for reporting timers diff --git a/tutorials/sphereGranFlow/toteblender/caseSetup/interaction b/tutorials/sphereGranFlow/toteblender/caseSetup/interaction index 6b4847dc..36ff43c5 100644 --- a/tutorials/sphereGranFlow/toteblender/caseSetup/interaction +++ b/tutorials/sphereGranFlow/toteblender/caseSetup/interaction @@ -4,7 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName interaction; objectType dicrionary; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // a list of materials names materials (solidProperty); diff --git a/tutorials/sphereGranFlow/toteblender/caseSetup/particleInsertion b/tutorials/sphereGranFlow/toteblender/caseSetup/particleInsertion index 45ca817c..d8e3f87f 100644 --- a/tutorials/sphereGranFlow/toteblender/caseSetup/particleInsertion +++ b/tutorials/sphereGranFlow/toteblender/caseSetup/particleInsertion @@ -4,7 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName particleInsertion; objectType dicrionary; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // is insertion active? active no; diff --git a/tutorials/sphereGranFlow/toteblender/caseSetup/sphereShape b/tutorials/sphereGranFlow/toteblender/caseSetup/sphereShape index b579d7c6..d895b1ee 100644 --- a/tutorials/sphereGranFlow/toteblender/caseSetup/sphereShape +++ b/tutorials/sphereGranFlow/toteblender/caseSetup/sphereShape @@ -4,7 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName sphereDict; objectType sphereShape; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // name of shapes names (sphere1); diff --git a/tutorials/sphereGranFlow/toteblender/settings/geometryDict b/tutorials/sphereGranFlow/toteblender/settings/geometryDict index b65854eb..9fbd80b3 100644 --- a/tutorials/sphereGranFlow/toteblender/settings/geometryDict +++ b/tutorials/sphereGranFlow/toteblender/settings/geometryDict @@ -4,7 +4,8 @@ \* ------------------------------------------------------------------------- */ objectName geometryDict; objectType dictionary; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ // motion model: rotating object around an axis motionModel rotatingAxisMotion; diff --git a/tutorials/sphereGranFlow/toteblender/settings/particlesDict b/tutorials/sphereGranFlow/toteblender/settings/particlesDict index 20f56227..c0e1b189 100644 --- a/tutorials/sphereGranFlow/toteblender/settings/particlesDict +++ b/tutorials/sphereGranFlow/toteblender/settings/particlesDict @@ -4,7 +4,9 @@ \* ------------------------------------------------------------------------- */ objectName particlesDict; objectType dictionary; -/* ------------------------------------------------------------------------- */ +fileFormat ASCII; +/*---------------------------------------------------------------------------*/ + setFields { /* diff --git a/tutorials/sphereGranFlow/toteblender/settings/settingsDict b/tutorials/sphereGranFlow/toteblender/settings/settingsDict index 34c287bb..224eb9a3 100644 --- a/tutorials/sphereGranFlow/toteblender/settings/settingsDict +++ b/tutorials/sphereGranFlow/toteblender/settings/settingsDict @@ -4,7 +4,9 @@ \* ------------------------------------------------------------------------- */ objectName settingsDict; objectType dictionary;; +fileFormat ASCII; /*---------------------------------------------------------------------------*/ + run toteBlender; // time step for integration (s) @@ -36,6 +38,8 @@ domain // integration method integrationMethod AdamsMoulton4; +writeFormat ascii; + // report timers? timersReport Yes; diff --git a/utilities/pFlowToVTK/pointFieldToVTK.hpp b/utilities/pFlowToVTK/pointFieldToVTK.hpp index ca71b028..1229ab3d 100755 --- a/utilities/pFlowToVTK/pointFieldToVTK.hpp +++ b/utilities/pFlowToVTK/pointFieldToVTK.hpp @@ -31,12 +31,12 @@ Licence: namespace pFlow::PFtoVTK { -template -bool addInt64PointField( +template +bool addIntPointField( iOstream& os, word fieldName, int32 numActivePoints, - int64* field, + IntType* field, IncludeMaskType includeMask ); template @@ -76,46 +76,46 @@ bool checkFieldType(word objectType) } -bool convertIntTypesPointField( +template +bool convertIntPointField +( iOstream& os, const IOfileHeader& header, - const pointStructure& pStruct ) + const pointStructure& pStruct +) { + + using PointFieldType = pointField; + word objectType = header.objectType(); - if( !(checkFieldType(objectType) || - checkFieldType(objectType) || - checkFieldType(objectType) || - checkFieldType(objectType) || - checkFieldType(objectType) || - checkFieldType