mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-12-08 06:57:54 +00:00
Particle base class and sphereParticle class have been updated
This commit is contained in:
@ -19,10 +19,12 @@ Licence:
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "sphereParticles.hpp"
|
||||
#include "setFieldList.hpp"
|
||||
#include "sphereParticlesKernels.hpp"
|
||||
#include "systemControl.hpp"
|
||||
#include "vocabs.hpp"
|
||||
//#include "setFieldList.hpp"
|
||||
//#include "sphereParticlesKernels.hpp"
|
||||
|
||||
pFlow::uniquePtr<pFlow::List<pFlow::eventObserver*>>
|
||||
/*pFlow::uniquePtr<pFlow::List<pFlow::eventObserver*>>
|
||||
pFlow::sphereParticles::getFieldObjectList()const
|
||||
{
|
||||
auto objListPtr = particles::getFieldObjectList();
|
||||
@ -78,10 +80,10 @@ bool pFlow::sphereParticles::initializeParticles()
|
||||
static_cast<int32>(shapeName_.size()));
|
||||
|
||||
return insertSphereParticles(shapeName_, indices, false);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
bool pFlow::sphereParticles::beforeIteration()
|
||||
/*bool pFlow::sphereParticles::beforeIteration()
|
||||
{
|
||||
particles::beforeIteration();
|
||||
|
||||
@ -98,45 +100,19 @@ bool pFlow::sphereParticles::beforeIteration()
|
||||
intPredictTimer_.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
bool pFlow::sphereParticles::iterate()
|
||||
{
|
||||
|
||||
accelerationTimer_.start();
|
||||
//INFO<<"before accelerationTimer_ "<<endINFO;
|
||||
pFlow::sphereParticlesKernels::acceleration(
|
||||
control().g(),
|
||||
mass().deviceVectorAll(),
|
||||
contactForce().deviceVectorAll(),
|
||||
I().deviceVectorAll(),
|
||||
contactTorque().deviceVectorAll(),
|
||||
pStruct().activePointsMaskD(),
|
||||
accelertion().deviceVectorAll(),
|
||||
rAcceleration().deviceVectorAll()
|
||||
);
|
||||
accelerationTimer_.end();
|
||||
|
||||
intCorrectTimer_.start();
|
||||
|
||||
dynPointStruct_.correct(this->dt(), accelertion_);
|
||||
|
||||
rVelIntegration_().correct(this->dt(), rVelocity_, rAcceleration_);
|
||||
|
||||
intCorrectTimer_.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::sphereParticles::afterIteration()
|
||||
|
||||
/*bool pFlow::sphereParticles::afterIteration()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
bool pFlow::sphereParticles::insertSphereParticles(
|
||||
/*bool pFlow::sphereParticles::insertSphereParticles(
|
||||
const wordVector& names,
|
||||
const int32IndexContainer& indices,
|
||||
bool setId
|
||||
@ -219,6 +195,39 @@ bool pFlow::sphereParticles::insertSphereParticles(
|
||||
|
||||
return true;
|
||||
|
||||
}*/
|
||||
|
||||
bool pFlow::sphereParticles::initInertia()
|
||||
{
|
||||
|
||||
using exeSpace = typename realPointField_D::execution_space;
|
||||
using policy = Kokkos::RangePolicy<
|
||||
exeSpace,
|
||||
Kokkos::IndexType<uint32>>;
|
||||
|
||||
auto aPointsMask = dynPointStruct().activePointsMaskDevice();
|
||||
auto aRange = aPointsMask.activeRange();
|
||||
|
||||
auto field_I = I_.fieldDevice();
|
||||
auto field_shapeIndex = shapeIndex().fieldDevice();
|
||||
|
||||
const auto& shp = getShapes();
|
||||
realVector_D I ("I", shp.Inertia());
|
||||
auto d_I = I.deviceVector();
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"particles::initInertia",
|
||||
policy(aRange.start(), aRange.end()),
|
||||
LAMBDA_HD(uint32 i)
|
||||
{
|
||||
if(aPointsMask(i))
|
||||
{
|
||||
uint32 index = field_shapeIndex[i];
|
||||
field_I[i] = d_I[index];
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -227,78 +236,67 @@ pFlow::sphereParticles::sphereParticles(
|
||||
const property& prop
|
||||
)
|
||||
:
|
||||
particles(
|
||||
control,
|
||||
control.settingsDict().getValOrSet(
|
||||
"integrationMethod",
|
||||
word("AdamsBashforth3")
|
||||
)
|
||||
particles(control),
|
||||
spheres_
|
||||
(
|
||||
shapeFile__,
|
||||
&control.caseSetup(),
|
||||
prop
|
||||
),
|
||||
I_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"I",
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
property_(prop),
|
||||
shapes_(
|
||||
control.caseSetup().emplaceObjectOrGet<sphereShape>(
|
||||
objectFile(
|
||||
sphereShapeFile__,
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_NEVER
|
||||
)
|
||||
)
|
||||
),
|
||||
I_(
|
||||
this->time().emplaceObject<realPointField_D>(
|
||||
objectFile(
|
||||
"I",
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
static_cast<real>(0.0000000001)
|
||||
)
|
||||
),
|
||||
rVelocity_(
|
||||
this->time().emplaceObject<realx3PointField_D>(
|
||||
objectFile(
|
||||
"rVelocity",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
zero3
|
||||
)
|
||||
),
|
||||
rAcceleration_(
|
||||
this->time().emplaceObject<realx3PointField_D>(
|
||||
objectFile(
|
||||
"rAcceleration",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
zero3
|
||||
)
|
||||
dynPointStruct(),
|
||||
static_cast<real>(0.0000000001)
|
||||
),
|
||||
rVelocity_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"rVelocity",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
dynPointStruct(),
|
||||
zero3
|
||||
),
|
||||
rAcceleration_
|
||||
(
|
||||
objectFile(
|
||||
"rAcceleration",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
dynPointStruct(),
|
||||
zero3
|
||||
),
|
||||
accelerationTimer_(
|
||||
"Acceleration", &this->timers() ),
|
||||
intPredictTimer_(
|
||||
"Integration-predict", &this->timers() ),
|
||||
intCorrectTimer_(
|
||||
"Integration-correct", &this->timers() )
|
||||
|
||||
{
|
||||
|
||||
REPORT(1)<<"Creating integration method "<<greenText(this->integrationMethod())
|
||||
<< " for rotational velocity."<<endREPORT;
|
||||
auto intMethod = control.settingsDict().getVal<word>("integrationMethod");
|
||||
REPORT(1)<<"Creating integration method "<<Green_Text(intMethod)
|
||||
<< " for rotational velocity."<<END_REPORT;
|
||||
|
||||
rVelIntegration_ =
|
||||
integration::create(
|
||||
rVelIntegration_ = integration::create
|
||||
(
|
||||
"rVelocity",
|
||||
this->time().integration(),
|
||||
this->pStruct(),
|
||||
this->integrationMethod());
|
||||
dynPointStruct(),
|
||||
intMethod,
|
||||
rVelocity_.field()
|
||||
);
|
||||
|
||||
if( !rVelIntegration_ )
|
||||
{
|
||||
@ -307,7 +305,8 @@ pFlow::sphereParticles::sphereParticles(
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
if(rVelIntegration_->needSetInitialVals())
|
||||
WARNING<<"setFields for rVelIntegration_"<<END_WARNING;
|
||||
/*if(rVelIntegration_->needSetInitialVals())
|
||||
{
|
||||
|
||||
auto [minInd, maxInd] = pStruct().activeRange();
|
||||
@ -327,17 +326,17 @@ pFlow::sphereParticles::sphereParticles(
|
||||
REPORT(2)<< "Initializing the required vectors for rotational velocity integratoin\n "<<endREPORT;
|
||||
rVelIntegration_->setInitialVals(indexHD, rvel);
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
if(!initializeParticles())
|
||||
if(!initInertia())
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::sphereParticles::update(const eventMessage& msg)
|
||||
/*bool pFlow::sphereParticles::update(const eventMessage& msg)
|
||||
{
|
||||
|
||||
if(rVelIntegration_->needSetInitialVals())
|
||||
@ -362,9 +361,9 @@ bool pFlow::sphereParticles::update(const eventMessage& msg)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
bool pFlow::sphereParticles::insertParticles
|
||||
/*bool pFlow::sphereParticles::insertParticles
|
||||
(
|
||||
const realx3Vector& position,
|
||||
const wordVector& shapes,
|
||||
@ -419,4 +418,70 @@ bool pFlow::sphereParticles::insertParticles
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
bool pFlow::sphereParticles::beforeIteration()
|
||||
{
|
||||
particles::beforeIteration();
|
||||
intPredictTimer_.start();
|
||||
dynPointStruct().predict(dt(), accelertion());
|
||||
rVelIntegration_().predict(dt(),rVelocity_, rAcceleration_);
|
||||
intPredictTimer_.end();
|
||||
|
||||
WARNING<<"pFlow::sphereParticles::beforeIteration()"<<END_WARNING;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::sphereParticles::iterate()
|
||||
{
|
||||
|
||||
particles::iterate();
|
||||
accelerationTimer_.start();
|
||||
WARNING<<"pFlow::sphereParticlesKernels::acceleration"<<END_WARNING;
|
||||
//INFO<<"before accelerationTimer_ "<<endINFO;
|
||||
/*pFlow::sphereParticlesKernels::acceleration(
|
||||
control().g(),
|
||||
mass().deviceVectorAll(),
|
||||
contactForce().deviceVectorAll(),
|
||||
I().deviceVectorAll(),
|
||||
contactTorque().deviceVectorAll(),
|
||||
pStruct().activePointsMaskD(),
|
||||
accelertion().deviceVectorAll(),
|
||||
rAcceleration().deviceVectorAll()
|
||||
);*/
|
||||
accelerationTimer_.end();
|
||||
|
||||
intCorrectTimer_.start();
|
||||
|
||||
if(!dynPointStruct().correct(dt(), accelertion()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!rVelIntegration_().correct(
|
||||
dt(),
|
||||
rVelocity_,
|
||||
rAcceleration_))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
intCorrectTimer_.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::sphereParticles::afterIteration()
|
||||
{
|
||||
particles::afterIteration();
|
||||
return true;
|
||||
}
|
||||
|
||||
pFlow::word pFlow::sphereParticles::shapeTypeName()const
|
||||
{
|
||||
return "sphere";
|
||||
}
|
||||
|
||||
const pFlow::shape &pFlow::sphereParticles::getShapes() const
|
||||
{
|
||||
return spheres_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user