particles and sphereParticles classes were tested for exit boundary

This commit is contained in:
Hamidreza Norouzi 2024-03-22 08:26:14 -07:00
parent acfaacfe4a
commit 49af1119f9
15 changed files with 287 additions and 92 deletions

View File

@ -4,7 +4,8 @@ dynamicPointStructure/dynamicPointStructure.cpp
particles/baseShapeNames.cpp particles/baseShapeNames.cpp
particles/shape.cpp particles/shape.cpp
particles/particles.cpp particles/particles.cpp
#particles/particleIdHandler.cpp particles/particleIdHandler.cpp
particles/regularParticleHandler.cpp
SphereParticles/sphereShape/sphereShape.cpp SphereParticles/sphereShape/sphereShape.cpp
SphereParticles/sphereParticles/sphereParticles.cpp SphereParticles/sphereParticles/sphereParticles.cpp
SphereParticles/sphereParticles/sphereParticlesKernels.cpp SphereParticles/sphereParticles/sphereParticlesKernels.cpp

View File

@ -460,11 +460,11 @@ bool pFlow::sphereParticles::beforeIteration()
{ {
particles::beforeIteration(); particles::beforeIteration();
intPredictTimer_.start(); intPredictTimer_.start();
dynPointStruct().predict(dt(), accelertion()); auto dt = this->dt();
rVelIntegration_().predict(dt(),rVelocity_, rAcceleration_); dynPointStruct().predict(dt, accelertion());
rVelIntegration_().predict(dt,rVelocity_, rAcceleration_);
intPredictTimer_.end(); intPredictTimer_.end();
//WARNING<<"pFlow::sphereParticles::beforeIteration()"<<END_WARNING;
return true; return true;
} }
@ -475,13 +475,13 @@ bool pFlow::sphereParticles::iterate()
accelerationTimer_.start(); accelerationTimer_.start();
pFlow::sphereParticlesKernels::acceleration( pFlow::sphereParticlesKernels::acceleration(
control().g(), control().g(),
mass().deviceView(), mass().deviceViewAll(),
contactForce().deviceView(), contactForce().deviceViewAll(),
I().deviceView(), I().deviceViewAll(),
contactTorque().deviceView(), contactTorque().deviceViewAll(),
dynPointStruct().activePointsMaskDevice(), dynPointStruct().activePointsMaskDevice(),
accelertion().deviceView(), accelertion().deviceViewAll(),
rAcceleration().deviceView() rAcceleration().deviceViewAll()
); );
accelerationTimer_.end(); accelerationTimer_.end();
@ -504,11 +504,6 @@ bool pFlow::sphereParticles::iterate()
return true; return true;
} }
bool pFlow::sphereParticles::afterIteration()
{
particles::afterIteration();
return true;
}
pFlow::word pFlow::sphereParticles::shapeTypeName()const pFlow::word pFlow::sphereParticles::shapeTypeName()const
{ {

View File

@ -184,8 +184,6 @@ public:
/// iterate particles /// iterate particles
bool iterate() override; bool iterate() override;
/// after iteration step
bool afterIteration() override;
realx3PointField_D& rAcceleration() override realx3PointField_D& rAcceleration() override
{ {

View File

@ -59,14 +59,14 @@ void pFlow::sphereParticlesKernels::addMassDiamInertiaProp
void pFlow::sphereParticlesKernels::acceleration void pFlow::sphereParticlesKernels::acceleration
( (
realx3 g, const realx3& g,
deviceViewType1D<real> mass, const deviceViewType1D<real>& mass,
deviceViewType1D<realx3> force, const deviceViewType1D<realx3>& force,
deviceViewType1D<real> I, const deviceViewType1D<real>& I,
deviceViewType1D<realx3> torque, const deviceViewType1D<realx3>& torque,
pFlagTypeDevice incld, const pFlagTypeDevice& incld,
deviceViewType1D<realx3> lAcc, deviceViewType1D<realx3> lAcc,
deviceViewType1D<realx3> rAcc deviceViewType1D<realx3> rAcc
) )
{ {

View File

@ -30,7 +30,7 @@ namespace pFlow::sphereParticlesKernels
void addMassDiamInertiaProp( void addMassDiamInertiaProp(
deviceViewType1D<uint32> shapeIndex, deviceViewType1D<uint32> shapeIndex,
deviceViewType1D<real> mass, deviceViewType1D<real> mass,
deviceViewType1D<real> diameter, deviceViewType1D<real> diameter,
deviceViewType1D<real> I, deviceViewType1D<real> I,
deviceViewType1D<uint32> propertyId, deviceViewType1D<uint32> propertyId,
pFlagTypeDevice incld, pFlagTypeDevice incld,
@ -41,14 +41,14 @@ void addMassDiamInertiaProp(
); );
void acceleration( void acceleration(
realx3 g, const realx3& g,
deviceViewType1D<real> mass, const deviceViewType1D<real>& mass,
deviceViewType1D<realx3> force, const deviceViewType1D<realx3>& force,
deviceViewType1D<real> I, const deviceViewType1D<real>& I,
deviceViewType1D<realx3> torque, const deviceViewType1D<realx3>& torque,
pFlagTypeDevice incld, const pFlagTypeDevice& incld,
deviceViewType1D<realx3> lAcc, deviceViewType1D<realx3> lAcc,
deviceViewType1D<realx3> rAcc deviceViewType1D<realx3> rAcc
); );

View File

@ -93,6 +93,25 @@ pFlow::dynamicPointStructure::dynamicPointStructure
}*/ }*/
bool pFlow::dynamicPointStructure::beforeIteration()
{
return pointStructure::beforeIteration();
/*real dt = this->dt();
auto& acc = time().lookupObject<realx3PointField_D>("acceleration");
return predict(dt, acc);*/
}
bool pFlow::dynamicPointStructure::iterate()
{
return pointStructure::iterate();
/*real dt = this->dt();
auto& acc = time().lookupObject<realx3PointField_D>("acceleration");
return correct(dt, acc);*/
}
bool pFlow::dynamicPointStructure::predict( bool pFlow::dynamicPointStructure::predict(
real dt, real dt,
realx3PointField_D &acceleration) realx3PointField_D &acceleration)

View File

@ -51,7 +51,7 @@ public:
TypeInfo("dynamicPointStructure"); TypeInfo("dynamicPointStructure");
dynamicPointStructure(systemControl& control); explicit dynamicPointStructure(systemControl& control);
dynamicPointStructure(const dynamicPointStructure& ps) = delete; dynamicPointStructure(const dynamicPointStructure& ps) = delete;
@ -81,11 +81,12 @@ public:
} }
/// In the time loop before iterate /// In the time loop before iterate
//bool beforeIteration() override; bool beforeIteration() override;
/// @brief This is called in time loop. Perform the main calculations /// @brief This is called in time loop. Perform the main calculations
/// when the component should evolve along time. /// when the component should evolve along time.
//bool iterate() override; bool iterate() override;

View File

@ -23,6 +23,10 @@ Licence:
bool pFlow::baseShapeNames::createHashNames() bool pFlow::baseShapeNames::createHashNames()
{ {
hashNames_.clear(); hashNames_.clear();
hashes_.clear();
std::hash<word> hasher;
uint32 i=0; uint32 i=0;
for(const auto& nm:shapeNames_) for(const auto& nm:shapeNames_)
{ {
@ -32,6 +36,7 @@ bool pFlow::baseShapeNames::createHashNames()
" repeated name in the list of shape names: " << shapeNames_; " repeated name in the list of shape names: " << shapeNames_;
return false; return false;
} }
hashes_.push_back(hasher(nm));
i++; i++;
} }
hashNames_.rehash(0); hashNames_.rehash(0);

View File

@ -36,18 +36,23 @@ class baseShapeNames
{ {
private: private:
size_t numShapes_; size_t numShapes_ = 0;
// - hashed list of spheres names // - hashed list of spheres names
wordHashMap<uint32> hashNames_; wordHashMap<uint32> hashNames_;
/// list of shape names /// list of shape names
wordVector shapeNames_; wordVector shapeNames_{"shapeNames"};
/// hash for names
Vector<size_t> hashes_{"hashes"};
bool createHashNames(); bool createHashNames();
bool readFromDictionary1(); bool readFromDictionary1();
using hasher = typename wordHashMap<uint32>::hasher;
protected: protected:
virtual virtual
@ -78,6 +83,12 @@ public:
return wl; return wl;
} }
inline
const auto& hashes()const
{
return hashes_;
}
inline inline
size_t numShapes()const size_t numShapes()const
{ {
@ -111,6 +122,20 @@ public:
return false; return false;
} }
inline bool hashToIndex(const size_t& hs, uint32& idx)
{
for(auto i=0; i<hashes_.size(); i++)
{
if(hashes_[i]==hs)
{
idx = i;
return true;
}
}
idx = -1;
return false;
}
inline inline
bool indexValid(uint32 index)const bool indexValid(uint32 index)const
{ {

View File

@ -20,39 +20,36 @@ Licence:
#include "particleIdHandler.hpp" #include "particleIdHandler.hpp"
pFlow::particleIdHandler::particleIdHandler(uint32PointField_D &id)
:
pFlow::particleIdHandler::particleIdHandler(int32PointField_HD & id) id_(id)
{ {
int32 maxID = maxActive<DeviceSide>(id); }
if( maxID != -1 && id.size() == 0 ) pFlow::uniquePtr<pFlow::particleIdHandler>
pFlow::particleIdHandler::create(uint32PointField_D &id)
{
word idHType = angleBracketsNames(
"particleIdHandler",
pFlowProcessors().localRunTypeName());
if( pointFieldvCtorSelector_.search(idHType) )
{ {
nextId_ = 0; REPORT(1)<<"Creating particle id handler "<<
} Green_Text(idHType)<<END_REPORT;
else if( maxID == -1 && id.size()>0 ) return pointFieldvCtorSelector_[idHType] (id);
{
nextId_ = 0;
id.modifyOnHost();
ForAll(i,id)
{
if(id.isActive(i))
{
id[i] = getNextId();
}
}
id.syncViews();
}
else if( maxID >= static_cast<int32>(id.size()) )
{
nextId_ = maxID + 1;
} }
else else
{ {
nextId_ = id.size(); printKeys
(
fatalError << "Ctor Selector "<< idHType << " dose not exist. \n"
<<"Avaiable ones are: \n\n"
,
pointFieldvCtorSelector_
);
fatalExit;
} }
return nullptr;
} }

View File

@ -29,20 +29,44 @@ namespace pFlow
class particleIdHandler class particleIdHandler
{ {
private:
uint32PointField_D& id_;
protected: protected:
int32 nextId_=0;
auto& id()
{
return id_;
}
public: public:
particleIdHandler(int32PointField_HD & id);
int32 getNextId() TypeInfo("particleIdHandler");
{
return nextId_++; explicit particleIdHandler(uint32PointField_D & id);
}
create_vCtor
(
particleIdHandler,
pointField,
(uint32PointField_D & id),
(id)
);
virtual
~particleIdHandler()=default;
virtual
Pair<uint32, uint32> getIdRange(uint32 nNewParticles)=0;
virtual
bool initialIdCheck()=0;
static
uniquePtr<particleIdHandler> create(
uint32PointField_D & id);
int32 nextId() const
{
return nextId_;
}
}; };
} }

View File

@ -40,6 +40,7 @@ pFlow::particles::particles
objectFile::WRITE_ALWAYS objectFile::WRITE_ALWAYS
), ),
dynPointStruct_, dynPointStruct_,
static_cast<uint32>(-1),
static_cast<uint32>(-1) static_cast<uint32>(-1)
), ),
shapeIndex_ shapeIndex_
@ -79,19 +80,22 @@ pFlow::particles::particles
objectFile::READ_IF_PRESENT, objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS), objectFile::WRITE_ALWAYS),
dynPointStruct_, dynPointStruct_,
zero3) zero3),
idHandler_(particleIdHandler::create(id_))
{ {
this->addToSubscriber(dynPointStruct_); this->addToSubscriber(dynPointStruct_);
idHandler_().initialIdCheck();
} }
bool pFlow::particles::beforeIteration() bool pFlow::particles::beforeIteration()
{ {
dynPointStruct_.beforeIteration();
zeroForce(); zeroForce();
zeroTorque(); zeroTorque();
return true; return dynPointStruct_.beforeIteration();
} }
bool pFlow::particles::iterate() bool pFlow::particles::iterate()

View File

@ -25,11 +25,11 @@ Licence:
#include "dynamicPointStructure.hpp" #include "dynamicPointStructure.hpp"
#include "demComponent.hpp" #include "demComponent.hpp"
#include "shape.hpp" #include "shape.hpp"
#include "particleIdHandler.hpp"
namespace pFlow namespace pFlow
{ {
class particles class particles
: :
public observer, public observer,
@ -55,14 +55,11 @@ private:
/// contact torque field /// contact torque field
realx3PointField_D contactTorque_; realx3PointField_D contactTorque_;
uniquePtr<particleIdHandler> idHandler_ = nullptr;
static inline static inline
const message defaultMessage_ = const message defaultMessage_{message::DEFAULT};
(
message::CAP_CHANGED+
message::SIZE_CHANGED+
message::ITEM_INSERT+
message::ITEM_DELETE
);
void zeroForce() void zeroForce()
@ -107,11 +104,30 @@ public:
explicit particles(systemControl& control); explicit particles(systemControl& control);
inline const auto& dynPointStruct()const inline
const auto& dynPointStruct()const
{ {
return dynPointStruct_; return dynPointStruct_;
} }
inline
const pointStructure& pStruct()const
{
return dynPointStruct_;
}
inline
const auto& simDomain()const
{
return dynPointStruct_.simDomain();
}
inline
const auto& thisDomain()const
{
return dynPointStruct_.thisDomain();
}
inline auto size()const{ inline auto size()const{
return dynPointStruct_.size(); return dynPointStruct_.size();
} }

View File

@ -0,0 +1,50 @@
#include "regularParticleHandler.hpp"
pFlow::regularParticleHandler::regularParticleHandler
(
uint32PointField_D & id
)
:
particleIdHandler(id)
{
}
pFlow::Pair<pFlow::uint32, pFlow::uint32>
pFlow::regularParticleHandler::getIdRange(uint32 nNewParticles)
{
uint32 startId;
if(maxId_==-1)
{
startId = 0;
}
else
{
startId = maxId_+1;
}
uint32 endId = startId+nNewParticles-1;
maxId_ = endId;
return {startId, endId};
}
bool pFlow::regularParticleHandler::initialIdCheck()
{
/// empty point structure / no particles in simulation
if( id().pStruct().empty() ) return true;
uint32 maxId = max(id());
/// particles should get ids from 0 to size-1
if(maxId == -1)
{
fillSequence(id(),0u);
maxId_ = id().size()-1;
}
else
{
maxId_ = maxId;
}
return true;
}

View File

@ -0,0 +1,60 @@
/*------------------------------- 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 __regularParticleHandler_hpp__
#define __regularParticleHandler_hpp__
#include "particleIdHandler.hpp"
namespace pFlow
{
class regularParticleHandler
:
public particleIdHandler
{
private:
uint32 maxId_ = -1;
public:
TypeInfo("particleIdHandler<regular>");
explicit regularParticleHandler(uint32PointField_D & id);
~regularParticleHandler()override = default;
add_vCtor
(
particleIdHandler,
regularParticleHandler,
pointField
);
Pair<uint32, uint32> getIdRange(uint32 nNewParticles)override;
bool initialIdCheck()override;
};
}
#endif //__regularParticleHandler_hpp__