mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +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_;
|
||||
}
|
||||
|
@ -44,22 +44,21 @@ class sphereParticles
|
||||
:
|
||||
public particles
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
using ShapeType = sphereShape;
|
||||
private:
|
||||
|
||||
/// reference to material properties
|
||||
const property& property_;
|
||||
|
||||
/// reference to shapes
|
||||
sphereShape& shapes_;
|
||||
/// reference to shapes
|
||||
ShapeType spheres_;
|
||||
|
||||
/// pointField of inertial of particles
|
||||
realPointField_D& I_;
|
||||
realPointField_D I_;
|
||||
|
||||
/// pointField of rotational Velocity of particles on device
|
||||
realx3PointField_D& rVelocity_;
|
||||
realx3PointField_D rVelocity_;
|
||||
|
||||
/// pointField of rotational acceleration of particles on device
|
||||
realx3PointField_D& rAcceleration_;
|
||||
realx3PointField_D rAcceleration_;
|
||||
|
||||
/// rotational velocity integrator
|
||||
uniquePtr<integration> rVelIntegration_ = nullptr;
|
||||
@ -73,9 +72,9 @@ protected:
|
||||
/// timer for integration computations (correction step)
|
||||
Timer intCorrectTimer_;
|
||||
|
||||
bool diameterMassInertiaPropId(const word& shName, real& diam, real& mass, real& I, int8& propIdx);
|
||||
bool initInertia();
|
||||
|
||||
bool initializeParticles();
|
||||
/*bool initializeParticles();
|
||||
|
||||
bool insertSphereParticles(
|
||||
const wordVector& names,
|
||||
@ -83,25 +82,17 @@ protected:
|
||||
bool setId = true);
|
||||
|
||||
virtual uniquePtr<List<eventObserver*>> getFieldObjectList()const override;
|
||||
*/
|
||||
|
||||
public:
|
||||
|
||||
/// construct from systemControl and property
|
||||
sphereParticles(systemControl &control, const property& prop);
|
||||
sphereParticles(
|
||||
systemControl &control,
|
||||
const property& prop);
|
||||
|
||||
/// no copy constructor
|
||||
sphereParticles(const sphereParticles&) = delete;
|
||||
|
||||
/// move constructor
|
||||
sphereParticles(sphereParticles&&) = default;
|
||||
|
||||
/// no copy-assignement
|
||||
sphereParticles& operator=(const sphereParticles&) = delete;
|
||||
|
||||
/// move-assignement
|
||||
sphereParticles& operator=(sphereParticles&&) = default;
|
||||
|
||||
virtual ~sphereParticles()=default;
|
||||
~sphereParticles()override=default;
|
||||
|
||||
/**
|
||||
* Insert new particles in position with specified shapes
|
||||
@ -112,17 +103,17 @@ public:
|
||||
* \param shape shape of new particles
|
||||
* \param setField initial value of the selected fields for new particles
|
||||
*/
|
||||
bool insertParticles
|
||||
/*bool insertParticles
|
||||
(
|
||||
const realx3Vector& position,
|
||||
const wordVector& shapes,
|
||||
const setFieldList& setField
|
||||
) override ;
|
||||
) override ;*/
|
||||
|
||||
/// const reference to shapes object
|
||||
const auto& shapes()const
|
||||
const auto& spheres()const
|
||||
{
|
||||
return shapes_;
|
||||
return spheres_;
|
||||
}
|
||||
|
||||
/// const reference to inertia pointField
|
||||
@ -137,41 +128,29 @@ public:
|
||||
return I_;
|
||||
}
|
||||
|
||||
const realx3Vector_D rVelocity()const
|
||||
const auto& rVelocity()const
|
||||
{
|
||||
return rVelocity_;
|
||||
}
|
||||
|
||||
const realVector_D& boundingSphere()const override
|
||||
{
|
||||
return this->diameter();
|
||||
auto& rVelocity()
|
||||
{
|
||||
return rVelocity_;
|
||||
}
|
||||
|
||||
word shapeTypeName() const override
|
||||
bool hearChanges
|
||||
(
|
||||
real t,
|
||||
real dt,
|
||||
uint32 iter,
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
) override
|
||||
{
|
||||
return "sphere";
|
||||
}
|
||||
|
||||
void boundingSphereMinMax(
|
||||
real& minDiam,
|
||||
real& maxDiam )const override
|
||||
{
|
||||
shapes_.diameterMinMax(minDiam, maxDiam);
|
||||
}
|
||||
|
||||
bool update(const eventMessage& msg) override;
|
||||
|
||||
|
||||
realx3PointField_D& rAcceleration() override
|
||||
{
|
||||
return rAcceleration_;
|
||||
notImplementedFunction;
|
||||
return false;
|
||||
}
|
||||
|
||||
const realx3PointField_D& rAcceleration() const override
|
||||
{
|
||||
return rAcceleration_;
|
||||
}
|
||||
|
||||
/// before iteration step
|
||||
bool beforeIteration() override;
|
||||
|
||||
@ -180,8 +159,25 @@ public:
|
||||
|
||||
/// after iteration step
|
||||
bool afterIteration() override;
|
||||
|
||||
|
||||
realx3PointField_D& rAcceleration() override
|
||||
{
|
||||
return rAcceleration_;
|
||||
}
|
||||
|
||||
const realx3PointField_D& rAcceleration() const override
|
||||
{
|
||||
return rAcceleration_;
|
||||
}
|
||||
|
||||
const realPointField_D& boundingSphere()const override
|
||||
{
|
||||
return diameter();
|
||||
}
|
||||
|
||||
word shapeTypeName()const override;
|
||||
|
||||
const shape& getShapes()const override;
|
||||
|
||||
}; //sphereParticles
|
||||
|
||||
|
Reference in New Issue
Block a user