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/shape.cpp
particles/particles.cpp
#particles/particleIdHandler.cpp
particles/particleIdHandler.cpp
particles/regularParticleHandler.cpp
SphereParticles/sphereShape/sphereShape.cpp
SphereParticles/sphereParticles/sphereParticles.cpp
SphereParticles/sphereParticles/sphereParticlesKernels.cpp

View File

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

View File

@ -184,9 +184,7 @@ public:
/// iterate particles
bool iterate() override;
/// after iteration step
bool afterIteration() override;
realx3PointField_D& rAcceleration() override
{
return rAcceleration_;

View File

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

View File

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

View File

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

View File

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

View File

@ -36,18 +36,23 @@ class baseShapeNames
{
private:
size_t numShapes_;
size_t numShapes_ = 0;
// - hashed list of spheres names
wordHashMap<uint32> hashNames_;
/// list of shape names
wordVector shapeNames_;
wordVector shapeNames_{"shapeNames"};
/// hash for names
Vector<size_t> hashes_{"hashes"};
bool createHashNames();
bool readFromDictionary1();
using hasher = typename wordHashMap<uint32>::hasher;
protected:
virtual
@ -78,6 +83,12 @@ public:
return wl;
}
inline
const auto& hashes()const
{
return hashes_;
}
inline
size_t numShapes()const
{
@ -111,6 +122,20 @@ public:
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
bool indexValid(uint32 index)const
{

View File

@ -20,39 +20,36 @@ Licence:
#include "particleIdHandler.hpp"
pFlow::particleIdHandler::particleIdHandler(int32PointField_HD & id)
pFlow::particleIdHandler::particleIdHandler(uint32PointField_D &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;
}
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<int32>(id.size()) )
{
nextId_ = maxID + 1;
REPORT(1)<<"Creating particle id handler "<<
Green_Text(idHType)<<END_REPORT;
return pointFieldvCtorSelector_[idHType] (id);
}
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
{
protected:
int32 nextId_=0;
public:
particleIdHandler(int32PointField_HD & id);
private:
int32 getNextId()
uint32PointField_D& id_;
protected:
auto& id()
{
return nextId_++;
return id_;
}
int32 nextId() const
{
return nextId_;
}
public:
TypeInfo("particleIdHandler");
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);
};
}

View File

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

View File

@ -25,11 +25,11 @@ Licence:
#include "dynamicPointStructure.hpp"
#include "demComponent.hpp"
#include "shape.hpp"
#include "particleIdHandler.hpp"
namespace pFlow
{
class particles
:
public observer,
@ -55,14 +55,11 @@ private:
/// contact torque field
realx3PointField_D contactTorque_;
uniquePtr<particleIdHandler> idHandler_ = nullptr;
static inline
const message defaultMessage_ =
(
message::CAP_CHANGED+
message::SIZE_CHANGED+
message::ITEM_INSERT+
message::ITEM_DELETE
);
const message defaultMessage_{message::DEFAULT};
void zeroForce()
@ -107,10 +104,29 @@ public:
explicit particles(systemControl& control);
inline const auto& dynPointStruct()const
inline
const auto& dynPointStruct()const
{
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{
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__