mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-08 03:07:03 +00:00
refactor up to particles.hpp
This commit is contained in:
@ -19,57 +19,40 @@ Licence:
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "dynamicPointStructure.hpp"
|
||||
|
||||
#include "systemControl.hpp"
|
||||
|
||||
pFlow::dynamicPointStructure::dynamicPointStructure
|
||||
(
|
||||
Time& time,
|
||||
const word& integrationMethod
|
||||
systemControl& control
|
||||
)
|
||||
:
|
||||
time_(time),
|
||||
integrationMethod_(integrationMethod),
|
||||
pStruct_(
|
||||
time_.emplaceObject<pointStructure>(
|
||||
objectFile(
|
||||
pointStructureFile__,
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
)
|
||||
)
|
||||
),
|
||||
velocity_(
|
||||
time_.emplaceObject<realx3PointField_D>(
|
||||
objectFile(
|
||||
"velocity",
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct(),
|
||||
zero3
|
||||
)
|
||||
)
|
||||
|
||||
pointStructure(control),
|
||||
velocity_
|
||||
(
|
||||
objectFile(
|
||||
"velocity",
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
*this,
|
||||
zero3
|
||||
),
|
||||
integrationMethod_
|
||||
(
|
||||
control.settingsDict().getVal<word>("integrationMethod")
|
||||
)
|
||||
{
|
||||
|
||||
this->subscribe(pStruct());
|
||||
|
||||
REPORT(1)<< "Creating integration method "<<
|
||||
greenText(integrationMethod_)<<" for dynamicPointStructure."<<endREPORT;
|
||||
Green_Text(integrationMethod_)<<" for dynamicPointStructure."<<END_REPORT;
|
||||
|
||||
integrationPos_ = integration::create(
|
||||
integrationPos_ = integration::create
|
||||
(
|
||||
"pStructPosition",
|
||||
time_.integration(),
|
||||
pStruct(),
|
||||
integrationMethod_);
|
||||
|
||||
integrationVel_ = integration::create(
|
||||
"pStructVelocity",
|
||||
time_.integration(),
|
||||
pStruct(),
|
||||
integrationMethod_);
|
||||
*this,
|
||||
integrationMethod_,
|
||||
pointPosition()
|
||||
);
|
||||
|
||||
if( !integrationPos_ )
|
||||
{
|
||||
@ -77,6 +60,14 @@ pFlow::dynamicPointStructure::dynamicPointStructure
|
||||
" error in creating integration object for dynamicPointStructure (position). \n";
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
integrationVel_ = integration::create
|
||||
(
|
||||
"pStructVelocity",
|
||||
*this,
|
||||
integrationMethod_,
|
||||
velocity_.field()
|
||||
);
|
||||
|
||||
if( !integrationVel_ )
|
||||
{
|
||||
@ -85,8 +76,10 @@ pFlow::dynamicPointStructure::dynamicPointStructure
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
|
||||
WARNING << "Initialization of integrationPos_ and integrationVel_ should be doen!"<<END_WARNING;
|
||||
|
||||
if(!integrationPos_->needSetInitialVals()) return;
|
||||
/*if(!integrationPos_->needSetInitialVals()) return;
|
||||
|
||||
|
||||
|
||||
@ -107,14 +100,13 @@ pFlow::dynamicPointStructure::dynamicPointStructure
|
||||
vel.push_back( hVel[index(i)]);
|
||||
}
|
||||
|
||||
//output<< "pos "<< pos<<endl;
|
||||
//output<< "vel "<< vel<<endl;
|
||||
|
||||
REPORT(2)<< "Initializing the required vectors for position integratoin "<<endREPORT;
|
||||
integrationPos_->setInitialVals(indexHD, pos);
|
||||
|
||||
REPORT(2)<< "Initializing the required vectors for velocity integratoin\n "<<endREPORT;
|
||||
integrationVel_->setInitialVals(indexHD, vel);
|
||||
integrationVel_->setInitialVals(indexHD, vel);*/
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::dynamicPointStructure::predict
|
||||
@ -123,10 +115,10 @@ bool pFlow::dynamicPointStructure::predict
|
||||
realx3PointField_D& acceleration
|
||||
)
|
||||
{
|
||||
auto& pos = pStruct().pointPosition();
|
||||
//auto& pos = pStruct().pointPosition();
|
||||
|
||||
if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false;
|
||||
if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
|
||||
//if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false;
|
||||
//if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -137,11 +129,11 @@ bool pFlow::dynamicPointStructure::correct
|
||||
realx3PointField_D& acceleration
|
||||
)
|
||||
{
|
||||
auto& pos = pStruct().pointPosition();
|
||||
//auto& pos = pStruct().pointPosition();
|
||||
|
||||
if(!integrationPos_().correct(dt, pos.VectorField(), velocity_.VectorField() ))return false;
|
||||
//if(!integrationPos_().correct(dt, pos.VectorField(), velocity_.VectorField() ))return false;
|
||||
|
||||
if(!integrationVel_().correct(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
|
||||
//if(!integrationVel_().correct(dt, velocity_.VectorField(), acceleration.VectorField()))return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -178,7 +170,7 @@ pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::dynamicPointStructure::inser
|
||||
}*/
|
||||
|
||||
|
||||
bool pFlow::dynamicPointStructure::update(
|
||||
/*bool pFlow::dynamicPointStructure::update(
|
||||
const eventMessage& msg)
|
||||
{
|
||||
if( msg.isInsert())
|
||||
@ -215,4 +207,4 @@ bool pFlow::dynamicPointStructure::update(
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
@ -30,98 +30,65 @@ Licence:
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class systemControl;
|
||||
|
||||
class dynamicPointStructure
|
||||
:
|
||||
//public pointStructure
|
||||
public eventObserver
|
||||
public pointStructure
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
Time& time_;
|
||||
realx3PointField_D velocity_;
|
||||
|
||||
word integrationMethod_;
|
||||
uniquePtr<integration> integrationPos_ = nullptr;
|
||||
|
||||
pointStructure& pStruct_;
|
||||
uniquePtr<integration> integrationVel_ = nullptr;
|
||||
|
||||
realx3PointField_D& velocity_;
|
||||
|
||||
uniquePtr<integration> integrationPos_;
|
||||
|
||||
uniquePtr<integration> integrationVel_;
|
||||
/// @brief integration method for velocity and position
|
||||
word integrationMethod_;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("dynamicPointStructure");
|
||||
|
||||
dynamicPointStructure(Time& time, const word& integrationMethod);
|
||||
|
||||
dynamicPointStructure(const dynamicPointStructure& ps) = default;
|
||||
dynamicPointStructure(systemControl& control);
|
||||
|
||||
dynamicPointStructure(const dynamicPointStructure& ps) = delete;
|
||||
|
||||
// - no move construct
|
||||
// - no move construct
|
||||
dynamicPointStructure(dynamicPointStructure&&) = delete;
|
||||
|
||||
// - copy assignment
|
||||
//
|
||||
// should be changed, may causs undefined behavior
|
||||
//////////////////////////////////////////////////////////////
|
||||
dynamicPointStructure& operator=(const dynamicPointStructure&) = default;
|
||||
///
|
||||
dynamicPointStructure& operator=(const dynamicPointStructure&) = delete;
|
||||
|
||||
// - no move assignment
|
||||
dynamicPointStructure& operator=(dynamicPointStructure&&) = delete;
|
||||
|
||||
// - destructor
|
||||
virtual ~dynamicPointStructure() = default;
|
||||
~dynamicPointStructure() override = default;
|
||||
|
||||
|
||||
inline pointStructure& pStruct()
|
||||
{
|
||||
return pStruct_;
|
||||
}
|
||||
|
||||
inline const pointStructure& pStruct() const
|
||||
{
|
||||
return pStruct_;
|
||||
}
|
||||
|
||||
inline const realx3PointField_D& velocity()const
|
||||
inline
|
||||
const realx3PointField_D& velocity()const
|
||||
{
|
||||
return velocity_;
|
||||
}
|
||||
|
||||
inline auto velocityHostAll()
|
||||
inline
|
||||
realx3PointField_D& velocity()
|
||||
{
|
||||
return velocity_;
|
||||
}
|
||||
|
||||
/*inline auto velocityHostAll()
|
||||
{
|
||||
return velocity_.hostVectorAll();
|
||||
}
|
||||
|
||||
inline auto pointPositionHostAll()
|
||||
{
|
||||
return pStruct_.pointPositionHostAll();
|
||||
}
|
||||
|
||||
auto markDeleteOutOfBox(const box& domain)
|
||||
{
|
||||
return pStruct_.markDeleteOutOfBox(domain);
|
||||
}
|
||||
}*/
|
||||
|
||||
bool predict(real dt, realx3PointField_D& acceleration);
|
||||
|
||||
bool correct(real dt, realx3PointField_D& acceleration);
|
||||
|
||||
|
||||
// - update data structure by inserting/setting new points
|
||||
// Notifies all the fields in the registered list of data structure
|
||||
// and exclude the fields that re in the exclusionList
|
||||
// retrun nullptr if it fails
|
||||
/*FUNCTION_H
|
||||
virtual uniquePtr<int32IndexContainer> insertPoints(
|
||||
const realx3Vector& pos,
|
||||
const List<eventObserver*>& exclusionList={nullptr}
|
||||
)override;*/
|
||||
|
||||
bool update(const eventMessage& msg) override;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user