sphereParticles tested
This commit is contained in:
parent
206df8924e
commit
0df384f546
|
@ -7,6 +7,7 @@ particles/particles.cpp
|
||||||
#particles/particleIdHandler.cpp
|
#particles/particleIdHandler.cpp
|
||||||
SphereParticles/sphereShape/sphereShape.cpp
|
SphereParticles/sphereShape/sphereShape.cpp
|
||||||
SphereParticles/sphereParticles/sphereParticles.cpp
|
SphereParticles/sphereParticles/sphereParticles.cpp
|
||||||
|
SphereParticles/sphereParticles/sphereParticlesKernels.cpp
|
||||||
#Insertion/shapeMixture/shapeMixture.cpp
|
#Insertion/shapeMixture/shapeMixture.cpp
|
||||||
#Insertion/insertion/insertion.cpp
|
#Insertion/insertion/insertion.cpp
|
||||||
#Insertion/Insertion/Insertions.cpp
|
#Insertion/Insertion/Insertions.cpp
|
||||||
|
|
|
@ -21,9 +21,10 @@ Licence:
|
||||||
#include "sphereParticles.hpp"
|
#include "sphereParticles.hpp"
|
||||||
#include "systemControl.hpp"
|
#include "systemControl.hpp"
|
||||||
#include "vocabs.hpp"
|
#include "vocabs.hpp"
|
||||||
//#include "setFieldList.hpp"
|
#include "sphereParticlesKernels.hpp"
|
||||||
//#include "sphereParticlesKernels.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
|
//#include "setFieldList.hpp"
|
||||||
/*pFlow::uniquePtr<pFlow::List<pFlow::eventObserver*>>
|
/*pFlow::uniquePtr<pFlow::List<pFlow::eventObserver*>>
|
||||||
pFlow::sphereParticles::getFieldObjectList()const
|
pFlow::sphereParticles::getFieldObjectList()const
|
||||||
{
|
{
|
||||||
|
@ -205,15 +206,35 @@ bool pFlow::sphereParticles::initInertia()
|
||||||
exeSpace,
|
exeSpace,
|
||||||
Kokkos::IndexType<uint32>>;
|
Kokkos::IndexType<uint32>>;
|
||||||
|
|
||||||
auto aPointsMask = dynPointStruct().activePointsMaskDevice();
|
auto [minIndex, maxIndex] = minMax(shapeIndex().internal());
|
||||||
auto aRange = aPointsMask.activeRange();
|
|
||||||
|
|
||||||
auto field_I = I_.fieldDevice();
|
if( !spheres_.indexValid(maxIndex) )
|
||||||
auto field_shapeIndex = shapeIndex().fieldDevice();
|
{
|
||||||
|
fatalErrorInFunction<<
|
||||||
|
"the maximum value of shapeIndex is "<< maxIndex <<
|
||||||
|
" which is not valid."<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const auto& shp = getShapes();
|
auto aPointsMask = dynPointStruct().activePointsMaskDevice();
|
||||||
realVector_D I ("I", shp.Inertia());
|
auto aRange = aPointsMask.activeRange();
|
||||||
auto d_I = I.deviceVector();
|
|
||||||
|
auto field_shapeIndex = shapeIndex().fieldDevice();
|
||||||
|
auto field_diameter = diameter_.fieldDevice();
|
||||||
|
auto field_mass = mass_.fieldDevice();
|
||||||
|
auto field_propId = propertyId_.fieldDevice();
|
||||||
|
auto field_I = I_.fieldDevice();
|
||||||
|
|
||||||
|
// get info from spheres shape
|
||||||
|
realVector_D d("diameter", spheres_.boundingDiameter());
|
||||||
|
realVector_D mass("mass",spheres_.mass());
|
||||||
|
uint32Vector_D propId("propId", spheres_.shapePropertyIds());
|
||||||
|
realVector_D I("I", spheres_.Inertia());
|
||||||
|
|
||||||
|
auto d_d = d.deviceVector();
|
||||||
|
auto d_mass = mass.deviceVector();
|
||||||
|
auto d_propId = propId.deviceVector();
|
||||||
|
auto d_I = I.deviceVector();
|
||||||
|
|
||||||
Kokkos::parallel_for(
|
Kokkos::parallel_for(
|
||||||
"particles::initInertia",
|
"particles::initInertia",
|
||||||
|
@ -224,9 +245,13 @@ bool pFlow::sphereParticles::initInertia()
|
||||||
{
|
{
|
||||||
uint32 index = field_shapeIndex[i];
|
uint32 index = field_shapeIndex[i];
|
||||||
field_I[i] = d_I[index];
|
field_I[i] = d_I[index];
|
||||||
|
field_diameter[i] = d_d[index];
|
||||||
|
field_mass[i] = d_mass[index];
|
||||||
|
field_propId[i] = d_propId[index];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Kokkos::fence();
|
Kokkos::fence();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,6 +268,38 @@ pFlow::sphereParticles::sphereParticles(
|
||||||
&control.caseSetup(),
|
&control.caseSetup(),
|
||||||
prop
|
prop
|
||||||
),
|
),
|
||||||
|
propertyId_
|
||||||
|
(
|
||||||
|
objectFile
|
||||||
|
(
|
||||||
|
"propertyId",
|
||||||
|
"",
|
||||||
|
objectFile::READ_ALWAYS,
|
||||||
|
objectFile::WRITE_NEVER
|
||||||
|
),
|
||||||
|
dynPointStruct(),
|
||||||
|
0u
|
||||||
|
),
|
||||||
|
diameter_
|
||||||
|
(
|
||||||
|
objectFile(
|
||||||
|
"diameter",
|
||||||
|
"",
|
||||||
|
objectFile::READ_NEVER,
|
||||||
|
objectFile::WRITE_NEVER),
|
||||||
|
dynPointStruct(),
|
||||||
|
0.00000000001
|
||||||
|
),
|
||||||
|
mass_
|
||||||
|
(
|
||||||
|
objectFile(
|
||||||
|
"mass",
|
||||||
|
"",
|
||||||
|
objectFile::READ_NEVER,
|
||||||
|
objectFile::WRITE_NEVER),
|
||||||
|
dynPointStruct(),
|
||||||
|
0.0000000001
|
||||||
|
),
|
||||||
I_
|
I_
|
||||||
(
|
(
|
||||||
objectFile
|
objectFile
|
||||||
|
@ -306,31 +363,10 @@ pFlow::sphereParticles::sphereParticles(
|
||||||
}
|
}
|
||||||
|
|
||||||
WARNING<<"setFields for rVelIntegration_"<<END_WARNING;
|
WARNING<<"setFields for rVelIntegration_"<<END_WARNING;
|
||||||
/*if(rVelIntegration_->needSetInitialVals())
|
|
||||||
{
|
|
||||||
|
|
||||||
auto [minInd, maxInd] = pStruct().activeRange();
|
|
||||||
int32IndexContainer indexHD(minInd, maxInd);
|
|
||||||
|
|
||||||
auto n = indexHD.size();
|
|
||||||
auto index = indexHD.indicesHost();
|
|
||||||
|
|
||||||
realx3Vector rvel(n,RESERVE());
|
|
||||||
const auto hrVel = rVelocity_.hostVector();
|
|
||||||
|
|
||||||
for(auto i=0; i<n; i++)
|
|
||||||
{
|
|
||||||
rvel.push_back( hrVel[index(i)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
REPORT(2)<< "Initializing the required vectors for rotational velocity integratoin\n "<<endREPORT;
|
|
||||||
rVelIntegration_->setInitialVals(indexHD, rvel);
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
if(!initInertia())
|
if(!initInertia())
|
||||||
{
|
{
|
||||||
|
fatalErrorInFunction;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,18 +473,16 @@ bool pFlow::sphereParticles::iterate()
|
||||||
|
|
||||||
particles::iterate();
|
particles::iterate();
|
||||||
accelerationTimer_.start();
|
accelerationTimer_.start();
|
||||||
WARNING<<"pFlow::sphereParticlesKernels::acceleration"<<END_WARNING;
|
pFlow::sphereParticlesKernels::acceleration(
|
||||||
//INFO<<"before accelerationTimer_ "<<endINFO;
|
|
||||||
/*pFlow::sphereParticlesKernels::acceleration(
|
|
||||||
control().g(),
|
control().g(),
|
||||||
mass().deviceVectorAll(),
|
mass().fieldDevice(),
|
||||||
contactForce().deviceVectorAll(),
|
contactForce().fieldDevice(),
|
||||||
I().deviceVectorAll(),
|
I().fieldDevice(),
|
||||||
contactTorque().deviceVectorAll(),
|
contactTorque().fieldDevice(),
|
||||||
pStruct().activePointsMaskD(),
|
dynPointStruct().activePointsMaskDevice(),
|
||||||
accelertion().deviceVectorAll(),
|
accelertion().fieldDevice(),
|
||||||
rAcceleration().deviceVectorAll()
|
rAcceleration().fieldDevice()
|
||||||
);*/
|
);
|
||||||
accelerationTimer_.end();
|
accelerationTimer_.end();
|
||||||
|
|
||||||
intCorrectTimer_.start();
|
intCorrectTimer_.start();
|
||||||
|
@ -485,3 +519,13 @@ const pFlow::shape &pFlow::sphereParticles::getShapes() const
|
||||||
{
|
{
|
||||||
return spheres_;
|
return spheres_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pFlow::sphereParticles::boundingSphereMinMax
|
||||||
|
(
|
||||||
|
real & minDiam,
|
||||||
|
real& maxDiam
|
||||||
|
)const
|
||||||
|
{
|
||||||
|
minDiam = spheres_.minBoundingSphere();
|
||||||
|
maxDiam = spheres_.maxBoundingSphere();
|
||||||
|
}
|
||||||
|
|
|
@ -51,6 +51,15 @@ private:
|
||||||
/// reference to shapes
|
/// reference to shapes
|
||||||
ShapeType spheres_;
|
ShapeType spheres_;
|
||||||
|
|
||||||
|
/// property id on device
|
||||||
|
uint32PointField_D propertyId_;
|
||||||
|
|
||||||
|
/// diameter / boundig sphere size of particles on device
|
||||||
|
realPointField_D diameter_;
|
||||||
|
|
||||||
|
/// mass of particles field
|
||||||
|
realPointField_D mass_;
|
||||||
|
|
||||||
/// pointField of inertial of particles
|
/// pointField of inertial of particles
|
||||||
realPointField_D I_;
|
realPointField_D I_;
|
||||||
|
|
||||||
|
@ -151,6 +160,24 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const uint32PointField_D& propertyId()const override
|
||||||
|
{
|
||||||
|
return propertyId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const realPointField_D& diameter()const override
|
||||||
|
{
|
||||||
|
return diameter_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const realPointField_D& mass()const override
|
||||||
|
{
|
||||||
|
return mass_;
|
||||||
|
}
|
||||||
|
|
||||||
/// before iteration step
|
/// before iteration step
|
||||||
bool beforeIteration() override;
|
bool beforeIteration() override;
|
||||||
|
|
||||||
|
@ -179,6 +206,9 @@ public:
|
||||||
|
|
||||||
const shape& getShapes()const override;
|
const shape& getShapes()const override;
|
||||||
|
|
||||||
|
|
||||||
|
void boundingSphereMinMax(real & minDiam, real& maxDiam)const override;
|
||||||
|
|
||||||
}; //sphereParticles
|
}; //sphereParticles
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*------------------------------- phasicFlow ---------------------------------
|
||||||
|
O C enter of
|
||||||
|
O O E ngineering and
|
||||||
|
O O M ultiscale modeling of
|
||||||
|
OOOOOOO F luid flow
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Copyright (C): www.cemf.ir
|
||||||
|
email: hamid.r.norouzi AT gmail.com
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Licence:
|
||||||
|
This file is part of phasicFlow code. It is a free software for simulating
|
||||||
|
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||||
|
the terms of GNU General Public License v3 or any other later versions.
|
||||||
|
|
||||||
|
phasicFlow is distributed to help others in their research in the field of
|
||||||
|
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "sphereParticlesKernels.hpp"
|
||||||
|
|
||||||
|
using policy = Kokkos::RangePolicy<
|
||||||
|
pFlow::DefaultExecutionSpace,
|
||||||
|
Kokkos::Schedule<Kokkos::Static>,
|
||||||
|
Kokkos::IndexType<pFlow::uint32>>;
|
||||||
|
|
||||||
|
void pFlow::sphereParticlesKernels::addMassDiamInertiaProp
|
||||||
|
(
|
||||||
|
deviceViewType1D<uint32> shapeIndex,
|
||||||
|
deviceViewType1D<real> mass,
|
||||||
|
deviceViewType1D<real> diameter,
|
||||||
|
deviceViewType1D<real> I,
|
||||||
|
deviceViewType1D<uint32> propertyId,
|
||||||
|
pFlagTypeDevice incld,
|
||||||
|
deviceViewType1D<real> src_mass,
|
||||||
|
deviceViewType1D<real> src_diameter,
|
||||||
|
deviceViewType1D<real> src_I,
|
||||||
|
deviceViewType1D<uint32> src_propertyId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto aRange = incld.activeRange();
|
||||||
|
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"particles::initInertia",
|
||||||
|
policy(aRange.start(), aRange.end()),
|
||||||
|
LAMBDA_HD(uint32 i)
|
||||||
|
{
|
||||||
|
if(incld(i))
|
||||||
|
{
|
||||||
|
uint32 index = shapeIndex[i];
|
||||||
|
I[i] = src_I[index];
|
||||||
|
diameter[i] = src_diameter[index];
|
||||||
|
mass[i] = src_mass[index];
|
||||||
|
propertyId[i] = src_propertyId[index];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void pFlow::sphereParticlesKernels::acceleration
|
||||||
|
(
|
||||||
|
realx3 g,
|
||||||
|
deviceViewType1D<real> mass,
|
||||||
|
deviceViewType1D<realx3> force,
|
||||||
|
deviceViewType1D<real> I,
|
||||||
|
deviceViewType1D<realx3> torque,
|
||||||
|
pFlagTypeDevice incld,
|
||||||
|
deviceViewType1D<realx3> lAcc,
|
||||||
|
deviceViewType1D<realx3> rAcc
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
auto activeRange = incld.activeRange();
|
||||||
|
if(incld.isAllActive())
|
||||||
|
{
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"pFlow::sphereParticlesKernels::acceleration",
|
||||||
|
policy(activeRange.start(), activeRange.end()),
|
||||||
|
LAMBDA_HD(uint32 i){
|
||||||
|
lAcc[i] = force[i]/mass[i] + g;
|
||||||
|
rAcc[i] = torque[i]/I[i];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Kokkos::parallel_for(
|
||||||
|
"pFlow::sphereParticlesKernels::acceleration",
|
||||||
|
policy(activeRange.start(), activeRange.end()),
|
||||||
|
LAMBDA_HD(uint32 i){
|
||||||
|
if(incld(i))
|
||||||
|
{
|
||||||
|
lAcc[i] = force[i]/mass[i] + g;
|
||||||
|
rAcc[i] = torque[i]/I[i];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Kokkos::fence();
|
||||||
|
}
|
|
@ -21,56 +21,36 @@ Licence:
|
||||||
#ifndef __sphereParticlesKernels_hpp__
|
#ifndef __sphereParticlesKernels_hpp__
|
||||||
#define __sphereParticlesKernels_hpp__
|
#define __sphereParticlesKernels_hpp__
|
||||||
|
|
||||||
|
#include "types.hpp"
|
||||||
|
#include "pointFlag.hpp"
|
||||||
|
|
||||||
namespace pFlow::sphereParticlesKernels
|
namespace pFlow::sphereParticlesKernels
|
||||||
{
|
{
|
||||||
|
|
||||||
using rpAcceleration = Kokkos::RangePolicy<
|
void addMassDiamInertiaProp(
|
||||||
DefaultExecutionSpace,
|
deviceViewType1D<uint32> shapeIndex,
|
||||||
Kokkos::Schedule<Kokkos::Static>,
|
deviceViewType1D<real> mass,
|
||||||
Kokkos::IndexType<int32>
|
deviceViewType1D<real> diameter,
|
||||||
>;
|
deviceViewType1D<real> I,
|
||||||
|
deviceViewType1D<uint32> propertyId,
|
||||||
|
pFlagTypeDevice incld,
|
||||||
|
deviceViewType1D<real> src_mass,
|
||||||
|
deviceViewType1D<real> src_diameter,
|
||||||
|
deviceViewType1D<real> src_I,
|
||||||
|
deviceViewType1D<uint32> src_propertyId
|
||||||
|
);
|
||||||
|
|
||||||
template<typename IncludeFunctionType>
|
|
||||||
void acceleration(
|
void acceleration(
|
||||||
realx3 g,
|
realx3 g,
|
||||||
deviceViewType1D<real> mass,
|
deviceViewType1D<real> mass,
|
||||||
deviceViewType1D<realx3> force,
|
deviceViewType1D<realx3> force,
|
||||||
deviceViewType1D<real> I,
|
deviceViewType1D<real> I,
|
||||||
deviceViewType1D<realx3> torque,
|
deviceViewType1D<realx3> torque,
|
||||||
IncludeFunctionType incld,
|
pFlagTypeDevice incld,
|
||||||
deviceViewType1D<realx3> lAcc,
|
deviceViewType1D<realx3> lAcc,
|
||||||
deviceViewType1D<realx3> rAcc
|
deviceViewType1D<realx3> rAcc
|
||||||
)
|
);
|
||||||
{
|
|
||||||
|
|
||||||
auto activeRange = incld.activeRange();
|
|
||||||
if(incld.allActive())
|
|
||||||
{
|
|
||||||
Kokkos::parallel_for(
|
|
||||||
"pFlow::sphereParticlesKernels::acceleration",
|
|
||||||
rpAcceleration(activeRange.first, activeRange.second),
|
|
||||||
LAMBDA_HD(int32 i){
|
|
||||||
lAcc[i] = force[i]/mass[i] + g;
|
|
||||||
rAcc[i] = torque[i]/I[i];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Kokkos::parallel_for(
|
|
||||||
"pFlow::sphereParticlesKernels::acceleration",
|
|
||||||
rpAcceleration(activeRange.first, activeRange.second),
|
|
||||||
LAMBDA_HD(int32 i){
|
|
||||||
if(incld(i))
|
|
||||||
{
|
|
||||||
lAcc[i] = force[i]/mass[i] + g;
|
|
||||||
rAcc[i] = torque[i]/I[i];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Kokkos::fence();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ Licence:
|
||||||
#include "sphereShape.hpp"
|
#include "sphereShape.hpp"
|
||||||
|
|
||||||
|
|
||||||
bool pFlow::sphereShape::readDictionary()
|
bool pFlow::sphereShape::readFromDictionary3()
|
||||||
{
|
{
|
||||||
|
|
||||||
diameters_ = getVal<realVector>("diameters");
|
diameters_ = getVal<realVector>("diameters");
|
||||||
|
@ -61,6 +61,11 @@ pFlow::sphereShape::sphereShape
|
||||||
shape(fileName, owner, prop)
|
shape(fileName, owner, prop)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(!readFromDictionary3())
|
||||||
|
{
|
||||||
|
fatalExit;
|
||||||
|
fatalErrorInFunction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::real pFlow::sphereShape::maxBoundingSphere() const
|
pFlow::real pFlow::sphereShape::maxBoundingSphere() const
|
||||||
|
|
|
@ -26,8 +26,6 @@ Licence:
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class sphereShape
|
class sphereShape
|
||||||
:
|
:
|
||||||
public shape
|
public shape
|
||||||
|
@ -37,7 +35,7 @@ private:
|
||||||
// - diameter of spheres
|
// - diameter of spheres
|
||||||
realVector diameters_;
|
realVector diameters_;
|
||||||
|
|
||||||
bool readDictionary();
|
bool readFromDictionary3();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -76,37 +76,6 @@ pFlow::dynamicPointStructure::dynamicPointStructure
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WARNING << "Initialization of integrationPos_ and integrationVel_ should be doen!"<<END_WARNING;
|
|
||||||
|
|
||||||
/*if(!integrationPos_->needSetInitialVals()) return;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
auto [minInd, maxInd] = pStruct().activeRange();
|
|
||||||
int32IndexContainer indexHD(minInd, maxInd);
|
|
||||||
|
|
||||||
auto n = indexHD.size();
|
|
||||||
auto index = indexHD.indicesHost();
|
|
||||||
|
|
||||||
realx3Vector pos(n,RESERVE());
|
|
||||||
realx3Vector vel(n,RESERVE());
|
|
||||||
const auto hVel = velocity().hostVector();
|
|
||||||
const auto hPos = pStruct().pointPosition().hostVector();
|
|
||||||
|
|
||||||
for(auto i=0; i<n; i++)
|
|
||||||
{
|
|
||||||
pos.push_back( hPos[index(i)]);
|
|
||||||
vel.push_back( hVel[index(i)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
REPORT(2)<< "Initializing the required vectors for position integratoin "<<endREPORT;
|
|
||||||
integrationPos_->setInitialVals(indexHD, pos);
|
|
||||||
|
|
||||||
REPORT(2)<< "Initializing the required vectors for velocity integratoin\n "<<endREPORT;
|
|
||||||
integrationVel_->setInitialVals(indexHD, vel);*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::dynamicPointStructure::predict
|
bool pFlow::dynamicPointStructure::predict
|
||||||
|
|
|
@ -40,7 +40,7 @@ bool pFlow::baseShapeNames::createHashNames()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool pFlow::baseShapeNames::readFromDictionary()
|
bool pFlow::baseShapeNames::readFromDictionary1()
|
||||||
{
|
{
|
||||||
|
|
||||||
shapeNames_ = getVal<wordVector>("names");
|
shapeNames_ = getVal<wordVector>("names");
|
||||||
|
@ -69,18 +69,21 @@ pFlow::baseShapeNames::baseShapeNames
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !readFromDictionary() )
|
if( !readFromDictionary1() )
|
||||||
{
|
{
|
||||||
|
fatalErrorInFunction;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !createHashNames())
|
if( !createHashNames())
|
||||||
{
|
{
|
||||||
|
fatalErrorInFunction;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool pFlow::baseShapeNames::writeToDict(dictionary &dict)const
|
bool pFlow::baseShapeNames::writeToDict(dictionary &dict)const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ private:
|
||||||
|
|
||||||
bool createHashNames();
|
bool createHashNames();
|
||||||
|
|
||||||
bool readFromDictionary();
|
bool readFromDictionary1();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -21,60 +21,6 @@ Licence:
|
||||||
|
|
||||||
#include "particles.hpp"
|
#include "particles.hpp"
|
||||||
|
|
||||||
bool pFlow::particles::initMassDiameter()const
|
|
||||||
{
|
|
||||||
|
|
||||||
auto [minIndex, maxIndex] = minMax(shapeIndex_.internal());
|
|
||||||
|
|
||||||
const auto& shp = getShapes();
|
|
||||||
|
|
||||||
if( !shp.indexValid(maxIndex) )
|
|
||||||
{
|
|
||||||
fatalErrorInFunction<<
|
|
||||||
"the maximum value of shape index is "<< maxIndex <<
|
|
||||||
" which is not valid."<<endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
realVector_D d("diameter", shp.boundingDiameter());
|
|
||||||
realVector_D mass("mass",shp.mass());
|
|
||||||
uint8Vector_D propId("propId", shp.shapePropertyIds());
|
|
||||||
|
|
||||||
|
|
||||||
auto aPointsMask = dynPointStruct_.activePointsMaskDevice();
|
|
||||||
auto aRange = aPointsMask.activeRange();
|
|
||||||
|
|
||||||
using exeSpace = typename realPointField_D::execution_space;
|
|
||||||
using policy = Kokkos::RangePolicy<
|
|
||||||
exeSpace,
|
|
||||||
Kokkos::IndexType<uint32>>;
|
|
||||||
|
|
||||||
auto field_diameter = diameter_.fieldDevice();
|
|
||||||
auto field_mass = mass_.fieldDevice();
|
|
||||||
auto field_propId = propertyId_.fieldDevice();
|
|
||||||
auto field_shapeIndex = shapeIndex_.fieldDevice();
|
|
||||||
|
|
||||||
auto d_d = d.deviceVector();
|
|
||||||
auto d_mass = mass.deviceVector();
|
|
||||||
auto d_propId = propId.deviceVector();
|
|
||||||
|
|
||||||
Kokkos::parallel_for(
|
|
||||||
"particles::initMassDiameter",
|
|
||||||
policy(aRange.start(), aRange.end()),
|
|
||||||
LAMBDA_HD(uint32 i)
|
|
||||||
{
|
|
||||||
if(aPointsMask(i))
|
|
||||||
{
|
|
||||||
uint32 index = field_shapeIndex[i];
|
|
||||||
field_diameter[i] = d_d[index];
|
|
||||||
field_mass[i] = d_mass[index];
|
|
||||||
field_propId[i] = d_propId[index];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Kokkos::fence();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pFlow::particles::particles
|
pFlow::particles::particles
|
||||||
(
|
(
|
||||||
|
@ -96,18 +42,6 @@ pFlow::particles::particles
|
||||||
dynPointStruct_,
|
dynPointStruct_,
|
||||||
static_cast<uint32>(-1)
|
static_cast<uint32>(-1)
|
||||||
),
|
),
|
||||||
propertyId_
|
|
||||||
(
|
|
||||||
objectFile
|
|
||||||
(
|
|
||||||
"propertyId",
|
|
||||||
"",
|
|
||||||
objectFile::READ_ALWAYS,
|
|
||||||
objectFile::WRITE_NEVER
|
|
||||||
),
|
|
||||||
dynPointStruct_,
|
|
||||||
static_cast<int8>(0)
|
|
||||||
),
|
|
||||||
shapeIndex_
|
shapeIndex_
|
||||||
(
|
(
|
||||||
objectFile
|
objectFile
|
||||||
|
@ -120,26 +54,6 @@ pFlow::particles::particles
|
||||||
dynPointStruct_,
|
dynPointStruct_,
|
||||||
0
|
0
|
||||||
),
|
),
|
||||||
diameter_
|
|
||||||
(
|
|
||||||
objectFile(
|
|
||||||
"diameter",
|
|
||||||
"",
|
|
||||||
objectFile::READ_NEVER,
|
|
||||||
objectFile::WRITE_NEVER),
|
|
||||||
dynPointStruct_,
|
|
||||||
0.00000000001
|
|
||||||
),
|
|
||||||
mass_
|
|
||||||
(
|
|
||||||
objectFile(
|
|
||||||
"mass",
|
|
||||||
"",
|
|
||||||
objectFile::READ_NEVER,
|
|
||||||
objectFile::WRITE_NEVER),
|
|
||||||
dynPointStruct_,
|
|
||||||
0.0000000001
|
|
||||||
),
|
|
||||||
accelertion_
|
accelertion_
|
||||||
(
|
(
|
||||||
objectFile(
|
objectFile(
|
||||||
|
@ -167,14 +81,7 @@ pFlow::particles::particles
|
||||||
dynPointStruct_,
|
dynPointStruct_,
|
||||||
zero3)
|
zero3)
|
||||||
{
|
{
|
||||||
|
|
||||||
this->addToSubscriber(dynPointStruct_);
|
this->addToSubscriber(dynPointStruct_);
|
||||||
|
|
||||||
if(!initMassDiameter())
|
|
||||||
{
|
|
||||||
fatalExit;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::particles::beforeIteration()
|
bool pFlow::particles::beforeIteration()
|
||||||
|
|
|
@ -43,18 +43,9 @@ private:
|
||||||
/// id of particles on host
|
/// id of particles on host
|
||||||
uint32PointField_D id_;
|
uint32PointField_D id_;
|
||||||
|
|
||||||
/// property id on device
|
|
||||||
uint8PointField_D propertyId_;
|
|
||||||
|
|
||||||
/// property id on device
|
|
||||||
uint32PointField_D shapeIndex_;
|
uint32PointField_D shapeIndex_;
|
||||||
|
|
||||||
/// diameter / boundig sphere size of particles on device
|
|
||||||
realPointField_D diameter_;
|
|
||||||
|
|
||||||
/// mass of particles field
|
|
||||||
realPointField_D mass_;
|
|
||||||
|
|
||||||
/// acceleration on device
|
/// acceleration on device
|
||||||
realx3PointField_D accelertion_;
|
realx3PointField_D accelertion_;
|
||||||
|
|
||||||
|
@ -73,7 +64,6 @@ private:
|
||||||
message::ITEM_DELETE
|
message::ITEM_DELETE
|
||||||
);
|
);
|
||||||
|
|
||||||
bool initMassDiameter()const;
|
|
||||||
|
|
||||||
void zeroForce()
|
void zeroForce()
|
||||||
{
|
{
|
||||||
|
@ -152,29 +142,6 @@ public:
|
||||||
return dynPointStruct_.velocity();
|
return dynPointStruct_.velocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
const auto& diameter()const
|
|
||||||
{
|
|
||||||
return diameter_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
auto& diameter()
|
|
||||||
{
|
|
||||||
return diameter_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
const auto& mass()const
|
|
||||||
{
|
|
||||||
return mass_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline auto& mass()
|
|
||||||
{
|
|
||||||
return mass_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
const auto& accelertion()const
|
const auto& accelertion()const
|
||||||
{
|
{
|
||||||
|
@ -211,18 +178,6 @@ public:
|
||||||
return contactTorque_;
|
return contactTorque_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
const auto& propertyId()const
|
|
||||||
{
|
|
||||||
return propertyId_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
auto& propertyId()
|
|
||||||
{
|
|
||||||
return propertyId_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool beforeIteration() override;
|
bool beforeIteration() override;
|
||||||
|
|
||||||
bool iterate()override;
|
bool iterate()override;
|
||||||
|
@ -237,7 +192,14 @@ public:
|
||||||
const setFieldList& setField
|
const setFieldList& setField
|
||||||
) = 0;*/
|
) = 0;*/
|
||||||
|
|
||||||
|
virtual
|
||||||
|
const uint32PointField_D& propertyId()const = 0;
|
||||||
|
|
||||||
|
virtual
|
||||||
|
const realPointField_D& diameter()const = 0;
|
||||||
|
|
||||||
|
virtual
|
||||||
|
const realPointField_D& mass()const = 0;
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
realx3PointField_D& rAcceleration() = 0;
|
realx3PointField_D& rAcceleration() = 0;
|
||||||
|
@ -255,7 +217,7 @@ public:
|
||||||
const shape& getShapes()const = 0;
|
const shape& getShapes()const = 0;
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
void boundingSphereMinMax(real & minDiam, real& maxDiam)const;
|
void boundingSphereMinMax(real & minDiam, real& maxDiam)const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,22 +7,21 @@ bool pFlow::shape::findPropertyIds()
|
||||||
|
|
||||||
ForAll( i, materialNames_)
|
ForAll( i, materialNames_)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(uint32 propId; property_.nameToIndex(materialNames_[i], propId) )
|
if(uint32 propId; property_.nameToIndex(materialNames_[i], propId) )
|
||||||
{
|
{
|
||||||
shapePropertyIds_[i] = static_cast<uint8>(propId);
|
shapePropertyIds_[i] = propId;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<"Material name "<< materialNames_[i]<<
|
fatalErrorInFunction<<"Material name "<< materialNames_[i]<<
|
||||||
"is not valid in dictionary "<<globalName()<<endl;
|
" is not valid in dictionary "<<globalName()<<endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::shape::readFromDictionary()
|
bool pFlow::shape::readFromDictionary2()
|
||||||
{
|
{
|
||||||
|
|
||||||
materialNames_ = getVal<wordVector>("materials");
|
materialNames_ = getVal<wordVector>("materials");
|
||||||
|
@ -49,13 +48,15 @@ pFlow::shape::shape
|
||||||
property_(prop)
|
property_(prop)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !readFromDictionary() )
|
if( !readFromDictionary2() )
|
||||||
{
|
{
|
||||||
|
fatalErrorInFunction;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!findPropertyIds())
|
if(!findPropertyIds())
|
||||||
{
|
{
|
||||||
|
fatalErrorInFunction;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
const property& property_;
|
const property& property_;
|
||||||
|
|
||||||
/// list of property ids of shapes (index)
|
/// list of property ids of shapes (index)
|
||||||
uint8Vector shapePropertyIds_;
|
uint32Vector shapePropertyIds_;
|
||||||
|
|
||||||
/// list of material names
|
/// list of material names
|
||||||
wordVector materialNames_;
|
wordVector materialNames_;
|
||||||
|
@ -45,7 +45,7 @@ private:
|
||||||
|
|
||||||
bool findPropertyIds();
|
bool findPropertyIds();
|
||||||
|
|
||||||
bool readFromDictionary();
|
bool readFromDictionary2();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool propIdValid(int8 propId)const
|
bool propIdValid(uint32 propId)const
|
||||||
{
|
{
|
||||||
return static_cast<uint32>(propId) < property_.numMaterials();
|
return static_cast<uint32>(propId) < property_.numMaterials();
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,13 +130,16 @@ bool pFlow::readDataAscii
|
||||||
token firstToken(is);
|
token firstToken(is);
|
||||||
|
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
bool lenFound = false;
|
||||||
if( firstToken.isInt64())
|
if( firstToken.isInt64())
|
||||||
{
|
{
|
||||||
len = firstToken.int64Token();
|
len = firstToken.int64Token();
|
||||||
|
lenFound = true;
|
||||||
vec.reserve(len);
|
vec.reserve(len);
|
||||||
firstToken = token(is);
|
firstToken = token(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
T val{};
|
T val{};
|
||||||
if( firstToken.isPunctuation() ) // start of vector
|
if( firstToken.isPunctuation() ) // start of vector
|
||||||
{
|
{
|
||||||
|
@ -164,6 +167,7 @@ bool pFlow::readDataAscii
|
||||||
|
|
||||||
is >> lastToken;
|
is >> lastToken;
|
||||||
is.fatalCheck(FUNCTION_NAME);
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
@ -174,7 +178,7 @@ bool pFlow::readDataAscii
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(len>0&& len != vec.size())
|
if(lenFound && len>0 && len != vec.size())
|
||||||
{
|
{
|
||||||
warningInFunction<<"vector length specified "<< len <<
|
warningInFunction<<"vector length specified "<< len <<
|
||||||
" is different from number of elements "<< vec.size()<<endl;
|
" is different from number of elements "<< vec.size()<<endl;
|
||||||
|
|
Loading…
Reference in New Issue