sphereDEMSystem is updated for version 1.0

This commit is contained in:
HRN 2024-12-26 19:07:39 +03:30
parent bc22012ecd
commit 16f8ab4572
10 changed files with 151 additions and 97 deletions

View File

@ -3,7 +3,7 @@ set(SourceFiles
domainDistribute/domainDistribute.cpp
DEMSystem/DEMSystem.cpp
sphereDEMSystem/sphereFluidParticles.cpp
#sphereDEMSystem/sphereDEMSystem.cpp
sphereDEMSystem/sphereDEMSystem.cpp
#
)

View File

@ -61,6 +61,7 @@ public:
DEMSystem(const DEMSystem&)=delete;
/// @brief no assignment
DEMSystem& operator = (const DEMSystem&)=delete;
create_vCtor(
@ -118,7 +119,7 @@ public:
span<const int32> parIndexInDomain(int32 domIndx)const = 0;
virtual
span<real> parDiameter() = 0;
span<real> diameter() = 0;
virtual
span<realx3> acceleration()=0;

View File

@ -33,7 +33,7 @@ void pFlow::domainDistribute::clcDomains(const std::vector<box>& domains)
pFlow::domainDistribute::domainDistribute(
const Vector<box>& domains,
const std::vector<box>& domains,
real maxBoundingBox)
:
numDomains_(domains.size()),

View File

@ -52,7 +52,7 @@ protected:
public:
domainDistribute(
const Vector<box>& domains,
const std::vector<box>& domains,
real maxBoundingBox);
~domainDistribute()=default;

View File

@ -19,6 +19,7 @@ Licence:
-----------------------------------------------------------------------------*/
#include "sphereDEMSystem.hpp"
#include "vocabs.hpp"
bool pFlow::sphereDEMSystem::loop()
{
@ -26,16 +27,15 @@ bool pFlow::sphereDEMSystem::loop()
do
{
//
if(! insertion_().insertParticles(
Control().time().currentIter(),
Control().time().currentTime(),
Control().time().dt() ) )
{
fatalError<<
"particle insertion failed in sphereDFlow solver.\n";
"particle insertion failed in sphereDEMSystem.\n";
return false;
}
}
geometry_->beforeIteration();
@ -63,29 +63,31 @@ pFlow::sphereDEMSystem::sphereDEMSystem(
word demSystemName,
const std::vector<box>& domains,
int argc,
char* argv[])
char* argv[],
bool requireRVel)
:
DEMSystem(demSystemName, domains, argc, argv)
DEMSystem(demSystemName, domains, argc, argv),
requireRVel_(requireRVel)
{
REPORT(0)<<"\nReading proprties . . . "<<endREPORT;
REPORT(0)<<"\nReading proprties . . . "<<END_REPORT;
property_ = makeUnique<property>(
Control().caseSetup().path()+propertyFile__);
propertyFile__,
Control().caseSetup().path());
REPORT(0)<< "\nCreating surface geometry for sphereDEMSystem . . . "<<endREPORT;
REPORT(0)<< "\nCreating surface geometry for sphereDEMSystem . . . "<<END_REPORT;
geometry_ = geometry::create(Control(), Property());
REPORT(0)<<"\nReading sphere particles . . ."<<endREPORT;
REPORT(0)<<"\nReading sphere particles . . ."<<END_REPORT;
particles_ = makeUnique<sphereFluidParticles>(Control(), Property());
insertion_ = makeUnique<sphereInsertion>(
Control().caseSetup().path()+insertionFile__,
insertion_ = makeUnique<sphereInsertion>(
particles_(),
particles_().shapes());
particles_().spheres());
REPORT(0)<<"\nCreating interaction model for sphere-sphere contact and sphere-wall contact . . ."<<endREPORT;
REPORT(0)<<"\nCreating interaction model for sphere-sphere contact and sphere-wall contact . . ."<<END_REPORT;
interaction_ = interaction::create(
Control(),
Particles(),
@ -98,6 +100,7 @@ pFlow::sphereDEMSystem::sphereDEMSystem(
}
pFlow::sphereDEMSystem::~sphereDEMSystem()
{
@ -119,8 +122,8 @@ bool pFlow::sphereDEMSystem::updateParticleDistribution(
}
if(!particleDistribution_->locateParticles(
parPosition_,
particles_->pStruct().activePointsMaskH()))
positionHost_,
particles_->pStruct().activePointsMaskHost()))
{
fatalErrorInFunction<<
"error in locating particles among sub-domains"<<endl;
@ -137,7 +140,7 @@ pFlow::int32
}
std::vector<pFlow::int32>
pFlow::sphereDEMSystem::numParInDomain()const
pFlow::sphereDEMSystem::numParInDomains()const
{
const auto& distribute = particleDistribution_();
int32 numDomains = distribute.numDomains();
@ -156,31 +159,51 @@ pFlow::sphereDEMSystem::parIndexInDomain(int32 di)const
return particleDistribution_->particlesInDomain(di);
}
pFlow::span<pFlow::real> pFlow::sphereDEMSystem::parDiameter()
pFlow::span<pFlow::real> pFlow::sphereDEMSystem::diameter()
{
return span<real>(parDiameter_.data(), parDiameter_.size());
return span<real>(diameterHost_.data(), diameterHost_.size());
}
pFlow::span<pFlow::realx3> pFlow::sphereDEMSystem::parVelocity()
pFlow::span<pFlow::realx3> pFlow::sphereDEMSystem::acceleration()
{
return span<realx3>(parVelocity_.data(), parVelocity_.size());
return span<realx3>(nullptr, 0);
}
pFlow::span<pFlow::realx3> pFlow::sphereDEMSystem::parPosition()
pFlow::span<pFlow::realx3> pFlow::sphereDEMSystem::velocity()
{
return span<realx3>(parPosition_.data(), parPosition_.size());
return span<realx3>(velocityHost_.data(), velocityHost_.size());
}
pFlow::span<pFlow::realx3> pFlow::sphereDEMSystem::position()
{
return span<realx3>(positionHost_.data(), positionHost_.size());
}
pFlow::span<pFlow::realx3> pFlow::sphereDEMSystem::rAcceleration()
{
return span<realx3>(nullptr, 0);
}
pFlow::span<pFlow::realx3> pFlow::sphereDEMSystem::rVelocity()
{
return span<realx3>(rVelocityHost_.data(), rVelocityHost_.size());
}
pFlow::span<pFlow::realx3> pFlow::sphereDEMSystem::rPosition()
{
return span<realx3>(nullptr, 0);
}
pFlow::span<pFlow::realx3> pFlow::sphereDEMSystem::parFluidForce()
{
auto& hVec = particles_->fluidForceHostAll();
auto& hVec = particles_->fluidForceHost();
return span<realx3>(hVec.data(), hVec.size());
}
pFlow::span<pFlow::realx3> pFlow::sphereDEMSystem::parFluidTorque()
{
auto& hVec = particles_->fluidTorqueHostAll();
auto& hVec = particles_->fluidTorqueHost();
return span<realx3>(hVec.data(), hVec.size());
}
@ -198,9 +221,14 @@ bool pFlow::sphereDEMSystem::sendFluidTorqueToDEM()
bool pFlow::sphereDEMSystem::beforeIteration()
{
parVelocity_ = particles_->dynPointStruct().velocityHostAll();
parPosition_ = particles_->dynPointStruct().pointPositionHostAll();
parDiameter_ = particles_->diameter().hostVectorAll();
velocityHost_ = std::as_const(particles_()).velocity().hostView();
positionHost_ = std::as_const(particles_()).pointPosition().hostView();
diameterHost_ = particles_->diameter().hostView();
if(requireRVel_)
rVelocityHost_ = std::as_const(particles_()).rVelocity().hostView();
return true;
}

View File

@ -42,24 +42,29 @@ protected:
// protected members
uniquePtr<property> property_ = nullptr;
uniquePtr<property> property_ = nullptr;
uniquePtr<geometry> geometry_ = nullptr;
uniquePtr<geometry> geometry_ = nullptr;
uniquePtr<sphereFluidParticles> particles_ = nullptr;
uniquePtr<sphereFluidParticles> particles_ = nullptr;
uniquePtr<sphereInsertion> insertion_ = nullptr;
uniquePtr<sphereInsertion> insertion_ = nullptr;
uniquePtr<interaction> interaction_ = nullptr;
uniquePtr<interaction> interaction_ = nullptr;
uniquePtr<domainDistribute> particleDistribution_=nullptr;
uniquePtr<domainDistribute> particleDistribution_=nullptr;
// to be used for CPU communications
ViewType1D<realx3, HostSpace> parVelocity_;
ViewType1D<realx3, HostSpace> velocityHost_;
ViewType1D<realx3, HostSpace> parPosition_;
ViewType1D<realx3, HostSpace> positionHost_;
ViewType1D<real, HostSpace> diameterHost_;
bool requireRVel_ = false;
ViewType1D<realx3, HostSpace> rVelocityHost_;
ViewType1D<real, HostSpace> parDiameter_;
// protected member functions
auto& Property()
@ -92,7 +97,8 @@ public:
word demSystemName,
const std::vector<box>& domains,
int argc,
char* argv[]);
char* argv[],
bool requireRVel=false);
virtual ~sphereDEMSystem();
@ -110,15 +116,23 @@ public:
int32 numParInDomain(int32 di)const override;
std::vector<int32> numParInDomain()const override;
std::vector<int32> numParInDomains()const override;
span<const int32> parIndexInDomain(int32 di)const override;
span<real> parDiameter() override;
span<real> diameter() override;
span<realx3> parVelocity() override;
span<realx3> acceleration() override;
span<realx3> parPosition() override;
span<realx3> velocity() override;
span<realx3> position() override;
span<realx3> rAcceleration() override;
span<realx3> rVelocity() override;
span<realx3> rPosition() override;
span<realx3> parFluidForce() override;

View File

@ -29,29 +29,25 @@ pFlow::sphereFluidParticles::sphereFluidParticles(
:
sphereParticles(control, prop),
fluidForce_(
this->time().emplaceObject<realx3PointField_HD>(
objectFile(
"fluidForce",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
pStruct(),
zero3
)
),
objectFile(
"fluidForce",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
dynPointStruct(),
zero3
),
fluidTorque_(
this->time().emplaceObject<realx3PointField_HD>(
objectFile(
"fluidTorque",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
pStruct(),
zero3
)
)
objectFile(
"fluidTorque",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_NEVER
),
dynPointStruct(),
zero3
)
{}
bool pFlow::sphereFluidParticles::beforeIteration()
@ -64,42 +60,40 @@ bool pFlow::sphereFluidParticles::beforeIteration()
bool pFlow::sphereFluidParticles::iterate()
{
accelerationTimer_.start();
accelerationTimer().start();
pFlow::sphereFluidParticlesKernels::acceleration(
control().g(),
mass().deviceVectorAll(),
contactForce().deviceVectorAll(),
fluidForce().deviceVectorAll(),
I().deviceVectorAll(),
contactTorque().deviceVectorAll(),
fluidTorque().deviceVectorAll(),
pStruct().activePointsMaskD(),
accelertion().deviceVectorAll(),
rAcceleration().deviceVectorAll()
mass().deviceViewAll(),
contactForce().deviceViewAll(),
fluidForce_.deviceViewAll(),
I().deviceViewAll(),
contactTorque().deviceViewAll(),
fluidTorque_.deviceViewAll(),
pStruct().activePointsMaskDevice(),
accelertion().deviceViewAll(),
rAcceleration().deviceViewAll()
);
accelerationTimer_.end();
accelerationTimer().end();
intCorrectTimer_.start();
intCorrectTimer().start();
dynPointStruct_.correct(this->dt(), accelertion_);
dynPointStruct().correct(this->dt(), accelertion());
rVelIntegration_().correct(this->dt(), rVelocity_, rAcceleration_);
rVelIntegration().correct(this->dt(), rVelocity(), rAcceleration());
intCorrectTimer_.end();
intCorrectTimer().end();
return true;
}
void pFlow::sphereFluidParticles::fluidForceHostUpdatedSync()
{
fluidForce_.modifyOnHost();
fluidForce_.syncViews();
copy(fluidForce_.deviceView(), fluidForceHost_);
return;
}
void pFlow::sphereFluidParticles::fluidTorqueHostUpdatedSync()
{
fluidTorque_.modifyOnHost();
fluidTorque_.syncViews();
copy(fluidTorque_.deviceView(), fluidTorqueHost_);
return;
}

View File

@ -43,12 +43,15 @@ class sphereFluidParticles
protected:
/// pointField of rotational acceleration of particles on device
realx3PointField_HD& fluidForce_;
realx3PointField_D fluidForce_;
realx3PointField_HD& fluidTorque_;
hostViewType1D<realx3> fluidForceHost_;
realx3PointField_D fluidTorque_;
void zeroFluidForce_H()
hostViewType1D<realx3> fluidTorqueHost_;
/*void zeroFluidForce_H()
{
fluidForce_.fillHost(zero3);
}
@ -56,7 +59,7 @@ protected:
void zeroFluidTorque_H()
{
fluidTorque_.fillHost(zero3);
}
}*/
public:
@ -81,17 +84,16 @@ public:
}
auto& fluidForceHostAll()
auto& fluidForceHost()
{
return fluidForce_.hostVectorAll();
return fluidForceHost_;
}
auto& fluidTorqueHostAll()
auto& fluidTorqueHost()
{
return fluidTorque_.hostVectorAll();
return fluidTorqueHost_;
}
void fluidForceHostUpdatedSync();
void fluidTorqueHostUpdatedSync();

View File

@ -46,7 +46,7 @@ void acceleration(
{
auto activeRange = incld.activeRange();
if(incld.allActive())
if(incld.isAllActive())
{
Kokkos::parallel_for(
"pFlow::sphereParticlesKernels::acceleration",

View File

@ -105,7 +105,22 @@ private:
virtual uniquePtr<List<eventObserver*>> getFieldObjectList()const override;
*/
protected:
Timer& accelerationTimer()
{
return accelerationTimer_;
}
Timer& intCorrectTimer()
{
return intCorrectTimer_;
}
integration& rVelIntegration()
{
return rVelIntegration_();
}
public:
/// construct from systemControl and property