Files
phasicFlow/src/Particles/SphereParticles/sphereShape/sphereShape.cpp

201 lines
4.2 KiB
C++
Raw Normal View History

2022-09-05 01:56:29 +04:30
/*------------------------------- 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.
-----------------------------------------------------------------------------*/
2022-12-10 01:32:54 +03:30
#include "sphereShape.hpp"
2022-09-05 01:56:29 +04:30
2024-01-26 01:10:10 -08:00
bool pFlow::sphereShape::readFromDictionary3()
2022-09-05 01:56:29 +04:30
{
2024-01-26 01:10:10 -08:00
diameters_ = getVal<realVector>("diameters");
if(diameters_.size() != numShapes() )
2022-09-05 01:56:29 +04:30
{
fatalErrorInFunction<<
" number of elements in diameters in "<< globalName()<<" is not consistent"<<endl;
return false;
2022-09-05 01:56:29 +04:30
}
2022-09-05 01:56:29 +04:30
return true;
}
bool pFlow::sphereShape::writeToDict(dictionary& dict)const
2022-09-05 01:56:29 +04:30
{
if(!shape::writeToDict(dict))return false;
2022-09-05 01:56:29 +04:30
if( !dict.add("diameters", diameters_) )
2022-09-05 01:56:29 +04:30
{
fatalErrorInFunction<<
" Error in writing diameters to dictionary "<< dict.globalName()<<endl;
2022-09-05 01:56:29 +04:30
return false;
}
return true;
}
pFlow::sphereShape::sphereShape
2022-09-05 01:56:29 +04:30
(
const word& fileName,
repository* owner,
const property& prop
)
:
shape(fileName, owner, prop)
2022-09-05 01:56:29 +04:30
{
2024-01-26 01:10:10 -08:00
if(!readFromDictionary3())
{
fatalExit;
fatalErrorInFunction;
}
}
2022-09-05 01:56:29 +04:30
pFlow::real pFlow::sphereShape::maxBoundingSphere() const
{
return max(diameters_);
}
2022-09-05 01:56:29 +04:30
pFlow::real pFlow::sphereShape::minBoundingSphere() const
{
return min(diameters_);
}
bool pFlow::sphereShape::boundingDiameter(uint32 index, real &bDiam) const
{
if( indexValid(index))
2022-09-05 01:56:29 +04:30
{
bDiam = diameters_[index];
return true;
2022-09-05 01:56:29 +04:30
}
return false;
}
2022-09-05 01:56:29 +04:30
pFlow::real pFlow::sphereShape::boundingDiameter(uint32 index) const
{
if(indexValid(index))
2022-09-05 01:56:29 +04:30
{
return diameters_[index];
2022-09-05 01:56:29 +04:30
}
fatalErrorInFunction<<"Invalid index for diameter "<<
index<<endl;
fatalExit;
return 0.0;
2022-09-05 01:56:29 +04:30
}
pFlow::realVector pFlow::sphereShape::boundingDiameter() const
{
return diameters_;
}
2022-09-05 01:56:29 +04:30
bool pFlow::sphereShape::mass(uint32 index, real &m) const
2022-09-05 01:56:29 +04:30
{
if( indexValid(index) )
2022-09-05 01:56:29 +04:30
{
real d = diameters_[index];
real rho = indexToDensity(index);
m = Pi/6.0*pow(d,3)*rho;
return true;
2022-09-05 01:56:29 +04:30
}
return false;
2022-09-05 01:56:29 +04:30
}
pFlow::real pFlow::sphereShape::mass(uint32 index) const
2022-09-05 01:56:29 +04:30
{
if(real m; mass(index, m))
2022-09-05 01:56:29 +04:30
{
return m;
2022-09-05 01:56:29 +04:30
}
fatalErrorInFunction<<"bad index for mass "<< index<<endl;
fatalExit;
return 0;
2022-09-05 01:56:29 +04:30
}
pFlow::realVector pFlow::sphereShape::mass() const
2022-09-05 01:56:29 +04:30
{
return realVector ("mass", Pi/6*pow(diameters_,(real)3.0)*density());
}
2022-09-05 01:56:29 +04:30
pFlow::realVector pFlow::sphereShape::density()const
{
auto pids = shapePropertyIds();
realVector rho("rho", numShapes());
ForAll(i, pids)
{
rho[i] = properties().density(pids[i]);
}
return rho;
}
2022-09-05 01:56:29 +04:30
bool pFlow::sphereShape::Inertia(uint32 index, real &I) const
{
if( indexValid(index) )
2022-09-05 01:56:29 +04:30
{
I = 0.4 * mass(index) * pow(diameters_[index]/2.0,2.0);
return true;
2022-09-05 01:56:29 +04:30
}
return false;
}
2022-09-05 01:56:29 +04:30
pFlow::real pFlow::sphereShape::Inertia(uint32 index) const
{
if(real I; Inertia(index, I))
2022-09-05 01:56:29 +04:30
{
return I;
2022-09-05 01:56:29 +04:30
}
fatalExit;
return 0;
}
2022-09-05 01:56:29 +04:30
pFlow::realVector pFlow::sphereShape::Inertia() const
{
2024-03-24 02:49:47 -07:00
return realVector("I", (real)0.4*mass()*pow((real)0.5*diameters_,(real)2.0));
2022-09-05 01:56:29 +04:30
}
bool pFlow::sphereShape::Inertia_xx(uint32 index, real &Ixx) const
2022-09-05 01:56:29 +04:30
{
return Inertia(index,Ixx);
}
2022-09-05 01:56:29 +04:30
pFlow::real pFlow::sphereShape::Inertial_xx(uint32 index) const
{
return Inertia(index);
}
2022-09-05 01:56:29 +04:30
bool pFlow::sphereShape::Inertia_yy(uint32 index, real &Iyy) const
{
return Inertia(index,Iyy);
}
2022-09-05 01:56:29 +04:30
pFlow::real pFlow::sphereShape::Inertial_yy(uint32 index) const
{
return Inertia(index);
}
2022-09-05 01:56:29 +04:30
bool pFlow::sphereShape::Inertia_zz(uint32 index, real &Izz) const
{
return Inertia(index,Izz);
}
pFlow::real pFlow::sphereShape::Inertial_zz(uint32 index) const
{
return Inertia(index);
2022-09-05 01:56:29 +04:30
}