Motion models integrated into geometryMotion, stationaryWall is added

This commit is contained in:
Hamidreza Norouzi 2024-02-05 21:27:24 -08:00
parent 9dfe98eea2
commit 5b4a524afe
39 changed files with 1203 additions and 726 deletions

View File

@ -7,11 +7,13 @@ add_subdirectory(Property)
add_subdirectory(Particles)
add_subdirectory(Geometry)
#add_subdirectory(Interaction)
add_subdirectory(MotionModel)
#add_subdirectory(Geometry)
#add_subdirectory(MPIParallelization)

View File

@ -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;
}
}

View File

@ -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);
};

View File

@ -1,3 +1,4 @@
#include "geometryMotion.hpp"
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
@ -21,37 +22,49 @@ Licence:
template<typename MotionModel>
bool pFlow::geometryMotion<MotionModel>::findMotionIndex()
{
motionIndex_.clear();
triMotionIndex_.reserve( this->surface().capacity() );
triMotionIndex_.clear();
ForAll( surfI, motionComponentName_)
if(motionComponentName().size() != numSurfaces() )
{
auto mName = motionComponentName_[surfI];
auto mInd = motionModel_.nameToIndex(mName);
motionIndex_.push_back(mInd);
// fill motionIndex for triangles of the surface
int32 surfSize = this->surface().surfNumTriangles(surfI);
for(int32 i=0; i<surfSize; i++)
fatalErrorInFunction<<
"size of motion component names in the triSurface is not"<<
" equal to size of number of sub-surfaces"<<endl;
return false;
}
uint32Vector surfMotionIndex("surfMotionIndex");
uint32Vector triMotionIndex("triMotionIndex");
uint32Vector pointMotionIndex("pointMotionIndex");
ForAll( surfI, motionComponentName())
{
auto mName = motionComponentName()[surfI];
uint32 mInd=0;
if( !motionModel_.nameToIndex(mName, mInd) )
{
triMotionIndex_.push_back(mInd);
fatalErrorInFunction<<
mName<< " does not exist in the list of motion names -> "<<
motionModel_.componentNames();
}
surfMotionIndex.push_back(mInd);
auto surfRange = this->surface().subSurfaceRange(surfI);
for(uint32 i=0; i<surfRange.numElements(); i++)
{
triMotionIndex.push_back(mInd);
}
auto pointRange = this->surface().subSurfacePointRange(surfI);
for(uint32 n=0; n<pointRange.numElements(); n++)
{
pointMotionIndex.push_back(mInd);
}
}
motionIndex_.syncViews();
triMotionIndex_.syncViews();
pointMotionIndex_.reserve(triSurface_.numPoints());
pointMotionIndex_.clear();
ForAll(surfI, motionIndex_)
{
auto nP = triSurface_.surfNumPoints(surfI);
for(int32 i=0; i<nP; i++)
{
pointMotionIndex_.push_back(motionIndex_[surfI]);
}
}
pointMotionIndex_.syncViews();
surfMotionIndex_.assign(surfMotionIndex);
triMotionIndex_.assign(triMotionIndex);
pointMotionIndex_.assign(pointMotionIndex);
return true;
}
@ -65,144 +78,188 @@ pFlow::geometryMotion<MotionModel>::geometryMotion
)
:
geometry(control, prop),
motionModel_(
this->owner().template emplaceObject<MotionModel>(
objectFile(
motionModelFile__,
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS
)
)
motionModel_
(
objectFile
(
motionModelFile__,
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS
),
owner()
),
moveGeomTimer_("move geometry", &this->timers())
{
findMotionIndex();
}
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>
bool pFlow::geometryMotion<MotionModel>::iterate()
{
if( motionModel_.isMoving() )
if(!findMotionIndex())
{
moveGeomTimer_.start();
moveGeometry();
moveGeomTimer_.end();
fatalExit;
}
return true;
}
template<typename MotionModel>
bool pFlow::geometryMotion<MotionModel>::afterIteration()
template <typename MotionModelType>
pFlow::geometryMotion<MotionModelType>::geometryMotion
(
systemControl &control,
const property &prop,
multiTriSurface &surf,
const wordVector &motionCompName,
const wordVector &materialName,
const dictionary &motionDict
)
:
geometry
(
control,
prop,
surf,
motionCompName,
materialName,
motionDict
),
motionModel_
(
objectFile
(
motionModelFile__,
"",
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
),
motionDict,
owner()
),
moveGeomTimer_("move geometry", &this->timers())
{
geometry::afterIteration();
return true;
}
if(!findMotionIndex())
{
fatalExit;
}
}
template<typename MotionModel>
bool pFlow::geometryMotion<MotionModel>::moveGeometry()
{
/*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();
}
real dt = this->dt();
real t = this->currentTime();
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();
}
auto pointMIndex= pointMotionIndex_.deviceVector();
auto mModel = motionModel_.getModel(t);
realx3* points = triSurface_.pointsData_D();
auto numPoints = triSurface_.numPoints();
template<typename MotionModel>
bool pFlow::geometryMotion<MotionModel>::beforeIteration()
{
geometry::beforeIteration();
return true;
}
template<typename MotionModel>
bool pFlow::geometryMotion<MotionModel>::iterate()
{
if( motionModel_.isMoving() )
{
moveGeomTimer_.start();
moveGeometry();
moveGeomTimer_.end();
}
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::parallel_for(
"geometryMotion<MotionModel>::movePoints",
numPoints,
LAMBDA_HD(int32 i){
auto newPos = mModel.transferPoint(pointMIndex[i], points[i], dt);
points[i] = newPos;
});
Kokkos::fence();
Kokkos::fence();
// move the motion components
motionModel_.move(t,dt);
// move the motion components
motionModel_.move(t,dt);
// end of calculations
moveGeomTimer_.end();
// end of calculations
moveGeomTimer_.end();
return true;
}
return true;
}*/

View File

@ -20,9 +20,8 @@ Licence:
#ifndef __geometryMotion_hpp__
#define __geometryMotion_hpp__
#include "vocabs.hpp"
#include "geometry.hpp"
#include "VectorDuals.hpp"
namespace pFlow
{
@ -38,22 +37,22 @@ class geometryMotion
public geometry
{
public:
using MotionModel = MotionModelType;
protected:
using ModelComponent = typename MotionModelType::ModelComponent;
private:
/// Ref to motion model
MotionModel& motionModel_;
MotionModelType motionModel_;
/// motion indext mapped on each surface
int32Vector_HD motionIndex_;
uint32Field_D surfMotionIndex_{"triMotionIndex"};
/// motion index mapped on each triangle
int8Vector_HD triMotionIndex_;
uint32Field_D triMotionIndex_ {"surfMotionIndex"};
/// motion index mapped on each point
int8Vector_HD pointMotionIndex_;
uint32Field_D pointMotionIndex_{"pointMotionIndex"};
/// timer for moveGeometry
Timer moveGeomTimer_;
@ -64,37 +63,45 @@ protected:
public:
/// Type info
TypeInfoTemplate("geometry", MotionModel);
TypeInfoTemplate11("geometry", ModelComponent);
// - Constructors
geometryMotion(systemControl& control, const property& prop);
geometryMotion(
systemControl& control,
const property& prop,
multiTriSurface& surf,
const wordVector& motionCompName,
const wordVector& materialName,
const dictionary& motionDict);
/*geometryMotion(
systemControl& control,
const property& prop,
const multiTriSurface& triSurface,
const wordVector& motionCompName,
const wordVector& propName,
const MotionModel& motionModel);
const MotionModel& motionModel);*/
/// Construct from components and dictionary that contains
/// motionModel
geometryMotion(systemControl& control,
/*geometryMotion(systemControl& control,
const property& prop,
const dictionary& dict,
const multiTriSurface& triSurface,
const wordVector& motionCompName,
const wordVector& propName);
const wordVector& propName);*/
/// Add virtual constructor
add_vCtor
/*add_vCtor
(
geometry,
geometryMotion,
systemControl
);
);*/
/// Add virtual constructor
add_vCtor
@ -107,19 +114,19 @@ public:
// - Methods
/// Obtain motion model at time t
auto getModel(real t)const
/*auto getModel(real t)const
{
return motionModel_.getModel(t);
}
}*/
/// TypeName / TypeInfo of motion model
word motionModelTypeName()const override
/*word motionModelTypeName()const override
{
return motionModel_.typeName();
}
}*/
/// Access to motion model index of triangles
const int8Vector_HD& triMotionIndex()const override
/*const auto& triMotionIndex()const override
{
return triMotionIndex_;
}
@ -128,19 +135,19 @@ public:
const int8Vector_HD& pointMotionIndex()const override
{
return pointMotionIndex_;
}
}*/
/// Operations before each iteration
bool beforeIteration() override;
/*bool beforeIteration() override;
/// Iterate geometry one time step
bool iterate() override ;
/// Operations after each iteration
bool afterIteration() override;
bool afterIteration() override;*/
/// Move geometry
bool moveGeometry();
//bool moveGeometry();
};

View File

@ -22,22 +22,22 @@ Licence:
#define __geometryMotions_hpp__
#include "geometryMotion.hpp"
#include "fixedWall.hpp"
#include "stationaryWall.hpp"
#include "rotatingAxisMotion.hpp"
#include "multiRotatingAxisMotion.hpp"
//#include "multiRotatingAxisMotion.hpp"
#include "vibratingMotion.hpp"
namespace pFlow
{
typedef geometryMotion<vibratingMotion> vibratingMotionGeometry;
using vibratingMotionGeometry = geometryMotion<vibratingMotion>;
typedef geometryMotion<rotatingAxisMotion> rotationAxisMotionGeometry;
using rotationAxisMotionGeometry = geometryMotion<rotatingAxisMotion>;
typedef geometryMotion<multiRotatingAxisMotion> multiRotationAxisMotionGeometry;
//typedef geometryMotion<multiRotatingAxisMotion> multiRotationAxisMotionGeometry;
typedef geometryMotion<fixedWall> fixedGeometry;
typedef geometryMotion<stationaryWall> stationaryGeometry;

View File

@ -18,15 +18,15 @@ Licence:
-----------------------------------------------------------------------------*/
#include "fixedWall.hpp"
#include "stationaryWall.hpp"
#include "rotatingAxisMotion.hpp"
#include "multiRotatingAxisMotion.hpp"
//#include "multiRotatingAxisMotion.hpp"
#include "vibratingMotion.hpp"
template class pFlow::geometryMotion<pFlow::fixedWall>;
template class pFlow::geometryMotion<pFlow::stationaryWall>;
template class pFlow::geometryMotion<pFlow::rotatingAxisMotion>;
template class pFlow::geometryMotion<pFlow::multiRotatingAxisMotion>;
//template class pFlow::geometryMotion<pFlow::multiRotatingAxisMotion>;
template class pFlow::geometryMotion<pFlow::vibratingMotion>;

View File

@ -1,13 +1,16 @@
list(APPEND SourceFiles
entities/timeInterval/timeInterval.cpp
entities/rotatingAxis/rotatingAxis.cpp
rotatingAxisMotion/rotatingAxisMotion.cpp
entities/vibrating/vibrating.cpp
vibratingMotion/vibratingMotion.cpp
#fixedWall/fixedWall.cpp
stationaryWall/stationaryWall.cpp
entities/stationary/stationary.cpp
#entities/multiRotatingAxis/multiRotatingAxis.cpp
#multiRotatingAxisMotion/multiRotatingAxisMotion.cpp

View File

@ -149,7 +149,11 @@ protected:
bool impl_indexToName(uint32 i, word& name)const;
const wordList& impl_componentNames()const
{
return componentNames_;
}
bool impl_isMoving()const
{
return false;
@ -221,6 +225,11 @@ public:
{
return getModel().impl_indexToName(idx, name);
}
const wordList& componentNames()const
{
return getModel().impl_componentNames();
}
/// Are walls moving
bool isMoving()const

View File

@ -75,6 +75,8 @@ public:
// - Constructor
TypeInfoNV("rotatingAxis");
/// Empty constructor
FUNCTION_HD
rotatingAxis()=default;

View File

@ -0,0 +1,57 @@
/*------------------------------- 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 "stationary.hpp"
FUNCTION_H
pFlow::stationary::stationary(const dictionary& dict)
{
}
FUNCTION_H
bool pFlow::stationary::read(const dictionary& dict)
{
return true;
}
FUNCTION_H
bool pFlow::stationary::write(dictionary& dict) const
{
return true;
}
FUNCTION_H
bool pFlow::stationary::read(iIstream& is)
{
notImplementedFunction;
return true;
}
FUNCTION_H
bool pFlow::stationary::write(iOstream& os)const
{
return true;
}

View File

@ -0,0 +1,104 @@
/*------------------------------- 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.
-----------------------------------------------------------------------------*/
#ifndef __stationary_hpp__
#define __stationary_hpp__
#include "types.hpp"
#include "typeInfo.hpp"
#include "streams.hpp"
namespace pFlow
{
// forward
class dictionary;
/**
* stationary model for a wall
*
*/
class stationary
{
public:
TypeInfoNV("stationary");
FUNCTION_HD
stationary()=default;
FUNCTION_H
explicit stationary(const dictionary& dict);
FUNCTION_HD
stationary(const stationary&) = default;
stationary& operator=(const stationary&) = default;
INLINE_FUNCTION_HD
void setTime(real t)
{}
INLINE_FUNCTION_HD
realx3 linTangentialVelocityPoint(const realx3 &)const
{
return zero3;
}
INLINE_FUNCTION_HD
realx3 transferPoint(const realx3& p, real dt)
{
return p;
}
// - IO operation
FUNCTION_H
bool read(const dictionary& dict);
FUNCTION_H
bool write(dictionary& dict) const;
FUNCTION_H
bool read(iIstream& is);
FUNCTION_H
bool write(iOstream& os)const;
};
inline iOstream& operator <<(iOstream& os, const stationary& obj)
{
return os;
}
inline iIstream& operator >>(iIstream& is, stationary& obj)
{
return is;
}
}
#endif

View File

@ -94,6 +94,8 @@ private:
public:
TypeInfoNV("vibrating");
FUNCTION_HD
vibrating()=default;

View File

@ -1,110 +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 "fixedWall.hpp"
#include "dictionary.hpp"
#include "vocabs.hpp"
bool pFlow::fixedWall::readDictionary
(
const dictionary& dict
)
{
auto motionModel = dict.getVal<word>("motionModel");
if(motionModel != "fixedWall")
{
fatalErrorInFunction<<
" motionModel should be fixedWall, but found " << motionModel <<endl;
return false;
}
return true;
}
bool pFlow::fixedWall::writeDictionary
(
dictionary& dict
)const
{
dict.add("motionModel", "fixedWall");
auto& motionInfo = dict.subDictOrCreate("fixedWallInfo");
return true;
}
pFlow::fixedWall::fixedWall()
{}
pFlow::fixedWall::fixedWall
(
const dictionary& dict
)
{
if(! readDictionary(dict) )
{
fatalExit;
}
}
bool pFlow::fixedWall::read
(
iIstream& is
)
{
// create an empty file dictionary
dictionary motionInfo(motionModelFile__, true);
// read dictionary from stream
if( !motionInfo.read(is) )
{
ioErrorInFile(is.name(), is.lineNumber()) <<
" error in reading dictionray " << motionModelFile__ <<" from file. \n";
return false;
}
if( !readDictionary(motionInfo) ) return false;
return true;
}
bool pFlow::fixedWall::write
(
iOstream& os
)const
{
// create an empty file dictionary
dictionary motionInfo(motionModelFile__, true);
if( !writeDictionary(motionInfo))
{
return false;
}
if( !motionInfo.write(os) )
{
ioErrorInFile( os.name(), os.lineNumber() )<<
" error in writing dictionray to file. \n";
return false;
}
return true;
}

View File

@ -1,206 +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.
-----------------------------------------------------------------------------*/
#ifndef __fixedWall_hpp__
#define __fixedWall_hpp__
#include "types.hpp"
#include "typeInfo.hpp"
#include "Vectors.hpp"
#include "uniquePtr.hpp"
namespace pFlow
{
class dictionary;
/**
* Fixed wall motion model for walls
*
* This class is used for geometries that are fixed during simulation.
*
*
\verbatim
// In geometryDict file, this will defines fixed walls during simulation
...
motionModel fixedWall;
...
\endverbatim
*/
class fixedWall
{
public:
/** Motion model class to be passed to computational units/kernels for
* transfing points and returning velocities at various positions
*/
class Model
{
public:
INLINE_FUNCTION_HD
Model(){}
INLINE_FUNCTION_HD
Model(const Model&) = default;
INLINE_FUNCTION_HD
Model& operator=(const Model&) = default;
INLINE_FUNCTION_HD
realx3 pointVelocity(int32 n, const realx3 p)const
{
return 0.0;
}
INLINE_FUNCTION_HD
realx3 operator()(int32 n, const realx3& p)const
{
return 0.0;
}
INLINE_FUNCTION_HD
realx3 transferPoint(int32 n, const realx3 p, real dt)const
{
return p;
}
INLINE_FUNCTION_HD int32 numComponents()const
{
return 0;
}
};
protected:
/// Name
const word name_ = "none";
/// Read from a dictionary
bool readDictionary(const dictionary& dict);
/// write to a dictionary
bool writeDictionary(dictionary& dict)const;
public:
/// Type info
TypeInfoNV("fixedWall");
// - Constructors
/// Empty
fixedWall();
/// Constructor with dictionary
fixedWall(const dictionary& dict);
/// Copy constructor
fixedWall(const fixedWall&) = default;
/// Move constructor
fixedWall(fixedWall&&) = default;
/// Copy assignment
fixedWall& operator=(const fixedWall&) = default;
/// Move assignment
fixedWall& operator=(fixedWall&&) = default;
/// Destructor
~fixedWall() = default;
// - Methods
/// Return motion model
/// t is the current simulation time
Model getModel(real t)const
{
return Model();
}
/// Name of the motion component to index
int32 nameToIndex(const word& name)const
{
return 0;
}
/// Index of motion component to name
word indexToName(label i)const
{
return name_;
}
/// Velocity at point p
INLINE_FUNCTION_HD
realx3 pointVelocity(label n, const realx3& p)const
{
return zero3;
}
/// Transfer point p for dt seconds according to motion component n
INLINE_FUNCTION_HD
realx3 transferPoint(label n, const realx3 p, real dt)const
{
return p;
}
/// Transfer a vector of point pVec for dt seconds according to motion
/// component n
INLINE_FUNCTION_HD
bool transferPoint(label n, realx3* pVec, size_t numP, real dt)
{
return true;
}
/// Are walls moving
INLINE_FUNCTION_HD
bool isMoving()const
{
return false;
}
/// Move points
bool move(real t, real dt)
{
return true;
}
// - IO operations
/// Read from input stream is
FUNCTION_H
bool read(iIstream& is);
/// Write to output stream os
FUNCTION_H
bool write(iOstream& os)const;
};
} // pFlow
#endif //__fixed_hpp__

View File

@ -37,6 +37,22 @@ pFlow::rotatingAxisMotion::rotatingAxisMotion
}
}
pFlow::rotatingAxisMotion::rotatingAxisMotion
(
const objectFile &objf,
const dictionary &dict,
repository *owner
)
:
fileDictionary(objf, dict, owner)
{
if(! getModel().impl_readDictionary(*this) )
{
fatalErrorInFunction;
fatalExit;
}
}
bool pFlow::rotatingAxisMotion::write
(
iOstream &os,

View File

@ -70,12 +70,17 @@ protected:
public:
TypeInfo("rotatingAxisMotion");
TypeInfo("rotatingAxisMotion");
rotatingAxisMotion(const objectFile& objf, repository* owner);
rotatingAxisMotion(const objectFile& objf, repository* owner);
rotatingAxisMotion(
const objectFile& objf,
const dictionary& dict,
repository* owner);
bool write(iOstream& os, const IOPattern& iop)const override;
bool write(iOstream& os, const IOPattern& iop)const override;
static
auto noneComponent()

View File

@ -0,0 +1,75 @@
/*------------------------------- 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"
pFlow::stationaryWall::stationaryWall
(
const objectFile &objf,
repository *owner
)
:
fileDictionary(objf, owner)
{
if(! getModel().impl_readDictionary(*this) )
{
fatalErrorInFunction;
fatalExit;
}
}
pFlow::stationaryWall::stationaryWall
(
const objectFile &objf,
const dictionary &dict,
repository *owner
)
:
fileDictionary(objf, dict, owner)
{
if(! getModel().impl_readDictionary(*this) )
{
fatalErrorInFunction;
fatalExit;
}
}
bool pFlow::stationaryWall::write
(
iOstream &os,
const IOPattern &iop
) const
{
// a global dictionary
dictionary newDict(fileDictionary::dictionary::name(), true);
if( iop.thisProcWriteData() )
{
if( !this->impl_writeDictionary(newDict) ||
!newDict.write(os))
{
fatalErrorInFunction<<
" error in writing to dictionary "<< newDict.globalName()<<endl;
return false;
}
}
return true;
}

View File

@ -0,0 +1,69 @@
/*------------------------------- 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.
-----------------------------------------------------------------------------*/
#ifndef __stationaryWall_hpp__
#define __stationaryWall_hpp__
#include "MotionModel.hpp"
#include "stationary.hpp"
#include "fileDictionary.hpp"
namespace pFlow
{
class stationaryWall
:
public fileDictionary,
public MotionModel<stationaryWall, stationary>
{
protected:
bool impl_isMoving()const
{
return false;
}
public:
TypeInfo("stationaryWall");
stationaryWall(const objectFile& objf, repository* owner);
stationaryWall(
const objectFile& objf,
const dictionary& dict,
repository* owner);
bool write(iOstream& os, const IOPattern& iop)const override;
static
auto noneComponent()
{
return stationary();
}
};
} // pFlow
#endif // __stationaryWall_hpp__

View File

@ -14,6 +14,22 @@ pFlow::vibratingMotion::vibratingMotion
}
}
pFlow::vibratingMotion::vibratingMotion
(
const objectFile &objf,
const dictionary &dict,
repository *owner
)
:
fileDictionary(objf,dict,owner)
{
if(! getModel().impl_readDictionary(*this) )
{
fatalErrorInFunction;
fatalExit;
}
}
bool pFlow::vibratingMotion::write(iOstream &os, const IOPattern &iop) const
{
// a global dictionary

View File

@ -81,6 +81,11 @@ public:
vibratingMotion(const objectFile& objf, repository* owner);
vibratingMotion(
const objectFile& objf,
const dictionary& dict,
repository* owner);
/// Destructor
~vibratingMotion()override = default;

View File

@ -118,7 +118,10 @@ bool pFlow::Field<T, MemorySpace>::write
if(!VectorType::write(os, iop)) return false;
if(iop.thisProcWriteData())
{
os.endEntry();
os.newLine();
}
if(!os.check(FUNCTION_NAME))return false;

View File

@ -82,7 +82,11 @@ public:
VectorType()
{}
Field(const word& name)
:
VectorType(name)
{}
/// Construct an empty field with name and fieldKey
Field(const word& name, const word& fieldKey)
:

View File

@ -289,6 +289,9 @@ public:
// - fill the whole content of vector, [begin, end), with val
void fill( const T& val);
/// fill the content in range [start, end)
void fill( uint32 start, uint32 end, const T& val);
inline
auto getSpan()
{

View File

@ -1,3 +1,4 @@
#include "Vector.hpp"
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
@ -24,9 +25,17 @@ inline void pFlow::Vector<T, Allocator>::fill( const T& val)
std::fill(this->begin(), this->end(), val);
}
template <typename T, typename Allocator>
inline void pFlow::Vector<T, Allocator>::fill(uint32 start, uint32 end, const T &val)
{
for(uint32 i=start; i<end; i++)
{
this->at(i) = val;
}
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline void pFlow::Vector<T, Allocator>::operator +=( const T& val)
template < typename T, typename Allocator> inline void pFlow::Vector < T, Allocator> ::operator+= (const T &val)
{
for( auto& v:(*this) )
{

View File

@ -362,6 +362,7 @@ void pFlow::VectorSingle<T,MemorySpace>::fill
const T& val
)
{
changeSize(r.end());
pFlow::fill(view_, r, val);
}
@ -373,6 +374,7 @@ void pFlow::VectorSingle<T,MemorySpace>::assign
const T& val
)
{
if( n > capacity() )
{
reallocateCapacitySize(evalCapacity(n), n);
@ -392,11 +394,13 @@ void pFlow::VectorSingle<T,MemorySpace>::assign
uint32 cap
)
{
// make sure that vector has enough capacity
uint32 newCap = max(static_cast<uint32>(src.size()), cap);
uint32 srcSize = src.size();
if(cap != capacity())
if(newCap != capacity())
{
reallocateCapacitySize(cap, srcSize);
reallocateCapacitySize(newCap, srcSize);
}
else
{
@ -415,7 +419,7 @@ void pFlow::VectorSingle<T,MemorySpace>::assign
const std::vector<T>& src
)
{
assign(src, src.capacity());
assign(src, this->capacity());
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H

View File

@ -107,7 +107,39 @@ public:
return surface_;
}
inline
auto size()const
{
return field_.size();
}
inline
auto capacity()const
{
return field_.capacity();
}
inline
void assign(const std::vector<T>& vals)
{
if(vals.size() != surface_.size())
{
fatalErrorInFunction;
fatalExit;
}
field_.assign(vals, surface_.capacity());
}
bool hearChanges(
real t,
real dt,
uint32 iter,
const message& msg,
const anyList& varList) override
{
notImplementedFunction;
return false;
}
//// - IO operations
bool write(iOstream& is, const IOPattern& iop)const override;

View File

@ -29,30 +29,19 @@ Licence:
namespace pFlow
{
/*using realTriSurfaceField_D = triSurfaceField<VectorSingle, real> ;
using uint32TriSurfaceField_D = triSurfaceField<uint32> ;
using realTriSurfaceField_H = triSurfaceField<VectorSingle, real, HostSpace> ;
using uint32TriSurfaceField_H = triSurfaceField<uint32, HostSpace> ;
using realx3TriSurfaceField_D = triSurfaceField<VectorSingle, realx3> ;
using realTriSurfaceField_D = triSurfaceField<real> ;
using realx3TriSurfaceField_H = triSurfaceField<VectorSingle, realx3, HostSpace> ;
using realTriSurfaceField_H = triSurfaceField<real, HostSpace> ;
using realTriSurfaceField_HD = triSurfaceField<VectorDual, real> ;
using realx3TriSurfaceField_D = triSurfaceField<realx3> ;
using realx3TriSurfaceField_HD = triSurfaceField<VectorDual, realx3> ;
using realx3TriSurfaceField_H = triSurfaceField<realx3, HostSpace> ;
using realTriSurfaceField = triSurfaceField<Vector, real, vecAllocator<real>> ;
using realx3TriSurfaceField = triSurfaceField<Vector, realx3, vecAllocator<realx3>> ;
using int8TriSurfaceField_D = triSurfaceField<VectorSingle, int8> ;
using int8TriSurfaceField_H = triSurfaceField<VectorSingle, int8, HostSpace> ;
using int8TriSurfaceField_HD = triSurfaceField<VectorDual, int8> ;
using int8TriSurfaceField = triSurfaceField<Vector, int8, vecAllocator<real>> ;
*/
}

View File

@ -299,6 +299,13 @@ pFlow::dictionary::dictionary
}
pFlow::dictionary::dictionary(const dictionary &src, bool global)
:
dictionary(src)
{
isGlobal_ = global;
}
pFlow::dictionary& pFlow::dictionary::operator=
(
const dictionary& rhs

View File

@ -144,6 +144,8 @@ public:
/// entries_ are copied smoothly. set parrent dict to nullDict
dictionary(const dictionary& );
dictionary(const dictionary& src, bool global);
/// assignment preserve name of this dictionary
/// only entries are transfered with ownership

View File

@ -43,6 +43,30 @@ pFlow::fileDictionary::fileDictionary(const word &keyword, const fileSystem &fil
)
{}
pFlow::fileDictionary::fileDictionary
(
const objectFile &objf,
const dictionary &dict,
repository *owner
)
:
IOobject
(
objectFile
(
objf.name(),
objf.localPath(),
objectFile::READ_NEVER,
objf.wFlag()
),
IOPattern::AllProcessorsSimilar,
owner
),
dictionary(dict, true)
{
dictionary::name_ = IOobject::path().wordPath();
}
bool pFlow::fileDictionary::read(iIstream &is, const IOPattern &iop)
{
return dictionary::read(is);

View File

@ -41,7 +41,10 @@ public:
/// construct a dictionary with name and read it from file
fileDictionary(const word& keyword, const fileSystem& file);
fileDictionary(
const objectFile& objf,
const dictionary& dict,
repository* owner=nullptr);
/// read from stream
bool read(iIstream& is, const IOPattern& iop) override;

View File

@ -36,6 +36,9 @@ pFlow::IOobject::IOobject
if(owner_&& !owner->addToRepository(this))
{
fatalErrorInFunction<<
"failed to add object "<< objf.name()<<
" to repository "<< owner->name()<<endl;
fatalExit;
}
}

View File

@ -144,7 +144,7 @@ bool pFlow::repository::addToRepository(IOobject* io)
if( !objects_.insertIf(io->name(), io ) )
{
warningInFunction<<
"Failed to add repository " << io->name() <<
"Failed to add object " << io->name() <<
" to repository " << this->name() <<
". It is already in this repository. \n";
return false;

View File

@ -171,6 +171,20 @@ pFlow::multiTriSurface::multiTriSurface
}
}
pFlow::multiTriSurface::multiTriSurface
(
const objectFile &objf,
repository *owner,
const multiTriSurface &surf
)
:
triSurface(objf, owner, surf),
subscriber("multiTriSurface"),
subSurfaces_(surf.subSurfaces_)
{
}
bool pFlow::multiTriSurface::appendTriSurface
(
const word &name,
@ -193,8 +207,17 @@ bool pFlow::multiTriSurface::appendTriSurface
}
bool pFlow::multiTriSurface::read(iIstream &is, const IOPattern &iop)
{
return false;
{
subSurfaces_.clear();
if( !is.findKeywordAndVal("subSurfaces", subSurfaces_ ) )
{
fatalErrorInFunction<<
"Error in reading subSurfaces from stream "<< is.name()<<endl;
return false;
}
return triSurface::read(is, iop);
}
bool pFlow::multiTriSurface::write
@ -203,6 +226,8 @@ bool pFlow::multiTriSurface::write
const IOPattern &iop
) const
{
if( iop.thisProcWriteData() )
{
os.writeWordEntry("subSurfaces", subSurfaces_);

View File

@ -53,6 +53,11 @@ public:
//
multiTriSurface(const objectFile& obj, repository* owner);
multiTriSurface(
const objectFile& objf,
repository* owner,
const multiTriSurface& surf);
multiTriSurface(const multiTriSurface&) = default;
multiTriSurface& operator = (const multiTriSurface&) = default;
@ -78,6 +83,29 @@ public:
{
return subSurfaces_;
}
rangeU32 subSurfaceRange(uint32 nSub)
{
if( !(nSub < numSurfaces() ) )
{
fatalErrorInFunction;
fatalExit;
}
return {subSurfaces_[nSub].start(),subSurfaces_[nSub].end()};
}
rangeU32 subSurfacePointRange(uint32 nSub)const
{
if( !(nSub < numSurfaces() ) )
{
fatalErrorInFunction;
fatalExit;
}
return {
subSurfaces_[nSub].pointStart(),
subSurfaces_[nSub].pointEnd()};
}
/*void clear()
{
triSurface::clear();

View File

@ -126,26 +126,44 @@ pFlow::triSurface::triSurface
pFlow::triSurface::triSurface
(
const realx3x3Field_H &triangles,
repository* owner
const objectFile &objf,
repository* owner,
const triSurface &surf
)
:
IOobject
(
objectFile
(
triangles.name(),
"",
IOobject::READ_NEVER,
IOobject::WRITE_ALWAYS
objf.name(),
objf.localPath(),
objectFile::READ_NEVER,
objf.wFlag()
),
IOPattern::AllProcessorsSimilar,
owner
),
points_("points", "points"),
vertices_("vertices", "vertices"),
area_("area", "area"),
normals_("normals","normals")
points_(surf.points_),
vertices_(surf.vertices_),
area_(surf.area_),
normals_(surf.normals_)
{}
pFlow::triSurface::triSurface(
const realx3x3Field_H &triangles,
repository *owner)
: IOobject(
objectFile(
triangles.name(),
"",
IOobject::READ_NEVER,
IOobject::WRITE_ALWAYS),
IOPattern::AllProcessorsSimilar,
owner),
points_("points", "points"),
vertices_("vertices", "vertices"),
area_("area", "area"),
normals_("normals", "normals")
{
if( !appendTriSurface(triangles) )
{
@ -238,6 +256,8 @@ bool pFlow::triSurface::read(iIstream &is, const IOPattern &iop)
" when reading field "<< vertices_.name()<<endl;
return false;
}
WARNING<<"You should calculate area and normal after reading "<<END_WARNING;
return true;
}

View File

@ -62,6 +62,11 @@ public:
// - type info
TypeInfo("triSurface");
triSurface(
const objectFile& objf,
repository* owner,
const triSurface& surf);
//// - Constructors
// - construct from vertices of triangles

View File

@ -145,10 +145,9 @@ namespace pFlow
#define TypeInfoTemplate11(tName, Type) \
has_static_member(TYPENAME); \
inline static word TYPENAME() \
{ \
return word(tName)+"<"+getTypeName<Type1>()+">"; \
return word(tName)+"<"+getTypeName<Type>()+">"; \
} \
virtual word typeName() const { return TYPENAME();}