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(
"propId",
surface().capacity(),
surface().size(),
capacity(),
size(),
RESERVE());
ForAll(i, materialName_)
@ -61,6 +61,11 @@ bool pFlow::geometry::createPropertyId()
}
void pFlow::geometry::zeroForce()
{
contactForceWall_.fill(zero3);
}
pFlow::geometry::geometry
(
systemControl& control,
@ -84,16 +89,6 @@ pFlow::geometry::geometry
control
),
wallProperty_(prop),
motionComponentName_
(
"motionComponentName",
"motionComponentName"
),
materialName_
(
"materialName",
"materialName"
),
propertyId_
(
objectFile
@ -197,16 +192,6 @@ pFlow::geometry::geometry
(
prop
),
motionComponentName_
(
"motionComponentName",
"motionComponentName"
),
materialName_
(
"materialName",
"materialName"
),
propertyId_
(
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)
{
motionComponentName_.read(is, iop);
materialName_.read(is, iop);
if( readWholeObject_ )
@ -305,6 +328,93 @@ bool pFlow::geometry::write(iOstream &os, const IOPattern &iop) const
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
(
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()
{
@ -473,49 +538,3 @@ bool pFlow::geometry::afterIteration()
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_;
/// The name of motion component of each wall surface
wordField_H motionComponentName_;
wordField_H motionComponentName_{
"motionComponentName",
"motionComponentName"};
/// 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
uint32TriSurfaceField_D propertyId_;
@ -81,12 +85,8 @@ private:
bool createPropertyId();
/// Initialize contact force to zero
/*void zeroForce()
{
contactForceWall_.fill(zero3);
}*/
void zeroForce();
public:
/// Type info
@ -122,10 +122,10 @@ public:
const wordVector& propName);*/
/// Destructor
virtual ~geometry() = default;
~geometry()override = default;
/// Virtual constructor
/*create_vCtor
create_vCtor
(
geometry,
systemControl,
@ -134,7 +134,7 @@ public:
const property& prop
),
(control, prop)
);*/
);
/// Virtual constructor
create_vCtor
@ -152,48 +152,6 @@ public:
);
//- 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
const auto& motionComponentName()const
{
@ -201,91 +159,54 @@ public:
}
/// Access to contact force
/*inline
realx3TriSurfaceField_D& contactForceWall()
inline
auto& contactForceWall()
{
return contactForceWall_;
}
/// Access to contact force
inline
const realx3TriSurfaceField_D& contactForceWall() const
const auto& contactForceWall() const
{
return contactForceWall_;
}
/// Property ide of triangles
inline
const auto& propertyId()const
{
return propertyId_;
}
/// Access to property
inline const auto& wallProperty()const
{
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
/*virtual
word motionModelTypeName()const = 0;*/
virtual
word motionModelTypeName()const = 0;
/// Motion model index of triangles
/*virtual
const int8Vector_HD& triMotionIndex() const =0;
virtual
const uint32Field_D& 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_;
}*/
/// Operations before each iteration
//bool beforeIteration() override;
/// Operations after each iteration
//bool afterIteration() override;
const uint32Field_D& pointMotionIndex()const = 0;
bool beforeIteration() override
{
notImplementedFunction;
return true;
}
bool beforeIteration() override;
/// This is called in time loop. Perform the main calculations
/// when the component should evolve along time.
bool iterate() override
{
notImplementedFunction;
return true;
}
bool iterate() override;
/// This is called in time loop, after iterate.
bool afterIteration() override
{
notImplementedFunction;
return true;
}
bool afterIteration() override;
//- IO
bool read(iIstream& is, const IOPattern& iop) override;
@ -297,8 +218,10 @@ public:
//- Static members
/*static
uniquePtr<geometry> create(systemControl& control, const property& prop);*/
static
uniquePtr<geometry> create(
systemControl& control,
const property& prop);
static
uniquePtr<geometry> create(