mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-08 03:07:03 +00:00
Motion models integrated into geometryMotion, stationaryWall is added
This commit is contained in:
@ -19,33 +19,41 @@ Licence:
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "geometry.hpp"
|
||||
#include "systemControl.hpp"
|
||||
#include "vocabs.hpp"
|
||||
|
||||
|
||||
bool pFlow::geometry::findPropertyId()
|
||||
bool pFlow::geometry::createPropertyId()
|
||||
{
|
||||
|
||||
int8Vector propId(0, surface().capacity(),RESERVE());
|
||||
propId.clear();
|
||||
|
||||
uint32 pId;
|
||||
ForAll(matI, materialName_)
|
||||
if(materialName_.size() != numSurfaces() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"number of subSurface and material names do not match"<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32Vector propId(
|
||||
"propId",
|
||||
surface().capacity(),
|
||||
surface().size(),
|
||||
RESERVE());
|
||||
|
||||
ForAll(i, materialName_)
|
||||
{
|
||||
uint32 pIdx =0;
|
||||
|
||||
if( !wallProperty_.nameToIndex( materialName_[matI], pId ) )
|
||||
if( !wallProperty_.nameToIndex(materialName_[i], pIdx) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"material name for the geometry is invalid: "<< materialName_[matI]<<endl;
|
||||
return false;
|
||||
fatalErrorInFunction<<
|
||||
"Property/material name is invalid "<<materialName_[i]<<
|
||||
". A list of valid names are \n"<< wallProperty_.materials()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 surfSize = surface().surfNumTriangles(matI);
|
||||
|
||||
for(int32 i=0; i<surfSize; i++)
|
||||
{
|
||||
propId.push_back(pId);
|
||||
}
|
||||
}
|
||||
|
||||
auto triRange = subSurfaceRange(i);
|
||||
propId.fill(triRange.start(), triRange.end(), pIdx);
|
||||
|
||||
}
|
||||
|
||||
propertyId_.assign(propId);
|
||||
|
||||
@ -59,77 +67,245 @@ pFlow::geometry::geometry
|
||||
const property& prop
|
||||
)
|
||||
:
|
||||
demGeometry(control),
|
||||
multiTriSurface
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
triSurfaceFile__,
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
&control.geometry()
|
||||
),
|
||||
demComponent
|
||||
(
|
||||
"geometry",
|
||||
control
|
||||
),
|
||||
wallProperty_(prop),
|
||||
geometryRepository_(control.geometry()),
|
||||
triSurface_(
|
||||
control.geometry().emplaceObject<multiTriSurface>(
|
||||
objectFile(
|
||||
"triSurface",
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
)
|
||||
)
|
||||
motionComponentName_
|
||||
(
|
||||
"motionComponentName",
|
||||
"motionComponentName"
|
||||
),
|
||||
materialName_
|
||||
(
|
||||
"materialName",
|
||||
"materialName"
|
||||
),
|
||||
propertyId_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"propertyId",
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
motionComponentName_(
|
||||
control.geometry().emplaceObject<wordField>(
|
||||
objectFile(
|
||||
"motionComponentName",
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
"motionNamesList"
|
||||
)
|
||||
*this,
|
||||
0u
|
||||
),
|
||||
contactForceWall_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"contactForcWall",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
materialName_(
|
||||
control.geometry().emplaceObject<wordField>(
|
||||
objectFile(
|
||||
"materialName",
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
"materialNamesList"
|
||||
)
|
||||
*this,
|
||||
zero3
|
||||
),
|
||||
normalStressWall_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"normalStressWall",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
propertyId_(
|
||||
control.geometry().emplaceObject<int8TriSurfaceField_D>(
|
||||
objectFile(
|
||||
"propertyId",
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_NEVER),
|
||||
surface(),
|
||||
0 ) ),
|
||||
contactForceWall_(
|
||||
control.geometry().emplaceObject<realx3TriSurfaceField_D>(
|
||||
objectFile(
|
||||
"contactForceWall",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS),
|
||||
surface(),
|
||||
zero3) ),
|
||||
stressWall_(
|
||||
control.geometry().emplaceObject<realx3TriSurfaceField_D>(
|
||||
objectFile(
|
||||
"stressWall",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS),
|
||||
surface(),
|
||||
zero3) )
|
||||
*this,
|
||||
zero3
|
||||
),
|
||||
shearStressWall_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"shearStressWall",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
*this,
|
||||
zero3
|
||||
)
|
||||
{
|
||||
|
||||
if(!findPropertyId())
|
||||
readWholeObject_ = false;
|
||||
if( !IOobject::readObject() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Error in reading from file "<<IOobject::path()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
readWholeObject_ = true;
|
||||
|
||||
if( this->numSurfaces() != motionComponentName_.size() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Number of surfaces is not equal to number of motion component names"<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
if(!createPropertyId())
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
pFlow::geometry::geometry
|
||||
(
|
||||
systemControl &control,
|
||||
const property &prop,
|
||||
multiTriSurface &surf,
|
||||
const wordVector &motionCompName,
|
||||
const wordVector &materialName,
|
||||
const dictionary& motionDict
|
||||
)
|
||||
:
|
||||
multiTriSurface
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
triSurfaceFile__,
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
&control.geometry(),
|
||||
surf
|
||||
),
|
||||
demComponent
|
||||
(
|
||||
"geometry",
|
||||
control
|
||||
),
|
||||
wallProperty_
|
||||
(
|
||||
prop
|
||||
),
|
||||
motionComponentName_
|
||||
(
|
||||
"motionComponentName",
|
||||
"motionComponentName"
|
||||
),
|
||||
materialName_
|
||||
(
|
||||
"materialName",
|
||||
"materialName"
|
||||
),
|
||||
propertyId_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"propertyId",
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
*this,
|
||||
0u
|
||||
),
|
||||
contactForceWall_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"contactForcWall",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
*this,
|
||||
zero3
|
||||
),
|
||||
normalStressWall_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"normalStressWall",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
*this,
|
||||
zero3
|
||||
),
|
||||
shearStressWall_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"shearStressWall",
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
*this,
|
||||
zero3
|
||||
)
|
||||
|
||||
{
|
||||
motionComponentName_.assign(motionCompName);
|
||||
materialName_.assign(materialName);
|
||||
|
||||
|
||||
if( this->numSurfaces() != motionComponentName_.size() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Number of surfaces is not equal to number of motion component names"<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
if(!createPropertyId())
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
bool pFlow::geometry::read(iIstream &is, const IOPattern &iop)
|
||||
{
|
||||
motionComponentName_.read(is, iop);
|
||||
materialName_.read(is, iop);
|
||||
|
||||
if( readWholeObject_ )
|
||||
{
|
||||
return multiTriSurface::read(is, iop);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::geometry::write(iOstream &os, const IOPattern &iop) const
|
||||
{
|
||||
|
||||
if( !motionComponentName_.write(os, iop) )
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !materialName_.write(os,iop))
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
return false;
|
||||
}
|
||||
|
||||
return multiTriSurface::write(os,iop);
|
||||
}
|
||||
|
||||
/*pFlow::geometry::geometry
|
||||
(
|
||||
systemControl& control,
|
||||
const property& prop,
|
||||
@ -296,23 +472,25 @@ bool pFlow::geometry::afterIteration()
|
||||
Kokkos::fence();
|
||||
return true;
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
pFlow::uniquePtr<pFlow::geometry>
|
||||
pFlow::geometry::create(
|
||||
systemControl& control,
|
||||
const property& prop,
|
||||
const dictionary& dict,
|
||||
const multiTriSurface& triSurface,
|
||||
const wordVector& motionCompName,
|
||||
const wordVector& propName)
|
||||
pFlow::geometry::create
|
||||
(
|
||||
systemControl& control,
|
||||
const property& prop,
|
||||
multiTriSurface& surf,
|
||||
const wordVector& motionCompName,
|
||||
const wordVector& materialName,
|
||||
const dictionary& motionDic
|
||||
)
|
||||
{
|
||||
|
||||
word model = dict.getVal<word>("motionModel");
|
||||
word model = motionDic.getVal<word>("motionModel");
|
||||
|
||||
auto geomModel = angleBracketsNames("geometry", model);
|
||||
|
||||
REPORT(1)<< "Selecting geometry model . . ."<<endREPORT;
|
||||
REPORT(1)<< "Selecting geometry model . . ."<<END_REPORT;
|
||||
|
||||
if( dictionaryvCtorSelector_.search(geomModel) )
|
||||
{
|
||||
@ -320,19 +498,19 @@ pFlow::uniquePtr<pFlow::geometry>
|
||||
(
|
||||
control,
|
||||
prop,
|
||||
dict,
|
||||
triSurface,
|
||||
surf,
|
||||
motionCompName,
|
||||
propName
|
||||
materialName,
|
||||
motionDic
|
||||
);
|
||||
REPORT(2)<<"Model "<< greenText(geomModel)<<" is created.\n"<<endREPORT;
|
||||
REPORT(2)<<"Model "<< Green_Text(geomModel)<<" is created.\n"<<END_REPORT;
|
||||
return objPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
printKeys
|
||||
(
|
||||
fatalError << "Ctor Selector "<< yellowText(geomModel) << " dose not exist. \n"
|
||||
fatalError << "Ctor Selector "<< Yellow_Text(geomModel) << " dose not exist. \n"
|
||||
<<"Avaiable ones are: \n\n"
|
||||
,
|
||||
dictionaryvCtorSelector_
|
||||
@ -340,4 +518,4 @@ pFlow::uniquePtr<pFlow::geometry>
|
||||
fatalExit;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -23,13 +23,14 @@ Licence:
|
||||
|
||||
|
||||
#include "virtualConstructor.hpp"
|
||||
#include "demGeometry.hpp"
|
||||
#include "demComponent.hpp"
|
||||
#include "property.hpp"
|
||||
#include "Fields.hpp"
|
||||
#include "Vectors.hpp"
|
||||
#include "multiTriSurface.hpp"
|
||||
#include "triSurfaceFields.hpp"
|
||||
#include "dictionary.hpp"
|
||||
//#include "Fields.hpp"
|
||||
//#include "Vectors.hpp"
|
||||
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
@ -42,47 +43,48 @@ namespace pFlow
|
||||
*/
|
||||
class geometry
|
||||
:
|
||||
public demGeometry
|
||||
public multiTriSurface,
|
||||
public demComponent
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
// - Protected members
|
||||
|
||||
/// Const reference to physical property of materials
|
||||
const property& wallProperty_;
|
||||
|
||||
/// Repository to store geometry data at each simulation moment
|
||||
repository& geometryRepository_;
|
||||
|
||||
/// All triangles in the set of wall surfaces
|
||||
multiTriSurface& triSurface_;
|
||||
|
||||
/// The name of motion component of each wall surface
|
||||
wordField& motionComponentName_;
|
||||
wordField_H motionComponentName_;
|
||||
|
||||
/// Material name of each wall surface
|
||||
wordField& materialName_;
|
||||
wordField_H materialName_;
|
||||
|
||||
/// Property id of each triangle in the set of wall surfaces
|
||||
int8TriSurfaceField_D& propertyId_;
|
||||
uint32TriSurfaceField_D propertyId_;
|
||||
|
||||
/// Contact force on each triangle in the set of wall surfaces
|
||||
realx3TriSurfaceField_D& contactForceWall_;
|
||||
realx3TriSurfaceField_D contactForceWall_;
|
||||
|
||||
/// Stress on ech triangle in the set of wall surfaces
|
||||
realx3TriSurfaceField_D& stressWall_;
|
||||
/// Stress on each triangle in the set of wall surfaces
|
||||
realx3TriSurfaceField_D normalStressWall_;
|
||||
|
||||
/// Stress on each triangle in the set of wall surfaces
|
||||
realx3TriSurfaceField_D shearStressWall_;
|
||||
|
||||
|
||||
bool readWholeObject_ = true;
|
||||
|
||||
// - 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();
|
||||
bool createPropertyId();
|
||||
|
||||
/// Initialize contact force to zero
|
||||
void zeroForce()
|
||||
/*void zeroForce()
|
||||
{
|
||||
contactForceWall_.fill(zero3);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
public:
|
||||
@ -95,8 +97,15 @@ public:
|
||||
/// Construct from controlSystem and property, for reading from file
|
||||
geometry(systemControl& control, const property& prop);
|
||||
|
||||
geometry(systemControl& control,
|
||||
const property& prop,
|
||||
multiTriSurface& surf,
|
||||
const wordVector& motionCompName,
|
||||
const wordVector& materialName,
|
||||
const dictionary& motionDict);
|
||||
|
||||
/// Construct from components
|
||||
geometry(systemControl& control,
|
||||
/*geometry(systemControl& control,
|
||||
const property& prop,
|
||||
const multiTriSurface& triSurface,
|
||||
const wordVector& motionCompName,
|
||||
@ -110,13 +119,13 @@ public:
|
||||
const dictionary& dict,
|
||||
const multiTriSurface& triSurface,
|
||||
const wordVector& motionCompName,
|
||||
const wordVector& propName);
|
||||
const wordVector& propName);*/
|
||||
|
||||
/// Destructor
|
||||
virtual ~geometry() = default;
|
||||
|
||||
/// Virtual constructor
|
||||
create_vCtor
|
||||
/*create_vCtor
|
||||
(
|
||||
geometry,
|
||||
systemControl,
|
||||
@ -125,37 +134,24 @@ public:
|
||||
const property& prop
|
||||
),
|
||||
(control, prop)
|
||||
);
|
||||
);*/
|
||||
|
||||
/// Virtual constructor
|
||||
create_vCtor
|
||||
(
|
||||
geometry,
|
||||
dictionary,
|
||||
(systemControl& control,
|
||||
const property& prop,
|
||||
const dictionary& dict,
|
||||
const multiTriSurface& triSurface,
|
||||
const wordVector& motionCompName,
|
||||
const wordVector& propName),
|
||||
(control, prop, dict, triSurface, motionCompName, propName)
|
||||
(
|
||||
systemControl& control,
|
||||
const property& prop,
|
||||
multiTriSurface& surf,
|
||||
const wordVector& motionCompName,
|
||||
const wordVector& materialName,
|
||||
const dictionary& motionDic),
|
||||
(control, prop, surf, motionCompName, materialName, motionDic)
|
||||
);
|
||||
|
||||
//- 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();
|
||||
}
|
||||
//- Methods
|
||||
|
||||
/// Number of triangles in the set of surface walls
|
||||
inline
|
||||
@ -165,39 +161,47 @@ public:
|
||||
}
|
||||
|
||||
/// Access to the points
|
||||
inline
|
||||
/*inline
|
||||
const auto& points()const
|
||||
{
|
||||
return triSurface_.points();
|
||||
}
|
||||
}*/
|
||||
|
||||
/// Access to the vertices
|
||||
inline
|
||||
/*inline
|
||||
const auto& vertices()const
|
||||
{
|
||||
return triSurface_.vertices();
|
||||
}
|
||||
}*/
|
||||
|
||||
/// Obtain an object for accessing triangles
|
||||
inline auto getTriangleAccessor()const
|
||||
/*inline auto getTriangleAccessor()const
|
||||
{
|
||||
return triSurface_.getTriangleAccessor();
|
||||
}*/
|
||||
|
||||
/// Surface
|
||||
inline
|
||||
auto& surface()
|
||||
{
|
||||
return static_cast<multiTriSurface&>(*this);
|
||||
}
|
||||
|
||||
/// Surface
|
||||
inline auto& surface()
|
||||
inline
|
||||
const auto& surface()const
|
||||
{
|
||||
return triSurface_;
|
||||
return static_cast<const multiTriSurface&>(*this);
|
||||
}
|
||||
|
||||
/// Surface
|
||||
inline const auto& surface()const
|
||||
inline
|
||||
const auto& motionComponentName()const
|
||||
{
|
||||
return triSurface_;
|
||||
return motionComponentName_;
|
||||
}
|
||||
|
||||
|
||||
/// Access to contact force
|
||||
inline
|
||||
/*inline
|
||||
realx3TriSurfaceField_D& contactForceWall()
|
||||
{
|
||||
return contactForceWall_;
|
||||
@ -214,34 +218,34 @@ public:
|
||||
inline const auto& wallProperty()const
|
||||
{
|
||||
return wallProperty_;
|
||||
}
|
||||
}*/
|
||||
|
||||
/// Owner repository
|
||||
inline
|
||||
/*inline
|
||||
const repository& owner()const
|
||||
{
|
||||
return geometryRepository_;
|
||||
}
|
||||
}*/
|
||||
|
||||
/// Owner repository
|
||||
inline
|
||||
/*inline
|
||||
repository& owner()
|
||||
{
|
||||
return geometryRepository_;
|
||||
}
|
||||
}*/
|
||||
|
||||
/// Path to the repository folder
|
||||
inline auto path()
|
||||
/*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
|
||||
/*virtual
|
||||
const int8Vector_HD& triMotionIndex() const =0;
|
||||
|
||||
/// Motion model index of points
|
||||
@ -252,36 +256,58 @@ public:
|
||||
const int8TriSurfaceField_D& propertyId() const
|
||||
{
|
||||
return propertyId_;
|
||||
}
|
||||
}*/
|
||||
|
||||
/// Operations before each iteration
|
||||
bool beforeIteration() override;
|
||||
//bool beforeIteration() override;
|
||||
|
||||
/// Operations after each iteration
|
||||
bool afterIteration() override;
|
||||
//bool afterIteration() override;
|
||||
|
||||
|
||||
bool beforeIteration() override
|
||||
{
|
||||
notImplementedFunction;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// This is called in time loop. Perform the main calculations
|
||||
/// when the component should evolve along time.
|
||||
bool iterate() override
|
||||
{
|
||||
notImplementedFunction;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// This is called in time loop, after iterate.
|
||||
bool afterIteration() override
|
||||
{
|
||||
notImplementedFunction;
|
||||
return true;
|
||||
}
|
||||
|
||||
//- IO
|
||||
|
||||
bool read(iIstream& is, const IOPattern& iop) override;
|
||||
|
||||
/// write
|
||||
bool write()const
|
||||
{
|
||||
return owner().write();
|
||||
}
|
||||
bool write( iOstream& os, const IOPattern& iop )const override;
|
||||
|
||||
|
||||
|
||||
//- Static members
|
||||
|
||||
static
|
||||
uniquePtr<geometry> create(systemControl& control, const property& prop);
|
||||
/*static
|
||||
uniquePtr<geometry> create(systemControl& control, const property& prop);*/
|
||||
|
||||
static
|
||||
uniquePtr<geometry> create(
|
||||
systemControl& control,
|
||||
const property& prop,
|
||||
const dictionary& dict,
|
||||
const multiTriSurface& triSurface,
|
||||
const wordVector& motionCompName,
|
||||
const wordVector& propName);
|
||||
systemControl& control,
|
||||
const property& prop,
|
||||
multiTriSurface& surf,
|
||||
const wordVector& motionCompName,
|
||||
const wordVector& materialName,
|
||||
const dictionary& motionDic);
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user