mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +00:00
sphereParticles tested
This commit is contained in:
@ -40,7 +40,7 @@ bool pFlow::baseShapeNames::createHashNames()
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::baseShapeNames::readFromDictionary()
|
||||
bool pFlow::baseShapeNames::readFromDictionary1()
|
||||
{
|
||||
|
||||
shapeNames_ = getVal<wordVector>("names");
|
||||
@ -69,18 +69,21 @@ pFlow::baseShapeNames::baseShapeNames
|
||||
)
|
||||
{
|
||||
|
||||
if( !readFromDictionary() )
|
||||
if( !readFromDictionary1() )
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
if( !createHashNames())
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::baseShapeNames::writeToDict(dictionary &dict)const
|
||||
{
|
||||
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
|
||||
bool createHashNames();
|
||||
|
||||
bool readFromDictionary();
|
||||
bool readFromDictionary1();
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -21,60 +21,6 @@ Licence:
|
||||
|
||||
#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
|
||||
(
|
||||
@ -96,18 +42,6 @@ pFlow::particles::particles
|
||||
dynPointStruct_,
|
||||
static_cast<uint32>(-1)
|
||||
),
|
||||
propertyId_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"propertyId",
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
dynPointStruct_,
|
||||
static_cast<int8>(0)
|
||||
),
|
||||
shapeIndex_
|
||||
(
|
||||
objectFile
|
||||
@ -120,26 +54,6 @@ pFlow::particles::particles
|
||||
dynPointStruct_,
|
||||
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_
|
||||
(
|
||||
objectFile(
|
||||
@ -167,14 +81,7 @@ pFlow::particles::particles
|
||||
dynPointStruct_,
|
||||
zero3)
|
||||
{
|
||||
|
||||
this->addToSubscriber(dynPointStruct_);
|
||||
|
||||
if(!initMassDiameter())
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::particles::beforeIteration()
|
||||
|
@ -43,18 +43,9 @@ private:
|
||||
/// id of particles on host
|
||||
uint32PointField_D id_;
|
||||
|
||||
/// property id on device
|
||||
uint8PointField_D propertyId_;
|
||||
|
||||
/// property id on device
|
||||
|
||||
uint32PointField_D shapeIndex_;
|
||||
|
||||
/// diameter / boundig sphere size of particles on device
|
||||
realPointField_D diameter_;
|
||||
|
||||
/// mass of particles field
|
||||
realPointField_D mass_;
|
||||
|
||||
/// acceleration on device
|
||||
realx3PointField_D accelertion_;
|
||||
|
||||
@ -73,8 +64,7 @@ private:
|
||||
message::ITEM_DELETE
|
||||
);
|
||||
|
||||
bool initMassDiameter()const;
|
||||
|
||||
|
||||
void zeroForce()
|
||||
{
|
||||
contactForce_.fill(zero3);
|
||||
@ -152,29 +142,6 @@ public:
|
||||
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
|
||||
const auto& accelertion()const
|
||||
{
|
||||
@ -211,18 +178,6 @@ public:
|
||||
return contactTorque_;
|
||||
}
|
||||
|
||||
inline
|
||||
const auto& propertyId()const
|
||||
{
|
||||
return propertyId_;
|
||||
}
|
||||
|
||||
inline
|
||||
auto& propertyId()
|
||||
{
|
||||
return propertyId_;
|
||||
}
|
||||
|
||||
bool beforeIteration() override;
|
||||
|
||||
bool iterate()override;
|
||||
@ -237,7 +192,14 @@ public:
|
||||
const setFieldList& setField
|
||||
) = 0;*/
|
||||
|
||||
virtual
|
||||
const uint32PointField_D& propertyId()const = 0;
|
||||
|
||||
virtual
|
||||
const realPointField_D& diameter()const = 0;
|
||||
|
||||
virtual
|
||||
const realPointField_D& mass()const = 0;
|
||||
|
||||
virtual
|
||||
realx3PointField_D& rAcceleration() = 0;
|
||||
@ -255,7 +217,7 @@ public:
|
||||
const shape& getShapes()const = 0;
|
||||
|
||||
virtual
|
||||
void boundingSphereMinMax(real & minDiam, real& maxDiam)const;
|
||||
void boundingSphereMinMax(real & minDiam, real& maxDiam)const = 0;
|
||||
|
||||
|
||||
|
||||
|
@ -7,24 +7,23 @@ bool pFlow::shape::findPropertyIds()
|
||||
|
||||
ForAll( i, materialNames_)
|
||||
{
|
||||
|
||||
if(uint32 propId; property_.nameToIndex(materialNames_[i], propId) )
|
||||
{
|
||||
shapePropertyIds_[i] = static_cast<uint8>(propId);
|
||||
shapePropertyIds_[i] = propId;
|
||||
}
|
||||
else
|
||||
{
|
||||
fatalErrorInFunction<<"Material name "<< materialNames_[i]<<
|
||||
"is not valid in dictionary "<<globalName()<<endl;
|
||||
" is not valid in dictionary "<<globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::shape::readFromDictionary()
|
||||
bool pFlow::shape::readFromDictionary2()
|
||||
{
|
||||
|
||||
|
||||
materialNames_ = getVal<wordVector>("materials");
|
||||
|
||||
if(materialNames_.size() != numShapes() )
|
||||
@ -49,13 +48,15 @@ pFlow::shape::shape
|
||||
property_(prop)
|
||||
{
|
||||
|
||||
if( !readFromDictionary() )
|
||||
if( !readFromDictionary2() )
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
if(!findPropertyIds())
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ private:
|
||||
const property& property_;
|
||||
|
||||
/// list of property ids of shapes (index)
|
||||
uint8Vector shapePropertyIds_;
|
||||
uint32Vector shapePropertyIds_;
|
||||
|
||||
/// list of material names
|
||||
wordVector materialNames_;
|
||||
@ -45,7 +45,7 @@ private:
|
||||
|
||||
bool findPropertyIds();
|
||||
|
||||
bool readFromDictionary();
|
||||
bool readFromDictionary2();
|
||||
|
||||
protected:
|
||||
|
||||
@ -96,7 +96,7 @@ public:
|
||||
}
|
||||
|
||||
inline
|
||||
bool propIdValid(int8 propId)const
|
||||
bool propIdValid(uint32 propId)const
|
||||
{
|
||||
return static_cast<uint32>(propId) < property_.numMaterials();
|
||||
}
|
||||
|
Reference in New Issue
Block a user