All messages are revisited for internal points and boundaries

This commit is contained in:
HRN 2025-02-06 11:04:30 +03:30
parent edb02ecfc7
commit 02e0b72082
53 changed files with 431 additions and 846 deletions

View File

@ -67,7 +67,7 @@ bool pFlow::grainFluidParticles::beforeIteration()
bool pFlow::grainFluidParticles::iterate()
{
const auto ti = this->TimeInfo();
accelerationTimer().start();
pFlow::grainFluidParticlesKernels::acceleration(
control().g(),
@ -78,16 +78,16 @@ bool pFlow::grainFluidParticles::iterate()
contactTorque().deviceViewAll(),
fluidTorque_.deviceViewAll(),
pStruct().activePointsMaskDevice(),
accelertion().deviceViewAll(),
acceleration().deviceViewAll(),
rAcceleration().deviceViewAll()
);
accelerationTimer().end();
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();

View File

@ -65,7 +65,7 @@ bool pFlow::sphereFluidParticles::beforeIteration()
bool pFlow::sphereFluidParticles::iterate()
{
const auto ti = this->TimeInfo();
accelerationTimer().start();
pFlow::sphereFluidParticlesKernels::acceleration(
control().g(),
@ -76,16 +76,16 @@ bool pFlow::sphereFluidParticles::iterate()
contactTorque().deviceViewAll(),
fluidTorque_.deviceViewAll(),
pStruct().activePointsMaskDevice(),
accelertion().deviceViewAll(),
acceleration().deviceViewAll(),
rAcceleration().deviceViewAll()
);
accelerationTimer().end();
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();

View File

@ -114,8 +114,11 @@ pFlow::AdamsBashforth2::AdamsBashforth2
zero3,
zero3
),
initialValField_(initialValField),
boundaryList_(pStruct, method, *this)
{}
{
realx3PointField_D::addEvent(message::ITEMS_INSERT);
}
void pFlow::AdamsBashforth2::updateBoundariesSlaveToMasterIfRequested()
{
@ -186,11 +189,21 @@ bool pFlow::AdamsBashforth2::correctPStruct(
return success;
}
bool pFlow::AdamsBashforth2::setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y)
bool pFlow::AdamsBashforth2::hearChanges
(
const timeInfo &ti,
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:
const realx3Field_D& initialValField_;
boundaryIntegrationList boundaryList_;
friend class processorAB2BoundaryIntegration;
@ -57,6 +59,11 @@ protected:
return static_cast<realx3PointField_D&>(*this);
}
auto& initialValField()
{
return initialValField_;
}
boundaryIntegrationList& boundaryList()
{
return boundaryList_;
@ -117,24 +124,12 @@ public:
pointStructure& pStruct,
realx3PointField_D& vel) override;
/*bool hearChanges
bool hearChanges
(
real t,
real dt,
uint32 iter,
const timeInfo& ti,
const message& msg,
const anyList& varList
) override;*/
bool setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y) override;
bool needSetInitialVals()const override
{
return false;
}
) override;
};

View File

@ -184,35 +184,20 @@ bool pFlow::AdamsBashforth3::correctPStruct(
return success;
}
bool pFlow::AdamsBashforth3::setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y)
bool pFlow::AdamsBashforth3::hearChanges
(
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());
}
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;
/*bool hearChanges
bool hearChanges
(
real t,
real dt,
uint32 iter,
const timeInfo& ti,
const message& msg,
const anyList& varList
) override;*/
bool setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y) override;
bool needSetInitialVals()const override
{
return false;
}
) override;
};

View File

@ -190,40 +190,21 @@ bool pFlow::AdamsBashforth4::correctPStruct(
return success;
}
bool pFlow::AdamsBashforth4::setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y)
bool pFlow::AdamsBashforth4::hearChanges
(
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

@ -104,16 +104,12 @@ public:
pointStructure& pStruct,
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(
real t,
real dt,
uint32 iter,
const timeInfo& ti,
const message &msg,
const anyList &varList) override
{

View File

@ -22,17 +22,39 @@ Licence:
#include "pointStructure.hpp"
#include "repository.hpp"
pFlow::integration::integration
bool pFlow::integration::insertValues
(
const word& baseName,
pointStructure& pStruct,
const word&,
const realx3Field_D&
const anyList& varList,
const deviceViewType1D<realx3>& srcVals,
realx3PointField_D& dstFeild
)
:
owner_(*pStruct.owner()),
pStruct_(pStruct),
baseName_(baseName)
{
const word eventName = message::eventName(message::ITEMS_INSERT);
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
const word baseName_;
protected:
bool insertValues(
const anyList& varList,
const deviceViewType1D<realx3>& srcVals,
realx3PointField_D& dstFeild);
public:
/// Type info
@ -151,17 +158,6 @@ public:
virtual
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
static
uniquePtr<integration> create(

View File

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

View File

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

View File

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

View File

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

View File

@ -148,7 +148,7 @@ public:
const ContactForceModel& cfModel,
uint32 step)
{
// for default boundary, no thing to be done
// for default boundary, nothing to be done
return false;
}
@ -156,16 +156,14 @@ public:
bool hearChanges
(
real t,
real dt,
uint32 iter,
const timeInfo& ti,
const message& msg,
const anyList& varList
) override
{
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;
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>
bool pFlow::sphereInteraction<cFM,gMM, cLT>::hearChanges
(
real t,
real dt,
uint32 iter,
const timeInfo& ti,
const message& msg,
const anyList& varList
)
{
if(msg.equivalentTo(message::ITEM_REARRANGE))
if(msg.equivalentTo(message::ITEMS_REARRANGE))
{
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)
bool hearChanges(
real t,
real dt,
uint32 iter,
const timeInfo& ti,
const message& msg,
const anyList& varList)override;

View File

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

View File

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

View File

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

View File

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

View File

@ -24,180 +24,6 @@ Licence:
#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()
{
@ -403,7 +229,7 @@ pFlow::sphereParticles::sphereParticles(
"rVelocity",
dynPointStruct(),
intMethod,
rVelocity_.field()
rAcceleration_.field()
);
if( !rVelIntegration_ )
@ -413,8 +239,6 @@ pFlow::sphereParticles::sphereParticles(
fatalExit;
}
WARNING<<"setFields for rVelIntegration_"<<END_WARNING;
if(!initializeParticles())
{
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()
{
particles::beforeIteration();
intPredictTimer_.start();
auto dt = this->dt();
dynPointStruct().predict(dt, accelertion());
dynPointStruct().predict(dt);
rVelIntegration_().predict(dt,rVelocity_, rAcceleration_);
intPredictTimer_.end();
@ -532,8 +272,8 @@ bool pFlow::sphereParticles::beforeIteration()
bool pFlow::sphereParticles::iterate()
{
timeInfo ti = TimeInfo();
realx3 g = control().g();
const timeInfo ti = TimeInfo();
const realx3 g = control().g();
particles::iterate();
accelerationTimer_.start();
@ -544,7 +284,7 @@ bool pFlow::sphereParticles::iterate()
I().deviceViewAll(),
contactTorque().deviceViewAll(),
dynPointStruct().activePointsMaskDevice(),
accelertion().deviceViewAll(),
acceleration().deviceViewAll(),
rAcceleration().deviceViewAll()
);
ForAllActiveBoundaries(i,boundarySphereParticles_)
@ -556,7 +296,7 @@ bool pFlow::sphereParticles::iterate()
intCorrectTimer_.start();
if(!dynPointStruct().correct(dt(), accelertion()))
if(!dynPointStruct().correct(ti.dt()))
{
return false;
}

View File

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

View File

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

View File

@ -42,6 +42,9 @@ private:
realx3PointField_D velocity_;
/// acceleration on device
realx3PointField_D acceleration_;
uniquePtr<integration> integrationPos_ = nullptr;
uniquePtr<integration> integrationVel_ = nullptr;
@ -86,6 +89,18 @@ public:
return velocity_;
}
inline
const realx3PointField_D& acceleration()const
{
return acceleration_;
}
inline
realx3PointField_D& acceleration()
{
return acceleration_;
}
/// In the time loop before iterate
bool beforeIteration() override;
@ -96,10 +111,10 @@ public:
bool afterIteration()override;
/// 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
bool correct(real dt, realx3PointField_D& acceleration);
bool correct(real dt);
};

View File

@ -41,16 +41,14 @@ pFlow::particleIdHandler::particleIdHandler(pointStructure& pStruct)
bool
pFlow::particleIdHandler::hearChanges(
real t,
real dt,
uint32 iter,
const timeInfo& ti,
const message& msg,
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>(
eventName);
@ -66,7 +64,7 @@ pFlow::particleIdHandler::hearChanges(
}
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
uint32 maxId()const = 0;
// heat change for possible insertion of particles
// overrdie from internalField
bool hearChanges
(
real t,
real dt,
uint32 iter,
const timeInfo& ti,
const message& msg,
const anyList& varList
) override;

View File

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

View File

@ -45,9 +45,6 @@ private:
/// shape index of each particle
uint32PointField_D shapeIndex_;
/// acceleration on device
realx3PointField_D accelertion_;
/// contact force field
realx3PointField_D contactForce_;
@ -60,7 +57,7 @@ private:
Timer baseFieldBoundaryUpdateTimer_;
/// messages for this objects
static inline const message defaultMessage_{ message::DEFAULT };
static inline const message defaultMessage_= message::Empty();
protected:
@ -156,14 +153,14 @@ public:
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()

View File

@ -162,12 +162,26 @@ public:
{
fatalErrorInFunction<<
"variable name "<< name << " does not exist in the anyList."<<endl<<
"list of variables is "<<names_<<endl;
"list of variables is \n"<<names_<<endl;
fatalExit;
}
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
template<typename T>
const T& getObject(const word& name)const

View File

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

View File

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

View File

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

View File

@ -61,26 +61,6 @@ public:
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
{
return false;

View File

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

View File

@ -61,29 +61,6 @@ public:
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)
{
//this->addEvent(message::BNDR_DELETE);
}
{}

View File

@ -61,26 +61,6 @@ public:
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
{
return false;

View File

@ -21,7 +21,14 @@ Licence:
template<class T, class MemorySpace>
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>(
eventName);
@ -30,14 +37,24 @@ bool pFlow::internalField<T, MemorySpace>::insert(const anyList& varList)
if(varList.contains(name()))
{
// 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());
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
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);
}
else
@ -57,8 +74,13 @@ bool pFlow::internalField<T, MemorySpace>::insert(const anyList& varList)
template<class T, class MemorySpace>
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>(
eventName);
@ -162,40 +184,47 @@ typename pFlow::internalField<T, MemorySpace>::FieldTypeHost
template <class T, class MemorySpace>
bool pFlow::internalField<T, MemorySpace>:: hearChanges
(
real t,
real dt,
uint32 iter,
const timeInfo& ti,
const message& msg,
const anyList& varList
)
{
if(msg.equivalentTo(message::CAP_CHANGED))
if(msg.equivalentTo(message::RANGE_CHANGED))
{
auto newCap = varList.getObject<uint32>(
message::eventName(message::CAP_CHANGED));
auto varName = message::eventName(message::RANGE_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))
{
auto newSize = varList.getObject<uint32>(
message::eventName(message::SIZE_CHANGED));
field_.resize(newSize);
}
if(msg.equivalentTo(message::ITEM_DELETE))
else if(msg.equivalentTo(message::ITEMS_DELETE))
{
// do nothing
return true;
}
if(msg.equivalentTo(message::ITEM_INSERT))
else if(msg.equivalentTo(message::ITEMS_INSERT))
{
return insert(varList);
}
if(msg.equivalentTo(message::ITEM_REARRANGE))
else if(msg.equivalentTo(message::ITEMS_REARRANGE))
{
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>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -133,7 +133,6 @@ bool pFlow::subscriber::notify
const anyList& varList
)
{
for(size_t i=0; i<msg.size(); i++)
{
if(msg.equivalentTo(i))
@ -151,11 +150,25 @@ bool pFlow::subscriber::notify
}
}
}
return true;
}
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;
/// TODO: remove this API from thie class
bool notify(
uint32 iter,
real t,

View File

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

View File

@ -71,6 +71,20 @@ public:
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_);
uint32 updateInterval =
boundaries.getValOrSetMax<uint32>("updateInterval", 1u);
boundaries.getValOrSet<uint32>("updateInterval", 5u);
updateInterval = max(updateInterval, 1u);
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
this->addDict(thisBoundariesDictName(), boundaries);

View File

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

View File

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