Particle insertion is added with anyList

- collision check is not active yet.
- variable velocity is not active yet.
- events and messages are not active yet.
This commit is contained in:
Hamidreza Norouzi
2024-04-12 22:39:09 -07:00
parent 97f0ddf82e
commit 9c2a9a81b0
71 changed files with 1878 additions and 1534 deletions

View File

@ -1,47 +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.
-----------------------------------------------------------------------------*/
#ifndef __demParticles_hpp__
#define __demParticles_hpp__
#include "demComponent.hpp"
namespace pFlow
{
class demParticles
:
public demComponent
{
public:
demParticles(systemControl& control):
demComponent("particles", control)
{}
};
}
#endif

View File

@ -20,25 +20,69 @@ Licence:
#include "particleIdHandler.hpp"
pFlow::particleIdHandler::particleIdHandler(uint32PointField_D &id)
pFlow::particleIdHandler::particleIdHandler(pointStructure& pStruct)
:
id_(id)
uint32PointField_D
(
objectFile
(
"id",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
pStruct,
static_cast<uint32>(-1),
static_cast<uint32>(-1)
)
{
}
pFlow::uniquePtr<pFlow::particleIdHandler>
pFlow::particleIdHandler::create(uint32PointField_D &id)
bool
pFlow::particleIdHandler::hearChanges(
real t,
real dt,
uint32 iter,
const message& msg,
const anyList& varList
)
{
if(msg.equivalentTo(message::ITEM_INSERT))
{
const word eventName = message::eventName(message::ITEM_INSERT);
const auto& indices = varList.getObject<uint32IndexContainer>(
eventName);
uint32 numNew = indices.size();
if(numNew == 0u)return true;
auto idRange = getIdRange(numNew);
uint32Vector newId("newId",numNew,numNew,RESERVE());
fillSequence(newId, idRange.first);
output<< "id "<< idRange<<endl;
return this->field().insertSetElement(indices, newId);
}
else
{
return uint32PointField_D::hearChanges(t,dt,iter, msg,varList);
}
}
pFlow::uniquePtr<pFlow::particleIdHandler>
pFlow::particleIdHandler::create(pointStructure& pStruct)
{
word idHType = angleBracketsNames(
"particleIdHandler",
pFlowProcessors().localRunTypeName());
if( pointFieldvCtorSelector_.search(idHType) )
if( pointStructurevCtorSelector_.search(idHType) )
{
REPORT(1)<<"Creating particle id handler "<<
Green_Text(idHType)<<END_REPORT;
return pointFieldvCtorSelector_[idHType] (id);
return pointStructurevCtorSelector_[idHType] (pStruct);
}
else
{
@ -47,7 +91,7 @@ pFlow::uniquePtr<pFlow::particleIdHandler>
fatalError << "Ctor Selector "<< idHType << " dose not exist. \n"
<<"Avaiable ones are: \n\n"
,
pointFieldvCtorSelector_
pointStructurevCtorSelector_
);
fatalExit;
}

View File

@ -28,34 +28,26 @@ namespace pFlow
{
class particleIdHandler
:
public uint32PointField_D
{
private:
uint32PointField_D& id_;
protected:
auto& id()
{
return id_;
}
public:
TypeInfo("particleIdHandler");
/// class info
ClassInfo("particleIdHandler");
explicit particleIdHandler(uint32PointField_D & id);
explicit particleIdHandler(pointStructure& pStruct);
create_vCtor
(
particleIdHandler,
pointField,
(uint32PointField_D & id),
(id)
pointStructure,
(pointStructure& pStruct),
(pStruct)
);
virtual
~particleIdHandler()=default;
~particleIdHandler()override=default;
virtual
Pair<uint32, uint32> getIdRange(uint32 nNewParticles)=0;
@ -63,9 +55,20 @@ public:
virtual
bool initialIdCheck()=0;
// heat change for possible insertion of particles
// overrdie from internalField
bool hearChanges
(
real t,
real dt,
uint32 iter,
const message& msg,
const anyList& varList
) override;
static
uniquePtr<particleIdHandler> create(
uint32PointField_D & id);
pointStructure& pStruct);
};

View File

@ -2,119 +2,111 @@
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
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
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
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 "particles.hpp"
pFlow::particles::particles
(
systemControl &control
)
:
observer(defaultMessage_),
demComponent("particles", control),
dynPointStruct_(control),
id_
(
objectFile
(
"id",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
dynPointStruct_,
static_cast<uint32>(-1),
static_cast<uint32>(-1)
),
shapeIndex_
(
objectFile
(
"shapeIndex",
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS
),
dynPointStruct_,
0
),
accelertion_
(
objectFile(
"accelertion",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS),
dynPointStruct_,
zero3
),
contactForce_(
objectFile(
"contactForce",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS),
dynPointStruct_,
zero3),
contactTorque_(
objectFile(
"contactTorque",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS),
dynPointStruct_,
zero3),
idHandler_(particleIdHandler::create(id_))
pFlow::particles::particles(systemControl& control)
: observer(defaultMessage_),
demComponent("particles", control),
dynPointStruct_(control),
/*id_(
objectFile(
"id",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
dynPointStruct_,
static_cast<uint32>(-1),
static_cast<uint32>(-1)
),*/
shapeIndex_(
objectFile(
"shapeIndex",
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS
),
dynPointStruct_,
0
),
accelertion_(
objectFile(
"accelertion",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
dynPointStruct_,
zero3
),
contactForce_(
objectFile(
"contactForce",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
dynPointStruct_,
zero3
),
contactTorque_(
objectFile(
"contactTorque",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
dynPointStruct_,
zero3
),
idHandler_(particleIdHandler::create(dynPointStruct_))
{
this->addToSubscriber(dynPointStruct_);
idHandler_().initialIdCheck();
}
bool pFlow::particles::beforeIteration()
bool
pFlow::particles::beforeIteration()
{
zeroForce();
zeroTorque();
return dynPointStruct_.beforeIteration();
}
bool pFlow::particles::iterate()
bool
pFlow::particles::iterate()
{
return dynPointStruct_.iterate();
}
bool pFlow::particles::afterIteration()
bool
pFlow::particles::afterIteration()
{
return dynPointStruct_.afterIteration();
}
void pFlow::particles::boundingSphereMinMax
(
real &minDiam,
real &maxDiam
) const
void
pFlow::particles::boundingSphereMinMax(real& minDiam, real& maxDiam) const
{
auto& shp = getShapes();
minDiam = shp.minBoundingSphere();
maxDiam = shp.maxBoundingSphere();
}
}

View File

@ -1,66 +1,63 @@
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
/*------------------------------- 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.
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 __particles_hpp__
#define __particles_hpp__
#include "dynamicPointStructure.hpp"
#include "demComponent.hpp"
#include "shape.hpp"
#include "dynamicPointStructure.hpp"
#include "particleIdHandler.hpp"
#include "shape.hpp"
namespace pFlow
{
class particles
:
public observer,
public demComponent
: public observer
, public demComponent
{
private:
/// dynamic point structure for particles center mass
dynamicPointStructure dynPointStruct_;
dynamicPointStructure dynPointStruct_;
/// id of particles on host
uint32PointField_D id_;
uint32PointField_D shapeIndex_;
/// shape index of each particle
uint32PointField_D shapeIndex_;
/// acceleration on device
realx3PointField_D accelertion_;
realx3PointField_D accelertion_;
/// contact force field
realx3PointField_D contactForce_;
realx3PointField_D contactForce_;
/// contact torque field
realx3PointField_D contactTorque_;
realx3PointField_D contactTorque_;
/// handling new ids for new particles
uniquePtr<particleIdHandler> idHandler_ = nullptr;
static inline
const message defaultMessage_{message::DEFAULT};
/// messages for this objects
static inline const message defaultMessage_{ message::DEFAULT };
protected:
void zeroForce()
{
@ -72,8 +69,6 @@ private:
contactTorque_.fill(zero3);
}
protected:
inline auto& dynPointStruct()
{
return dynPointStruct_;
@ -81,17 +76,15 @@ protected:
inline auto& pointPosition()
{
return dynPointStruct_.pointPosition();
return dynPointStruct_.pointPosition();
}
/*inline
auto& velocity()
inline auto& idHandler()
{
return dynPointStruct_.velocity();
}*/
inline
auto& shapeIndex()
return idHandler_();
}
inline auto& shapeIndex()
{
return shapeIndex_;
}
@ -103,148 +96,123 @@ public:
explicit particles(systemControl& control);
inline
const auto& dynPointStruct()const
inline const auto& dynPointStruct() const
{
return dynPointStruct_;
}
inline
const pointStructure& pStruct()const
inline const pointStructure& pStruct() const
{
return dynPointStruct_;
}
inline
const auto& simDomain()const
inline const auto& simDomain() const
{
return dynPointStruct_.simDomain();
}
inline
const auto& thisDomain()const
inline const auto& thisDomain() const
{
return dynPointStruct_.thisDomain();
}
inline
const auto& extendedDomain()const
inline const auto& extendedDomain() const
{
return dynPointStruct_.extendedDomain();
}
inline auto size()const{
inline auto size() const
{
return dynPointStruct_.size();
}
inline auto capacity() const{
inline auto capacity() const
{
return dynPointStruct_.capacity();
}
inline auto numActive()const
inline auto numActive() const
{
return dynPointStruct_.numActive();
}
inline bool isAllActive()const
inline bool isAllActive() const
{
return dynPointStruct_.isAllActive();
}
inline
const auto& pointPosition()const
inline const auto& pointPosition() const
{
return dynPointStruct_.pointPosition();
}
inline
const auto& velocity()const
inline const auto& velocity() const
{
return dynPointStruct_.velocity();
}
inline
const auto& accelertion()const
inline const auto& accelertion() const
{
return accelertion_;
}
inline
auto& accelertion()
inline auto& accelertion()
{
return accelertion_;
}
inline
auto& contactForce()
inline auto& contactForce()
{
return contactForce_;
}
inline
const auto& contactForce() const
inline const auto& contactForce() const
{
return contactForce_;
}
inline
auto& contactTorque()
inline auto& contactTorque()
{
return contactTorque_;
}
inline
const auto& contactTorque() const
inline const auto& contactTorque() const
{
return contactTorque_;
}
bool beforeIteration() override;
bool beforeIteration() override;
bool iterate()override;
bool iterate() override;
bool afterIteration() override;
bool afterIteration() override;
/*virtual
bool insertParticles
(
const realx3Vector& position,
const wordVector& shapes,
const setFieldList& setField
) = 0;*/
virtual bool insertParticles(
const realx3Vector& position,
const wordVector& shapesNames,
const anyList& setVarList
) = 0;
virtual
const uint32PointField_D& propertyId()const = 0;
virtual
const realPointField_D& diameter()const = 0;
virtual const uint32PointField_D& propertyId() const = 0;
virtual
const realPointField_D& mass()const = 0;
virtual const realPointField_D& diameter() const = 0;
virtual
realx3PointField_D& rAcceleration() = 0;
virtual const realPointField_D& mass() const = 0;
virtual
const realx3PointField_D& rAcceleration() const = 0;
virtual realx3PointField_D& rAcceleration() = 0;
virtual
const realPointField_D& boundingSphere()const = 0;
virtual const realx3PointField_D& rAcceleration() const = 0;
virtual
word shapeTypeName()const = 0;
virtual const realPointField_D& boundingSphere() const = 0;
virtual
const shape& getShapes()const = 0;
virtual word shapeTypeName() const = 0;
virtual
void boundingSphereMinMax(real & minDiam, real& maxDiam)const = 0;
virtual const shape& getShapes() const = 0;
virtual void boundingSphereMinMax(real& minDiam, real& maxDiam) const = 0;
}; // particles
} // pFlow
} // namespace pFlow
#endif //__particles_hpp__

View File

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

View File

@ -17,15 +17,15 @@ Licence:
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#ifndef __regularParticleHandler_hpp__
#define __regularParticleHandler_hpp__
#ifndef __regularParticleIdHandler_hpp__
#define __regularParticleIdHandler_hpp__
#include "particleIdHandler.hpp"
namespace pFlow
{
class regularParticleHandler
class regularParticleIdHandler
:
public particleIdHandler
{
@ -35,17 +35,17 @@ private:
public:
TypeInfo("particleIdHandler<regular>");
ClassInfo("particleIdHandler<regular>");
explicit regularParticleIdHandler(pointStructure& pStruct);
explicit regularParticleHandler(uint32PointField_D & id);
~regularParticleHandler()override = default;
~regularParticleIdHandler()override = default;
add_vCtor
(
particleIdHandler,
regularParticleHandler,
pointField
regularParticleIdHandler,
pointStructure
);
Pair<uint32, uint32> getIdRange(uint32 nNewParticles)override;
@ -57,4 +57,4 @@ public:
}
#endif //__regularParticleHandler_hpp__
#endif //__regularParticleIdHandler_hpp__

View File

@ -122,6 +122,17 @@ public:
return 0.0;
}
inline
uint32 propertyId(uint32 index)const
{
if(indexValid(index))
{
return shapePropertyIds_[index];
}
fatalExit;
return 0.0;
}
virtual
real maxBoundingSphere()const = 0;