Merge pull request #159 from PhasicFlow/develop

All messages are revisited for internal points and boundaries
This commit is contained in:
PhasicFlow 2025-02-06 11:06:35 +03:30 committed by GitHub
commit 59fbaa91ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
53 changed files with 431 additions and 846 deletions

View File

@ -67,7 +67,7 @@ bool pFlow::grainFluidParticles::beforeIteration()
bool pFlow::grainFluidParticles::iterate() bool pFlow::grainFluidParticles::iterate()
{ {
const auto ti = this->TimeInfo();
accelerationTimer().start(); accelerationTimer().start();
pFlow::grainFluidParticlesKernels::acceleration( pFlow::grainFluidParticlesKernels::acceleration(
control().g(), control().g(),
@ -78,16 +78,16 @@ bool pFlow::grainFluidParticles::iterate()
contactTorque().deviceViewAll(), contactTorque().deviceViewAll(),
fluidTorque_.deviceViewAll(), fluidTorque_.deviceViewAll(),
pStruct().activePointsMaskDevice(), pStruct().activePointsMaskDevice(),
accelertion().deviceViewAll(), acceleration().deviceViewAll(),
rAcceleration().deviceViewAll() rAcceleration().deviceViewAll()
); );
accelerationTimer().end(); accelerationTimer().end();
intCorrectTimer().start(); intCorrectTimer().start();
dynPointStruct().correct(this->dt(), accelertion()); dynPointStruct().correct(ti.dt());
rVelIntegration().correct(this->dt(), rVelocity(), rAcceleration()); rVelIntegration().correct(ti.dt(), rVelocity(), rAcceleration());
intCorrectTimer().end(); intCorrectTimer().end();

View File

@ -65,7 +65,7 @@ bool pFlow::sphereFluidParticles::beforeIteration()
bool pFlow::sphereFluidParticles::iterate() bool pFlow::sphereFluidParticles::iterate()
{ {
const auto ti = this->TimeInfo();
accelerationTimer().start(); accelerationTimer().start();
pFlow::sphereFluidParticlesKernels::acceleration( pFlow::sphereFluidParticlesKernels::acceleration(
control().g(), control().g(),
@ -76,16 +76,16 @@ bool pFlow::sphereFluidParticles::iterate()
contactTorque().deviceViewAll(), contactTorque().deviceViewAll(),
fluidTorque_.deviceViewAll(), fluidTorque_.deviceViewAll(),
pStruct().activePointsMaskDevice(), pStruct().activePointsMaskDevice(),
accelertion().deviceViewAll(), acceleration().deviceViewAll(),
rAcceleration().deviceViewAll() rAcceleration().deviceViewAll()
); );
accelerationTimer().end(); accelerationTimer().end();
intCorrectTimer().start(); intCorrectTimer().start();
dynPointStruct().correct(this->dt(), accelertion()); dynPointStruct().correct(ti.dt());
rVelIntegration().correct(this->dt(), rVelocity(), rAcceleration()); rVelIntegration().correct(ti.dt(), rVelocity(), rAcceleration());
intCorrectTimer().end(); intCorrectTimer().end();

View File

@ -114,8 +114,11 @@ pFlow::AdamsBashforth2::AdamsBashforth2
zero3, zero3,
zero3 zero3
), ),
initialValField_(initialValField),
boundaryList_(pStruct, method, *this) boundaryList_(pStruct, method, *this)
{} {
realx3PointField_D::addEvent(message::ITEMS_INSERT);
}
void pFlow::AdamsBashforth2::updateBoundariesSlaveToMasterIfRequested() void pFlow::AdamsBashforth2::updateBoundariesSlaveToMasterIfRequested()
{ {
@ -186,11 +189,21 @@ bool pFlow::AdamsBashforth2::correctPStruct(
return success; return success;
} }
bool pFlow::AdamsBashforth2::hearChanges
bool pFlow::AdamsBashforth2::setInitialVals( (
const int32IndexContainer& newIndices, const timeInfo &ti,
const realx3Vector& y) const message &msg,
const anyList &varList
)
{ {
return true; if(msg.equivalentTo(message::ITEMS_INSERT))
{
return insertValues(varList, initialValField_.deviceViewAll(), dy1());
}
else
{
return realx3PointField_D::hearChanges(ti, msg, varList);
}
} }

View File

@ -41,6 +41,8 @@ class AdamsBashforth2
{ {
private: private:
const realx3Field_D& initialValField_;
boundaryIntegrationList boundaryList_; boundaryIntegrationList boundaryList_;
friend class processorAB2BoundaryIntegration; friend class processorAB2BoundaryIntegration;
@ -57,6 +59,11 @@ protected:
return static_cast<realx3PointField_D&>(*this); return static_cast<realx3PointField_D&>(*this);
} }
auto& initialValField()
{
return initialValField_;
}
boundaryIntegrationList& boundaryList() boundaryIntegrationList& boundaryList()
{ {
return boundaryList_; return boundaryList_;
@ -116,25 +123,13 @@ public:
real dt, real dt,
pointStructure& pStruct, pointStructure& pStruct,
realx3PointField_D& vel) override; realx3PointField_D& vel) override;
/*bool hearChanges bool hearChanges
( (
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) override;*/ ) override;
bool setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y) override;
bool needSetInitialVals()const override
{
return false;
}
}; };

View File

@ -184,35 +184,20 @@ bool pFlow::AdamsBashforth3::correctPStruct(
return success; return success;
} }
bool pFlow::AdamsBashforth3::hearChanges
bool pFlow::AdamsBashforth3::setInitialVals( (
const int32IndexContainer& newIndices, const timeInfo &ti,
const realx3Vector& y) const message &msg,
const anyList &varList
)
{ {
return true; if(msg.equivalentTo(message::ITEMS_INSERT))
{
return insertValues(varList, initialValField().deviceViewAll(), dy1()) &&
insertValues(varList, initialValField().deviceViewAll(), dy2());
}
else
{
return realx3PointField_D::hearChanges(ti, msg, varList);
}
} }
/*bool pFlow::AdamsBashforth3::intAll(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
range activeRng)
{
auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceViewAll();
auto d_history = history_.deviceViewAll();
Kokkos::parallel_for(
"AdamsBashforth3::correct",
rpIntegration (activeRng.first, activeRng.second),
LAMBDA_HD(int32 i){
auto ldy = d_dy[i];
d_y[i] += dt*( static_cast<real>(23.0 / 12.0) * ldy
- static_cast<real>(16.0 / 12.0) * d_history[i].dy1_
+ static_cast<real>(5.0 / 12.0) * d_history[i].dy2_);
d_history[i] = {ldy ,d_history[i].dy1_};
});
Kokkos::fence();
return true;
}*/

View File

@ -108,23 +108,12 @@ public:
realx3PointField_D& vel) override; realx3PointField_D& vel) override;
/*bool hearChanges bool hearChanges
( (
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) override;*/ ) override;
bool setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y) override;
bool needSetInitialVals()const override
{
return false;
}
}; };

View File

@ -190,40 +190,21 @@ bool pFlow::AdamsBashforth4::correctPStruct(
return success; return success;
} }
bool pFlow::AdamsBashforth4::setInitialVals( bool pFlow::AdamsBashforth4::hearChanges
const int32IndexContainer& newIndices, (
const realx3Vector& y) const timeInfo &ti,
const message &msg,
const anyList &varList
)
{ {
return true; if(msg.equivalentTo(message::ITEMS_INSERT))
{
return insertValues(varList, initialValField().deviceViewAll(), dy1()) &&
insertValues(varList, initialValField().deviceViewAll(), dy2()) &&
insertValues(varList, initialValField().deviceViewAll(), dy3());
}
else
{
return realx3PointField_D::hearChanges(ti, msg, varList);
}
} }
/*bool pFlow::AdamsBashforth4::intAll(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
range activeRng)
{
auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceViewAll();
auto d_history = history_.deviceViewAll();
Kokkos::parallel_for(
"AdamsBashforth4::correct",
rpIntegration (activeRng.first, activeRng.second),
LAMBDA_HD(int32 i){
d_y[i] += dt*(
static_cast<real>(55.0 / 24.0) * d_dy[i]
- static_cast<real>(59.0 / 24.0) * d_history[i].dy1_
+ static_cast<real>(37.0 / 24.0) * d_history[i].dy2_
- static_cast<real>( 9.0 / 24.0) * d_history[i].dy3_
);
d_history[i].dy3_ = d_history[i].dy2_;
d_history[i].dy2_ = d_history[i].dy1_;
d_history[i].dy1_ = d_dy[i];
});
Kokkos::fence();
return true;
}*/

View File

@ -103,17 +103,13 @@ public:
real dt, real dt,
pointStructure& pStruct, pointStructure& pStruct,
realx3PointField_D& vel) override; realx3PointField_D& vel) override;
bool setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y) override;
bool needSetInitialVals()const override
{
return false;
}
bool hearChanges
(
const timeInfo& ti,
const message& msg,
const anyList& varList
) override;
}; };

View File

@ -51,9 +51,7 @@ public:
); );
bool hearChanges( bool hearChanges(
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message &msg, const message &msg,
const anyList &varList) override const anyList &varList) override
{ {

View File

@ -22,17 +22,39 @@ Licence:
#include "pointStructure.hpp" #include "pointStructure.hpp"
#include "repository.hpp" #include "repository.hpp"
pFlow::integration::integration bool pFlow::integration::insertValues
( (
const word& baseName, const anyList& varList,
pointStructure& pStruct, const deviceViewType1D<realx3>& srcVals,
const word&, realx3PointField_D& dstFeild
const realx3Field_D&
) )
: {
owner_(*pStruct.owner()), const word eventName = message::eventName(message::ITEMS_INSERT);
pStruct_(pStruct),
baseName_(baseName) if(!varList.checkObjectType<uint32IndexContainer>(eventName))
{
fatalErrorInFunction<<"Insertion failed in integration for "<< baseName_<<
", variable "<< eventName <<
" does not exist or the type is incorrect"<<endl;
return false;
}
const auto& indices = varList.getObject<uint32IndexContainer>(
eventName);
dstFeild.field().insertSetElement(indices, srcVals);
return true;
}
pFlow::integration::integration(
const word &baseName,
pointStructure &pStruct,
const word &,
const realx3Field_D &)
: owner_(*pStruct.owner()),
pStruct_(pStruct),
baseName_(baseName)
{} {}

View File

@ -63,6 +63,13 @@ private:
/// The base name for integration /// The base name for integration
const word baseName_; const word baseName_;
protected:
bool insertValues(
const anyList& varList,
const deviceViewType1D<realx3>& srcVals,
realx3PointField_D& dstFeild);
public: public:
/// Type info /// Type info
@ -151,17 +158,6 @@ public:
virtual virtual
bool correctPStruct(real dt, pointStructure& pStruct, realx3PointField_D& vel) = 0; bool correctPStruct(real dt, pointStructure& pStruct, realx3PointField_D& vel) = 0;
/// Set the initial values for new indices
virtual
bool setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y) = 0;
/// Check if the method requires any set initial vals
virtual
bool needSetInitialVals()const = 0;
/// Create the polymorphic object based on inputs /// Create the polymorphic object based on inputs
static static
uniquePtr<integration> create( uniquePtr<integration> create(

View File

@ -73,9 +73,7 @@ public:
} }
bool hearChanges( bool hearChanges(
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message &msg, const message &msg,
const anyList &varList) override const anyList &varList) override
{ {
@ -83,8 +81,10 @@ public:
if (msg.equivalentTo(message::BNDR_RESET)) if (msg.equivalentTo(message::BNDR_RESET))
{ {
// do nothing // do nothing
return true;
} }
return true; fatalErrorInFunction;
return false;
} }
virtual bool broadSearch( virtual bool broadSearch(

View File

@ -154,18 +154,17 @@ public:
bool hearChanges bool hearChanges
( (
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) override ) override
{ {
if(msg.equivalentTo(message::BNDR_RESET))
pOutput<<"Function (hearChanges in boundarySphereInteractions)is not implmented Message "<< {
msg <<endl<<" name "<< this->boundaryName() <<" type "<< this->type()<<endl;; return true;
//notImplementedFunction; }
return true; fatalErrorInFunction<<"Event "<< msg.eventNames() << " is not handled !"<<endl;
return false;
} }
bool isActive()const override bool isActive()const override

View File

@ -344,16 +344,12 @@ bool pFlow::grainInteraction<cFM,gMM, cLT>::afterIteration()
template<typename cFM,typename gMM,template <class, class, class> class cLT> template<typename cFM,typename gMM,template <class, class, class> class cLT>
bool pFlow::grainInteraction<cFM,gMM, cLT>::hearChanges bool pFlow::grainInteraction<cFM,gMM, cLT>::hearChanges
( (
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) )
{ {
if(msg.equivalentTo(message::ITEM_REARRANGE)) fatalErrorInFunction<<"Event "<< msg.eventNames()<<
{ " is not handled in grainInteraction"<<endl;
notImplementedFunction; return false;
}
return true;
} }

View File

@ -152,9 +152,7 @@ public:
/// Check for changes in the point structures. (overriden from observer) /// Check for changes in the point structures. (overriden from observer)
bool hearChanges( bool hearChanges(
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList)override; const anyList& varList)override;

View File

@ -51,7 +51,7 @@ private:
const geometry& geometry_; const geometry& geometry_;
static inline static inline
const message msg_ = message::ITEM_REARRANGE; const message msg_ = message::ITEMS_REARRANGE;
public: public:

View File

@ -148,7 +148,7 @@ public:
const ContactForceModel& cfModel, const ContactForceModel& cfModel,
uint32 step) uint32 step)
{ {
// for default boundary, no thing to be done // for default boundary, nothing to be done
return false; return false;
} }
@ -156,16 +156,14 @@ public:
bool hearChanges bool hearChanges
( (
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) override ) override
{ {
pOutput<<"Function (hearChanges in boundarySphereInteractions)is not implmented Message "<< pOutput<<"Function (hearChanges in boundarySphereInteractions)is not implmented Message "<<
msg <<endl<<" name "<< this->boundaryName() <<" type "<< this->type()<<endl;; msg <<endl<<" name "<< this->boundaryName() <<" type "<< this->type()<<endl;
//notImplementedFunction; //notImplementedFunction;
return true; return true;
} }

View File

@ -351,16 +351,18 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::afterIteration()
template<typename cFM,typename gMM,template <class, class, class> class cLT> template<typename cFM,typename gMM,template <class, class, class> class cLT>
bool pFlow::sphereInteraction<cFM,gMM, cLT>::hearChanges bool pFlow::sphereInteraction<cFM,gMM, cLT>::hearChanges
( (
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) )
{ {
if(msg.equivalentTo(message::ITEM_REARRANGE)) if(msg.equivalentTo(message::ITEMS_REARRANGE))
{ {
notImplementedFunction; notImplementedFunction;
return false;
} }
return true;
fatalErrorInFunction<<"Event "<< msg.eventNames()<<
" is not handled in sphereInteraction"<<endl;
return false;
} }

View File

@ -152,9 +152,7 @@ public:
/// Check for changes in the point structures. (overriden from observer) /// Check for changes in the point structures. (overriden from observer)
bool hearChanges( bool hearChanges(
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList)override; const anyList& varList)override;

View File

@ -50,9 +50,7 @@ public:
const grainParticles& Particles()const; const grainParticles& Particles()const;
bool hearChanges( bool hearChanges(
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message &msg, const message &msg,
const anyList &varList) override const anyList &varList) override
{ {

View File

@ -248,7 +248,7 @@ pFlow::grainParticles::grainParticles(
"rVelocity", "rVelocity",
dynPointStruct(), dynPointStruct(),
intMethod, intMethod,
rVelocity_.field() rAcceleration_.field()
); );
if( !rVelIntegration_ ) if( !rVelIntegration_ )
@ -275,7 +275,7 @@ bool pFlow::grainParticles::beforeIteration()
particles::beforeIteration(); particles::beforeIteration();
intPredictTimer_.start(); intPredictTimer_.start();
auto dt = this->dt(); auto dt = this->dt();
dynPointStruct().predict(dt, accelertion()); dynPointStruct().predict(dt);
rVelIntegration_().predict(dt,rVelocity_, rAcceleration_); rVelIntegration_().predict(dt,rVelocity_, rAcceleration_);
intPredictTimer_.end(); intPredictTimer_.end();
@ -296,8 +296,8 @@ bool pFlow::grainParticles::beforeIteration()
bool pFlow::grainParticles::iterate() bool pFlow::grainParticles::iterate()
{ {
timeInfo ti = TimeInfo(); const timeInfo ti = TimeInfo();
realx3 g = control().g(); const realx3 g = control().g();
particles::iterate(); particles::iterate();
accelerationTimer_.start(); accelerationTimer_.start();
@ -308,7 +308,7 @@ bool pFlow::grainParticles::iterate()
I().deviceViewAll(), I().deviceViewAll(),
contactTorque().deviceViewAll(), contactTorque().deviceViewAll(),
dynPointStruct().activePointsMaskDevice(), dynPointStruct().activePointsMaskDevice(),
accelertion().deviceViewAll(), acceleration().deviceViewAll(),
rAcceleration().deviceViewAll() rAcceleration().deviceViewAll()
); );
@ -320,12 +320,12 @@ bool pFlow::grainParticles::iterate()
intCorrectTimer_.start(); intCorrectTimer_.start();
if(!dynPointStruct().correct(dt(), accelertion())) if(!dynPointStruct().correct(ti.dt()))
{ {
return false; return false;
} }
if(!rVelIntegration_().correct( if(!rVelIntegration_().correct(
dt(), ti.dt(),
rVelocity_, rVelocity_,
rAcceleration_)) rAcceleration_))
{ {

View File

@ -172,9 +172,7 @@ public:
} }
bool hearChanges( bool hearChanges(
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) override ) override

View File

@ -50,9 +50,7 @@ public:
const sphereParticles& Particles()const; const sphereParticles& Particles()const;
bool hearChanges( bool hearChanges(
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message &msg, const message &msg,
const anyList &varList) override const anyList &varList) override
{ {

View File

@ -24,180 +24,6 @@ Licence:
#include "sphereParticlesKernels.hpp" #include "sphereParticlesKernels.hpp"
//#include "setFieldList.hpp"
/*pFlow::uniquePtr<pFlow::List<pFlow::eventObserver*>>
pFlow::sphereParticles::getFieldObjectList()const
{
auto objListPtr = particles::getFieldObjectList();
objListPtr().push_back(
static_cast<eventObserver*>(&I_) );
return objListPtr;
}
bool pFlow::sphereParticles::diameterMassInertiaPropId
(
const word& shName,
real& diam,
real& mass,
real& I,
int8& propIdx
)
{
uint32 idx;
if( !shapes_.nameToIndex(shName, idx) )
{
printKeys(fatalErrorInFunction<<
" wrong shape name in the input: "<< shName<<endl<<
" available shape names are: ", shapes_.names())<<endl;
return false;
}
diam = shapes_.diameter(idx);
word materialName = shapes_.material(idx);
uint32 pIdx;
if( !property_.nameToIndex(materialName, pIdx) )
{
fatalErrorInFunction <<
" wrong material name "<< materialName <<" specified for shape "<< shName<<
" in the sphereShape dictionary.\n"<<
" available materials are "<< property_.materials()<<endl;
return false;
}
real rho = property_.density(pIdx);
mass = Pi/6.0*pow(diam,3.0)*rho;
I = 0.4 * mass * pow(diam/2.0,2.0);
propIdx= static_cast<int8>(pIdx);
return true;
}
bool pFlow::sphereParticles::initializeParticles()
{
int32IndexContainer indices(
0,
static_cast<int32>(shapeName_.size()));
return insertSphereParticles(shapeName_, indices, false);
}*/
/*bool pFlow::sphereParticles::beforeIteration()
{
particles::beforeIteration();
intPredictTimer_.start();
//INFO<<"before dyn predict"<<endINFO;
dynPointStruct_.predict(this->dt(), accelertion_);
//INFO<<"after dyn predict"<<endINFO;
//INFO<<"before revel predict"<<endINFO;
rVelIntegration_().predict(this->dt(),rVelocity_, rAcceleration_);
//INFO<<"after rvel predict"<<endINFO;
intPredictTimer_.end();
return true;
}*/
/*bool pFlow::sphereParticles::afterIteration()
{
return true;
}*/
/*bool pFlow::sphereParticles::insertSphereParticles(
const wordVector& names,
const int32IndexContainer& indices,
bool setId
)
{
if(names.size()!= indices.size())
{
fatalErrorInFunction <<
"sizes of names ("<<names.size()<<") and indices ("
<< indices.size()<<") do not match \n";
return false;
}
auto len = names.size();
realVector diamVec(len, RESERVE());
realVector massVec(len, RESERVE());
realVector IVec(len, RESERVE());
int8Vector pIdVec(len, RESERVE());
int32Vector IdVec(len, RESERVE());
real d, m, I;
int8 pId;
ForAll(i, names )
{
if (diameterMassInertiaPropId(names[i], d, m, I, pId))
{
diamVec.push_back(d);
massVec.push_back(m);
IVec.push_back(I);
pIdVec.push_back(pId);
if(setId) IdVec.push_back(idHandler_.getNextId());
//output<<" we are in sphereParticles nextId "<< idHandler_.nextId()<<endl;
}
else
{
fatalErrorInFunction<< "failed to calculate properties of shape " <<
names[i]<<endl;
return false;
}
}
if(!diameter_.insertSetElement(indices, diamVec))
{
fatalErrorInFunction<< " failed to insert diameters to the diameter field. \n";
return false;
}
if(!mass_.insertSetElement(indices, massVec))
{
fatalErrorInFunction<< " failed to insert mass to the mass field. \n";
return false;
}
if(!I_.insertSetElement(indices, IVec))
{
fatalErrorInFunction<< " failed to insert I to the I field. \n";
return false;
}
if(!propertyId_.insertSetElement(indices, pIdVec))
{
fatalErrorInFunction<< " failed to insert propertyId to the propertyId field. \n";
return false;
}
if(setId)
{
if( !id_.insertSetElement(indices, IdVec))
{
fatalErrorInFunction<< " failed to insert id to the id field. \n";
return false;
}
}
return true;
}*/
bool pFlow::sphereParticles::initializeParticles() bool pFlow::sphereParticles::initializeParticles()
{ {
@ -403,7 +229,7 @@ pFlow::sphereParticles::sphereParticles(
"rVelocity", "rVelocity",
dynPointStruct(), dynPointStruct(),
intMethod, intMethod,
rVelocity_.field() rAcceleration_.field()
); );
if( !rVelIntegration_ ) if( !rVelIntegration_ )
@ -413,8 +239,6 @@ pFlow::sphereParticles::sphereParticles(
fatalExit; fatalExit;
} }
WARNING<<"setFields for rVelIntegration_"<<END_WARNING;
if(!initializeParticles()) if(!initializeParticles())
{ {
fatalErrorInFunction; fatalErrorInFunction;
@ -423,96 +247,12 @@ pFlow::sphereParticles::sphereParticles(
} }
/*bool pFlow::sphereParticles::update(const eventMessage& msg)
{
if(rVelIntegration_->needSetInitialVals())
{
auto indexHD = pStruct().insertedPointIndex();
auto n = indexHD.size();
auto index = indexHD.indicesHost();
realx3Vector rvel(n,RESERVE());
const auto hrVel = rVelocity_.hostView();
for(auto i=0; i<n; i++)
{
rvel.push_back( hrVel[index(i)]);
}
rVelIntegration_->setInitialVals(indexHD, rvel);
}
return true;
}*/
/*bool pFlow::sphereParticles::insertParticles
(
const realx3Vector& position,
const wordVector& shapes,
const setFieldList& setField
)
{
if( position.size() != shapes.size() )
{
fatalErrorInFunction<<
" size of vectors position ("<<position.size()<<
") and shapes ("<<shapes.size()<<") are not the same. \n";
return false;
}
auto exclusionListAllPtr = getFieldObjectList();
auto newInsertedPtr = pStruct().insertPoints( position, setField, time(), exclusionListAllPtr());
if(!newInsertedPtr)
{
fatalErrorInFunction<<
" error in inserting points into pStruct. \n";
return false;
}
auto& newInserted = newInsertedPtr();
if(!shapeName_.insertSetElement(newInserted, shapes))
{
fatalErrorInFunction<<
" error in inserting shapes into sphereParticles system.\n";
return false;
}
if( !insertSphereParticles(shapes, newInserted) )
{
fatalErrorInFunction<<
"error in inserting shapes into the sphereParticles. \n";
return false;
}
auto activeR = this->activeRange();
REPORT(1)<< "Active range is "<<yellowText("["<<activeR.first<<", "<<activeR.second<<")")<<
" and number of active points is "<< cyanText(this->numActive())<<
" and pointStructure capacity is "<<cyanText(this->capacity())<<endREPORT;
return true;
}*/
bool pFlow::sphereParticles::beforeIteration() bool pFlow::sphereParticles::beforeIteration()
{ {
particles::beforeIteration(); particles::beforeIteration();
intPredictTimer_.start(); intPredictTimer_.start();
auto dt = this->dt(); auto dt = this->dt();
dynPointStruct().predict(dt, accelertion()); dynPointStruct().predict(dt);
rVelIntegration_().predict(dt,rVelocity_, rAcceleration_); rVelIntegration_().predict(dt,rVelocity_, rAcceleration_);
intPredictTimer_.end(); intPredictTimer_.end();
@ -532,8 +272,8 @@ bool pFlow::sphereParticles::beforeIteration()
bool pFlow::sphereParticles::iterate() bool pFlow::sphereParticles::iterate()
{ {
timeInfo ti = TimeInfo(); const timeInfo ti = TimeInfo();
realx3 g = control().g(); const realx3 g = control().g();
particles::iterate(); particles::iterate();
accelerationTimer_.start(); accelerationTimer_.start();
@ -544,7 +284,7 @@ bool pFlow::sphereParticles::iterate()
I().deviceViewAll(), I().deviceViewAll(),
contactTorque().deviceViewAll(), contactTorque().deviceViewAll(),
dynPointStruct().activePointsMaskDevice(), dynPointStruct().activePointsMaskDevice(),
accelertion().deviceViewAll(), acceleration().deviceViewAll(),
rAcceleration().deviceViewAll() rAcceleration().deviceViewAll()
); );
ForAllActiveBoundaries(i,boundarySphereParticles_) ForAllActiveBoundaries(i,boundarySphereParticles_)
@ -556,7 +296,7 @@ bool pFlow::sphereParticles::iterate()
intCorrectTimer_.start(); intCorrectTimer_.start();
if(!dynPointStruct().correct(dt(), accelertion())) if(!dynPointStruct().correct(ti.dt()))
{ {
return false; return false;
} }

View File

@ -175,9 +175,7 @@ public:
} }
bool hearChanges( bool hearChanges(
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) override ) override

View File

@ -40,6 +40,16 @@ pFlow::dynamicPointStructure::dynamicPointStructure
*this, *this,
zero3 zero3
), ),
acceleration_(
objectFile(
"acceleration",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
*this,
zero3
),
velocityUpdateTimer_("velocity boundary update", &timers()), velocityUpdateTimer_("velocity boundary update", &timers()),
integrationMethod_ integrationMethod_
( (
@ -54,7 +64,7 @@ pFlow::dynamicPointStructure::dynamicPointStructure
"pStructPosition", "pStructPosition",
*this, *this,
integrationMethod_, integrationMethod_,
pointPosition() velocity_.field()
); );
if( !integrationPos_ ) if( !integrationPos_ )
@ -69,7 +79,7 @@ pFlow::dynamicPointStructure::dynamicPointStructure
"pStructVelocity", "pStructVelocity",
*this, *this,
integrationMethod_, integrationMethod_,
velocity_.field() acceleration_.field()
); );
if( !integrationVel_ ) if( !integrationVel_ )
@ -90,6 +100,7 @@ bool pFlow::dynamicPointStructure::beforeIteration()
if(!pointStructure::beforeIteration())return false; if(!pointStructure::beforeIteration())return false;
velocityUpdateTimer_.start(); velocityUpdateTimer_.start();
velocity_.updateBoundariesSlaveToMasterIfRequested(); velocity_.updateBoundariesSlaveToMasterIfRequested();
acceleration_.updateBoundariesSlaveToMasterIfRequested();
integrationPos_->updateBoundariesSlaveToMasterIfRequested(); integrationPos_->updateBoundariesSlaveToMasterIfRequested();
integrationVel_->updateBoundariesSlaveToMasterIfRequested(); integrationVel_->updateBoundariesSlaveToMasterIfRequested();
velocityUpdateTimer_.end(); velocityUpdateTimer_.end();
@ -116,29 +127,21 @@ bool pFlow::dynamicPointStructure::afterIteration()
return succs; return succs;
} }
bool pFlow::dynamicPointStructure::predict( bool pFlow::dynamicPointStructure::predict(real dt)
real dt,
realx3PointField_D &acceleration)
{ {
if(!integrationPos_().predict(dt, pointPosition(), velocity_ ))return false; if(!integrationPos_().predict(dt, pointPosition(), velocity_ ))return false;
if(!integrationVel_().predict(dt, velocity_, acceleration))return false; if(!integrationVel_().predict(dt, velocity_, acceleration_))return false;
return true; return true;
} }
bool pFlow::dynamicPointStructure::correct bool pFlow::dynamicPointStructure::correct(real dt)
(
real dt,
realx3PointField_D& acceleration
)
{ {
//auto& pos = pStruct().pointPosition(); const auto& ti = TimeInfo();
const auto ti = TimeInfo();
if(!integrationPos_().correctPStruct(dt, *this, velocity_) )return false; if(!integrationPos_().correctPStruct(dt, *this, velocity_) )return false;
if(!integrationVel_().correct(dt, velocity_, acceleration_, velDamping_().dampingFactor(ti)))return false;
if(!integrationVel_().correct(dt, velocity_, acceleration, velDamping_().dampingFactor(ti)))return false;
return true; return true;
} }

View File

@ -42,6 +42,9 @@ private:
realx3PointField_D velocity_; realx3PointField_D velocity_;
/// acceleration on device
realx3PointField_D acceleration_;
uniquePtr<integration> integrationPos_ = nullptr; uniquePtr<integration> integrationPos_ = nullptr;
uniquePtr<integration> integrationVel_ = nullptr; uniquePtr<integration> integrationVel_ = nullptr;
@ -86,6 +89,18 @@ public:
return velocity_; return velocity_;
} }
inline
const realx3PointField_D& acceleration()const
{
return acceleration_;
}
inline
realx3PointField_D& acceleration()
{
return acceleration_;
}
/// In the time loop before iterate /// In the time loop before iterate
bool beforeIteration() override; bool beforeIteration() override;
@ -96,10 +111,10 @@ public:
bool afterIteration()override; bool afterIteration()override;
/// prediction step (if any), is called in beforeIteration /// prediction step (if any), is called in beforeIteration
bool predict(real dt, realx3PointField_D& acceleration); bool predict(real dt);
/// correction step, is called in iterate /// correction step, is called in iterate
bool correct(real dt, realx3PointField_D& acceleration); bool correct(real dt);
}; };

View File

@ -41,16 +41,14 @@ pFlow::particleIdHandler::particleIdHandler(pointStructure& pStruct)
bool bool
pFlow::particleIdHandler::hearChanges( pFlow::particleIdHandler::hearChanges(
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) )
{ {
if(msg.equivalentTo(message::ITEM_INSERT)) if(msg.equivalentTo(message::ITEMS_INSERT))
{ {
const word eventName = message::eventName(message::ITEM_INSERT); const word eventName = message::eventName(message::ITEMS_INSERT);
const auto& indices = varList.getObject<uint32IndexContainer>( const auto& indices = varList.getObject<uint32IndexContainer>(
eventName); eventName);
@ -66,7 +64,7 @@ pFlow::particleIdHandler::hearChanges(
} }
else else
{ {
return uint32PointField_D::hearChanges(t,dt,iter, msg,varList); return uint32PointField_D::hearChanges(ti, msg, varList);
} }
} }

View File

@ -60,15 +60,11 @@ public:
virtual virtual
uint32 maxId()const = 0; uint32 maxId()const = 0;
// heat change for possible insertion of particles // heat change for possible insertion of particles
// overrdie from internalField // overrdie from internalField
bool hearChanges bool hearChanges
( (
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) override; ) override;

View File

@ -34,16 +34,6 @@ pFlow::particles::particles(systemControl& control, const shape& shapes)
dynPointStruct_, dynPointStruct_,
0 0
), ),
accelertion_(
objectFile(
"accelertion",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
dynPointStruct_,
zero3
),
contactForce_( contactForce_(
objectFile( objectFile(
"contactForce", "contactForce",
@ -84,7 +74,6 @@ pFlow::particles::beforeIteration()
zeroTorque(); zeroTorque();
baseFieldBoundaryUpdateTimer_.start(); baseFieldBoundaryUpdateTimer_.start();
shapeIndex_.updateBoundariesSlaveToMasterIfRequested(); shapeIndex_.updateBoundariesSlaveToMasterIfRequested();
accelertion_.updateBoundariesSlaveToMasterIfRequested();
idHandler_().updateBoundariesSlaveToMasterIfRequested(); idHandler_().updateBoundariesSlaveToMasterIfRequested();
baseFieldBoundaryUpdateTimer_.end(); baseFieldBoundaryUpdateTimer_.end();
return true; return true;

View File

@ -45,9 +45,6 @@ private:
/// shape index of each particle /// shape index of each particle
uint32PointField_D shapeIndex_; uint32PointField_D shapeIndex_;
/// acceleration on device
realx3PointField_D accelertion_;
/// contact force field /// contact force field
realx3PointField_D contactForce_; realx3PointField_D contactForce_;
@ -60,7 +57,7 @@ private:
Timer baseFieldBoundaryUpdateTimer_; Timer baseFieldBoundaryUpdateTimer_;
/// messages for this objects /// messages for this objects
static inline const message defaultMessage_{ message::DEFAULT }; static inline const message defaultMessage_= message::Empty();
protected: protected:
@ -156,14 +153,14 @@ public:
return dynPointStruct_.velocity(); return dynPointStruct_.velocity();
} }
inline const auto& accelertion() const inline const auto& acceleration() const
{ {
return accelertion_; return dynPointStruct_.acceleration();
} }
inline auto& accelertion() inline auto& acceleration()
{ {
return accelertion_; return dynPointStruct_.acceleration();
} }
inline auto& contactForce() inline auto& contactForce()

View File

@ -53,7 +53,7 @@ private:
/// List of variable names in anyList_ /// List of variable names in anyList_
wordList names_; wordList names_;
wordList types_; wordList types_;
public: public:
@ -162,12 +162,26 @@ public:
{ {
fatalErrorInFunction<< fatalErrorInFunction<<
"variable name "<< name << " does not exist in the anyList."<<endl<< "variable name "<< name << " does not exist in the anyList."<<endl<<
"list of variables is "<<names_<<endl; "list of variables is \n"<<names_<<endl;
fatalExit; fatalExit;
} }
return getObject<T>(static_cast<size_t>(i)); return getObject<T>(static_cast<size_t>(i));
} }
template<typename T>
bool checkObjectType(const word& name)const
{
int32 i = names_.findi(name);
if(i == -1 )
{
fatalErrorInFunction<<
"variable name "<< name << " does not exist in the anyList."<<endl<<
"list of variables is \n"<<names_<<endl;
return false;
}
return getTypeName<T>() != types_[i];
}
/// Get the const reference to variable by name /// Get the const reference to variable by name
template<typename T> template<typename T>
const T& getObject(const word& name)const const T& getObject(const word& name)const

View File

@ -34,15 +34,14 @@ pFlow::boundaryField<T, MemorySpace>::boundaryField
memory_space::name() memory_space::name()
), ),
internal_(internal) internal_(internal)
{} {
}
template<class T, class MemorySpace> template<class T, class MemorySpace>
typename pFlow::boundaryField<T, MemorySpace>::ProcVectorType& typename pFlow::boundaryField<T, MemorySpace>::ProcVectorType&
pFlow::boundaryField<T, MemorySpace>::neighborProcField() pFlow::boundaryField<T, MemorySpace>::neighborProcField()
{ {
static ProcVectorType dummyVector{"dummyVector"}; static ProcVectorType dummyVector{"dummyVector"};
//notImplementedFunction;
//fatalExit;
return dummyVector; return dummyVector;
} }
@ -51,8 +50,6 @@ const typename pFlow::boundaryField<T, MemorySpace>::ProcVectorType&
pFlow::boundaryField<T, MemorySpace>::neighborProcField() const pFlow::boundaryField<T, MemorySpace>::neighborProcField() const
{ {
static ProcVectorType dummyVector{"dummyVector"}; static ProcVectorType dummyVector{"dummyVector"};
//notImplementedFunction;
//fatalExit;
return dummyVector; return dummyVector;
} }

View File

@ -102,23 +102,21 @@ public:
bool hearChanges bool hearChanges
( (
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) override ) override
{ {
if(msg.equivalentTo(message::BNDR_REARRANGE))
{
// do nothing
}
if(msg.equivalentTo(message::BNDR_RESET)) if(msg.equivalentTo(message::BNDR_RESET))
{ {
//do nothing //do nothing
return true;
} }
return true;
fatalErrorInFunction<<"Event"<< msg.eventNames()<<"with code "<< msg <<
" is not handled in boundaryField."<<endl;
return false;
} }
inline inline

View File

@ -27,6 +27,4 @@ template<class T, class MemorySpace>
) )
: :
BoundaryFieldType(boundary, pStruct, internal) BoundaryFieldType(boundary, pStruct, internal)
{ {}
this->addEvent(message::BNDR_DELETE);
}

View File

@ -61,26 +61,6 @@ public:
boundaryBase boundaryBase
); );
bool hearChanges
(
real t,
real dt,
uint32 iter,
const message& msg,
const anyList& varList
) override
{
BoundaryFieldType::hearChanges(t,dt,iter, msg,varList);
if(msg.equivalentTo(message::BNDR_DELETE))
{
// do nothing;
}
return true;
}
bool isActive()const override bool isActive()const override
{ {
return false; return false;

View File

@ -26,7 +26,4 @@ template<class T, class MemorySpace>
) )
: :
BoundaryFieldType(boundary, pStruct, internal) BoundaryFieldType(boundary, pStruct, internal)
{ {}
this->addEvent(message::BNDR_APPEND)
.addEvent(message::BNDR_TRANSFER);
}

View File

@ -61,29 +61,6 @@ public:
boundaryBase boundaryBase
); );
bool hearChanges
(
real t,
real dt,
uint32 iter,
const message& msg,
const anyList& varList
) override
{
BoundaryFieldType::hearChanges(t,dt,iter, msg,varList);
if(msg.equivalentTo(message::BNDR_APPEND))
{
// do nothing;
}
if(msg.equivalentTo(message::BNDR_TRANSFER))
{
//do nothing
}
return true;
}
}; };
} }

View File

@ -26,6 +26,4 @@ template<class T, class MemorySpace>
) )
: :
BoundaryFieldType(boundary, pStruct, internal) BoundaryFieldType(boundary, pStruct, internal)
{ {}
//this->addEvent(message::BNDR_DELETE);
}

View File

@ -61,26 +61,6 @@ public:
boundaryBase boundaryBase
); );
bool hearChanges
(
real t,
real dt,
uint32 iter,
const message& msg,
const anyList& varList
) override
{
BoundaryFieldType::hearChanges(t,dt,iter, msg,varList);
if(msg.equivalentTo(message::BNDR_DELETE))
{
// do nothing;
}
return true;
}
bool isActive()const override bool isActive()const override
{ {
return false; return false;

View File

@ -21,7 +21,14 @@ Licence:
template<class T, class MemorySpace> template<class T, class MemorySpace>
bool pFlow::internalField<T, MemorySpace>::insert(const anyList& varList) bool pFlow::internalField<T, MemorySpace>::insert(const anyList& varList)
{ {
const word eventName = message::eventName(message::ITEM_INSERT); const word eventName = message::eventName(message::ITEMS_INSERT);
if(!varList.checkObjectType<uint32IndexContainer>(eventName))
{
fatalErrorInFunction<<"Insertion failed in internalField, "<< eventName <<
" does not exist or the type is incorrect"<<endl;
return false;
}
const auto& indices = varList.getObject<uint32IndexContainer>( const auto& indices = varList.getObject<uint32IndexContainer>(
eventName); eventName);
@ -30,14 +37,24 @@ bool pFlow::internalField<T, MemorySpace>::insert(const anyList& varList)
if(varList.contains(name())) if(varList.contains(name()))
{ {
// a single value is assigned // a single value is assigned
if(!varList.checkObjectType<T>(name()))
{
fatalErrorInFunction<<"wrong type for variable "<< name()<<endl;
return false;
}
T val = varList.getObject<T>(name()); T val = varList.getObject<T>(name());
success = field_.insertSetElement(indices, val); success = field_.insertSetElement(indices, val);
} }
else if(varList.contains(name()+"Vector")) else if(word fn = name()+"Vector"; varList.contains(fn))
{ {
// a vector of values is going to be assigned // a vector of values is going to be assigned
const auto& valVec = varList.getObject<Vector<T>>(name()+"Vector"); if(!varList.checkObjectType<Vector<T>>(fn))
{
fatalErrorInFunction<<"wrong type for variable "<< fn<<endl;
return false;
}
const auto& valVec = varList.getObject<Vector<T>>(fn);
success = field_.insertSetElement(indices,valVec); success = field_.insertSetElement(indices,valVec);
} }
else else
@ -57,8 +74,13 @@ bool pFlow::internalField<T, MemorySpace>::insert(const anyList& varList)
template<class T, class MemorySpace> template<class T, class MemorySpace>
bool pFlow::internalField<T, MemorySpace>::rearrange(const anyList& varList) bool pFlow::internalField<T, MemorySpace>::rearrange(const anyList& varList)
{ {
const word eventName = message::eventName(message::ITEM_REARRANGE); const word eventName = message::eventName(message::ITEMS_REARRANGE);
if(!varList.checkObjectType<uint32IndexContainer>(eventName))
{
fatalErrorInFunction<<"Wrong type for variable "<< eventName<<endl;
return false;
}
const auto& indices = varList.getObject<uint32IndexContainer>( const auto& indices = varList.getObject<uint32IndexContainer>(
eventName); eventName);
@ -162,40 +184,47 @@ typename pFlow::internalField<T, MemorySpace>::FieldTypeHost
template <class T, class MemorySpace> template <class T, class MemorySpace>
bool pFlow::internalField<T, MemorySpace>:: hearChanges bool pFlow::internalField<T, MemorySpace>:: hearChanges
( (
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) )
{ {
if(msg.equivalentTo(message::CAP_CHANGED)) if(msg.equivalentTo(message::RANGE_CHANGED))
{ {
auto newCap = varList.getObject<uint32>( auto varName = message::eventName(message::RANGE_CHANGED);
message::eventName(message::CAP_CHANGED)); if( !varList.checkObjectType<rangeU32>(varName) )
{
fatalErrorInFunction<<"Wrong type for variable "<< varName<<endl;
return false;
}
field_.reserve(newCap); auto newRange = varList.getObject<rangeU32>(varName);
if(newRange.end() > size())
field_.resize(newRange.end());
return true;
} }
if(msg.equivalentTo(message::SIZE_CHANGED)) else if(msg.equivalentTo(message::ITEMS_DELETE))
{
auto newSize = varList.getObject<uint32>(
message::eventName(message::SIZE_CHANGED));
field_.resize(newSize);
}
if(msg.equivalentTo(message::ITEM_DELETE))
{ {
// do nothing // do nothing
return true;
} }
if(msg.equivalentTo(message::ITEM_INSERT)) else if(msg.equivalentTo(message::ITEMS_INSERT))
{ {
return insert(varList); return insert(varList);
} }
if(msg.equivalentTo(message::ITEM_REARRANGE)) else if(msg.equivalentTo(message::ITEMS_REARRANGE))
{ {
return rearrange(varList); return rearrange(varList);
} }
return true; else
{
fatalErrorInFunction<<"hear changes in internal field is not processing "<<
message::eventName(message::RANGE_CHANGED)<<
" event with message code "<< msg<<endl;
return false;
}
} }
template<class T, class MemorySpace> template<class T, class MemorySpace>

View File

@ -64,13 +64,12 @@ protected:
static inline static inline
const message defaultMessage_ = const message defaultMessage_ =
( (
message::CAP_CHANGED+ message::RANGE_CHANGED +
message::SIZE_CHANGED+ message::ITEMS_INSERT +
message::ITEM_INSERT+ message::ITEMS_REARRANGE +
message::ITEM_REARRANGE+ message::ITEMS_DELETE
message::ITEM_DELETE
); );
bool insert(const anyList& varList); bool insert(const anyList& varList);
bool rearrange(const anyList& varList); bool rearrange(const anyList& varList);
@ -188,11 +187,15 @@ public:
return internalPoints_.time(); return internalPoints_.time();
} }
inline
const internalPoints& InternalPoints()const
{
return internalPoints_;
}
bool hearChanges bool hearChanges
( (
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList const anyList& varList
) override; ) override;

View File

@ -56,7 +56,7 @@ pFlow::triSurfaceField<T,MemorySpace>::triSurfaceField
observer observer
( (
&surface, &surface,
message::Default() message::Empty()
), ),
field_ field_
( (
@ -130,7 +130,7 @@ pFlow::triSurfaceField<T, MemorySpace>::triSurfaceField
observer observer
( (
&surface, &surface,
message::Default() message::Empty()
), ),
field_ field_
( (

View File

@ -166,9 +166,7 @@ public:
} }
bool hearChanges( bool hearChanges(
real t, const timeInfo& ti,
real dt,
uint32 iter,
const message& msg, const message& msg,
const anyList& varList) override const anyList& varList) override
{ {

View File

@ -25,6 +25,7 @@ Licence:
#include "types.hpp" #include "types.hpp"
#include "iOstream.hpp" #include "iOstream.hpp"
#include "List.hpp"
namespace pFlow namespace pFlow
@ -35,52 +36,42 @@ class message
public: public:
enum EVENT : size_t enum EVENT : size_t
{ {
DEFAULT = 0, RANGE_CHANGED = 0, // internal points active range has been changed
CAP_CHANGED = 1, // internal points capacity changed ITEMS_INSERT = 1, // internal points are being inserted
SIZE_CHANGED = 2, // internal points size changed ITEMS_DELETE = 2, // internal points are being deleted
ITEM_DELETE = 3, // internal points item deleted ITEMS_REARRANGE = 3, // internal points are being rearrange
ITEM_INSERT = 4, // internal points item inserted ITEMS_FLAGCHANGED = 4, // internal points flag changed, this occurs when transfer occurs
RANGE_CHANGED = 5, // internal points range changed BNDR_APPEND = 5, // boundary: new indices are appended
ITEM_REARRANGE = 6, // internal points item rearrange BNDR_RESET = 6, // boundary: indices are reset entirely
ITEM_FLAGCHANGED= 7, // internal points item flag changed, this occurs when transfer occurs BNDR_DELETE = 7, // boundary: indices are deleted
BNDR_REARRANGE = 8, // boundary indices rearrange BNDR_PROC_SIZE_CHANGED = 8, // processor boundary: size has been changed
BNDR_TRANSFER = 9, // boundary indices transfered BNDR_PROCTRANSFER_SEND = 9, // processor boundary: transfer of data between processors step 1 (send)
BNDR_RESET = 10, // boundary indices reset entirely BNDR_PROCTRANSFER_RECIEVE = 10, // processor boundary: transfer of data between processors step 2 (recieve)
BNDR_DELETE = 11, // boundary indices deleted BNDR_PROCTRANSFER_WAITFILL = 11 // processor boundary: wait for data and fill the field
BNDR_APPEND = 12, //
BNDR_PROCTRANSFER_SEND = 13, // transfer of data between processors step 1
BNDR_PROCTRANSFER_RECIEVE = 14, // transfer of data between processors step 2
BNDR_PROCTRANSFER_WAITFILL = 15, // wait for data and fill the field
BNDR_PROC_SIZE_CHANGED = 16
}; };
private: private:
static constexpr size_t numberOfEvents_ = 17; static constexpr size_t numberOfEvents_ = 12;
std::bitset<numberOfEvents_> events_{0x0000}; std::bitset<numberOfEvents_> events_{0x0000};
static static
inline const std::array<word,numberOfEvents_> eventNames_ inline const std::array<word,numberOfEvents_> eventNames_
{ {
"", "activeRange",
"capacity",
"size",
"deletedIndices",
"insertedIndices", "insertedIndices",
"range",
"rearrangedIndices",
"transferredIndices",
"rearrangedIndices",
"transferredIndices",
"",
"deletedIndices", "deletedIndices",
"appendedIndices", "rearrangedIndices",
"transferredIndices", "flagChange",
"numToRecieve", "bndryAppendedIndices",
"insertedIndices", "bndryReset",
"size" "bndryDeletedIndices",
"bndrySize",
"bndryTransferIndices",
"bndryNumToRecieve",
"bndryWait"
}; };
public: public:
@ -173,18 +164,23 @@ public:
return *this; return *this;
} }
wordList eventNames()const
{
wordList lst;
for(size_t i=0; i<events_.size(); i++)
{
if(events_[i])
lst.push_back(eventNames_[i]);
}
return lst;
}
static static
auto constexpr numEvents() auto constexpr numEvents()
{ {
return numberOfEvents_; return numberOfEvents_;
} }
static
message Default()
{
message msg;
return msg+DEFAULT;
}
static static
message Empty() message Empty()
{ {

View File

@ -29,6 +29,7 @@ namespace pFlow
class subscriber; class subscriber;
class anyList; class anyList;
class timeInfo;
class observer class observer
{ {
@ -87,11 +88,21 @@ public:
return message::numEvents(); return message::numEvents();
} }
/// TODO: remove this API from this class
virtual bool hearChanges( virtual bool hearChanges(
real t, real t,
real dt, real dt,
uint32 iter, uint32 iter,
const message& msg, const message& msg,
const anyList& varList)
{
notImplementedFunction;
return false;
};
virtual bool hearChanges(
const timeInfo& ti,
const message& msg,
const anyList& varList)=0; const anyList& varList)=0;
}; };

View File

@ -133,7 +133,6 @@ bool pFlow::subscriber::notify
const anyList& varList const anyList& varList
) )
{ {
for(size_t i=0; i<msg.size(); i++) for(size_t i=0; i<msg.size(); i++)
{ {
if(msg.equivalentTo(i)) if(msg.equivalentTo(i))
@ -150,12 +149,26 @@ bool pFlow::subscriber::notify
); );
} }
} }
} }
return true; return true;
} }
bool pFlow::subscriber::notify(const timeInfo &ti, const message msg, const anyList &varList) bool pFlow::subscriber::notify(const timeInfo &ti, const message msg, const anyList &varList)
{ {
return notify(ti.iter(), ti.t(), ti.dt(), msg, varList); for(size_t i=0; i<msg.size(); i++)
{
if(msg.equivalentTo(i))
{
for( auto obsvr: observerList_[i] )
{
obsvr->hearChanges
(
ti,
message(i),
varList
);
}
}
}
return true;
} }

View File

@ -68,6 +68,7 @@ public:
virtual bool unsubscribe(observer* obsevr)const; virtual bool unsubscribe(observer* obsevr)const;
/// TODO: remove this API from thie class
bool notify( bool notify(
uint32 iter, uint32 iter,
real t, real t,

View File

@ -145,7 +145,5 @@ bool pFlow::boundaryReflective::afterIteration
); );
Kokkos::fence(); Kokkos::fence();
// TODO: notify integration for changes in the velocity
return true; return true;
} }

View File

@ -71,6 +71,20 @@ public:
bool afterIteration(const timeInfo& ti)final; bool afterIteration(const timeInfo& ti)final;
const real restitution()const
{
return restitution_;
}
const word& velocityName()const
{
return velocityName_;
}
const word& diameterName()const
{
return diameterName_;
}
}; };

View File

@ -36,12 +36,19 @@ bool pFlow::simulationDomain::prepareBoundaryDicts()
(1+boundaryExtntionLengthRatio)*maxBoundingSphere_); (1+boundaryExtntionLengthRatio)*maxBoundingSphere_);
uint32 updateInterval = uint32 updateInterval =
boundaries.getValOrSetMax<uint32>("updateInterval", 1u); boundaries.getValOrSet<uint32>("updateInterval", 5u);
updateInterval = max(updateInterval, 1u);
uint32 neighborListUpdateInterval = uint32 neighborListUpdateInterval =
boundaries.getValMax("neighborListUpdateInterval", updateInterval); boundaries.getValOrSet("neighborListUpdateInterval", 50u);
boundaries.addOrReplace("neighborListUpdateInterval", neighborListUpdateInterval); neighborListUpdateInterval = max(neighborListUpdateInterval, updateInterval);
boundaries.addOrReplace("neighborListUpdateInterval", neighborListUpdateInterval);
boundaries.addOrReplace("updateInterval", updateInterval);
boundaries.addOrReplace("neighborLength", neighborLength);
boundaries.addOrReplace("boundaryExtntionLengthRatio", boundaryExtntionLengthRatio);
// create this boundaries dictionary // create this boundaries dictionary
this->addDict(thisBoundariesDictName(), boundaries); this->addDict(thisBoundariesDictName(), boundaries);

View File

@ -40,7 +40,6 @@ bool pFlow::internalPoints::deletePoints(const uint32Vector_D& delPoints)
if(delPoints.empty())return true; if(delPoints.empty())return true;
auto oldRange = pFlagsD_.activeRange(); auto oldRange = pFlagsD_.activeRange();
auto oldSize = size();
if(!pFlagsD_.deletePoints(delPoints.deviceView())) if(!pFlagsD_.deletePoints(delPoints.deviceView()))
{ {
@ -51,46 +50,35 @@ bool pFlow::internalPoints::deletePoints(const uint32Vector_D& delPoints)
unSyncFlag(); unSyncFlag();
auto newRange = pFlagsD_.activeRange(); auto newRange = pFlagsD_.activeRange();
auto newSize = size();
anyList varList; anyList varList;
message msg;
varList.emplaceBack( varList.emplaceBack(
message::eventName(message::ITEM_DELETE), msg.addAndName(message::ITEMS_DELETE),
delPoints); delPoints.deviceView());
message msg(message::ITEM_DELETE);
if(oldSize!= newSize)
{
msg.add(message::SIZE_CHANGED);
varList.emplaceBack(
message::eventName(message::SIZE_CHANGED),
newSize);
}
if(oldRange!=newRange) if(oldRange!=newRange)
{ {
msg.add(message::RANGE_CHANGED); msg.add(message::RANGE_CHANGED);
varList.emplaceBack( varList.emplaceBack(
message::eventName(message::RANGE_CHANGED), msg.addAndName(message::RANGE_CHANGED),
newRange); newRange);
} }
auto iter = time().currentIter();
auto t = time().currentTime(); const auto& ti = time().TimeInfo();
auto dt = time().dt();
if( !notify(ti , msg, varList) )
if( !notify(iter, t, dt, msg, varList) )
{ {
fatalErrorInFunction; fatalErrorInFunction;
return false; return false;
} }
return true; return true;
} }
bool pFlow::internalPoints::changePointsFlagPosition bool pFlow::internalPoints::changePointsFlagPosition
( (
const uint32Vector_D& changePoints, const uint32Vector_D& changePointsIndices,
realx3 transferVector, realx3 transferVector,
uint32 fromBoundaryIndex, uint32 fromBoundaryIndex,
uint32 toBoundaryIndex uint32 toBoundaryIndex
@ -104,14 +92,14 @@ bool pFlow::internalPoints::changePointsFlagPosition
} }
// change the flag // change the flag
pFlagsD_.changeFlags(changePoints.deviceView(), toBoundaryIndex); pFlagsD_.changeFlags(changePointsIndices.deviceView(), toBoundaryIndex);
unSyncFlag(); unSyncFlag();
// change the position // change the position
pFlow::internalPointsKernels::changePosition pFlow::internalPointsKernels::changePosition
( (
pointPosition_.deviceViewAll(), pointPosition_.deviceViewAll(),
changePoints.deviceView(), changePointsIndices.deviceView(),
transferVector transferVector
); );
@ -119,17 +107,13 @@ bool pFlow::internalPoints::changePointsFlagPosition
message msg; message msg;
varList.emplaceBack( varList.emplaceBack(
message::eventName(message::ITEM_FLAGCHANGED), msg.addAndName(message::ITEMS_FLAGCHANGED),
changePoints); changePointsIndices.deviceView());
varList.emplaceBack("fromBoundaryIndex", fromBoundaryIndex); varList.emplaceBack("fromBoundaryIndex", fromBoundaryIndex);
varList.emplaceBack("toBoundaryIndex", toBoundaryIndex); varList.emplaceBack("toBoundaryIndex", toBoundaryIndex);
msg.add(message::ITEM_FLAGCHANGED);
if( !notify( if( !notify(
time().currentIter(), time().TimeInfo(),
time().currentTime(),
time().dt(),
msg, msg,
varList)) varList))
{ {
@ -313,106 +297,16 @@ pFlow::internalPoints::insertPoints(
anyList& varList anyList& varList
) )
{ {
uint32 numNew = static_cast<uint32>(points.size());
auto aRange = pFlagsD_.activeRange();
uint32 emptySpots = pFlagsD_.capacity() - pFlagsD_.numActive();
if(emptySpots!= 0) emptySpots--;
message msg; message msg;
realx3Vector_D points_D(points.name(), points);
if( numNew > emptySpots ) if(!insertPointsOnly(points_D, msg, varList))
{ {
// increase the capacity to hold new points return false;
aRange = pFlagsD_.activeRange();
uint32 newCap = pFlagsD_.changeCapacity(numNew);
unSyncFlag();
varList.emplaceBack(
msg.addAndName(message::CAP_CHANGED),
newCap);
} }
// first check if it is possible to add to the beggining of list
if(numNew <= aRange.start())
{
varList.emplaceBack<uint32IndexContainer>(
msg.addAndName(message::ITEM_INSERT),
0u, numNew);
}
// check if it is possible to add to the end of the list
else if( numNew <= pFlagsD_.capacity() - aRange.end() )
{
varList.emplaceBack<uint32IndexContainer>(
msg.addAndName(message::ITEM_INSERT),
aRange.end(), aRange.end()+numNew);
}
// we should fill the scattered empty spots
else
{
auto newIndices = pFlagsD_.getEmptyPoints(numNew);
if(numNew != newIndices.size())
{
fatalErrorInFunction<<"not enough empty points in pointFlag"<<
numNew<< " "<<newIndices.size() <<endl;
pOutput<< pFlagsD_.capacity()<<endl;
pOutput<< pFlagsD_.numActive()<<endl;
return false;
}
varList.emplaceBack<uint32IndexContainer>(
msg.addAndName(message::ITEM_INSERT),
newIndices
);
}
const auto& indices = varList.getObject<uint32IndexContainer>(
message::eventName(message::ITEM_INSERT)
);
auto nAdded = pFlagsD_.addInternalPoints(indices.deviceView());
unSyncFlag();
if(nAdded != numNew )
{
fatalErrorInFunction;
return false;
}
pointPosition_.reserve( pFlagsD_.capacity() );
if(!pointPosition_.insertSetElement(indices, points))
{
fatalErrorInFunction<<
"Error in inserting new positions into pointPosition"<<
" internalPoints field"<<endl;
return false;
}
auto newARange = pFlagsD_.activeRange();
if( aRange.end() != newARange.end() )
{
varList.emplaceBack(
msg.addAndName(message::RANGE_CHANGED),
newARange);
varList.emplaceBack(
msg.addAndName(message::SIZE_CHANGED),
newARange.end());
}
else if(aRange.start() != newARange.start())
{
varList.emplaceBack(
msg.addAndName(message::RANGE_CHANGED),
newARange);
}
auto tInfo = time().TimeInfo();
if(!notify( if(!notify(
tInfo.iter(), time().TimeInfo(),
tInfo.t(),
tInfo.dt(),
msg, msg,
varList)) varList))
{ {
@ -433,39 +327,36 @@ bool pFlow::internalPoints::insertPointsOnly(
uint32 numNew = static_cast<uint32>(points.size()); uint32 numNew = static_cast<uint32>(points.size());
auto aRange = pFlagsD_.activeRange(); auto oldActiveRange = pFlagsD_.activeRange();
uint32 emptySpots = pFlagsD_.capacity() - pFlagsD_.numActive(); uint32 emptySpots = pFlagsD_.capacity() - pFlagsD_.numActive();
if(emptySpots!= 0) emptySpots--; if(emptySpots!= 0) emptySpots--;
if( numNew > emptySpots ) if( numNew > emptySpots )
{ {
// increase the capacity to hold new points // increase the capacity to hold new points
aRange = pFlagsD_.activeRange(); pFlagsD_.changeCapacity(numNew);
uint32 newCap = pFlagsD_.changeCapacity(numNew);
unSyncFlag(); unSyncFlag();
varList.emplaceBack(
msg.addAndName(message::CAP_CHANGED),
newCap);
} }
// first check if it is possible to add to the beggining of list // first check if it is possible to add to the beggining of list
if(numNew <= aRange.start()) if(numNew <= oldActiveRange.start())
{ {
varList.emplaceBack<uint32IndexContainer>( varList.emplaceBack<uint32IndexContainer>(
msg.addAndName(message::ITEM_INSERT), msg.addAndName(message::ITEMS_INSERT),
0u, numNew); 0u, numNew);
}// check if it is possible to add to the end of the list }
else if( numNew <= pFlagsD_.capacity() - aRange.end() ) // check if it is possible to add to the end of the list
else if( numNew <= pFlagsD_.capacity() - oldActiveRange.end() )
{ {
varList.emplaceBack<uint32IndexContainer>( varList.emplaceBack<uint32IndexContainer>(
msg.addAndName(message::ITEM_INSERT), msg.addAndName(message::ITEMS_INSERT),
aRange.end(), aRange.end()+numNew); oldActiveRange.end(), oldActiveRange.end()+numNew);
}// we should fill the scattered empty spots }
// we should fill the scattered empty spots
else else
{ {
auto newIndices = pFlagsD_.getEmptyPoints(numNew); auto newIndices = pFlagsD_.getEmptyPoints(numNew);
if(numNew != newIndices.size()) if(numNew != newIndices.size())
{ {
@ -477,14 +368,13 @@ bool pFlow::internalPoints::insertPointsOnly(
} }
varList.emplaceBack<uint32IndexContainer>( varList.emplaceBack<uint32IndexContainer>(
msg.addAndName(message::ITEM_INSERT), msg.addAndName(message::ITEMS_INSERT),
newIndices newIndices
); );
} }
const auto& indices = varList.getObject<uint32IndexContainer>( const auto& indices = varList.getObject<uint32IndexContainer>(
message::eventName(message::ITEM_INSERT) message::eventName(message::ITEMS_INSERT));
);
auto nAdded = pFlagsD_.addInternalPoints(indices.deviceView()); auto nAdded = pFlagsD_.addInternalPoints(indices.deviceView());
unSyncFlag(); unSyncFlag();
@ -496,7 +386,6 @@ bool pFlow::internalPoints::insertPointsOnly(
} }
pointPosition_.reserve( pFlagsD_.capacity() ); pointPosition_.reserve( pFlagsD_.capacity() );
if(!pointPosition_.insertSetElement(indices, points.deviceView())) if(!pointPosition_.insertSetElement(indices, points.deviceView()))
{ {
fatalErrorInFunction<< fatalErrorInFunction<<
@ -505,25 +394,16 @@ bool pFlow::internalPoints::insertPointsOnly(
return false; return false;
} }
auto newARange = pFlagsD_.activeRange(); auto newActiveRange = pFlagsD_.activeRange();
if( aRange.end() != newARange.end() ) if(oldActiveRange != newActiveRange)
{ {
varList.emplaceBack( varList.emplaceBack(
msg.addAndName(message::RANGE_CHANGED), msg.addAndName(message::RANGE_CHANGED),
newARange); newActiveRange);
varList.emplaceBack(
msg.addAndName(message::SIZE_CHANGED),
newARange.end());
}
else if(aRange.start() != newARange.start())
{
varList.emplaceBack(
msg.addAndName(message::RANGE_CHANGED),
newARange);
} }
return true; return true;
} }
bool pFlow::internalPoints::read bool pFlow::internalPoints::read

View File

@ -204,7 +204,7 @@ bool pFlow::pointStructure::beforeIteration()
anyList varList; anyList varList;
varList.emplaceBack( varList.emplaceBack(
msg.addAndName(message::ITEM_REARRANGE), msg.addAndName(message::ITEMS_REARRANGE),
sortedIndices); sortedIndices);
if(!notify(ti, msg, varList)) if(!notify(ti, msg, varList))