Doc for Geometry added
This commit is contained in:
parent
c34c55bdde
commit
1fe2256079
|
@ -27,13 +27,16 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
/** base for geometry that manages control
|
||||
*
|
||||
*/
|
||||
class demGeometry
|
||||
:
|
||||
public demComponent
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
demGeometry(systemControl& control)
|
||||
:
|
||||
demComponent("geometry", control)
|
||||
|
|
|
@ -190,7 +190,7 @@ pFlow::geometry::geometry
|
|||
objectFile(
|
||||
"contactForceWall",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_ALWAYS),
|
||||
surface(),
|
||||
zero3) ),
|
||||
|
@ -199,7 +199,7 @@ pFlow::geometry::geometry
|
|||
objectFile(
|
||||
"stressWall",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_ALWAYS),
|
||||
surface(),
|
||||
zero3) )
|
||||
|
@ -271,6 +271,33 @@ pFlow::uniquePtr<pFlow::geometry>
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool pFlow::geometry::beforeIteration()
|
||||
{
|
||||
this->zeroForce();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::geometry::afterIteration()
|
||||
{
|
||||
|
||||
auto Force = contactForceWall_.deviceVectorAll();
|
||||
auto area = triSurface_.area().deviceVectorAll();
|
||||
auto stress = stressWall_.deviceVectorAll();
|
||||
auto numTri =triSurface_.size();
|
||||
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"geometry::calculateStress",
|
||||
numTri,
|
||||
LAMBDA_HD(int32 i){
|
||||
stress[i] = Force[i]/area[i];
|
||||
});
|
||||
Kokkos::fence();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
pFlow::uniquePtr<pFlow::geometry>
|
||||
pFlow::geometry::create(
|
||||
systemControl& control,
|
||||
|
|
|
@ -34,51 +34,68 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Base class for geometry for managing tri-surfaces, geometry motion,
|
||||
* and surface physical properties.
|
||||
*
|
||||
*/
|
||||
class geometry
|
||||
:
|
||||
public demGeometry
|
||||
{
|
||||
protected:
|
||||
|
||||
const property& wallProperty_;
|
||||
// - Protected members
|
||||
|
||||
// - this object is owned by geometryRepository_
|
||||
repository& geometryRepository_;
|
||||
/// Const reference to physical property of materials
|
||||
const property& wallProperty_;
|
||||
|
||||
// all triangles of walls
|
||||
multiTriSurface& triSurface_;
|
||||
/// Repository to store geometry data at each simulation moment
|
||||
repository& geometryRepository_;
|
||||
|
||||
//
|
||||
wordField& motionComponentName_;
|
||||
/// All triangles in the set of wall surfaces
|
||||
multiTriSurface& triSurface_;
|
||||
|
||||
//
|
||||
wordField& materialName_;
|
||||
/// The name of motion component of each wall surface
|
||||
wordField& motionComponentName_;
|
||||
|
||||
int8TriSurfaceField_D& propertyId_;
|
||||
/// Material name of each wall surface
|
||||
wordField& materialName_;
|
||||
|
||||
realx3TriSurfaceField_D& contactForceWall_;
|
||||
/// Property id of each triangle in the set of wall surfaces
|
||||
int8TriSurfaceField_D& propertyId_;
|
||||
|
||||
realx3TriSurfaceField_D& stressWall_;
|
||||
/// Contact force on each triangle in the set of wall surfaces
|
||||
realx3TriSurfaceField_D& contactForceWall_;
|
||||
|
||||
bool findPropertyId();
|
||||
/// Stress on ech triangle in the set of wall surfaces
|
||||
realx3TriSurfaceField_D& stressWall_;
|
||||
|
||||
void zeroForce()
|
||||
{
|
||||
contactForceWall_.fill(zero3);
|
||||
}
|
||||
// - Protected member functions
|
||||
|
||||
/// Find property id of each triangle based on the supplied material name
|
||||
/// and the surface wall that the triangle belongs to.
|
||||
bool findPropertyId();
|
||||
|
||||
/// Initialize contact force to zero
|
||||
void zeroForce()
|
||||
{
|
||||
contactForceWall_.fill(zero3);
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// - type info
|
||||
/// Type info
|
||||
TypeInfo("geometry");
|
||||
|
||||
//// - Constructors
|
||||
// - Constructors
|
||||
|
||||
// - empty
|
||||
/// Construct from controlSystem and property, for reading from file
|
||||
geometry(systemControl& control, const property& prop);
|
||||
|
||||
// - from components
|
||||
/// Construct from components
|
||||
geometry(systemControl& control,
|
||||
const property& prop,
|
||||
const multiTriSurface& triSurface,
|
||||
|
@ -86,6 +103,8 @@ public:
|
|||
const wordVector& propName
|
||||
);
|
||||
|
||||
/// Construct from components and dictionary that contains
|
||||
/// motionModel
|
||||
geometry(systemControl& control,
|
||||
const property& prop,
|
||||
const dictionary& dict,
|
||||
|
@ -93,9 +112,10 @@ public:
|
|||
const wordVector& motionCompName,
|
||||
const wordVector& propName);
|
||||
|
||||
|
||||
/// Destructor
|
||||
virtual ~geometry() = default;
|
||||
|
||||
/// Virtual constructor
|
||||
create_vCtor
|
||||
(
|
||||
geometry,
|
||||
|
@ -107,6 +127,7 @@ public:
|
|||
(control, prop)
|
||||
);
|
||||
|
||||
/// Virtual constructor
|
||||
create_vCtor
|
||||
(
|
||||
geometry,
|
||||
|
@ -120,141 +141,141 @@ public:
|
|||
(control, prop, dict, triSurface, motionCompName, propName)
|
||||
);
|
||||
|
||||
////- Methods
|
||||
//- Methods
|
||||
|
||||
/// Size of tri-surface
|
||||
inline
|
||||
auto size()const
|
||||
{
|
||||
return triSurface_.size();
|
||||
}
|
||||
|
||||
/// Number of points in the set of surface walls
|
||||
inline
|
||||
auto numPoints()const
|
||||
{
|
||||
return triSurface_.numPoints();
|
||||
}
|
||||
|
||||
/// 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 triSurface_;
|
||||
}
|
||||
|
||||
/// Surface
|
||||
inline const auto& surface()const
|
||||
{
|
||||
return triSurface_;
|
||||
}
|
||||
|
||||
/// Access to contact force
|
||||
inline
|
||||
realx3TriSurfaceField_D& contactForceWall()
|
||||
{
|
||||
return contactForceWall_;
|
||||
}
|
||||
|
||||
/// Access to contact force
|
||||
inline
|
||||
const realx3TriSurfaceField_D& contactForceWall() const
|
||||
{
|
||||
return contactForceWall_;
|
||||
}
|
||||
|
||||
/// Access to property
|
||||
inline const auto& wallProperty()const
|
||||
{
|
||||
return wallProperty_;
|
||||
}
|
||||
|
||||
// owner repository
|
||||
/// 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
|
||||
virtual
|
||||
word motionModelTypeName()const = 0;
|
||||
|
||||
/// Motion model index of triangles
|
||||
virtual
|
||||
const int8Vector_HD& triMotionIndex() const =0;
|
||||
|
||||
/// Motion model index of points
|
||||
virtual
|
||||
const int8Vector_HD& pointMotionIndex()const = 0;
|
||||
|
||||
/// Property ide of triangles
|
||||
const int8TriSurfaceField_D& propertyId() const
|
||||
{
|
||||
return propertyId_;
|
||||
}
|
||||
|
||||
bool beforeIteration() override {
|
||||
/// Operations before each iteration
|
||||
bool beforeIteration() override;
|
||||
|
||||
this->zeroForce();
|
||||
return true;
|
||||
/// Operations after each iteration
|
||||
bool afterIteration() override;
|
||||
|
||||
}
|
||||
|
||||
bool afterIteration() override {
|
||||
|
||||
auto Force = contactForceWall_.deviceVectorAll();
|
||||
auto area = triSurface_.area().deviceVectorAll();
|
||||
auto stress = stressWall_.deviceVectorAll();
|
||||
auto numTri =triSurface_.size();
|
||||
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"geometry::calculateStress",
|
||||
numTri,
|
||||
LAMBDA_HD(int32 i){
|
||||
stress[i] = Force[i]/area[i];
|
||||
});
|
||||
Kokkos::fence();
|
||||
return true;
|
||||
|
||||
}
|
||||
//- IO
|
||||
|
||||
/// write
|
||||
bool write()const
|
||||
{
|
||||
return owner().write();
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
//- Static members
|
||||
|
||||
static
|
||||
uniquePtr<geometry> create(systemControl& control, const property& prop);
|
||||
uniquePtr<geometry> create(systemControl& control, const property& prop);
|
||||
|
||||
static
|
||||
uniquePtr<geometry> create(
|
||||
uniquePtr<geometry> create(
|
||||
systemControl& control,
|
||||
const property& prop,
|
||||
const dictionary& dict,
|
||||
|
|
|
@ -18,38 +18,6 @@ Licence:
|
|||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
template<typename MotionModel>
|
||||
bool pFlow::geometryMotion<MotionModel>::findMotionIndex()
|
||||
{
|
||||
|
@ -88,6 +56,7 @@ bool pFlow::geometryMotion<MotionModel>::findMotionIndex()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<typename MotionModel>
|
||||
pFlow::geometryMotion<MotionModel>::geometryMotion
|
||||
(
|
||||
|
@ -180,6 +149,13 @@ pFlow::geometryMotion<MotionModel>::geometryMotion
|
|||
findMotionIndex();
|
||||
}
|
||||
|
||||
template<typename MotionModel>
|
||||
bool pFlow::geometryMotion<MotionModel>::beforeIteration()
|
||||
{
|
||||
geometry::beforeIteration();
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename MotionModel>
|
||||
bool pFlow::geometryMotion<MotionModel>::iterate()
|
||||
{
|
||||
|
@ -191,3 +167,42 @@ bool pFlow::geometryMotion<MotionModel>::iterate()
|
|||
}
|
||||
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;
|
||||
}
|
|
@ -17,8 +17,6 @@ Licence:
|
|||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __geometryMotion_hpp__
|
||||
#define __geometryMotion_hpp__
|
||||
|
||||
|
@ -29,7 +27,11 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* A class that represent surfaces in the simulation and moves surfaces
|
||||
* based on the MotionModelType. MotionModelType can be any motion model.
|
||||
*
|
||||
*/
|
||||
template<typename MotionModelType>
|
||||
class geometryMotion
|
||||
:
|
||||
|
@ -41,34 +43,34 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
|
||||
/// Ref to motion model
|
||||
MotionModel& motionModel_;
|
||||
|
||||
// motion indext mapped on each surface
|
||||
/// motion indext mapped on each surface
|
||||
int32Vector_HD motionIndex_;
|
||||
|
||||
// motion index mapped on each triangle
|
||||
/// motion index mapped on each triangle
|
||||
int8Vector_HD triMotionIndex_;
|
||||
|
||||
/// motion index mapped on each point
|
||||
int8Vector_HD pointMotionIndex_;
|
||||
|
||||
// timer for moveGeometry
|
||||
/// timer for moveGeometry
|
||||
Timer moveGeomTimer_;
|
||||
|
||||
|
||||
/// determine the motion index of each triangle
|
||||
bool findMotionIndex();
|
||||
|
||||
public:
|
||||
|
||||
// type info
|
||||
/// Type info
|
||||
TypeInfoTemplate("geometry", MotionModel);
|
||||
|
||||
//// - Constructors
|
||||
// - Constructors
|
||||
|
||||
geometryMotion(systemControl& control, const property& prop);
|
||||
|
||||
// construct from components
|
||||
|
||||
geometryMotion(
|
||||
systemControl& control,
|
||||
const property& prop,
|
||||
|
@ -77,8 +79,8 @@ public:
|
|||
const wordVector& propName,
|
||||
const MotionModel& motionModel);
|
||||
|
||||
// - construct from components and dictionary that contains
|
||||
// motionModel
|
||||
/// Construct from components and dictionary that contains
|
||||
/// motionModel
|
||||
geometryMotion(systemControl& control,
|
||||
const property& prop,
|
||||
const dictionary& dict,
|
||||
|
@ -86,8 +88,7 @@ public:
|
|||
const wordVector& motionCompName,
|
||||
const wordVector& propName);
|
||||
|
||||
|
||||
|
||||
/// Add virtual constructor
|
||||
add_vCtor
|
||||
(
|
||||
geometry,
|
||||
|
@ -95,6 +96,7 @@ public:
|
|||
systemControl
|
||||
);
|
||||
|
||||
/// Add virtual constructor
|
||||
add_vCtor
|
||||
(
|
||||
geometry,
|
||||
|
@ -102,48 +104,47 @@ public:
|
|||
dictionary
|
||||
);
|
||||
|
||||
//// - Methods
|
||||
// - Methods
|
||||
|
||||
auto getModel(real t)const
|
||||
{
|
||||
return motionModel_.getModel(t);
|
||||
}
|
||||
/// Obtain motion model at time t
|
||||
auto getModel(real t)const
|
||||
{
|
||||
return motionModel_.getModel(t);
|
||||
}
|
||||
|
||||
word motionModelTypeName()const override
|
||||
{
|
||||
return motionModel_.typeName();
|
||||
}
|
||||
/// TypeName / TypeInfo of motion model
|
||||
word motionModelTypeName()const override
|
||||
{
|
||||
return motionModel_.typeName();
|
||||
}
|
||||
|
||||
const int8Vector_HD& triMotionIndex()const override
|
||||
{
|
||||
return triMotionIndex_;
|
||||
}
|
||||
/// Access to motion model index of triangles
|
||||
const int8Vector_HD& triMotionIndex()const override
|
||||
{
|
||||
return triMotionIndex_;
|
||||
}
|
||||
|
||||
const int8Vector_HD& pointMotionIndex()const override
|
||||
{
|
||||
return pointMotionIndex_;
|
||||
}
|
||||
/// Access to motion model index of points
|
||||
const int8Vector_HD& pointMotionIndex()const override
|
||||
{
|
||||
return pointMotionIndex_;
|
||||
}
|
||||
|
||||
// - iterate
|
||||
bool beforeIteration() override {
|
||||
geometry::beforeIteration();
|
||||
return true;
|
||||
}
|
||||
/// Operations before each iteration
|
||||
bool beforeIteration() override;
|
||||
|
||||
bool iterate() override ;
|
||||
/// Iterate geometry one time step
|
||||
bool iterate() override ;
|
||||
|
||||
bool afterIteration() override {
|
||||
geometry::afterIteration();
|
||||
return true;
|
||||
}
|
||||
/// Operations after each iteration
|
||||
bool afterIteration() override;
|
||||
|
||||
|
||||
bool moveGeometry();
|
||||
/// Move geometry
|
||||
bool moveGeometry();
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
} // pFlow
|
||||
|
||||
#include "geometryMotion.cpp"
|
||||
|
||||
|
|
Loading…
Reference in New Issue