phasicFlow/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp

148 lines
3.7 KiB
C++
Raw Normal View History

2022-09-04 21:26:29 +00:00
/*------------------------------- 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.
-----------------------------------------------------------------------------*/
2022-12-09 22:02:54 +00:00
#include "dynamicPointStructure.hpp"
2024-01-21 21:26:23 +00:00
#include "systemControl.hpp"
2022-09-04 21:26:29 +00:00
2025-01-20 17:32:50 +00:00
2022-09-04 21:26:29 +00:00
pFlow::dynamicPointStructure::dynamicPointStructure
(
systemControl& control,
real maxBSphere
2022-09-04 21:26:29 +00:00
)
:
pointStructure(control, maxBSphere),
2024-01-21 21:26:23 +00:00
velocity_
(
objectFile(
"velocity",
"",
objectFile::READ_ALWAYS,
objectFile::WRITE_ALWAYS
),
*this,
zero3
),
acceleration_(
objectFile(
"acceleration",
"",
objectFile::READ_IF_PRESENT,
objectFile::WRITE_ALWAYS
),
*this,
zero3
),
velocityUpdateTimer_("velocity boundary update", &timers()),
2024-01-21 21:26:23 +00:00
integrationMethod_
(
control.settingsDict().getVal<word>("integrationMethod")
)
2022-09-04 21:26:29 +00:00
{
REPORT(1)<< "Creating integration method "<<
2024-01-21 21:26:23 +00:00
Green_Text(integrationMethod_)<<" for dynamicPointStructure."<<END_REPORT;
2022-09-04 21:26:29 +00:00
2024-01-21 21:26:23 +00:00
integrationPos_ = integration::create
(
2022-09-04 21:26:29 +00:00
"pStructPosition",
2024-01-21 21:26:23 +00:00
*this,
integrationMethod_,
velocity_.field()
2024-01-21 21:26:23 +00:00
);
2022-09-04 21:26:29 +00:00
if( !integrationPos_ )
{
fatalErrorInFunction<<
" error in creating integration object for dynamicPointStructure (position). \n";
fatalExit;
}
2024-01-21 21:26:23 +00:00
integrationVel_ = integration::create
(
"pStructVelocity",
*this,
integrationMethod_,
acceleration_.field()
2024-01-21 21:26:23 +00:00
);
2022-09-04 21:26:29 +00:00
if( !integrationVel_ )
{
fatalErrorInFunction<<
" error in creating integration object for dynamicPointStructure (velocity). \n";
fatalExit;
}
2025-01-20 17:32:50 +00:00
REPORT(1)<<"Reading globalDamping dictionary ..."<<END_REPORT;
velDamping_ = makeUnique<globalDamping>(control);
2022-09-04 21:26:29 +00:00
}
bool pFlow::dynamicPointStructure::beforeIteration()
{
if(!pointStructure::beforeIteration())return false;
velocityUpdateTimer_.start();
velocity_.updateBoundariesSlaveToMasterIfRequested();
acceleration_.updateBoundariesSlaveToMasterIfRequested();
2024-10-18 19:43:20 +00:00
integrationPos_->updateBoundariesSlaveToMasterIfRequested();
integrationVel_->updateBoundariesSlaveToMasterIfRequested();
velocityUpdateTimer_.end();
return true;
}
bool pFlow::dynamicPointStructure::iterate()
{
return pointStructure::iterate();
/*real dt = this->dt();
auto& acc = time().lookupObject<realx3PointField_D>("acceleration");
return correct(dt, acc);*/
}
2025-01-20 17:32:50 +00:00
bool pFlow::dynamicPointStructure::afterIteration()
{
//const auto ti = TimeInfo();
auto succs = pointStructure::afterIteration();
//velDamping_().applyDamping(ti, velocity_);
return succs;
}
bool pFlow::dynamicPointStructure::predict(real dt)
{
if(!integrationPos_().predict(dt, pointPosition(), velocity_ ))return false;
if(!integrationVel_().predict(dt, velocity_, acceleration_))return false;
2022-09-04 21:26:29 +00:00
return true;
}
bool pFlow::dynamicPointStructure::correct(real dt)
2022-09-04 21:26:29 +00:00
{
const auto& ti = TimeInfo();
2022-09-04 21:26:29 +00:00
2024-10-18 19:43:20 +00:00
if(!integrationPos_().correctPStruct(dt, *this, velocity_) )return false;
if(!integrationVel_().correct(dt, velocity_, acceleration_, velDamping_().dampingFactor(ti)))return false;
2022-09-04 21:26:29 +00:00
return true;
}