mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +00:00
particles and sphereParticles classes were tested for exit boundary
This commit is contained in:
@ -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);
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
|
50
src/Particles/particles/regularParticleHandler.cpp
Normal file
50
src/Particles/particles/regularParticleHandler.cpp
Normal 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;
|
||||
}
|
60
src/Particles/particles/regularParticleHandler.hpp
Normal file
60
src/Particles/particles/regularParticleHandler.hpp
Normal 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__
|
Reference in New Issue
Block a user