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

@ -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()