diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6f339f58..6f4967e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,11 +7,13 @@ add_subdirectory(Property) add_subdirectory(Particles) +add_subdirectory(Geometry) + #add_subdirectory(Interaction) add_subdirectory(MotionModel) -#add_subdirectory(Geometry) + #add_subdirectory(MPIParallelization) diff --git a/src/Geometry/geometry/geometry.cpp b/src/Geometry/geometry/geometry.cpp index 4d7edc04..0875dbd6 100644 --- a/src/Geometry/geometry/geometry.cpp +++ b/src/Geometry/geometry/geometry.cpp @@ -19,33 +19,41 @@ Licence: -----------------------------------------------------------------------------*/ #include "geometry.hpp" +#include "systemControl.hpp" #include "vocabs.hpp" -bool pFlow::geometry::findPropertyId() +bool pFlow::geometry::createPropertyId() { - - int8Vector propId(0, surface().capacity(),RESERVE()); - propId.clear(); - - uint32 pId; - ForAll(matI, materialName_) + if(materialName_.size() != numSurfaces() ) { + fatalErrorInFunction<< + "number of subSurface and material names do not match"<( - objectFile( - "triSurface", - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_ALWAYS - ) - ) + motionComponentName_ + ( + "motionComponentName", + "motionComponentName" + ), + materialName_ + ( + "materialName", + "materialName" + ), + propertyId_ + ( + objectFile + ( + "propertyId", + "", + objectFile::READ_NEVER, + objectFile::WRITE_NEVER ), - motionComponentName_( - control.geometry().emplaceObject( - objectFile( - "motionComponentName", - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_ALWAYS - ), - "motionNamesList" - ) + *this, + 0u + ), + contactForceWall_ + ( + objectFile + ( + "contactForcWall", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_NEVER ), - materialName_( - control.geometry().emplaceObject( - objectFile( - "materialName", - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_ALWAYS - ), - "materialNamesList" - ) + *this, + zero3 + ), + normalStressWall_ + ( + objectFile + ( + "normalStressWall", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_NEVER ), - propertyId_( - control.geometry().emplaceObject( - objectFile( - "propertyId", - "", - objectFile::READ_NEVER, - objectFile::WRITE_NEVER), - surface(), - 0 ) ), - contactForceWall_( - control.geometry().emplaceObject( - objectFile( - "contactForceWall", - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS), - surface(), - zero3) ), - stressWall_( - control.geometry().emplaceObject( - objectFile( - "stressWall", - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS), - surface(), - zero3) ) + *this, + zero3 + ), + shearStressWall_ + ( + objectFile + ( + "shearStressWall", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_NEVER + ), + *this, + zero3 + ) { - if(!findPropertyId()) + readWholeObject_ = false; + if( !IOobject::readObject() ) + { + fatalErrorInFunction<< + "Error in reading from file "<numSurfaces() != motionComponentName_.size() ) + { + fatalErrorInFunction<< + "Number of surfaces is not equal to number of motion component names"<numSurfaces() != motionComponentName_.size() ) + { + fatalErrorInFunction<< + "Number of surfaces is not equal to number of motion component names"< - pFlow::geometry::create( - systemControl& control, - const property& prop, - const dictionary& dict, - const multiTriSurface& triSurface, - const wordVector& motionCompName, - const wordVector& propName) + pFlow::geometry::create + ( + systemControl& control, + const property& prop, + multiTriSurface& surf, + const wordVector& motionCompName, + const wordVector& materialName, + const dictionary& motionDic + ) { - word model = dict.getVal("motionModel"); + word model = motionDic.getVal("motionModel"); auto geomModel = angleBracketsNames("geometry", model); - REPORT(1)<< "Selecting geometry model . . ."< ( control, prop, - dict, - triSurface, + surf, motionCompName, - propName + materialName, + motionDic ); - REPORT(2)<<"Model "<< greenText(geomModel)<<" is created.\n"< fatalExit; } return nullptr; -} \ No newline at end of file +} diff --git a/src/Geometry/geometry/geometry.hpp b/src/Geometry/geometry/geometry.hpp index a8296700..bc1016b0 100644 --- a/src/Geometry/geometry/geometry.hpp +++ b/src/Geometry/geometry/geometry.hpp @@ -23,13 +23,14 @@ Licence: #include "virtualConstructor.hpp" -#include "demGeometry.hpp" +#include "demComponent.hpp" #include "property.hpp" -#include "Fields.hpp" -#include "Vectors.hpp" #include "multiTriSurface.hpp" #include "triSurfaceFields.hpp" -#include "dictionary.hpp" +//#include "Fields.hpp" +//#include "Vectors.hpp" + + namespace pFlow { @@ -42,47 +43,48 @@ namespace pFlow */ class geometry : - public demGeometry + public multiTriSurface, + public demComponent { -protected: +private: // - Protected members /// Const reference to physical property of materials const property& wallProperty_; - /// Repository to store geometry data at each simulation moment - repository& geometryRepository_; - - /// All triangles in the set of wall surfaces - multiTriSurface& triSurface_; - /// The name of motion component of each wall surface - wordField& motionComponentName_; + wordField_H motionComponentName_; /// Material name of each wall surface - wordField& materialName_; + wordField_H materialName_; /// Property id of each triangle in the set of wall surfaces - int8TriSurfaceField_D& propertyId_; + uint32TriSurfaceField_D propertyId_; /// Contact force on each triangle in the set of wall surfaces - realx3TriSurfaceField_D& contactForceWall_; + realx3TriSurfaceField_D contactForceWall_; - /// Stress on ech triangle in the set of wall surfaces - realx3TriSurfaceField_D& stressWall_; + /// Stress on each triangle in the set of wall surfaces + realx3TriSurfaceField_D normalStressWall_; + + /// Stress on each triangle in the set of wall surfaces + realx3TriSurfaceField_D shearStressWall_; + + + bool readWholeObject_ = true; // - 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(); + bool createPropertyId(); /// Initialize contact force to zero - void zeroForce() + /*void zeroForce() { contactForceWall_.fill(zero3); - } + }*/ public: @@ -95,8 +97,15 @@ public: /// Construct from controlSystem and property, for reading from file geometry(systemControl& control, const property& prop); + geometry(systemControl& control, + const property& prop, + multiTriSurface& surf, + const wordVector& motionCompName, + const wordVector& materialName, + const dictionary& motionDict); + /// Construct from components - geometry(systemControl& control, + /*geometry(systemControl& control, const property& prop, const multiTriSurface& triSurface, const wordVector& motionCompName, @@ -110,13 +119,13 @@ public: const dictionary& dict, const multiTriSurface& triSurface, const wordVector& motionCompName, - const wordVector& propName); + const wordVector& propName);*/ /// Destructor virtual ~geometry() = default; /// Virtual constructor - create_vCtor + /*create_vCtor ( geometry, systemControl, @@ -125,37 +134,24 @@ public: const property& prop ), (control, prop) - ); + );*/ /// Virtual constructor create_vCtor ( geometry, dictionary, - (systemControl& control, - const property& prop, - const dictionary& dict, - const multiTriSurface& triSurface, - const wordVector& motionCompName, - const wordVector& propName), - (control, prop, dict, triSurface, motionCompName, propName) + ( + systemControl& control, + const property& prop, + multiTriSurface& surf, + const wordVector& motionCompName, + const wordVector& materialName, + const dictionary& motionDic), + (control, prop, surf, motionCompName, materialName, motionDic) ); - //- 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(); - } + //- Methods /// Number of triangles in the set of surface walls inline @@ -165,39 +161,47 @@ public: } /// Access to the points - inline + /*inline const auto& points()const { return triSurface_.points(); - } + }*/ /// Access to the vertices - inline + /*inline const auto& vertices()const { return triSurface_.vertices(); - } + }*/ /// Obtain an object for accessing triangles - inline auto getTriangleAccessor()const + /*inline auto getTriangleAccessor()const { return triSurface_.getTriangleAccessor(); + }*/ + + /// Surface + inline + auto& surface() + { + return static_cast(*this); } /// Surface - inline auto& surface() + inline + const auto& surface()const { - return triSurface_; + return static_cast(*this); } - /// Surface - inline const auto& surface()const + inline + const auto& motionComponentName()const { - return triSurface_; + return motionComponentName_; } - + /// Access to contact force - inline + /*inline realx3TriSurfaceField_D& contactForceWall() { return contactForceWall_; @@ -214,34 +218,34 @@ public: inline const auto& wallProperty()const { return wallProperty_; - } + }*/ /// Owner repository - inline + /*inline const repository& owner()const { return geometryRepository_; - } + }*/ /// Owner repository - inline + /*inline repository& owner() { return geometryRepository_; - } + }*/ /// Path to the repository folder - inline auto path() + /*inline auto path() { return owner().path(); - } + }*/ /// The name of motion model - virtual - word motionModelTypeName()const = 0; + /*virtual + word motionModelTypeName()const = 0;*/ /// Motion model index of triangles - virtual + /*virtual const int8Vector_HD& triMotionIndex() const =0; /// Motion model index of points @@ -252,36 +256,58 @@ public: const int8TriSurfaceField_D& propertyId() const { return propertyId_; - } + }*/ /// Operations before each iteration - bool beforeIteration() override; + //bool beforeIteration() override; /// Operations after each iteration - bool afterIteration() override; + //bool afterIteration() override; + + + bool beforeIteration() override + { + notImplementedFunction; + return true; + } + + /// This is called in time loop. Perform the main calculations + /// when the component should evolve along time. + bool iterate() override + { + notImplementedFunction; + return true; + } + + /// This is called in time loop, after iterate. + bool afterIteration() override + { + notImplementedFunction; + return true; + } //- IO + bool read(iIstream& is, const IOPattern& iop) override; + /// write - bool write()const - { - return owner().write(); - } + bool write( iOstream& os, const IOPattern& iop )const override; + //- Static members - static - uniquePtr create(systemControl& control, const property& prop); + /*static + uniquePtr create(systemControl& control, const property& prop);*/ static uniquePtr create( - systemControl& control, - const property& prop, - const dictionary& dict, - const multiTriSurface& triSurface, - const wordVector& motionCompName, - const wordVector& propName); + systemControl& control, + const property& prop, + multiTriSurface& surf, + const wordVector& motionCompName, + const wordVector& materialName, + const dictionary& motionDic); }; diff --git a/src/Geometry/geometryMotion/geometryMotion.cpp b/src/Geometry/geometryMotion/geometryMotion.cpp index ece859df..53f3509d 100644 --- a/src/Geometry/geometryMotion/geometryMotion.cpp +++ b/src/Geometry/geometryMotion/geometryMotion.cpp @@ -1,3 +1,4 @@ +#include "geometryMotion.hpp" /*------------------------------- phasicFlow --------------------------------- O C enter of O O E ngineering and @@ -21,37 +22,49 @@ Licence: template bool pFlow::geometryMotion::findMotionIndex() { - motionIndex_.clear(); - triMotionIndex_.reserve( this->surface().capacity() ); - triMotionIndex_.clear(); - - ForAll( surfI, motionComponentName_) + + if(motionComponentName().size() != numSurfaces() ) { - auto mName = motionComponentName_[surfI]; - auto mInd = motionModel_.nameToIndex(mName); - motionIndex_.push_back(mInd); - // fill motionIndex for triangles of the surface - int32 surfSize = this->surface().surfNumTriangles(surfI); - for(int32 i=0; i "<< + motionModel_.componentNames(); + } + surfMotionIndex.push_back(mInd); + + auto surfRange = this->surface().subSurfaceRange(surfI); + + for(uint32 i=0; isurface().subSurfacePointRange(surfI); + for(uint32 n=0; n::geometryMotion ) : geometry(control, prop), - motionModel_( - this->owner().template emplaceObject( - objectFile( - motionModelFile__, - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_ALWAYS - ) - ) + motionModel_ + ( + objectFile + ( + motionModelFile__, + "", + objectFile::READ_ALWAYS, + objectFile::WRITE_ALWAYS ), + owner() + ), moveGeomTimer_("move geometry", &this->timers()) { - findMotionIndex(); -} - -template -pFlow::geometryMotion::geometryMotion -( - systemControl& control, - const property& prop, - const multiTriSurface& triSurface, - const wordVector& motionCompName, - const wordVector& propName, - const MotionModel& motionModel -) -: - geometry( - control, - prop, - triSurface, - motionCompName, - propName - ), - motionModel_( - this->owner().template emplaceObject( - objectFile( - motionModelFile__, - "", - objectFile::READ_NEVER, - objectFile::WRITE_ALWAYS - ), - motionModel - ) - ), - moveGeomTimer_("move geometry", &this->timers()) -{ - findMotionIndex(); -} - -template -pFlow::geometryMotion::geometryMotion -( - systemControl& control, - const property& prop, - const dictionary& dict, - const multiTriSurface& triSurface, - const wordVector& motionCompName, - const wordVector& propName -) -: - geometry( - control, - prop, - dict, - triSurface, - motionCompName, - propName - ), - motionModel_( - this->owner().template emplaceObject( - objectFile( - motionModelFile__, - "", - objectFile::READ_NEVER, - objectFile::WRITE_ALWAYS - ), - dict - ) - ), - moveGeomTimer_("move geometry", &this->timers()) -{ - findMotionIndex(); -} - -template -bool pFlow::geometryMotion::beforeIteration() -{ - geometry::beforeIteration(); - return true; -} - -template -bool pFlow::geometryMotion::iterate() -{ - if( motionModel_.isMoving() ) + if(!findMotionIndex()) { - moveGeomTimer_.start(); - moveGeometry(); - moveGeomTimer_.end(); + fatalExit; } - return true; } -template -bool pFlow::geometryMotion::afterIteration() +template +pFlow::geometryMotion::geometryMotion +( + systemControl &control, + const property &prop, + multiTriSurface &surf, + const wordVector &motionCompName, + const wordVector &materialName, + const dictionary &motionDict +) +: + geometry + ( + control, + prop, + surf, + motionCompName, + materialName, + motionDict + ), + motionModel_ + ( + objectFile + ( + motionModelFile__, + "", + objectFile::READ_NEVER, + objectFile::WRITE_ALWAYS + ), + motionDict, + owner() + ), + moveGeomTimer_("move geometry", &this->timers()) { - geometry::afterIteration(); - return true; -} + if(!findMotionIndex()) + { + fatalExit; + } +} -template -bool pFlow::geometryMotion::moveGeometry() -{ +/*template + pFlow::geometryMotion::geometryMotion + ( + systemControl& control, + const property& prop, + const multiTriSurface& triSurface, + const wordVector& motionCompName, + const wordVector& propName, + const MotionModel& motionModel + ) + : + geometry( + control, + prop, + triSurface, + motionCompName, + propName + ), + motionModel_( + this->owner().template emplaceObject( + objectFile( + motionModelFile__, + "", + objectFile::READ_NEVER, + objectFile::WRITE_ALWAYS + ), + motionModel + ) + ), + moveGeomTimer_("move geometry", &this->timers()) + { + findMotionIndex(); + } - real dt = this->dt(); - real t = this->currentTime(); + template + pFlow::geometryMotion::geometryMotion + ( + systemControl& control, + const property& prop, + const dictionary& dict, + const multiTriSurface& triSurface, + const wordVector& motionCompName, + const wordVector& propName + ) + : + geometry( + control, + prop, + dict, + triSurface, + motionCompName, + propName + ), + motionModel_( + this->owner().template emplaceObject( + objectFile( + motionModelFile__, + "", + objectFile::READ_NEVER, + objectFile::WRITE_ALWAYS + ), + dict + ) + ), + moveGeomTimer_("move geometry", &this->timers()) + { + findMotionIndex(); + } - auto pointMIndex= pointMotionIndex_.deviceVector(); - auto mModel = motionModel_.getModel(t); - realx3* points = triSurface_.pointsData_D(); - auto numPoints = triSurface_.numPoints(); + template + bool pFlow::geometryMotion::beforeIteration() + { + geometry::beforeIteration(); + return true; + } + + template + bool pFlow::geometryMotion::iterate() + { + if( motionModel_.isMoving() ) + { + moveGeomTimer_.start(); + 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::parallel_for( + "geometryMotion::movePoints", + numPoints, + LAMBDA_HD(int32 i){ + auto newPos = mModel.transferPoint(pointMIndex[i], points[i], dt); + points[i] = newPos; + }); - Kokkos::fence(); + Kokkos::fence(); - // move the motion components - motionModel_.move(t,dt); + // move the motion components + motionModel_.move(t,dt); - // end of calculations - moveGeomTimer_.end(); + // end of calculations + moveGeomTimer_.end(); - return true; -} \ No newline at end of file + return true; + }*/ \ No newline at end of file diff --git a/src/Geometry/geometryMotion/geometryMotion.hpp b/src/Geometry/geometryMotion/geometryMotion.hpp index cf47c613..a7b0c3bc 100644 --- a/src/Geometry/geometryMotion/geometryMotion.hpp +++ b/src/Geometry/geometryMotion/geometryMotion.hpp @@ -20,9 +20,8 @@ Licence: #ifndef __geometryMotion_hpp__ #define __geometryMotion_hpp__ - +#include "vocabs.hpp" #include "geometry.hpp" -#include "VectorDuals.hpp" namespace pFlow { @@ -38,22 +37,22 @@ class geometryMotion public geometry { public: - - using MotionModel = MotionModelType; -protected: + using ModelComponent = typename MotionModelType::ModelComponent; + +private: /// Ref to motion model - MotionModel& motionModel_; + MotionModelType motionModel_; /// motion indext mapped on each surface - int32Vector_HD motionIndex_; + uint32Field_D surfMotionIndex_{"triMotionIndex"}; /// motion index mapped on each triangle - int8Vector_HD triMotionIndex_; + uint32Field_D triMotionIndex_ {"surfMotionIndex"}; /// motion index mapped on each point - int8Vector_HD pointMotionIndex_; + uint32Field_D pointMotionIndex_{"pointMotionIndex"}; /// timer for moveGeometry Timer moveGeomTimer_; @@ -64,37 +63,45 @@ protected: public: /// Type info - TypeInfoTemplate("geometry", MotionModel); + TypeInfoTemplate11("geometry", ModelComponent); // - Constructors geometryMotion(systemControl& control, const property& prop); - geometryMotion( + systemControl& control, + const property& prop, + multiTriSurface& surf, + const wordVector& motionCompName, + const wordVector& materialName, + const dictionary& motionDict); + + + /*geometryMotion( systemControl& control, const property& prop, const multiTriSurface& triSurface, const wordVector& motionCompName, const wordVector& propName, - const MotionModel& motionModel); + const MotionModel& motionModel);*/ /// Construct from components and dictionary that contains /// motionModel - geometryMotion(systemControl& control, + /*geometryMotion(systemControl& control, const property& prop, const dictionary& dict, const multiTriSurface& triSurface, const wordVector& motionCompName, - const wordVector& propName); + const wordVector& propName);*/ /// Add virtual constructor - add_vCtor + /*add_vCtor ( geometry, geometryMotion, systemControl - ); + );*/ /// Add virtual constructor add_vCtor @@ -107,19 +114,19 @@ public: // - Methods /// Obtain motion model at time t - auto getModel(real t)const + /*auto getModel(real t)const { return motionModel_.getModel(t); - } + }*/ /// TypeName / TypeInfo of motion model - word motionModelTypeName()const override + /*word motionModelTypeName()const override { return motionModel_.typeName(); - } + }*/ /// Access to motion model index of triangles - const int8Vector_HD& triMotionIndex()const override + /*const auto& triMotionIndex()const override { return triMotionIndex_; } @@ -128,19 +135,19 @@ public: const int8Vector_HD& pointMotionIndex()const override { return pointMotionIndex_; - } + }*/ /// Operations before each iteration - bool beforeIteration() override; + /*bool beforeIteration() override; /// Iterate geometry one time step bool iterate() override ; /// Operations after each iteration - bool afterIteration() override; + bool afterIteration() override;*/ /// Move geometry - bool moveGeometry(); + //bool moveGeometry(); }; diff --git a/src/Geometry/geometryMotion/geometryMotions.hpp b/src/Geometry/geometryMotion/geometryMotions.hpp index cd636ae6..e0c109a1 100644 --- a/src/Geometry/geometryMotion/geometryMotions.hpp +++ b/src/Geometry/geometryMotion/geometryMotions.hpp @@ -22,22 +22,22 @@ Licence: #define __geometryMotions_hpp__ #include "geometryMotion.hpp" -#include "fixedWall.hpp" +#include "stationaryWall.hpp" #include "rotatingAxisMotion.hpp" -#include "multiRotatingAxisMotion.hpp" +//#include "multiRotatingAxisMotion.hpp" #include "vibratingMotion.hpp" namespace pFlow { -typedef geometryMotion vibratingMotionGeometry; +using vibratingMotionGeometry = geometryMotion; -typedef geometryMotion rotationAxisMotionGeometry; +using rotationAxisMotionGeometry = geometryMotion; -typedef geometryMotion multiRotationAxisMotionGeometry; +//typedef geometryMotion multiRotationAxisMotionGeometry; -typedef geometryMotion fixedGeometry; +typedef geometryMotion stationaryGeometry; diff --git a/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp b/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp index a8ec4fd9..334e2aad 100644 --- a/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp +++ b/src/Geometry/geometryMotion/geometryMotionsInstantiate.cpp @@ -18,15 +18,15 @@ Licence: -----------------------------------------------------------------------------*/ -#include "fixedWall.hpp" +#include "stationaryWall.hpp" #include "rotatingAxisMotion.hpp" -#include "multiRotatingAxisMotion.hpp" +//#include "multiRotatingAxisMotion.hpp" #include "vibratingMotion.hpp" -template class pFlow::geometryMotion; +template class pFlow::geometryMotion; template class pFlow::geometryMotion; -template class pFlow::geometryMotion; +//template class pFlow::geometryMotion; template class pFlow::geometryMotion; diff --git a/src/MotionModel/CMakeLists.txt b/src/MotionModel/CMakeLists.txt index 6f74b231..b0b084fd 100644 --- a/src/MotionModel/CMakeLists.txt +++ b/src/MotionModel/CMakeLists.txt @@ -1,13 +1,16 @@ list(APPEND SourceFiles entities/timeInterval/timeInterval.cpp + entities/rotatingAxis/rotatingAxis.cpp rotatingAxisMotion/rotatingAxisMotion.cpp - entities/vibrating/vibrating.cpp vibratingMotion/vibratingMotion.cpp -#fixedWall/fixedWall.cpp + +stationaryWall/stationaryWall.cpp +entities/stationary/stationary.cpp + #entities/multiRotatingAxis/multiRotatingAxis.cpp #multiRotatingAxisMotion/multiRotatingAxisMotion.cpp diff --git a/src/MotionModel/MotionModel/MotionModel.hpp b/src/MotionModel/MotionModel/MotionModel.hpp index a6a2b2ab..db1cdf46 100644 --- a/src/MotionModel/MotionModel/MotionModel.hpp +++ b/src/MotionModel/MotionModel/MotionModel.hpp @@ -149,7 +149,11 @@ protected: bool impl_indexToName(uint32 i, word& name)const; - + const wordList& impl_componentNames()const + { + return componentNames_; + } + bool impl_isMoving()const { return false; @@ -221,6 +225,11 @@ public: { return getModel().impl_indexToName(idx, name); } + + const wordList& componentNames()const + { + return getModel().impl_componentNames(); + } /// Are walls moving bool isMoving()const diff --git a/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp b/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp index 1f023e1c..2625ad30 100644 --- a/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp +++ b/src/MotionModel/entities/rotatingAxis/rotatingAxis.hpp @@ -75,6 +75,8 @@ public: // - Constructor + TypeInfoNV("rotatingAxis"); + /// Empty constructor FUNCTION_HD rotatingAxis()=default; diff --git a/src/MotionModel/entities/stationary/stationary.cpp b/src/MotionModel/entities/stationary/stationary.cpp new file mode 100644 index 00000000..def835df --- /dev/null +++ b/src/MotionModel/entities/stationary/stationary.cpp @@ -0,0 +1,57 @@ +/*------------------------------- 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 "stationary.hpp" + + + +FUNCTION_H +pFlow::stationary::stationary(const dictionary& dict) +{ +} + + + +FUNCTION_H +bool pFlow::stationary::read(const dictionary& dict) +{ + return true; +} + +FUNCTION_H +bool pFlow::stationary::write(dictionary& dict) const +{ + + return true; +} + +FUNCTION_H +bool pFlow::stationary::read(iIstream& is) +{ + + notImplementedFunction; + return true; +} + +FUNCTION_H +bool pFlow::stationary::write(iOstream& os)const +{ + return true; +} \ No newline at end of file diff --git a/src/MotionModel/entities/stationary/stationary.hpp b/src/MotionModel/entities/stationary/stationary.hpp new file mode 100644 index 00000000..43dd495f --- /dev/null +++ b/src/MotionModel/entities/stationary/stationary.hpp @@ -0,0 +1,104 @@ +/*------------------------------- 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 __stationary_hpp__ +#define __stationary_hpp__ + + +#include "types.hpp" +#include "typeInfo.hpp" +#include "streams.hpp" + +namespace pFlow +{ + +// forward +class dictionary; + + +/** + * stationary model for a wall + * + */ +class stationary +{ +public: + + TypeInfoNV("stationary"); + + FUNCTION_HD + stationary()=default; + + FUNCTION_H + explicit stationary(const dictionary& dict); + + + FUNCTION_HD + stationary(const stationary&) = default; + + stationary& operator=(const stationary&) = default; + + INLINE_FUNCTION_HD + void setTime(real t) + {} + + INLINE_FUNCTION_HD + realx3 linTangentialVelocityPoint(const realx3 &)const + { + return zero3; + } + + INLINE_FUNCTION_HD + realx3 transferPoint(const realx3& p, real dt) + { + return p; + } + + // - IO operation + FUNCTION_H + bool read(const dictionary& dict); + + FUNCTION_H + bool write(dictionary& dict) const; + + FUNCTION_H + bool read(iIstream& is); + + FUNCTION_H + bool write(iOstream& os)const; + +}; + +inline iOstream& operator <<(iOstream& os, const stationary& obj) +{ + + return os; +} + +inline iIstream& operator >>(iIstream& is, stationary& obj) +{ + + return is; +} + +} + + +#endif diff --git a/src/MotionModel/entities/vibrating/vibrating.hpp b/src/MotionModel/entities/vibrating/vibrating.hpp index 610fd0f7..f7c3f56b 100644 --- a/src/MotionModel/entities/vibrating/vibrating.hpp +++ b/src/MotionModel/entities/vibrating/vibrating.hpp @@ -94,6 +94,8 @@ private: public: + TypeInfoNV("vibrating"); + FUNCTION_HD vibrating()=default; diff --git a/src/MotionModel/fixedWall/fixedWall.cpp b/src/MotionModel/fixedWall/fixedWall.cpp deleted file mode 100644 index 6c3dba2e..00000000 --- a/src/MotionModel/fixedWall/fixedWall.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/*------------------------------- 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 "fixedWall.hpp" -#include "dictionary.hpp" -#include "vocabs.hpp" - -bool pFlow::fixedWall::readDictionary -( - const dictionary& dict -) -{ - - auto motionModel = dict.getVal("motionModel"); - - if(motionModel != "fixedWall") - { - fatalErrorInFunction<< - " motionModel should be fixedWall, but found " << motionModel <impl_writeDictionary(newDict) || + !newDict.write(os)) + { + fatalErrorInFunction<< + " error in writing to dictionary "<< newDict.globalName()< +{ +protected: + + bool impl_isMoving()const + { + return false; + } + +public: + + TypeInfo("stationaryWall"); + + stationaryWall(const objectFile& objf, repository* owner); + + stationaryWall( + const objectFile& objf, + const dictionary& dict, + repository* owner); + + + bool write(iOstream& os, const IOPattern& iop)const override; + + static + auto noneComponent() + { + return stationary(); + } +}; + +} // pFlow + + +#endif // __stationaryWall_hpp__ \ No newline at end of file diff --git a/src/MotionModel/vibratingMotion/vibratingMotion.cpp b/src/MotionModel/vibratingMotion/vibratingMotion.cpp index 12039b60..1226384c 100644 --- a/src/MotionModel/vibratingMotion/vibratingMotion.cpp +++ b/src/MotionModel/vibratingMotion/vibratingMotion.cpp @@ -14,6 +14,22 @@ pFlow::vibratingMotion::vibratingMotion } } +pFlow::vibratingMotion::vibratingMotion +( + const objectFile &objf, + const dictionary &dict, + repository *owner +) +: + fileDictionary(objf,dict,owner) +{ + if(! getModel().impl_readDictionary(*this) ) + { + fatalErrorInFunction; + fatalExit; + } +} + bool pFlow::vibratingMotion::write(iOstream &os, const IOPattern &iop) const { // a global dictionary diff --git a/src/MotionModel/vibratingMotion/vibratingMotion.hpp b/src/MotionModel/vibratingMotion/vibratingMotion.hpp index d97b2380..65b9e3c2 100644 --- a/src/MotionModel/vibratingMotion/vibratingMotion.hpp +++ b/src/MotionModel/vibratingMotion/vibratingMotion.hpp @@ -81,6 +81,11 @@ public: vibratingMotion(const objectFile& objf, repository* owner); + vibratingMotion( + const objectFile& objf, + const dictionary& dict, + repository* owner); + /// Destructor ~vibratingMotion()override = default; diff --git a/src/phasicFlow/containers/Field/Field.cpp b/src/phasicFlow/containers/Field/Field.cpp index dd4506e4..335fbe49 100644 --- a/src/phasicFlow/containers/Field/Field.cpp +++ b/src/phasicFlow/containers/Field/Field.cpp @@ -118,7 +118,10 @@ bool pFlow::Field::write if(!VectorType::write(os, iop)) return false; if(iop.thisProcWriteData()) + { os.endEntry(); + os.newLine(); + } if(!os.check(FUNCTION_NAME))return false; diff --git a/src/phasicFlow/containers/Field/Field.hpp b/src/phasicFlow/containers/Field/Field.hpp index e1eb18c2..405cf68e 100644 --- a/src/phasicFlow/containers/Field/Field.hpp +++ b/src/phasicFlow/containers/Field/Field.hpp @@ -82,7 +82,11 @@ public: VectorType() {} - + Field(const word& name) + : + VectorType(name) + {} + /// Construct an empty field with name and fieldKey Field(const word& name, const word& fieldKey) : diff --git a/src/phasicFlow/containers/Vector/Vector.hpp b/src/phasicFlow/containers/Vector/Vector.hpp index f2511fd5..6b6eda77 100644 --- a/src/phasicFlow/containers/Vector/Vector.hpp +++ b/src/phasicFlow/containers/Vector/Vector.hpp @@ -289,6 +289,9 @@ public: // - fill the whole content of vector, [begin, end), with val void fill( const T& val); + /// fill the content in range [start, end) + void fill( uint32 start, uint32 end, const T& val); + inline auto getSpan() { diff --git a/src/phasicFlow/containers/Vector/VectorI.hpp b/src/phasicFlow/containers/Vector/VectorI.hpp index c4426169..38c7a5fd 100644 --- a/src/phasicFlow/containers/Vector/VectorI.hpp +++ b/src/phasicFlow/containers/Vector/VectorI.hpp @@ -1,3 +1,4 @@ +#include "Vector.hpp" /*------------------------------- phasicFlow --------------------------------- O C enter of O O E ngineering and @@ -24,9 +25,17 @@ inline void pFlow::Vector::fill( const T& val) std::fill(this->begin(), this->end(), val); } +template +inline void pFlow::Vector::fill(uint32 start, uint32 end, const T &val) +{ + + for(uint32 i=start; iat(i) = val; + } +} #pragma hd_warning_disable -template -inline void pFlow::Vector::operator +=( const T& val) +template < typename T, typename Allocator> inline void pFlow::Vector < T, Allocator> ::operator+= (const T &val) { for( auto& v:(*this) ) { diff --git a/src/phasicFlow/containers/VectorHD/VectorSingle.cpp b/src/phasicFlow/containers/VectorHD/VectorSingle.cpp index 72f2790b..b4d9079a 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingle.cpp +++ b/src/phasicFlow/containers/VectorHD/VectorSingle.cpp @@ -362,6 +362,7 @@ void pFlow::VectorSingle::fill const T& val ) { + changeSize(r.end()); pFlow::fill(view_, r, val); } @@ -373,6 +374,7 @@ void pFlow::VectorSingle::assign const T& val ) { + if( n > capacity() ) { reallocateCapacitySize(evalCapacity(n), n); @@ -392,11 +394,13 @@ void pFlow::VectorSingle::assign uint32 cap ) { + // make sure that vector has enough capacity + uint32 newCap = max(static_cast(src.size()), cap); uint32 srcSize = src.size(); - if(cap != capacity()) + if(newCap != capacity()) { - reallocateCapacitySize(cap, srcSize); + reallocateCapacitySize(newCap, srcSize); } else { @@ -415,7 +419,7 @@ void pFlow::VectorSingle::assign const std::vector& src ) { - assign(src, src.capacity()); + assign(src, this->capacity()); } template INLINE_FUNCTION_H diff --git a/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp b/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp index 37a17c38..9659ab66 100644 --- a/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp +++ b/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp @@ -107,7 +107,39 @@ public: return surface_; } + inline + auto size()const + { + return field_.size(); + } + + inline + auto capacity()const + { + return field_.capacity(); + } + + inline + void assign(const std::vector& vals) + { + if(vals.size() != surface_.size()) + { + fatalErrorInFunction; + fatalExit; + } + field_.assign(vals, surface_.capacity()); + } + bool hearChanges( + real t, + real dt, + uint32 iter, + const message& msg, + const anyList& varList) override + { + notImplementedFunction; + return false; + } //// - IO operations bool write(iOstream& is, const IOPattern& iop)const override; diff --git a/src/phasicFlow/containers/triSurfaceField/triSurfaceFields.hpp b/src/phasicFlow/containers/triSurfaceField/triSurfaceFields.hpp index cf3f6ffa..15311602 100644 --- a/src/phasicFlow/containers/triSurfaceField/triSurfaceFields.hpp +++ b/src/phasicFlow/containers/triSurfaceField/triSurfaceFields.hpp @@ -29,30 +29,19 @@ Licence: namespace pFlow { -/*using realTriSurfaceField_D = triSurfaceField ; +using uint32TriSurfaceField_D = triSurfaceField ; -using realTriSurfaceField_H = triSurfaceField ; +using uint32TriSurfaceField_H = triSurfaceField ; -using realx3TriSurfaceField_D = triSurfaceField ; +using realTriSurfaceField_D = triSurfaceField ; -using realx3TriSurfaceField_H = triSurfaceField ; +using realTriSurfaceField_H = triSurfaceField ; -using realTriSurfaceField_HD = triSurfaceField ; +using realx3TriSurfaceField_D = triSurfaceField ; -using realx3TriSurfaceField_HD = triSurfaceField ; +using realx3TriSurfaceField_H = triSurfaceField ; -using realTriSurfaceField = triSurfaceField> ; -using realx3TriSurfaceField = triSurfaceField> ; - -using int8TriSurfaceField_D = triSurfaceField ; - -using int8TriSurfaceField_H = triSurfaceField ; - -using int8TriSurfaceField_HD = triSurfaceField ; - -using int8TriSurfaceField = triSurfaceField> ; -*/ } diff --git a/src/phasicFlow/dictionary/dictionary.cpp b/src/phasicFlow/dictionary/dictionary.cpp index 156f99a2..58a76958 100644 --- a/src/phasicFlow/dictionary/dictionary.cpp +++ b/src/phasicFlow/dictionary/dictionary.cpp @@ -299,6 +299,13 @@ pFlow::dictionary::dictionary } +pFlow::dictionary::dictionary(const dictionary &src, bool global) +: + dictionary(src) +{ + isGlobal_ = global; +} + pFlow::dictionary& pFlow::dictionary::operator= ( const dictionary& rhs diff --git a/src/phasicFlow/dictionary/dictionary.hpp b/src/phasicFlow/dictionary/dictionary.hpp index d09c03bc..9baba109 100644 --- a/src/phasicFlow/dictionary/dictionary.hpp +++ b/src/phasicFlow/dictionary/dictionary.hpp @@ -144,6 +144,8 @@ public: /// entries_ are copied smoothly. set parrent dict to nullDict dictionary(const dictionary& ); + dictionary(const dictionary& src, bool global); + /// assignment preserve name of this dictionary /// only entries are transfered with ownership diff --git a/src/phasicFlow/dictionary/fileDictionary.cpp b/src/phasicFlow/dictionary/fileDictionary.cpp index 62bd3b2d..0b4eb37c 100644 --- a/src/phasicFlow/dictionary/fileDictionary.cpp +++ b/src/phasicFlow/dictionary/fileDictionary.cpp @@ -43,6 +43,30 @@ pFlow::fileDictionary::fileDictionary(const word &keyword, const fileSystem &fil ) {} +pFlow::fileDictionary::fileDictionary +( + const objectFile &objf, + const dictionary &dict, + repository *owner +) +: + IOobject + ( + objectFile + ( + objf.name(), + objf.localPath(), + objectFile::READ_NEVER, + objf.wFlag() + ), + IOPattern::AllProcessorsSimilar, + owner + ), + dictionary(dict, true) +{ + dictionary::name_ = IOobject::path().wordPath(); +} + bool pFlow::fileDictionary::read(iIstream &is, const IOPattern &iop) { return dictionary::read(is); diff --git a/src/phasicFlow/dictionary/fileDictionary.hpp b/src/phasicFlow/dictionary/fileDictionary.hpp index 2fdc9fe2..b8685dfd 100644 --- a/src/phasicFlow/dictionary/fileDictionary.hpp +++ b/src/phasicFlow/dictionary/fileDictionary.hpp @@ -41,7 +41,10 @@ public: /// construct a dictionary with name and read it from file fileDictionary(const word& keyword, const fileSystem& file); - + fileDictionary( + const objectFile& objf, + const dictionary& dict, + repository* owner=nullptr); /// read from stream bool read(iIstream& is, const IOPattern& iop) override; diff --git a/src/phasicFlow/repository/IOobject/IOobject.cpp b/src/phasicFlow/repository/IOobject/IOobject.cpp index 6745ad0b..052d2afb 100644 --- a/src/phasicFlow/repository/IOobject/IOobject.cpp +++ b/src/phasicFlow/repository/IOobject/IOobject.cpp @@ -36,6 +36,9 @@ pFlow::IOobject::IOobject if(owner_&& !owner->addToRepository(this)) { + fatalErrorInFunction<< + "failed to add object "<< objf.name()<< + " to repository "<< owner->name()<name(), io ) ) { warningInFunction<< - "Failed to add repository " << io->name() << + "Failed to add object " << io->name() << " to repository " << this->name() << ". It is already in this repository. \n"; return false; diff --git a/src/phasicFlow/triSurface/multiTriSurface.cpp b/src/phasicFlow/triSurface/multiTriSurface.cpp index 8b62fa18..b2c04995 100644 --- a/src/phasicFlow/triSurface/multiTriSurface.cpp +++ b/src/phasicFlow/triSurface/multiTriSurface.cpp @@ -171,6 +171,20 @@ pFlow::multiTriSurface::multiTriSurface } } +pFlow::multiTriSurface::multiTriSurface +( + const objectFile &objf, + repository *owner, + const multiTriSurface &surf +) +: + triSurface(objf, owner, surf), + subscriber("multiTriSurface"), + subSurfaces_(surf.subSurfaces_) +{ + +} + bool pFlow::multiTriSurface::appendTriSurface ( const word &name, @@ -193,8 +207,17 @@ bool pFlow::multiTriSurface::appendTriSurface } bool pFlow::multiTriSurface::read(iIstream &is, const IOPattern &iop) -{ - return false; +{ + subSurfaces_.clear(); + + if( !is.findKeywordAndVal("subSurfaces", subSurfaces_ ) ) + { + fatalErrorInFunction<< + "Error in reading subSurfaces from stream "<< is.name()<()+">"; \ + return word(tName)+"<"+getTypeName()+">"; \ } \ virtual word typeName() const { return TYPENAME();}