mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-08-07 03:37:02 +00:00
This is the first merge from main into MPI branch
Merge branch 'main' into local-MPI
This commit is contained in:
@ -50,9 +50,7 @@ public:
|
||||
const sphereParticles& Particles()const;
|
||||
|
||||
bool hearChanges(
|
||||
real t,
|
||||
real dt,
|
||||
uint32 iter,
|
||||
const timeInfo& ti,
|
||||
const message &msg,
|
||||
const anyList &varList) override
|
||||
{
|
||||
@ -65,6 +63,11 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isActive()const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
uniquePtr<boundarySphereParticles> create(
|
||||
const boundaryBase &boundary,
|
||||
|
@ -5,10 +5,10 @@ pFlow::boundarySphereParticlesList::boundarySphereParticlesList(
|
||||
sphereParticles &prtcls
|
||||
)
|
||||
:
|
||||
ListPtr(bndrs.size()),
|
||||
boundaryListPtr(),
|
||||
boundaries_(bndrs)
|
||||
{
|
||||
for(auto i=0; i<boundaries_.size(); i++)
|
||||
ForAllBoundariesPtr(i, this)
|
||||
{
|
||||
this->set
|
||||
(
|
||||
|
@ -3,7 +3,7 @@
|
||||
#ifndef __boundarySphereParticlesList_hpp__
|
||||
#define __boundarySphereParticlesList_hpp__
|
||||
|
||||
#include "ListPtr.hpp"
|
||||
#include "boundaryListPtr.hpp"
|
||||
#include "boundaryList.hpp"
|
||||
#include "boundarySphereParticles.hpp"
|
||||
|
||||
@ -12,7 +12,7 @@ namespace pFlow
|
||||
|
||||
class boundarySphereParticlesList
|
||||
:
|
||||
public ListPtr<boundarySphereParticles>
|
||||
public boundaryListPtr<boundarySphereParticles>
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -24,180 +24,6 @@ Licence:
|
||||
#include "sphereParticlesKernels.hpp"
|
||||
|
||||
|
||||
//#include "setFieldList.hpp"
|
||||
/*pFlow::uniquePtr<pFlow::List<pFlow::eventObserver*>>
|
||||
pFlow::sphereParticles::getFieldObjectList()const
|
||||
{
|
||||
auto objListPtr = particles::getFieldObjectList();
|
||||
|
||||
objListPtr().push_back(
|
||||
static_cast<eventObserver*>(&I_) );
|
||||
|
||||
return objListPtr;
|
||||
}
|
||||
|
||||
bool pFlow::sphereParticles::diameterMassInertiaPropId
|
||||
(
|
||||
const word& shName,
|
||||
real& diam,
|
||||
real& mass,
|
||||
real& I,
|
||||
int8& propIdx
|
||||
)
|
||||
{
|
||||
uint32 idx;
|
||||
if( !shapes_.nameToIndex(shName, idx) )
|
||||
{
|
||||
printKeys(fatalErrorInFunction<<
|
||||
" wrong shape name in the input: "<< shName<<endl<<
|
||||
" available shape names are: ", shapes_.names())<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
diam = shapes_.diameter(idx);
|
||||
word materialName = shapes_.material(idx);
|
||||
uint32 pIdx;
|
||||
if( !property_.nameToIndex(materialName, pIdx) )
|
||||
{
|
||||
fatalErrorInFunction <<
|
||||
" wrong material name "<< materialName <<" specified for shape "<< shName<<
|
||||
" in the sphereShape dictionary.\n"<<
|
||||
" available materials are "<< property_.materials()<<endl;
|
||||
return false;
|
||||
}
|
||||
real rho = property_.density(pIdx);
|
||||
|
||||
mass = Pi/6.0*pow(diam,3.0)*rho;
|
||||
I = 0.4 * mass * pow(diam/2.0,2.0);
|
||||
propIdx= static_cast<int8>(pIdx);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::sphereParticles::initializeParticles()
|
||||
{
|
||||
|
||||
int32IndexContainer indices(
|
||||
0,
|
||||
static_cast<int32>(shapeName_.size()));
|
||||
|
||||
return insertSphereParticles(shapeName_, indices, false);
|
||||
}*/
|
||||
|
||||
|
||||
/*bool pFlow::sphereParticles::beforeIteration()
|
||||
{
|
||||
particles::beforeIteration();
|
||||
|
||||
intPredictTimer_.start();
|
||||
|
||||
//INFO<<"before dyn predict"<<endINFO;
|
||||
dynPointStruct_.predict(this->dt(), accelertion_);
|
||||
//INFO<<"after dyn predict"<<endINFO;
|
||||
|
||||
//INFO<<"before revel predict"<<endINFO;
|
||||
rVelIntegration_().predict(this->dt(),rVelocity_, rAcceleration_);
|
||||
//INFO<<"after rvel predict"<<endINFO;
|
||||
|
||||
intPredictTimer_.end();
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*bool pFlow::sphereParticles::afterIteration()
|
||||
{
|
||||
return true;
|
||||
}*/
|
||||
|
||||
|
||||
/*bool pFlow::sphereParticles::insertSphereParticles(
|
||||
const wordVector& names,
|
||||
const int32IndexContainer& indices,
|
||||
bool setId
|
||||
)
|
||||
{
|
||||
|
||||
if(names.size()!= indices.size())
|
||||
{
|
||||
fatalErrorInFunction <<
|
||||
"sizes of names ("<<names.size()<<") and indices ("
|
||||
<< indices.size()<<") do not match \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto len = names.size();
|
||||
|
||||
realVector diamVec(len, RESERVE());
|
||||
realVector massVec(len, RESERVE());
|
||||
realVector IVec(len, RESERVE());
|
||||
int8Vector pIdVec(len, RESERVE());
|
||||
int32Vector IdVec(len, RESERVE());
|
||||
|
||||
real d, m, I;
|
||||
int8 pId;
|
||||
|
||||
ForAll(i, names )
|
||||
{
|
||||
|
||||
if (diameterMassInertiaPropId(names[i], d, m, I, pId))
|
||||
{
|
||||
diamVec.push_back(d);
|
||||
massVec.push_back(m);
|
||||
IVec.push_back(I);
|
||||
pIdVec.push_back(pId);
|
||||
if(setId) IdVec.push_back(idHandler_.getNextId());
|
||||
//output<<" we are in sphereParticles nextId "<< idHandler_.nextId()<<endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
fatalErrorInFunction<< "failed to calculate properties of shape " <<
|
||||
names[i]<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!diameter_.insertSetElement(indices, diamVec))
|
||||
{
|
||||
fatalErrorInFunction<< " failed to insert diameters to the diameter field. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!mass_.insertSetElement(indices, massVec))
|
||||
{
|
||||
fatalErrorInFunction<< " failed to insert mass to the mass field. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!I_.insertSetElement(indices, IVec))
|
||||
{
|
||||
fatalErrorInFunction<< " failed to insert I to the I field. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!propertyId_.insertSetElement(indices, pIdVec))
|
||||
{
|
||||
fatalErrorInFunction<< " failed to insert propertyId to the propertyId field. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(setId)
|
||||
{
|
||||
if( !id_.insertSetElement(indices, IdVec))
|
||||
{
|
||||
fatalErrorInFunction<< " failed to insert id to the id field. \n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}*/
|
||||
|
||||
bool pFlow::sphereParticles::initializeParticles()
|
||||
{
|
||||
|
||||
@ -307,16 +133,11 @@ pFlow::sphereParticles::getParticlesInfoFromShape(
|
||||
|
||||
pFlow::sphereParticles::sphereParticles(
|
||||
systemControl &control,
|
||||
const property& prop
|
||||
const sphereShape& shpShape
|
||||
)
|
||||
:
|
||||
particles(control),
|
||||
spheres_
|
||||
(
|
||||
shapeFile__,
|
||||
&control.caseSetup(),
|
||||
prop
|
||||
),
|
||||
particles(control, shpShape),
|
||||
spheres_(shpShape),
|
||||
propertyId_
|
||||
(
|
||||
objectFile
|
||||
@ -384,6 +205,11 @@ pFlow::sphereParticles::sphereParticles(
|
||||
dynPointStruct(),
|
||||
zero3
|
||||
),
|
||||
boundarySphereParticles_
|
||||
(
|
||||
dynPointStruct().boundaries(),
|
||||
*this
|
||||
),
|
||||
accelerationTimer_(
|
||||
"Acceleration", &this->timers() ),
|
||||
intPredictTimer_(
|
||||
@ -403,7 +229,8 @@ pFlow::sphereParticles::sphereParticles(
|
||||
"rVelocity",
|
||||
dynPointStruct(),
|
||||
intMethod,
|
||||
rVelocity_.field()
|
||||
rAcceleration_.field(),
|
||||
control.keepIntegrationHistory()
|
||||
);
|
||||
|
||||
if( !rVelIntegration_ )
|
||||
@ -413,8 +240,6 @@ pFlow::sphereParticles::sphereParticles(
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
WARNING<<"setFields for rVelIntegration_"<<END_WARNING;
|
||||
|
||||
if(!initializeParticles())
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
@ -423,96 +248,12 @@ pFlow::sphereParticles::sphereParticles(
|
||||
|
||||
}
|
||||
|
||||
/*bool pFlow::sphereParticles::update(const eventMessage& msg)
|
||||
{
|
||||
|
||||
if(rVelIntegration_->needSetInitialVals())
|
||||
{
|
||||
|
||||
|
||||
auto indexHD = pStruct().insertedPointIndex();
|
||||
|
||||
auto n = indexHD.size();
|
||||
auto index = indexHD.indicesHost();
|
||||
|
||||
realx3Vector rvel(n,RESERVE());
|
||||
const auto hrVel = rVelocity_.hostView();
|
||||
|
||||
for(auto i=0; i<n; i++)
|
||||
{
|
||||
rvel.push_back( hrVel[index(i)]);
|
||||
}
|
||||
|
||||
rVelIntegration_->setInitialVals(indexHD, rvel);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
/*bool pFlow::sphereParticles::insertParticles
|
||||
(
|
||||
const realx3Vector& position,
|
||||
const wordVector& shapes,
|
||||
const setFieldList& setField
|
||||
)
|
||||
{
|
||||
|
||||
if( position.size() != shapes.size() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" size of vectors position ("<<position.size()<<
|
||||
") and shapes ("<<shapes.size()<<") are not the same. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
auto exclusionListAllPtr = getFieldObjectList();
|
||||
|
||||
auto newInsertedPtr = pStruct().insertPoints( position, setField, time(), exclusionListAllPtr());
|
||||
|
||||
|
||||
if(!newInsertedPtr)
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in inserting points into pStruct. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto& newInserted = newInsertedPtr();
|
||||
|
||||
if(!shapeName_.insertSetElement(newInserted, shapes))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in inserting shapes into sphereParticles system.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !insertSphereParticles(shapes, newInserted) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"error in inserting shapes into the sphereParticles. \n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
auto activeR = this->activeRange();
|
||||
|
||||
REPORT(1)<< "Active range is "<<yellowText("["<<activeR.first<<", "<<activeR.second<<")")<<
|
||||
" and number of active points is "<< cyanText(this->numActive())<<
|
||||
" and pointStructure capacity is "<<cyanText(this->capacity())<<endREPORT;
|
||||
|
||||
return true;
|
||||
|
||||
}*/
|
||||
|
||||
bool pFlow::sphereParticles::beforeIteration()
|
||||
{
|
||||
particles::beforeIteration();
|
||||
intPredictTimer_.start();
|
||||
auto dt = this->dt();
|
||||
dynPointStruct().predict(dt, accelertion());
|
||||
dynPointStruct().predict(dt);
|
||||
rVelIntegration_().predict(dt,rVelocity_, rAcceleration_);
|
||||
intPredictTimer_.end();
|
||||
|
||||
@ -523,6 +264,7 @@ bool pFlow::sphereParticles::beforeIteration()
|
||||
I_.updateBoundariesSlaveToMasterIfRequested();
|
||||
rVelocity_.updateBoundariesSlaveToMasterIfRequested();
|
||||
rAcceleration_.updateBoundariesSlaveToMasterIfRequested();
|
||||
rVelIntegration_().updateBoundariesSlaveToMasterIfRequested();
|
||||
fieldUpdateTimer_.end();
|
||||
|
||||
return true;
|
||||
@ -531,30 +273,40 @@ bool pFlow::sphereParticles::beforeIteration()
|
||||
bool pFlow::sphereParticles::iterate()
|
||||
{
|
||||
|
||||
const timeInfo ti = TimeInfo();
|
||||
const realx3 g = control().g();
|
||||
|
||||
particles::iterate();
|
||||
accelerationTimer_.start();
|
||||
pFlow::sphereParticlesKernels::acceleration(
|
||||
control().g(),
|
||||
g,
|
||||
mass().deviceViewAll(),
|
||||
contactForce().deviceViewAll(),
|
||||
I().deviceViewAll(),
|
||||
contactTorque().deviceViewAll(),
|
||||
dynPointStruct().activePointsMaskDevice(),
|
||||
accelertion().deviceViewAll(),
|
||||
acceleration().deviceViewAll(),
|
||||
rAcceleration().deviceViewAll()
|
||||
);
|
||||
ForAllActiveBoundaries(i,boundarySphereParticles_)
|
||||
{
|
||||
boundarySphereParticles_[i].acceleration(ti, g);
|
||||
}
|
||||
|
||||
accelerationTimer_.end();
|
||||
|
||||
intCorrectTimer_.start();
|
||||
|
||||
if(!dynPointStruct().correct(dt(), accelertion()))
|
||||
if(!dynPointStruct().correct(ti.dt()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
real damping = dynPointStruct().dampingFactor(ti);
|
||||
if(!rVelIntegration_().correct(
|
||||
dt(),
|
||||
ti.dt(),
|
||||
rVelocity_,
|
||||
rAcceleration_))
|
||||
rAcceleration_,
|
||||
damping))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ Licence:
|
||||
#include "particles.hpp"
|
||||
#include "property.hpp"
|
||||
#include "sphereShape.hpp"
|
||||
#include "boundarySphereParticlesList.hpp"
|
||||
#include "systemControl.hpp"
|
||||
|
||||
namespace pFlow
|
||||
@ -47,7 +48,7 @@ public:
|
||||
private:
|
||||
|
||||
/// reference to shapes
|
||||
ShapeType spheres_;
|
||||
const ShapeType& spheres_;
|
||||
|
||||
/// property id on device
|
||||
uint32PointField_D propertyId_;
|
||||
@ -67,6 +68,9 @@ private:
|
||||
/// pointField of rotational acceleration of particles on device
|
||||
realx3PointField_D rAcceleration_;
|
||||
|
||||
/// boundaries
|
||||
boundarySphereParticlesList boundarySphereParticles_;
|
||||
|
||||
/// rotational velocity integrator
|
||||
uniquePtr<integration> rVelIntegration_ = nullptr;
|
||||
|
||||
@ -101,11 +105,26 @@ 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
|
||||
sphereParticles(systemControl& control, const property& prop);
|
||||
sphereParticles(systemControl& control, const sphereShape& shpShape);
|
||||
|
||||
~sphereParticles() override = default;
|
||||
|
||||
@ -156,9 +175,7 @@ public:
|
||||
}
|
||||
|
||||
bool hearChanges(
|
||||
real t,
|
||||
real dt,
|
||||
uint32 iter,
|
||||
const timeInfo& ti,
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
) override
|
||||
|
@ -68,6 +68,18 @@ pFlow::sphereShape::sphereShape
|
||||
}
|
||||
}
|
||||
|
||||
pFlow::sphereShape::sphereShape
|
||||
(
|
||||
const word &shapeType,
|
||||
const word &fileName,
|
||||
repository *owner,
|
||||
const property &prop
|
||||
)
|
||||
:
|
||||
sphereShape(fileName, owner, prop)
|
||||
{
|
||||
}
|
||||
|
||||
pFlow::real pFlow::sphereShape::maxBoundingSphere() const
|
||||
{
|
||||
return max(diameters_);
|
||||
@ -105,6 +117,11 @@ pFlow::realVector pFlow::sphereShape::boundingDiameter() const
|
||||
return diameters_;
|
||||
}
|
||||
|
||||
pFlow::realVector pFlow::sphereShape::volume() const
|
||||
{
|
||||
return realVector("volume", Pi/6*pow(diameters_,(real)3.0));
|
||||
}
|
||||
|
||||
bool pFlow::sphereShape::mass(uint32 index, real &m) const
|
||||
{
|
||||
if( indexValid(index) )
|
||||
|
@ -51,9 +51,22 @@ public:
|
||||
repository* owner,
|
||||
const property& prop);
|
||||
|
||||
sphereShape(
|
||||
const word& shapeType,
|
||||
const word& fileName,
|
||||
repository* owner,
|
||||
const property& prop);
|
||||
|
||||
|
||||
~sphereShape() override = default;
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
shape,
|
||||
sphereShape,
|
||||
word
|
||||
);
|
||||
|
||||
//// - Methods
|
||||
|
||||
real maxBoundingSphere()const override;
|
||||
@ -66,6 +79,8 @@ public:
|
||||
|
||||
realVector boundingDiameter()const override;
|
||||
|
||||
realVector volume()const override;
|
||||
|
||||
bool mass(uint32 index, real& m)const override;
|
||||
|
||||
real mass(uint32 index) const override;
|
||||
|
Reference in New Issue
Block a user