Geometry folder is finalized

This commit is contained in:
Hamidreza Norouzi 2024-03-20 00:50:58 -07:00
parent df8bea213d
commit acfaacfe4a
7 changed files with 235 additions and 422 deletions

View File

@ -34,8 +34,8 @@ bool pFlow::geometry::createPropertyId()
uint32Vector propId( uint32Vector propId(
"propId", "propId",
surface().capacity(), capacity(),
surface().size(), size(),
RESERVE()); RESERVE());
ForAll(i, materialName_) ForAll(i, materialName_)
@ -61,6 +61,11 @@ bool pFlow::geometry::createPropertyId()
} }
void pFlow::geometry::zeroForce()
{
contactForceWall_.fill(zero3);
}
pFlow::geometry::geometry pFlow::geometry::geometry
( (
systemControl& control, systemControl& control,
@ -84,16 +89,6 @@ pFlow::geometry::geometry
control control
), ),
wallProperty_(prop), wallProperty_(prop),
motionComponentName_
(
"motionComponentName",
"motionComponentName"
),
materialName_
(
"materialName",
"materialName"
),
propertyId_ propertyId_
( (
objectFile objectFile
@ -197,16 +192,6 @@ pFlow::geometry::geometry
( (
prop prop
), ),
motionComponentName_
(
"motionComponentName",
"motionComponentName"
),
materialName_
(
"materialName",
"materialName"
),
propertyId_ propertyId_
( (
objectFile objectFile
@ -274,9 +259,47 @@ pFlow::geometry::geometry
} }
} }
bool pFlow::geometry::beforeIteration()
{
zeroForce();
return true;
}
bool pFlow::geometry::iterate()
{
return true;
}
bool pFlow::geometry::afterIteration()
{
auto numTris = size();
auto& normalsD = normals().deviceViewAll();
auto& areaD = area().deviceViewAll();
auto& cForceD = contactForceWall_.deviceViewAll();
auto& sStressD = shearStressWall_.deviceViewAll();
auto& nStressD = normalStressWall_.deviceViewAll();
Kokkos::parallel_for(
"pFlow::geometry::afterIteration",
deviceRPolicyStatic(0, numTris),
LAMBDA_HD(uint32 i)
{
realx3 n = normalsD[i];
real A = max(areaD[i],smallValue);
realx3 nF = dot(cForceD[i],n)*n;
realx3 sF = cForceD[i] - nF;
nStressD[i] = nF/A;
sStressD[i] = sF/A;
});
Kokkos::fence();
return true;
}
bool pFlow::geometry::read(iIstream &is, const IOPattern &iop) bool pFlow::geometry::read(iIstream &is, const IOPattern &iop)
{ {
motionComponentName_.read(is, iop); motionComponentName_.read(is, iop);
materialName_.read(is, iop); materialName_.read(is, iop);
if( readWholeObject_ ) if( readWholeObject_ )
@ -305,6 +328,93 @@ bool pFlow::geometry::write(iOstream &os, const IOPattern &iop) const
return multiTriSurface::write(os,iop); return multiTriSurface::write(os,iop);
} }
pFlow::uniquePtr<pFlow::geometry>
pFlow::geometry::create
(
systemControl& control,
const property& prop
)
{
//
fileDictionary dict( motionModelFile__, control.time().geometry().path());
word model = dict.getVal<word>("motionModel");
auto geomModel = angleBracketsNames("geometry", model);
REPORT(1)<< "Selecting geometry model . . ."<<END_REPORT;
if( systemControlvCtorSelector_.search(geomModel) )
{
auto objPtr = systemControlvCtorSelector_[geomModel] (control, prop);
REPORT(2)<<"Model "<< Green_Text(geomModel)<<" is created.\n"<<END_REPORT;
return objPtr;
}
else
{
printKeys
(
fatalError << "Ctor Selector "<< Yellow_Text(geomModel) << " dose not exist. \n"
<<"Avaiable ones are: \n\n"
,
systemControlvCtorSelector_
);
fatalExit;
}
return nullptr;
}
pFlow::uniquePtr<pFlow::geometry>
pFlow::geometry::create
(
systemControl& control,
const property& prop,
multiTriSurface& surf,
const wordVector& motionCompName,
const wordVector& materialName,
const dictionary& motionDic
)
{
word model = motionDic.getVal<word>("motionModel");
auto geomModel = angleBracketsNames("geometry", model);
REPORT(1)<< "Selecting geometry model . . ."<<END_REPORT;
if( dictionaryvCtorSelector_.search(geomModel) )
{
auto objPtr = dictionaryvCtorSelector_[geomModel]
(
control,
prop,
surf,
motionCompName,
materialName,
motionDic
);
REPORT(2)<<"Model "<< Green_Text(geomModel)<<" is created.\n"<<END_REPORT;
return objPtr;
}
else
{
printKeys
(
fatalError << "Ctor Selector "<< Yellow_Text(geomModel) << " dose not exist. \n"
<<"Avaiable ones are: \n\n"
,
dictionaryvCtorSelector_
);
fatalExit;
}
return nullptr;
}
/*pFlow::geometry::geometry /*pFlow::geometry::geometry
( (
systemControl& control, systemControl& control,
@ -400,52 +510,7 @@ pFlow::geometry::geometry
{} {}
pFlow::uniquePtr<pFlow::geometry>
pFlow::geometry::create
(
systemControl& control,
const property& prop
)
{
//motionModelFile__
auto motionDictPtr = IOobject::make<dictionary>
(
objectFile
(
motionModelFile__,
control.geometry().path(),
objectFile::READ_ALWAYS,
objectFile::WRITE_NEVER
),
motionModelFile__,
true
);
word model = motionDictPtr().getObject<dictionary>().getVal<word>("motionModel");
auto geomModel = angleBracketsNames("geometry", model);
REPORT(1)<< "Selecting geometry model . . ."<<endREPORT;
if( systemControlvCtorSelector_.search(geomModel) )
{
auto objPtr = systemControlvCtorSelector_[geomModel] (control, prop);
REPORT(2)<<"Model "<< greenText(geomModel)<<" is created.\n"<<endREPORT;
return objPtr;
}
else
{
printKeys
(
fatalError << "Ctor Selector "<< yellowText(geomModel) << " dose not exist. \n"
<<"Avaiable ones are: \n\n"
,
systemControlvCtorSelector_
);
fatalExit;
}
return nullptr;
}
bool pFlow::geometry::beforeIteration() bool pFlow::geometry::beforeIteration()
{ {
@ -473,49 +538,3 @@ bool pFlow::geometry::afterIteration()
return true; return true;
}*/ }*/
pFlow::uniquePtr<pFlow::geometry>
pFlow::geometry::create
(
systemControl& control,
const property& prop,
multiTriSurface& surf,
const wordVector& motionCompName,
const wordVector& materialName,
const dictionary& motionDic
)
{
word model = motionDic.getVal<word>("motionModel");
auto geomModel = angleBracketsNames("geometry", model);
REPORT(1)<< "Selecting geometry model . . ."<<END_REPORT;
if( dictionaryvCtorSelector_.search(geomModel) )
{
auto objPtr = dictionaryvCtorSelector_[geomModel]
(
control,
prop,
surf,
motionCompName,
materialName,
motionDic
);
REPORT(2)<<"Model "<< Green_Text(geomModel)<<" is created.\n"<<END_REPORT;
return objPtr;
}
else
{
printKeys
(
fatalError << "Ctor Selector "<< Yellow_Text(geomModel) << " dose not exist. \n"
<<"Avaiable ones are: \n\n"
,
dictionaryvCtorSelector_
);
fatalExit;
}
return nullptr;
}

View File

@ -54,10 +54,14 @@ private:
const property& wallProperty_; const property& wallProperty_;
/// The name of motion component of each wall surface /// The name of motion component of each wall surface
wordField_H motionComponentName_; wordField_H motionComponentName_{
"motionComponentName",
"motionComponentName"};
/// Material name of each wall surface /// Material name of each wall surface
wordField_H materialName_; wordField_H materialName_{
"materialName",
"materialName"};
/// Property id of each triangle in the set of wall surfaces /// Property id of each triangle in the set of wall surfaces
uint32TriSurfaceField_D propertyId_; uint32TriSurfaceField_D propertyId_;
@ -81,11 +85,7 @@ private:
bool createPropertyId(); bool createPropertyId();
/// Initialize contact force to zero /// Initialize contact force to zero
/*void zeroForce() void zeroForce();
{
contactForceWall_.fill(zero3);
}*/
public: public:
@ -122,10 +122,10 @@ public:
const wordVector& propName);*/ const wordVector& propName);*/
/// Destructor /// Destructor
virtual ~geometry() = default; ~geometry()override = default;
/// Virtual constructor /// Virtual constructor
/*create_vCtor create_vCtor
( (
geometry, geometry,
systemControl, systemControl,
@ -134,7 +134,7 @@ public:
const property& prop const property& prop
), ),
(control, prop) (control, prop)
);*/ );
/// Virtual constructor /// Virtual constructor
create_vCtor create_vCtor
@ -152,48 +152,6 @@ public:
); );
//- Methods //- Methods
/// Number of triangles in the set of surface walls
inline
auto numTriangles()const
{
return size();
}
/// Access to the points
/*inline
const auto& points()const
{
return triSurface_.points();
}*/
/// Access to the vertices
/*inline
const auto& vertices()const
{
return triSurface_.vertices();
}*/
/// Obtain an object for accessing triangles
/*inline auto getTriangleAccessor()const
{
return triSurface_.getTriangleAccessor();
}*/
/// Surface
inline
auto& surface()
{
return static_cast<multiTriSurface&>(*this);
}
/// Surface
inline
const auto& surface()const
{
return static_cast<const multiTriSurface&>(*this);
}
inline inline
const auto& motionComponentName()const const auto& motionComponentName()const
{ {
@ -201,90 +159,53 @@ public:
} }
/// Access to contact force /// Access to contact force
/*inline inline
realx3TriSurfaceField_D& contactForceWall() auto& contactForceWall()
{ {
return contactForceWall_; return contactForceWall_;
} }
/// Access to contact force /// Access to contact force
inline inline
const realx3TriSurfaceField_D& contactForceWall() const const auto& contactForceWall() const
{ {
return contactForceWall_; return contactForceWall_;
} }
/// Property ide of triangles
inline
const auto& propertyId()const
{
return propertyId_;
}
/// Access to property /// Access to property
inline const auto& wallProperty()const inline const auto& wallProperty()const
{ {
return wallProperty_; return wallProperty_;
}*/ }
/// Owner repository
/*inline
const repository& owner()const
{
return geometryRepository_;
}*/
/// Owner repository
/*inline
repository& owner()
{
return geometryRepository_;
}*/
/// Path to the repository folder
/*inline auto path()
{
return owner().path();
}*/
/// The name of motion model /// The name of motion model
/*virtual virtual
word motionModelTypeName()const = 0;*/ word motionModelTypeName()const = 0;
/// Motion model index of triangles /// Motion model index of triangles
/*virtual virtual
const int8Vector_HD& triMotionIndex() const =0; const uint32Field_D& triMotionIndex() const =0;
/// Motion model index of points /// Motion model index of points
virtual virtual
const int8Vector_HD& pointMotionIndex()const = 0; const uint32Field_D& pointMotionIndex()const = 0;
/// Property ide of triangles
const int8TriSurfaceField_D& propertyId() const
{
return propertyId_;
}*/
/// Operations before each iteration
//bool beforeIteration() override;
/// Operations after each iteration
//bool afterIteration() override;
bool beforeIteration() override bool beforeIteration() override;
{
notImplementedFunction;
return true;
}
/// This is called in time loop. Perform the main calculations /// This is called in time loop. Perform the main calculations
/// when the component should evolve along time. /// when the component should evolve along time.
bool iterate() override bool iterate() override;
{
notImplementedFunction;
return true;
}
/// This is called in time loop, after iterate. /// This is called in time loop, after iterate.
bool afterIteration() override bool afterIteration() override;
{
notImplementedFunction;
return true;
}
//- IO //- IO
@ -297,8 +218,10 @@ public:
//- Static members //- Static members
/*static static
uniquePtr<geometry> create(systemControl& control, const property& prop);*/ uniquePtr<geometry> create(
systemControl& control,
const property& prop);
static static
uniquePtr<geometry> create( uniquePtr<geometry> create(

View File

@ -45,17 +45,18 @@ bool pFlow::geometryMotion<MotionModel>::findMotionIndex()
fatalErrorInFunction<< fatalErrorInFunction<<
mName<< " does not exist in the list of motion names -> "<< mName<< " does not exist in the list of motion names -> "<<
motionModel_.componentNames(); motionModel_.componentNames();
return false;
} }
surfMotionIndex.push_back(mInd); surfMotionIndex.push_back(mInd);
auto surfRange = this->surface().subSurfaceRange(surfI); auto surfRange = subSurfaceRange(surfI);
for(uint32 i=0; i<surfRange.numElements(); i++) for(uint32 i=0; i<surfRange.numElements(); i++)
{ {
triMotionIndex.push_back(mInd); triMotionIndex.push_back(mInd);
} }
auto pointRange = this->surface().subSurfacePointRange(surfI); auto pointRange = subSurfacePointRange(surfI);
for(uint32 n=0; n<pointRange.numElements(); n++) for(uint32 n=0; n<pointRange.numElements(); n++)
{ {
pointMotionIndex.push_back(mInd); pointMotionIndex.push_back(mInd);
@ -70,6 +71,39 @@ bool pFlow::geometryMotion<MotionModel>::findMotionIndex()
} }
template<typename MotionModel>
bool pFlow::geometryMotion<MotionModel>::moveGeometry()
{
uint32 iter = this->currentIter();
real t = this->currentTime();
real dt = this->dt();
auto mModel = motionModel_.getModelInterface(iter, t, dt);
auto& pointMIndexD= pointMotionIndex_.deviceViewAll();
auto& pointsD = points().deviceViewAll();
Kokkos::parallel_for(
"geometryMotion<MotionModel>::movePoints",
deviceRPolicyStatic(0, numPoints()),
LAMBDA_HD(uint32 i){
auto newPos = mModel.transferPoint(pointMIndexD[i], pointsD[i], dt);
pointsD[i] = newPos;
});
Kokkos::fence();
// move the motion components
motionModel_.move(iter, t,dt);
// end of calculations
return true;
}
template<typename MotionModel> template<typename MotionModel>
pFlow::geometryMotion<MotionModel>::geometryMotion pFlow::geometryMotion<MotionModel>::geometryMotion
( (
@ -137,129 +171,16 @@ pFlow::geometryMotion<MotionModelType>::geometryMotion
} }
} }
/*template<typename MotionModel>
pFlow::geometryMotion<MotionModel>::geometryMotion
(
systemControl& control,
const property& prop,
const multiTriSurface& triSurface,
const wordVector& motionCompName,
const wordVector& propName,
const MotionModel& motionModel
)
:
geometry(
control,
prop,
triSurface,
motionCompName,
propName
),
motionModel_(
this->owner().template emplaceObject<MotionModel>(
objectFile(
motionModelFile__,
"",
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
),
motionModel
)
),
moveGeomTimer_("move geometry", &this->timers())
{
findMotionIndex();
}
template<typename MotionModel>
pFlow::geometryMotion<MotionModel>::geometryMotion
(
systemControl& control,
const property& prop,
const dictionary& dict,
const multiTriSurface& triSurface,
const wordVector& motionCompName,
const wordVector& propName
)
:
geometry(
control,
prop,
dict,
triSurface,
motionCompName,
propName
),
motionModel_(
this->owner().template emplaceObject<MotionModel>(
objectFile(
motionModelFile__,
"",
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
),
dict
)
),
moveGeomTimer_("move geometry", &this->timers())
{
findMotionIndex();
}
template<typename MotionModel>
bool pFlow::geometryMotion<MotionModel>::beforeIteration()
{
geometry::beforeIteration();
return true;
}
template<typename MotionModel> template<typename MotionModel>
bool pFlow::geometryMotion<MotionModel>::iterate() bool pFlow::geometryMotion<MotionModel>::iterate()
{ {
if( motionModel_.isMoving() ) if( motionModel_.isMoving() )
{ {
moveGeomTimer_.start(); moveGeomTimer_.start();
moveGeometry(); moveGeometry();
moveGeomTimer_.end(); this->calculateNormals();
moveGeomTimer_.end();
} }
return true; return true;
} }
template<typename MotionModel>
bool pFlow::geometryMotion<MotionModel>::afterIteration()
{
geometry::afterIteration();
return true;
}
template<typename MotionModel>
bool pFlow::geometryMotion<MotionModel>::moveGeometry()
{
real dt = this->dt();
real t = this->currentTime();
auto pointMIndex= pointMotionIndex_.deviceVector();
auto mModel = motionModel_.getModel(t);
realx3* points = triSurface_.pointsData_D();
auto numPoints = triSurface_.numPoints();
Kokkos::parallel_for(
"geometryMotion<MotionModel>::movePoints",
numPoints,
LAMBDA_HD(int32 i){
auto newPos = mModel.transferPoint(pointMIndex[i], points[i], dt);
points[i] = newPos;
});
Kokkos::fence();
// move the motion components
motionModel_.move(t,dt);
// end of calculations
moveGeomTimer_.end();
return true;
}*/

View File

@ -38,6 +38,8 @@ class geometryMotion
{ {
public: public:
using MotionModel = MotionModelType;
using ModelComponent = typename MotionModelType::ModelComponent; using ModelComponent = typename MotionModelType::ModelComponent;
private: private:
@ -60,6 +62,9 @@ private:
/// determine the motion index of each triangle /// determine the motion index of each triangle
bool findMotionIndex(); bool findMotionIndex();
/// Move geometry
bool moveGeometry();
public: public:
/// Type info /// Type info
@ -77,31 +82,13 @@ public:
const wordVector& materialName, const wordVector& materialName,
const dictionary& motionDict); const dictionary& motionDict);
/*geometryMotion(
systemControl& control,
const property& prop,
const multiTriSurface& triSurface,
const wordVector& motionCompName,
const wordVector& propName,
const MotionModel& motionModel);*/
/// Construct from components and dictionary that contains
/// motionModel
/*geometryMotion(systemControl& control,
const property& prop,
const dictionary& dict,
const multiTriSurface& triSurface,
const wordVector& motionCompName,
const wordVector& propName);*/
/// Add virtual constructor /// Add virtual constructor
/*add_vCtor add_vCtor
( (
geometry, geometry,
geometryMotion, geometryMotion,
systemControl systemControl
);*/ );
/// Add virtual constructor /// Add virtual constructor
add_vCtor add_vCtor
@ -114,40 +101,33 @@ public:
// - Methods // - Methods
/// Obtain motion model at time t /// Obtain motion model at time t
/*auto getModel(real t)const auto getModel(uint32 iter, real t, real dt)const
{ {
return motionModel_.getModel(t); return motionModel_.getModelInterface(iter, t, dt);
}*/ }
/// TypeName / TypeInfo of motion model /// TypeName / TypeInfo of motion model
/*word motionModelTypeName()const override word motionModelTypeName()const override
{ {
return motionModel_.typeName(); return motionModel_.typeName();
}*/ }
/// Access to motion model index of triangles /// Access to motion model index of triangles
/*const auto& triMotionIndex()const override const uint32Field_D& triMotionIndex()const override
{ {
return triMotionIndex_; return triMotionIndex_;
} }
/// Access to motion model index of points /// Access to motion model index of points
const int8Vector_HD& pointMotionIndex()const override const uint32Field_D& pointMotionIndex()const override
{ {
return pointMotionIndex_; return pointMotionIndex_;
}*/ }
/// Operations before each iteration
/*bool beforeIteration() override;
/// Iterate geometry one time step /// Iterate geometry one time step
bool iterate() override ; bool iterate() override ;
/// Operations after each iteration
bool afterIteration() override;*/
/// Move geometry
//bool moveGeometry();
}; };
@ -155,9 +135,6 @@ public:
#include "geometryMotion.cpp" #include "geometryMotion.cpp"
#ifndef BUILD_SHARED_LIBS
#include "geometryMotionsInstantiate.cpp"
#endif
#endif //__geometryMotion_hpp__ #endif //__geometryMotion_hpp__

View File

@ -17,9 +17,13 @@ Licence:
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#include "geometryMotions.hpp" #include "geometryMotions.hpp"
#ifdef BUILD_SHARED_LIBS
#include "geometryMotionsInstantiate.cpp" template class pFlow::geometryMotion<pFlow::vibratingMotion>;
#endif
template class pFlow::geometryMotion<pFlow::rotatingAxisMotion>;
template class pFlow::geometryMotion<pFlow::stationaryWall>;
//template class pFlow::geometryMotion<pFlow::multiRotatingAxisMotion>;

View File

@ -35,9 +35,10 @@ using vibratingMotionGeometry = geometryMotion<vibratingMotion>;
using rotationAxisMotionGeometry = geometryMotion<rotatingAxisMotion>; using rotationAxisMotionGeometry = geometryMotion<rotatingAxisMotion>;
using stationaryGeometry = geometryMotion<stationaryWall>;
//typedef geometryMotion<multiRotatingAxisMotion> multiRotationAxisMotionGeometry; //typedef geometryMotion<multiRotatingAxisMotion> multiRotationAxisMotionGeometry;
typedef geometryMotion<stationaryWall> stationaryGeometry;

View File

@ -1,32 +0,0 @@
/*------------------------------- 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 "stationaryWall.hpp"
#include "rotatingAxisMotion.hpp"
//#include "multiRotatingAxisMotion.hpp"
#include "vibratingMotion.hpp"
template class pFlow::geometryMotion<pFlow::stationaryWall>;
template class pFlow::geometryMotion<pFlow::rotatingAxisMotion>;
//template class pFlow::geometryMotion<pFlow::multiRotatingAxisMotion>;
template class pFlow::geometryMotion<pFlow::vibratingMotion>;