mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +00:00
This is the first merge from main into MPI branch
Merge branch 'main' into local-MPI
This commit is contained in:
@ -37,7 +37,8 @@ bool intAllActive(
|
||||
real dt,
|
||||
realx3Field_D& y,
|
||||
realx3PointField_D& dy,
|
||||
realx3PointField_D& dy1)
|
||||
realx3PointField_D& dy1,
|
||||
real damping = 1.0)
|
||||
{
|
||||
|
||||
auto d_dy = dy.deviceView();
|
||||
@ -49,7 +50,7 @@ bool intAllActive(
|
||||
"AdamsBashforth2::correct",
|
||||
rpIntegration (activeRng.start(), activeRng.end()),
|
||||
LAMBDA_HD(uint32 i){
|
||||
d_y[i] += dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i]);
|
||||
d_y[i] += damping * dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i]);
|
||||
d_dy1[i] = d_dy[i];
|
||||
});
|
||||
Kokkos::fence();
|
||||
@ -62,7 +63,8 @@ bool intScattered
|
||||
real dt,
|
||||
realx3Field_D& y,
|
||||
realx3PointField_D& dy,
|
||||
realx3PointField_D& dy1
|
||||
realx3PointField_D& dy1,
|
||||
real damping = 1.0
|
||||
)
|
||||
{
|
||||
|
||||
@ -78,7 +80,7 @@ bool intScattered
|
||||
LAMBDA_HD(uint32 i){
|
||||
if( activeP(i))
|
||||
{
|
||||
d_y[i] += dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i]);
|
||||
d_y[i] += damping * dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i]);
|
||||
d_dy1[i] = d_dy[i];
|
||||
}
|
||||
});
|
||||
@ -90,17 +92,16 @@ bool intScattered
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
pFlow::AdamsBashforth2::AdamsBashforth2
|
||||
(
|
||||
const word& baseName,
|
||||
pointStructure& pStruct,
|
||||
const word& method,
|
||||
const realx3Field_D& initialValField
|
||||
const realx3Field_D& initialValField,
|
||||
bool keepHistory
|
||||
)
|
||||
:
|
||||
integration(baseName, pStruct, method, initialValField),
|
||||
integration(baseName, pStruct, method, initialValField, keepHistory),
|
||||
realx3PointField_D
|
||||
(
|
||||
objectFile
|
||||
@ -108,20 +109,27 @@ pFlow::AdamsBashforth2::AdamsBashforth2
|
||||
groupNames(baseName,"dy1"),
|
||||
pStruct.time().integrationFolder(),
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
keepHistory?objectFile::WRITE_ALWAYS:objectFile::WRITE_NEVER
|
||||
),
|
||||
pStruct,
|
||||
zero3,
|
||||
zero3
|
||||
)
|
||||
{}
|
||||
),
|
||||
initialValField_(initialValField),
|
||||
boundaryList_(pStruct, method, *this)
|
||||
{
|
||||
realx3PointField_D::addEvent(message::ITEMS_INSERT);
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth2::predict
|
||||
(
|
||||
real UNUSED(dt),
|
||||
realx3PointField_D& UNUSED(y),
|
||||
realx3PointField_D& UNUSED(dy)
|
||||
)
|
||||
void pFlow::AdamsBashforth2::updateBoundariesSlaveToMasterIfRequested()
|
||||
{
|
||||
realx3PointField_D::updateBoundariesSlaveToMasterIfRequested();
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth2::predict(
|
||||
real UNUSED(dt),
|
||||
realx3PointField_D &UNUSED(y),
|
||||
realx3PointField_D &UNUSED(dy))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -140,31 +148,63 @@ bool pFlow::AdamsBashforth2::correct
|
||||
(
|
||||
real dt,
|
||||
realx3PointField_D& y,
|
||||
realx3PointField_D& dy
|
||||
realx3PointField_D& dy,
|
||||
real damping
|
||||
)
|
||||
{
|
||||
return correct(dt, y.field(), dy);
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth2::correct(real dt, realx3Field_D &y, realx3PointField_D &dy)
|
||||
{
|
||||
auto& dy1l = dy1();
|
||||
|
||||
bool success = false;
|
||||
if(dy1l.isAllActive())
|
||||
{
|
||||
return intAllActive(dt, y, dy, dy1l);
|
||||
success = intAllActive(dt, y.field(), dy, dy1(), damping);
|
||||
}
|
||||
else
|
||||
{
|
||||
return intScattered(dt, y, dy, dy1l);
|
||||
success = intScattered(dt, y.field(), dy, dy1(), damping);
|
||||
}
|
||||
return false;
|
||||
|
||||
success = success && boundaryList_.correct(dt, y, dy);
|
||||
|
||||
return success;
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth2::setInitialVals(
|
||||
const int32IndexContainer& newIndices,
|
||||
const realx3Vector& y)
|
||||
bool pFlow::AdamsBashforth2::correctPStruct(
|
||||
real dt,
|
||||
pointStructure &pStruct,
|
||||
realx3PointField_D &vel)
|
||||
{
|
||||
return true;
|
||||
auto& dy1l = dy1();
|
||||
bool success = false;
|
||||
if(dy1l.isAllActive())
|
||||
{
|
||||
success = intAllActive(dt, pStruct.pointPosition(), vel, dy1());
|
||||
}
|
||||
else
|
||||
{
|
||||
success = intScattered(dt, pStruct.pointPosition(), vel, dy1());
|
||||
}
|
||||
|
||||
success = success && boundaryList_.correctPStruct(dt, pStruct, vel);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/*bool pFlow::AdamsBashforth2::hearChanges
|
||||
(
|
||||
const timeInfo &ti,
|
||||
const message &msg,
|
||||
const anyList &varList
|
||||
)
|
||||
{
|
||||
if(msg.equivalentTo(message::ITEMS_INSERT))
|
||||
{
|
||||
|
||||
return insertValues(varList, initialValField_.deviceViewAll(), dy1());
|
||||
}
|
||||
else
|
||||
{
|
||||
return realx3PointField_D::hearChanges(ti, msg, varList);
|
||||
}
|
||||
|
||||
}*/
|
||||
|
@ -17,13 +17,13 @@ Licence:
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __AdamsBashforth2_hpp__
|
||||
#define __AdamsBashforth2_hpp__
|
||||
|
||||
|
||||
#include "integration.hpp"
|
||||
#include "pointFields.hpp"
|
||||
#include "boundaryIntegrationList.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
@ -41,10 +41,33 @@ class AdamsBashforth2
|
||||
{
|
||||
private:
|
||||
|
||||
const realx3Field_D& initialValField_;
|
||||
|
||||
boundaryIntegrationList boundaryList_;
|
||||
|
||||
friend class processorAB2BoundaryIntegration;
|
||||
|
||||
protected:
|
||||
|
||||
const auto& dy1()const
|
||||
{
|
||||
return static_cast<const realx3PointField_D&>(*this);
|
||||
}
|
||||
|
||||
auto& dy1()
|
||||
{
|
||||
return static_cast<realx3PointField_D&>(*this);
|
||||
}
|
||||
|
||||
auto& initialValField()
|
||||
{
|
||||
return initialValField_;
|
||||
}
|
||||
|
||||
boundaryIntegrationList& boundaryList()
|
||||
{
|
||||
return boundaryList_;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@ -58,10 +81,11 @@ public:
|
||||
const word& baseName,
|
||||
pointStructure& pStruct,
|
||||
const word& method,
|
||||
const realx3Field_D& initialValField);
|
||||
const realx3Field_D& initialValField,
|
||||
bool keepHistory);
|
||||
|
||||
/// Destructor
|
||||
~AdamsBashforth2()final = default;
|
||||
~AdamsBashforth2()override = default;
|
||||
|
||||
/// Add this to the virtual constructor table
|
||||
add_vCtor(
|
||||
@ -71,6 +95,9 @@ public:
|
||||
|
||||
|
||||
// - Methods
|
||||
|
||||
void updateBoundariesSlaveToMasterIfRequested()override;
|
||||
|
||||
/// return integration method
|
||||
word method()const override
|
||||
{
|
||||
@ -90,31 +117,21 @@ public:
|
||||
bool correct(
|
||||
real dt,
|
||||
realx3PointField_D& y,
|
||||
realx3PointField_D& dy) final;
|
||||
realx3PointField_D& dy,
|
||||
real damping = 1.0) override;
|
||||
|
||||
bool correct(
|
||||
bool correctPStruct(
|
||||
real dt,
|
||||
realx3Field_D& y,
|
||||
realx3PointField_D& dy) final;
|
||||
pointStructure& pStruct,
|
||||
realx3PointField_D& vel) override;
|
||||
|
||||
/*bool hearChanges
|
||||
(
|
||||
real t,
|
||||
real dt,
|
||||
uint32 iter,
|
||||
const timeInfo& ti,
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
) override;*/
|
||||
|
||||
bool setInitialVals(
|
||||
const int32IndexContainer& newIndices,
|
||||
const realx3Vector& y) final;
|
||||
|
||||
bool needSetInitialVals()const final
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -20,90 +20,185 @@ Licence:
|
||||
|
||||
#include "AdamsBashforth3.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
/// Range policy for integration kernel (alias)
|
||||
using rpIntegration = Kokkos::RangePolicy<
|
||||
DefaultExecutionSpace,
|
||||
Kokkos::Schedule<Kokkos::Static>,
|
||||
Kokkos::IndexType<uint32>
|
||||
>;
|
||||
|
||||
bool intAllActive(
|
||||
real dt,
|
||||
realx3Field_D& y,
|
||||
realx3PointField_D& dy,
|
||||
realx3PointField_D& dy1,
|
||||
realx3PointField_D& dy2,
|
||||
real damping = 1.0)
|
||||
{
|
||||
|
||||
auto d_dy = dy.deviceView();
|
||||
auto d_y = y.deviceView();
|
||||
auto d_dy1= dy1.deviceView();
|
||||
auto d_dy2= dy2.deviceView();
|
||||
auto activeRng = dy1.activeRange();
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"AdamsBashforth3::correct",
|
||||
rpIntegration (activeRng.start(), activeRng.end()),
|
||||
LAMBDA_HD(uint32 i){
|
||||
d_y[i] += damping* dt*( static_cast<real>(23.0 / 12.0) * d_dy[i]
|
||||
- static_cast<real>(16.0 / 12.0) * d_dy1[i]
|
||||
+ static_cast<real>(5.0 / 12.0) * d_dy2[i]) ;
|
||||
|
||||
d_dy2[i] = d_dy1[i];
|
||||
d_dy1[i] = d_dy[i];
|
||||
|
||||
});
|
||||
Kokkos::fence();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool intScattered
|
||||
(
|
||||
real dt,
|
||||
realx3Field_D& y,
|
||||
realx3PointField_D& dy,
|
||||
realx3PointField_D& dy1,
|
||||
realx3PointField_D& dy2,
|
||||
real damping = 1.0
|
||||
)
|
||||
{
|
||||
|
||||
auto d_dy = dy.deviceView();
|
||||
auto d_y = y.deviceView();
|
||||
auto d_dy1 = dy1.deviceView();
|
||||
auto d_dy2 = dy2.deviceView();
|
||||
auto activeRng = dy1.activeRange();
|
||||
const auto& activeP = dy1.activePointsMaskDevice();
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"AdamsBashforth3::correct",
|
||||
rpIntegration (activeRng.start(), activeRng.end()),
|
||||
LAMBDA_HD(uint32 i){
|
||||
if( activeP(i))
|
||||
{
|
||||
d_y[i] += damping * dt*( static_cast<real>(23.0 / 12.0) * d_dy[i]
|
||||
- static_cast<real>(16.0 / 12.0) * d_dy1[i]
|
||||
+ static_cast<real>(5.0 / 12.0) * d_dy2[i]);
|
||||
|
||||
d_dy2[i] = d_dy1[i];
|
||||
d_dy1[i] = d_dy[i];
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//const real AB3_coef[] = { 23.0 / 12.0, 16.0 / 12.0, 5.0 / 12.0 };
|
||||
|
||||
pFlow::AdamsBashforth3::AdamsBashforth3
|
||||
(
|
||||
const word& baseName,
|
||||
repository& owner,
|
||||
const pointStructure& pStruct,
|
||||
const word& method
|
||||
pointStructure& pStruct,
|
||||
const word& method,
|
||||
const realx3Field_D& initialValField,
|
||||
bool keepHistory
|
||||
)
|
||||
:
|
||||
integration(baseName, owner, pStruct, method),
|
||||
history_(
|
||||
owner.emplaceObject<pointField<VectorSingle,AB3History>>(
|
||||
objectFile(
|
||||
groupNames(baseName,"AB3History"),
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS),
|
||||
pStruct,
|
||||
AB3History({zero3,zero3})))
|
||||
AdamsBashforth2(baseName, pStruct, method, initialValField, keepHistory),
|
||||
dy2_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
groupNames(baseName,"dy2"),
|
||||
pStruct.time().integrationFolder(),
|
||||
objectFile::READ_IF_PRESENT,
|
||||
keepHistory ? objectFile::WRITE_ALWAYS : objectFile::WRITE_NEVER
|
||||
),
|
||||
pStruct,
|
||||
zero3,
|
||||
zero3
|
||||
)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth3::predict
|
||||
(
|
||||
real UNUSED(dt),
|
||||
realx3Vector_D& UNUSED(y),
|
||||
realx3Vector_D& UNUSED(dy)
|
||||
)
|
||||
void pFlow::AdamsBashforth3::updateBoundariesSlaveToMasterIfRequested()
|
||||
{
|
||||
|
||||
return true;
|
||||
AdamsBashforth2::updateBoundariesSlaveToMasterIfRequested();
|
||||
dy2_.updateBoundariesSlaveToMasterIfRequested();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool pFlow::AdamsBashforth3::correct
|
||||
(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy
|
||||
real dt,
|
||||
realx3PointField_D& y,
|
||||
realx3PointField_D& dy,
|
||||
real damping
|
||||
)
|
||||
{
|
||||
|
||||
if(this->pStruct().allActive())
|
||||
bool success = false;
|
||||
if(y.isAllActive())
|
||||
{
|
||||
return intAll(dt, y, dy, this->pStruct().activeRange());
|
||||
success = intAllActive(dt, y.field(), dy, dy1(), dy2(), damping);
|
||||
}
|
||||
else
|
||||
{
|
||||
return intRange(dt, y, dy, this->pStruct().activePointsMaskD());
|
||||
success = intScattered(dt, y.field(), dy, dy1(), dy2(), damping);
|
||||
}
|
||||
|
||||
return true;
|
||||
success = success && boundaryList().correct(dt, y, dy);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth3::setInitialVals(
|
||||
const int32IndexContainer& newIndices,
|
||||
const realx3Vector& y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth3::intAll(
|
||||
bool pFlow::AdamsBashforth3::correctPStruct(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy,
|
||||
range activeRng)
|
||||
pointStructure &pStruct,
|
||||
realx3PointField_D &vel)
|
||||
{
|
||||
auto d_dy = dy.deviceViewAll();
|
||||
auto d_y = y.deviceViewAll();
|
||||
auto d_history = history_.deviceViewAll();
|
||||
|
||||
bool success = false;
|
||||
if(dy2().isAllActive())
|
||||
{
|
||||
success = intAllActive(dt, pStruct.pointPosition(), vel, dy1(), dy2());
|
||||
}
|
||||
else
|
||||
{
|
||||
success = intScattered(dt, pStruct.pointPosition(), vel, dy1(), dy2());
|
||||
}
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"AdamsBashforth3::correct",
|
||||
rpIntegration (activeRng.first, activeRng.second),
|
||||
LAMBDA_HD(int32 i){
|
||||
auto ldy = d_dy[i];
|
||||
d_y[i] += dt*( static_cast<real>(23.0 / 12.0) * ldy
|
||||
- static_cast<real>(16.0 / 12.0) * d_history[i].dy1_
|
||||
+ static_cast<real>(5.0 / 12.0) * d_history[i].dy2_);
|
||||
d_history[i] = {ldy ,d_history[i].dy1_};
|
||||
});
|
||||
Kokkos::fence();
|
||||
success = success && boundaryList().correctPStruct(dt, pStruct, vel);
|
||||
|
||||
return true;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
/*bool pFlow::AdamsBashforth3::hearChanges
|
||||
(
|
||||
const timeInfo &ti,
|
||||
const message &msg,
|
||||
const anyList &varList
|
||||
)
|
||||
{
|
||||
if(msg.equivalentTo(message::ITEMS_INSERT))
|
||||
{
|
||||
return insertValues(varList, initialValField().deviceViewAll(), dy1()) &&
|
||||
insertValues(varList, initialValField().deviceViewAll(), dy2());
|
||||
}
|
||||
else
|
||||
{
|
||||
return realx3PointField_D::hearChanges(ti, msg, varList);
|
||||
}
|
||||
}*/
|
||||
|
@ -22,48 +22,14 @@ Licence:
|
||||
#define __AdamsBashforth3_hpp__
|
||||
|
||||
|
||||
#include "integration.hpp"
|
||||
#include "AdamsBashforth2.hpp"
|
||||
#include "pointFields.hpp"
|
||||
#include "boundaryIntegrationList.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
struct AB3History
|
||||
{
|
||||
TypeInfoNV("AB3History");
|
||||
|
||||
realx3 dy1_={0,0,0};
|
||||
realx3 dy2_={0,0,0};
|
||||
};
|
||||
|
||||
|
||||
INLINE_FUNCTION
|
||||
iIstream& operator>>(iIstream& str, AB3History& ab3)
|
||||
{
|
||||
str.readBegin("AB3History");
|
||||
|
||||
str >> ab3.dy1_;
|
||||
str >> ab3.dy2_;
|
||||
|
||||
str.readEnd("AB3History");
|
||||
|
||||
str.check(FUNCTION_NAME);
|
||||
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
INLINE_FUNCTION
|
||||
iOstream& operator<<(iOstream& str, const AB3History& ab3)
|
||||
{
|
||||
str << token::BEGIN_LIST << ab3.dy1_
|
||||
<< token::SPACE << ab3.dy2_
|
||||
<< token::END_LIST;
|
||||
|
||||
str.check(FUNCTION_NAME);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Third order Adams-Bashforth integration method for solving ODE
|
||||
@ -72,19 +38,26 @@ iOstream& operator<<(iOstream& str, const AB3History& ab3)
|
||||
*/
|
||||
class AdamsBashforth3
|
||||
:
|
||||
public integration
|
||||
public AdamsBashforth2
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
/// Integration history
|
||||
pointField<VectorSingle,AB3History>& history_;
|
||||
friend class processorAB3BoundaryIntegration;
|
||||
|
||||
/// Range policy for integration kernel
|
||||
using rpIntegration = Kokkos::RangePolicy<
|
||||
DefaultExecutionSpace,
|
||||
Kokkos::Schedule<Kokkos::Static>,
|
||||
Kokkos::IndexType<int32>
|
||||
>;
|
||||
realx3PointField_D dy2_;
|
||||
|
||||
protected:
|
||||
|
||||
const auto& dy2()const
|
||||
{
|
||||
return dy2_;
|
||||
}
|
||||
|
||||
auto& dy2()
|
||||
{
|
||||
return dy2_;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -96,17 +69,14 @@ public:
|
||||
/// Construct from components
|
||||
AdamsBashforth3(
|
||||
const word& baseName,
|
||||
repository& owner,
|
||||
const pointStructure& pStruct,
|
||||
const word& method);
|
||||
pointStructure& pStruct,
|
||||
const word& method,
|
||||
const realx3Field_D& initialValField,
|
||||
bool keepHistory);
|
||||
|
||||
uniquePtr<integration> clone()const override
|
||||
{
|
||||
return makeUnique<AdamsBashforth3>(*this);
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
virtual ~AdamsBashforth3()=default;
|
||||
~AdamsBashforth3() override =default;
|
||||
|
||||
/// Add this to the virtual constructor table
|
||||
add_vCtor(
|
||||
@ -117,43 +87,39 @@ public:
|
||||
|
||||
// - Methods
|
||||
|
||||
bool predict(
|
||||
real UNUSED(dt),
|
||||
realx3Vector_D & UNUSED(y),
|
||||
realx3Vector_D& UNUSED(dy)) override;
|
||||
void updateBoundariesSlaveToMasterIfRequested()override;
|
||||
|
||||
bool correct(real dt,
|
||||
realx3Vector_D & y,
|
||||
realx3Vector_D& dy) override;
|
||||
|
||||
bool setInitialVals(
|
||||
const int32IndexContainer& newIndices,
|
||||
const realx3Vector& y) override;
|
||||
|
||||
bool needSetInitialVals()const override
|
||||
/// return integration method
|
||||
word method()const override
|
||||
{
|
||||
return false;
|
||||
return "AdamsBashforth3";
|
||||
}
|
||||
|
||||
/// Integrate on all points in the active range
|
||||
bool intAll(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy,
|
||||
range activeRng);
|
||||
|
||||
|
||||
/// Integrate on active points in the active range
|
||||
template<typename activeFunctor>
|
||||
bool intRange(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy,
|
||||
activeFunctor activeP );
|
||||
bool correct(
|
||||
real dt,
|
||||
realx3PointField_D& y,
|
||||
realx3PointField_D& dy,
|
||||
real damping = 1.0) override;
|
||||
|
||||
bool correctPStruct(
|
||||
real dt,
|
||||
pointStructure& pStruct,
|
||||
realx3PointField_D& vel) override;
|
||||
|
||||
|
||||
/*bool hearChanges
|
||||
(
|
||||
const timeInfo& ti,
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
) override;*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<typename activeFunctor>
|
||||
/*template<typename activeFunctor>
|
||||
bool pFlow::AdamsBashforth3::intRange(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
@ -181,7 +147,7 @@ bool pFlow::AdamsBashforth3::intRange(
|
||||
Kokkos::fence();
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
@ -20,96 +20,187 @@ Licence:
|
||||
|
||||
#include "AdamsBashforth4.hpp"
|
||||
|
||||
|
||||
|
||||
pFlow::AdamsBashforth4::AdamsBashforth4
|
||||
(
|
||||
const word& baseName,
|
||||
repository& owner,
|
||||
const pointStructure& pStruct,
|
||||
const word& method
|
||||
)
|
||||
:
|
||||
integration(baseName, owner, pStruct, method),
|
||||
history_(
|
||||
owner.emplaceObject<pointField<VectorSingle,AB4History>>(
|
||||
objectFile(
|
||||
groupNames(baseName,"AB4History"),
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS),
|
||||
pStruct,
|
||||
AB4History({zero3,zero3, zero3})))
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
}
|
||||
/// Range policy for integration kernel (alias)
|
||||
using rpIntegration = Kokkos::RangePolicy<
|
||||
DefaultExecutionSpace,
|
||||
Kokkos::Schedule<Kokkos::Static>,
|
||||
Kokkos::IndexType<uint32>
|
||||
>;
|
||||
|
||||
bool pFlow::AdamsBashforth4::predict
|
||||
(
|
||||
real UNUSED(dt),
|
||||
realx3Vector_D& UNUSED(y),
|
||||
realx3Vector_D& UNUSED(dy)
|
||||
)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth4::correct
|
||||
(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy
|
||||
)
|
||||
{
|
||||
|
||||
if(this->pStruct().allActive())
|
||||
{
|
||||
return intAll(dt, y, dy, this->pStruct().activeRange());
|
||||
}
|
||||
else
|
||||
{
|
||||
return intRange(dt, y, dy, this->pStruct().activePointsMaskD());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth4::setInitialVals(
|
||||
const int32IndexContainer& newIndices,
|
||||
const realx3Vector& y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth4::intAll(
|
||||
bool intAllActive(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy,
|
||||
range activeRng)
|
||||
realx3Field_D& y,
|
||||
realx3PointField_D& dy,
|
||||
realx3PointField_D& dy1,
|
||||
realx3PointField_D& dy2,
|
||||
realx3PointField_D& dy3,
|
||||
real damping = 1.0)
|
||||
{
|
||||
auto d_dy = dy.deviceViewAll();
|
||||
auto d_y = y.deviceViewAll();
|
||||
auto d_history = history_.deviceViewAll();
|
||||
|
||||
auto d_dy = dy.deviceView();
|
||||
auto d_y = y.deviceView();
|
||||
auto d_dy1= dy1.deviceView();
|
||||
auto d_dy2= dy2.deviceView();
|
||||
auto d_dy3= dy3.deviceView();
|
||||
auto activeRng = dy1.activeRange();
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"AdamsBashforth4::correct",
|
||||
rpIntegration (activeRng.first, activeRng.second),
|
||||
LAMBDA_HD(int32 i){
|
||||
d_y[i] += dt*(
|
||||
static_cast<real>(55.0 / 24.0) * d_dy[i]
|
||||
- static_cast<real>(59.0 / 24.0) * d_history[i].dy1_
|
||||
+ static_cast<real>(37.0 / 24.0) * d_history[i].dy2_
|
||||
- static_cast<real>( 9.0 / 24.0) * d_history[i].dy3_
|
||||
);
|
||||
d_history[i].dy3_ = d_history[i].dy2_;
|
||||
d_history[i].dy2_ = d_history[i].dy1_;
|
||||
d_history[i].dy1_ = d_dy[i];
|
||||
|
||||
rpIntegration (activeRng.start(), activeRng.end()),
|
||||
LAMBDA_HD(uint32 i){
|
||||
d_y[i] += damping * dt*(
|
||||
static_cast<real>(55.0 / 24.0) * d_dy[i]
|
||||
- static_cast<real>(59.0 / 24.0) * d_dy1[i]
|
||||
+ static_cast<real>(37.0 / 24.0) * d_dy2[i]
|
||||
- static_cast<real>( 9.0 / 24.0) * d_dy3[i]);
|
||||
|
||||
d_dy3[i] = d_dy2[i];
|
||||
d_dy2[i] = d_dy1[i];
|
||||
d_dy1[i] = d_dy[i];
|
||||
});
|
||||
Kokkos::fence();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool intScattered
|
||||
(
|
||||
real dt,
|
||||
realx3Field_D& y,
|
||||
realx3PointField_D& dy,
|
||||
realx3PointField_D& dy1,
|
||||
realx3PointField_D& dy2,
|
||||
realx3PointField_D& dy3,
|
||||
real damping = 1.0
|
||||
)
|
||||
{
|
||||
|
||||
auto d_dy = dy.deviceView();
|
||||
auto d_y = y.deviceView();
|
||||
auto d_dy1 = dy1.deviceView();
|
||||
auto d_dy2 = dy2.deviceView();
|
||||
auto d_dy3 = dy3.deviceView();
|
||||
auto activeRng = dy1.activeRange();
|
||||
const auto& activeP = dy1.activePointsMaskDevice();
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"AdamsBashforth4::correct",
|
||||
rpIntegration (activeRng.start(), activeRng.end()),
|
||||
LAMBDA_HD(uint32 i){
|
||||
if( activeP(i))
|
||||
{
|
||||
d_y[i] += damping* dt*(
|
||||
static_cast<real>(55.0 / 24.0) * d_dy[i]
|
||||
- static_cast<real>(59.0 / 24.0) * d_dy1[i]
|
||||
+ static_cast<real>(37.0 / 24.0) * d_dy2[i]
|
||||
- static_cast<real>( 9.0 / 24.0) * d_dy3[i] );
|
||||
d_dy3[i] = d_dy2[i];
|
||||
d_dy2[i] = d_dy1[i];
|
||||
d_dy1[i] = d_dy[i];
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pFlow::AdamsBashforth4::AdamsBashforth4
|
||||
(
|
||||
const word& baseName,
|
||||
pointStructure& pStruct,
|
||||
const word& method,
|
||||
const realx3Field_D& initialValField,
|
||||
bool keepHistory
|
||||
)
|
||||
:
|
||||
AdamsBashforth3(baseName, pStruct, method, initialValField, keepHistory),
|
||||
dy3_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
groupNames(baseName,"dy3"),
|
||||
pStruct.time().integrationFolder(),
|
||||
objectFile::READ_IF_PRESENT,
|
||||
keepHistory?objectFile::WRITE_ALWAYS:objectFile::WRITE_NEVER
|
||||
),
|
||||
pStruct,
|
||||
zero3,
|
||||
zero3
|
||||
)
|
||||
{}
|
||||
|
||||
void pFlow::AdamsBashforth4::updateBoundariesSlaveToMasterIfRequested()
|
||||
{
|
||||
AdamsBashforth3::updateBoundariesSlaveToMasterIfRequested();
|
||||
dy3_.updateBoundariesSlaveToMasterIfRequested();
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth4::correct
|
||||
(
|
||||
real dt,
|
||||
realx3PointField_D& y,
|
||||
realx3PointField_D& dy,
|
||||
real damping
|
||||
)
|
||||
{
|
||||
|
||||
bool success = false;
|
||||
if(y.isAllActive())
|
||||
{
|
||||
success = intAllActive(dt, y.field(), dy, dy1(), dy2(), dy3(), damping);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = intScattered(dt, y.field(), dy, dy1(), dy2(), dy3(), damping);
|
||||
}
|
||||
|
||||
success = success && boundaryList().correct(dt, y, dy);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth4::correctPStruct(
|
||||
real dt,
|
||||
pointStructure &pStruct,
|
||||
realx3PointField_D &vel)
|
||||
{
|
||||
|
||||
bool success = false;
|
||||
if(dy2().isAllActive())
|
||||
{
|
||||
success = intAllActive(dt, pStruct.pointPosition(), vel, dy1(), dy2(), dy3());
|
||||
}
|
||||
else
|
||||
{
|
||||
success = intScattered(dt, pStruct.pointPosition(), vel, dy1(), dy2(), dy3());
|
||||
}
|
||||
|
||||
success = success && boundaryList().correctPStruct(dt, pStruct, vel);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/*bool pFlow::AdamsBashforth4::hearChanges
|
||||
(
|
||||
const timeInfo &ti,
|
||||
const message &msg,
|
||||
const anyList &varList
|
||||
)
|
||||
{
|
||||
if(msg.equivalentTo(message::ITEMS_INSERT))
|
||||
{
|
||||
return insertValues(varList, initialValField().deviceViewAll(), dy1()) &&
|
||||
insertValues(varList, initialValField().deviceViewAll(), dy2()) &&
|
||||
insertValues(varList, initialValField().deviceViewAll(), dy3());
|
||||
}
|
||||
else
|
||||
{
|
||||
return realx3PointField_D::hearChanges(ti, msg, varList);
|
||||
}
|
||||
}*/
|
||||
|
@ -22,53 +22,14 @@ Licence:
|
||||
#define __AdamsBashforth4_hpp__
|
||||
|
||||
|
||||
#include "integration.hpp"
|
||||
#include "AdamsBashforth3.hpp"
|
||||
#include "pointFields.hpp"
|
||||
#include "boundaryIntegrationList.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
struct AB4History
|
||||
{
|
||||
TypeInfoNV("AB4History");
|
||||
|
||||
realx3 dy1_={0,0,0};
|
||||
realx3 dy2_={0,0,0};
|
||||
realx3 dy3_={0,0,0};
|
||||
|
||||
};
|
||||
|
||||
|
||||
INLINE_FUNCTION
|
||||
iIstream& operator>>(iIstream& str, AB4History& ab4)
|
||||
{
|
||||
str.readBegin("AB4History");
|
||||
|
||||
str >> ab4.dy1_;
|
||||
str >> ab4.dy2_;
|
||||
str >> ab4.dy3_;
|
||||
|
||||
str.readEnd("AB4History");
|
||||
|
||||
str.check(FUNCTION_NAME);
|
||||
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
INLINE_FUNCTION
|
||||
iOstream& operator<<(iOstream& str, const AB4History& ab4)
|
||||
{
|
||||
str << token::BEGIN_LIST << ab4.dy1_
|
||||
<< token::SPACE << ab4.dy2_
|
||||
<< token::SPACE << ab4.dy3_
|
||||
<< token::END_LIST;
|
||||
|
||||
str.check(FUNCTION_NAME);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fourth order Adams-Bashforth integration method for solving ODE
|
||||
*
|
||||
@ -76,19 +37,25 @@ iOstream& operator<<(iOstream& str, const AB4History& ab4)
|
||||
*/
|
||||
class AdamsBashforth4
|
||||
:
|
||||
public integration
|
||||
public AdamsBashforth3
|
||||
{
|
||||
private:
|
||||
|
||||
friend class processorAB4BoundaryIntegration;
|
||||
|
||||
realx3PointField_D dy3_;
|
||||
|
||||
protected:
|
||||
|
||||
/// Integration history
|
||||
pointField<VectorSingle,AB4History>& history_;
|
||||
const auto& dy3()const
|
||||
{
|
||||
return dy3_;
|
||||
}
|
||||
|
||||
/// Range policy for integration kernel
|
||||
using rpIntegration = Kokkos::RangePolicy<
|
||||
DefaultExecutionSpace,
|
||||
Kokkos::Schedule<Kokkos::Static>,
|
||||
Kokkos::IndexType<int32>
|
||||
>;
|
||||
auto& dy3()
|
||||
{
|
||||
return dy3_;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@ -100,17 +67,15 @@ public:
|
||||
/// Construct from components
|
||||
AdamsBashforth4(
|
||||
const word& baseName,
|
||||
repository& owner,
|
||||
const pointStructure& pStruct,
|
||||
const word& method);
|
||||
pointStructure& pStruct,
|
||||
const word& method,
|
||||
const realx3Field_D& initialValField,
|
||||
bool keepHistory);
|
||||
|
||||
|
||||
uniquePtr<integration> clone()const override
|
||||
{
|
||||
return makeUnique<AdamsBashforth4>(*this);
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
virtual ~AdamsBashforth4()=default;
|
||||
~AdamsBashforth4() override =default;
|
||||
|
||||
/// Add a this to the virtual constructor table
|
||||
add_vCtor(
|
||||
@ -121,77 +86,36 @@ public:
|
||||
|
||||
// - Methods
|
||||
|
||||
bool predict(
|
||||
real UNUSED(dt),
|
||||
realx3Vector_D & UNUSED(y),
|
||||
realx3Vector_D& UNUSED(dy)) override;
|
||||
void updateBoundariesSlaveToMasterIfRequested()override;
|
||||
|
||||
/// return integration method
|
||||
word method()const override
|
||||
{
|
||||
return "AdamsBashforth4";
|
||||
}
|
||||
|
||||
bool correct(
|
||||
real dt,
|
||||
realx3Vector_D & y,
|
||||
realx3Vector_D& dy) override;
|
||||
realx3PointField_D& y,
|
||||
realx3PointField_D& dy,
|
||||
real damping = 1.0) override;
|
||||
|
||||
bool setInitialVals(
|
||||
const int32IndexContainer& newIndices,
|
||||
const realx3Vector& y) override;
|
||||
|
||||
bool needSetInitialVals()const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Integrate on all points in the active range
|
||||
bool intAll(
|
||||
bool correctPStruct(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy,
|
||||
range activeRng);
|
||||
|
||||
/// Integrate on active points in the active range
|
||||
template<typename activeFunctor>
|
||||
bool intRange(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy,
|
||||
activeFunctor activeP );
|
||||
pointStructure& pStruct,
|
||||
realx3PointField_D& vel) override;
|
||||
|
||||
/*bool hearChanges
|
||||
(
|
||||
const timeInfo& ti,
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
) override;*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<typename activeFunctor>
|
||||
bool pFlow::AdamsBashforth4::intRange(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy,
|
||||
activeFunctor activeP )
|
||||
{
|
||||
auto d_dy = dy.deviceViewAll();
|
||||
auto d_y = y.deviceViewAll();
|
||||
auto d_history = history_.deviceViewAll();
|
||||
auto activeRng = activeP.activeRange();
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"AdamsBashforth4::correct",
|
||||
rpIntegration (activeRng.first, activeRng.second),
|
||||
LAMBDA_HD(int32 i){
|
||||
if( activeP(i))
|
||||
{
|
||||
|
||||
d_y[i] += dt*(
|
||||
static_cast<real>(55.0 / 24.0) * d_dy[i]
|
||||
- static_cast<real>(59.0 / 24.0) * d_history[i].dy1_
|
||||
+ static_cast<real>(37.0 / 24.0) * d_history[i].dy2_
|
||||
- static_cast<real>( 9.0 / 24.0) * d_history[i].dy3_
|
||||
);
|
||||
d_history[i].dy3_ = d_history[i].dy2_;
|
||||
d_history[i].dy2_ = d_history[i].dy1_;
|
||||
d_history[i].dy1_ = d_dy[i];
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
@ -20,93 +20,179 @@ Licence:
|
||||
|
||||
#include "AdamsBashforth5.hpp"
|
||||
|
||||
|
||||
|
||||
pFlow::AdamsBashforth5::AdamsBashforth5
|
||||
(
|
||||
const word& baseName,
|
||||
repository& owner,
|
||||
const pointStructure& pStruct,
|
||||
const word& method
|
||||
)
|
||||
:
|
||||
integration(baseName, owner, pStruct, method),
|
||||
history_(
|
||||
owner.emplaceObject<pointField<VectorSingle,AB5History>>(
|
||||
objectFile(
|
||||
groupNames(baseName,"AB5History"),
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS),
|
||||
pStruct,
|
||||
AB5History({zero3,zero3, zero3})))
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
}
|
||||
/// Range policy for integration kernel (alias)
|
||||
using rpIntegration = Kokkos::RangePolicy<
|
||||
DefaultExecutionSpace,
|
||||
Kokkos::Schedule<Kokkos::Static>,
|
||||
Kokkos::IndexType<uint32>
|
||||
>;
|
||||
|
||||
bool pFlow::AdamsBashforth5::predict
|
||||
(
|
||||
real UNUSED(dt),
|
||||
realx3Vector_D& UNUSED(y),
|
||||
realx3Vector_D& UNUSED(dy)
|
||||
)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth5::correct
|
||||
(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy
|
||||
)
|
||||
{
|
||||
|
||||
if(this->pStruct().allActive())
|
||||
{
|
||||
return intAll(dt, y, dy, this->pStruct().activeRange());
|
||||
}
|
||||
else
|
||||
{
|
||||
return intRange(dt, y, dy, this->pStruct().activePointsMaskD());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth5::setInitialVals(
|
||||
const int32IndexContainer& newIndices,
|
||||
const realx3Vector& y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth5::intAll(
|
||||
bool intAllActive(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy,
|
||||
range activeRng)
|
||||
realx3Field_D& y,
|
||||
realx3PointField_D& dy,
|
||||
realx3PointField_D& dy1,
|
||||
realx3PointField_D& dy2,
|
||||
realx3PointField_D& dy3,
|
||||
realx3PointField_D& dy4,
|
||||
real damping = 1.0)
|
||||
{
|
||||
auto d_dy = dy.deviceViewAll();
|
||||
auto d_y = y.deviceViewAll();
|
||||
auto d_history = history_.deviceViewAll();
|
||||
|
||||
auto d_dy = dy.deviceView();
|
||||
auto d_y = y.deviceView();
|
||||
auto d_dy1= dy1.deviceView();
|
||||
auto d_dy2= dy2.deviceView();
|
||||
auto d_dy3= dy3.deviceView();
|
||||
auto d_dy4= dy4.deviceView();
|
||||
auto activeRng = dy1.activeRange();
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"AdamsBashforth5::correct",
|
||||
rpIntegration (activeRng.first, activeRng.second),
|
||||
LAMBDA_HD(int32 i){
|
||||
d_y[i] += dt*(
|
||||
rpIntegration (activeRng.start(), activeRng.end()),
|
||||
LAMBDA_HD(uint32 i){
|
||||
d_y[i] += damping* dt*(
|
||||
static_cast<real>(1901.0 / 720.0) * d_dy[i]
|
||||
- static_cast<real>(2774.0 / 720.0) * d_history[i].dy1_
|
||||
+ static_cast<real>(2616.0 / 720.0) * d_history[i].dy2_
|
||||
- static_cast<real>(1274.0 / 720.0) * d_history[i].dy3_
|
||||
+ static_cast<real>( 251.0 / 720.0) * d_history[i].dy4_
|
||||
);
|
||||
d_history[i] = {d_dy[i] ,d_history[i].dy1_, d_history[i].dy2_, d_history[i].dy3_};
|
||||
- static_cast<real>(2774.0 / 720.0) * d_dy1[i]
|
||||
+ static_cast<real>(2616.0 / 720.0) * d_dy2[i]
|
||||
- static_cast<real>(1274.0 / 720.0) * d_dy3[i]
|
||||
+ static_cast<real>( 251.0 / 720.0) * d_dy4[i]);
|
||||
|
||||
d_dy4[i] = d_dy3[i];
|
||||
d_dy3[i] = d_dy2[i];
|
||||
d_dy2[i] = d_dy1[i];
|
||||
d_dy1[i] = d_dy[i];
|
||||
});
|
||||
Kokkos::fence();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool intScattered
|
||||
(
|
||||
real dt,
|
||||
realx3Field_D& y,
|
||||
realx3PointField_D& dy,
|
||||
realx3PointField_D& dy1,
|
||||
realx3PointField_D& dy2,
|
||||
realx3PointField_D& dy3,
|
||||
realx3PointField_D& dy4,
|
||||
real damping = 1.0
|
||||
)
|
||||
{
|
||||
|
||||
auto d_dy = dy.deviceView();
|
||||
auto d_y = y.deviceView();
|
||||
auto d_dy1 = dy1.deviceView();
|
||||
auto d_dy2 = dy2.deviceView();
|
||||
auto d_dy3 = dy3.deviceView();
|
||||
auto d_dy4 = dy4.deviceView();
|
||||
auto activeRng = dy1.activeRange();
|
||||
const auto& activeP = dy1.activePointsMaskDevice();
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"AdamsBashforth5::correct",
|
||||
rpIntegration (activeRng.start(), activeRng.end()),
|
||||
LAMBDA_HD(uint32 i){
|
||||
if( activeP(i))
|
||||
{
|
||||
d_y[i] += damping* dt*(
|
||||
static_cast<real>(1901.0 / 720.0) * d_dy[i]
|
||||
- static_cast<real>(2774.0 / 720.0) * d_dy1[i]
|
||||
+ static_cast<real>(2616.0 / 720.0) * d_dy2[i]
|
||||
- static_cast<real>(1274.0 / 720.0) * d_dy3[i]
|
||||
+ static_cast<real>( 251.0 / 720.0) * d_dy4[i]);
|
||||
|
||||
d_dy4[i] = d_dy3[i];
|
||||
d_dy3[i] = d_dy2[i];
|
||||
d_dy2[i] = d_dy1[i];
|
||||
d_dy1[i] = d_dy[i];
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pFlow::AdamsBashforth5::AdamsBashforth5
|
||||
(
|
||||
const word &baseName,
|
||||
pointStructure &pStruct,
|
||||
const word &method,
|
||||
const realx3Field_D &initialValField,
|
||||
bool keepHistory
|
||||
)
|
||||
:
|
||||
AdamsBashforth4(baseName, pStruct, method, initialValField, keepHistory),
|
||||
dy4_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
groupNames(baseName,"dy4"),
|
||||
pStruct.time().integrationFolder(),
|
||||
objectFile::READ_IF_PRESENT,
|
||||
keepHistory?objectFile::WRITE_ALWAYS:objectFile::WRITE_NEVER
|
||||
),
|
||||
pStruct,
|
||||
zero3,
|
||||
zero3
|
||||
)
|
||||
{}
|
||||
|
||||
void pFlow::AdamsBashforth5::updateBoundariesSlaveToMasterIfRequested()
|
||||
{
|
||||
AdamsBashforth4::updateBoundariesSlaveToMasterIfRequested();
|
||||
dy4_.updateBoundariesSlaveToMasterIfRequested();
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth5::correct
|
||||
(
|
||||
real dt,
|
||||
realx3PointField_D &y,
|
||||
realx3PointField_D &dy,
|
||||
real damping
|
||||
)
|
||||
{
|
||||
|
||||
bool success = false;
|
||||
if(y.isAllActive())
|
||||
{
|
||||
success = intAllActive(dt, y.field(), dy, dy1(), dy2(), dy3(), dy4(), damping);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = intScattered(dt, y.field(), dy, dy1(), dy2(), dy3(), dy4(), damping);
|
||||
}
|
||||
|
||||
success = success && boundaryList().correct(dt, y, dy);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool pFlow::AdamsBashforth5::correctPStruct
|
||||
(
|
||||
real dt,
|
||||
pointStructure &pStruct,
|
||||
realx3PointField_D &vel
|
||||
)
|
||||
{
|
||||
bool success = false;
|
||||
if(dy2().isAllActive())
|
||||
{
|
||||
success = intAllActive(dt, pStruct.pointPosition(), vel, dy1(), dy2(), dy3(), dy4());
|
||||
}
|
||||
else
|
||||
{
|
||||
success = intScattered(dt, pStruct.pointPosition(), vel, dy1(), dy2(), dy3(), dy4());
|
||||
}
|
||||
|
||||
success = success && boundaryList().correctPStruct(dt, pStruct, vel);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,54 +22,12 @@ Licence:
|
||||
#define __AdamsBashforth5_hpp__
|
||||
|
||||
|
||||
#include "integration.hpp"
|
||||
#include "AdamsBashforth4.hpp"
|
||||
#include "pointFields.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
struct AB5History
|
||||
{
|
||||
TypeInfoNV("AB5History");
|
||||
|
||||
realx3 dy1_={0,0,0};
|
||||
realx3 dy2_={0,0,0};
|
||||
realx3 dy3_={0,0,0};
|
||||
realx3 dy4_={0,0,0};
|
||||
};
|
||||
|
||||
|
||||
INLINE_FUNCTION
|
||||
iIstream& operator>>(iIstream& str, AB5History& ab5)
|
||||
{
|
||||
str.readBegin("AB5History");
|
||||
|
||||
str >> ab5.dy1_;
|
||||
str >> ab5.dy2_;
|
||||
str >> ab5.dy3_;
|
||||
str >> ab5.dy4_;
|
||||
|
||||
str.readEnd("AB5History");
|
||||
|
||||
str.check(FUNCTION_NAME);
|
||||
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
INLINE_FUNCTION
|
||||
iOstream& operator<<(iOstream& str, const AB5History& ab5)
|
||||
{
|
||||
str << token::BEGIN_LIST << ab5.dy1_
|
||||
<< token::SPACE << ab5.dy2_
|
||||
<< token::SPACE << ab5.dy3_
|
||||
<< token::SPACE << ab5.dy4_
|
||||
<< token::END_LIST;
|
||||
|
||||
str.check(FUNCTION_NAME);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fifth order Adams-Bashforth integration method for solving ODE
|
||||
@ -78,19 +36,25 @@ iOstream& operator<<(iOstream& str, const AB5History& ab5)
|
||||
*/
|
||||
class AdamsBashforth5
|
||||
:
|
||||
public integration
|
||||
public AdamsBashforth4
|
||||
{
|
||||
private:
|
||||
|
||||
friend class processorAB4BoundaryIntegration;
|
||||
|
||||
realx3PointField_D dy4_;
|
||||
|
||||
protected:
|
||||
|
||||
/// Integration history
|
||||
pointField<VectorSingle,AB5History>& history_;
|
||||
const auto& dy4()const
|
||||
{
|
||||
return dy4_;
|
||||
}
|
||||
|
||||
/// Range policy for integration kernel
|
||||
using rpIntegration = Kokkos::RangePolicy<
|
||||
DefaultExecutionSpace,
|
||||
Kokkos::Schedule<Kokkos::Static>,
|
||||
Kokkos::IndexType<int32>
|
||||
>;
|
||||
auto& dy4()
|
||||
{
|
||||
return dy4_;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@ -99,20 +63,20 @@ public:
|
||||
|
||||
// - Constructors
|
||||
|
||||
/// Construct from components
|
||||
AdamsBashforth5(
|
||||
const word& baseName,
|
||||
repository& owner,
|
||||
const pointStructure& pStruct,
|
||||
const word& method);
|
||||
pointStructure& pStruct,
|
||||
const word& method,
|
||||
const realx3Field_D& initialValField,
|
||||
bool keepHistory);
|
||||
|
||||
|
||||
|
||||
uniquePtr<integration> clone()const override
|
||||
{
|
||||
return makeUnique<AdamsBashforth5>(*this);
|
||||
}
|
||||
/// Destructor
|
||||
~AdamsBashforth5() override =default;
|
||||
|
||||
virtual ~AdamsBashforth5()=default;
|
||||
|
||||
/// Add this to the virtual constructor table
|
||||
/// Add a this to the virtual constructor table
|
||||
add_vCtor(
|
||||
integration,
|
||||
AdamsBashforth5,
|
||||
@ -121,44 +85,29 @@ public:
|
||||
|
||||
// - Methods
|
||||
|
||||
bool predict(
|
||||
real UNUSED(dt),
|
||||
realx3Vector_D & UNUSED(y),
|
||||
realx3Vector_D& UNUSED(dy)) override;
|
||||
void updateBoundariesSlaveToMasterIfRequested()override;
|
||||
|
||||
/// return integration method
|
||||
word method()const override
|
||||
{
|
||||
return "AdamsBashforth5";
|
||||
}
|
||||
|
||||
bool correct(
|
||||
real dt,
|
||||
realx3Vector_D & y,
|
||||
realx3Vector_D& dy) override;
|
||||
realx3PointField_D& y,
|
||||
realx3PointField_D& dy,
|
||||
real damping = 1.0) override;
|
||||
|
||||
bool setInitialVals(
|
||||
const int32IndexContainer& newIndices,
|
||||
const realx3Vector& y) override;
|
||||
|
||||
bool needSetInitialVals()const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Integrate on all points in the active range
|
||||
bool intAll(
|
||||
bool correctPStruct(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy,
|
||||
range activeRng);
|
||||
|
||||
/// Integrate on active points in the active range
|
||||
template<typename activeFunctor>
|
||||
bool intRange(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
realx3Vector_D& dy,
|
||||
activeFunctor activeP );
|
||||
pointStructure& pStruct,
|
||||
realx3PointField_D& vel) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<typename activeFunctor>
|
||||
/*template<typename activeFunctor>
|
||||
bool pFlow::AdamsBashforth5::intRange(
|
||||
real dt,
|
||||
realx3Vector_D& y,
|
||||
@ -190,7 +139,7 @@ bool pFlow::AdamsBashforth5::intRange(
|
||||
Kokkos::fence();
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
@ -1,15 +1,23 @@
|
||||
|
||||
list(APPEND SourceFiles
|
||||
integration/integration.cpp
|
||||
integration/integration.cpp
|
||||
boundaries/boundaryIntegration.cpp
|
||||
boundaries/boundaryIntegrationList.cpp
|
||||
AdamsBashforth2/AdamsBashforth2.cpp
|
||||
#AdamsBashforth5/AdamsBashforth5.cpp
|
||||
#AdamsBashforth4/AdamsBashforth4.cpp
|
||||
#AdamsBashforth3/AdamsBashforth3.cpp
|
||||
AdamsBashforth3/AdamsBashforth3.cpp
|
||||
AdamsBashforth4/AdamsBashforth4.cpp
|
||||
AdamsBashforth5/AdamsBashforth5.cpp
|
||||
|
||||
#AdamsMoulton3/AdamsMoulton3.cpp
|
||||
#AdamsMoulton4/AdamsMoulton4.cpp
|
||||
#AdamsMoulton5/AdamsMoulton5.cpp
|
||||
)
|
||||
|
||||
if(pFlow_Build_MPI)
|
||||
list(APPEND SourceFiles
|
||||
AdamsBashforth2/processorAB2BoundaryIntegration.cpp)
|
||||
endif()
|
||||
|
||||
set(link_libs Kokkos::kokkos phasicFlow)
|
||||
|
||||
pFlow_add_library_install(Integration SourceFiles link_libs)
|
||||
|
@ -51,9 +51,7 @@ public:
|
||||
);
|
||||
|
||||
bool hearChanges(
|
||||
real t,
|
||||
real dt,
|
||||
uint32 iter,
|
||||
const timeInfo& ti,
|
||||
const message &msg,
|
||||
const anyList &varList) override
|
||||
{
|
||||
@ -77,6 +75,11 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isActive()const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
uniquePtr<boundaryIntegration> create(
|
||||
const boundaryBase& boundary,
|
||||
|
@ -7,11 +7,11 @@ pFlow::boundaryIntegrationList::boundaryIntegrationList(
|
||||
integration &intgrtn
|
||||
)
|
||||
:
|
||||
ListPtr<boundaryIntegration>(6),
|
||||
boundaryListPtr<boundaryIntegration>(),
|
||||
boundaries_(pStruct.boundaries())
|
||||
{
|
||||
|
||||
for(uint32 i=0; i<6; i++)
|
||||
|
||||
ForAllBoundariesPtr(i, this)
|
||||
{
|
||||
this->set(
|
||||
i,
|
||||
@ -19,23 +19,40 @@ pFlow::boundaryIntegrationList::boundaryIntegrationList(
|
||||
boundaries_[i],
|
||||
pStruct,
|
||||
method,
|
||||
intgrtn
|
||||
)
|
||||
);
|
||||
intgrtn
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::boundaryIntegrationList::correct(real dt, realx3PointField_D &y, realx3PointField_D &dy)
|
||||
{
|
||||
for(auto& bndry:*this)
|
||||
ForAllActiveBoundariesPtr(i,this)
|
||||
{
|
||||
if(!bndry->correct(dt, y, dy))
|
||||
if(!boundaryPtr(i)->correct(dt, y, dy))
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
fatalErrorInFunction<<"Error in correcting boundary "<<
|
||||
boundaryPtr(i)->boundaryName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::boundaryIntegrationList::correctPStruct(
|
||||
real dt,
|
||||
pointStructure &pStruct,
|
||||
const realx3PointField_D &vel)
|
||||
{
|
||||
ForAllActiveBoundariesPtr(i,this)
|
||||
{
|
||||
if(!boundaryPtr(i)->correctPStruct(dt, vel))
|
||||
{
|
||||
fatalErrorInFunction<<"Error in correcting boundary "<<
|
||||
boundaryPtr(i)->boundaryName()<<" in pointStructure."<<endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
#include "boundaryList.hpp"
|
||||
#include "ListPtr.hpp"
|
||||
#include "boundaryListPtr.hpp"
|
||||
#include "boundaryIntegration.hpp"
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ class integration;
|
||||
|
||||
class boundaryIntegrationList
|
||||
:
|
||||
public ListPtr<boundaryIntegration>
|
||||
public boundaryListPtr<boundaryIntegration>
|
||||
{
|
||||
private:
|
||||
|
||||
@ -35,6 +35,12 @@ public:
|
||||
real dt,
|
||||
realx3PointField_D& y,
|
||||
realx3PointField_D& dy);
|
||||
|
||||
bool correctPStruct(
|
||||
real dt,
|
||||
pointStructure& pStruct,
|
||||
const realx3PointField_D& vel);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -22,17 +22,41 @@ Licence:
|
||||
#include "pointStructure.hpp"
|
||||
#include "repository.hpp"
|
||||
|
||||
pFlow::integration::integration
|
||||
bool pFlow::integration::insertValues
|
||||
(
|
||||
const word& baseName,
|
||||
pointStructure& pStruct,
|
||||
const word&,
|
||||
const realx3Field_D&
|
||||
const anyList& varList,
|
||||
const deviceViewType1D<realx3>& srcVals,
|
||||
realx3PointField_D& dstFeild
|
||||
)
|
||||
:
|
||||
owner_(*pStruct.owner()),
|
||||
pStruct_(pStruct),
|
||||
baseName_(baseName)
|
||||
{
|
||||
const word eventName = message::eventName(message::ITEMS_INSERT);
|
||||
|
||||
if(!varList.checkObjectType<uint32IndexContainer>(eventName))
|
||||
{
|
||||
fatalErrorInFunction<<"Insertion failed in integration for "<< baseName_<<
|
||||
", variable "<< eventName <<
|
||||
" does not exist or the type is incorrect"<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& indices = varList.getObject<uint32IndexContainer>(
|
||||
eventName);
|
||||
|
||||
dstFeild.field().insertSetElement(indices, srcVals);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pFlow::integration::integration(
|
||||
const word &baseName,
|
||||
pointStructure &pStruct,
|
||||
const word &,
|
||||
const realx3Field_D &,
|
||||
bool keepHistory)
|
||||
: owner_(*pStruct.owner()),
|
||||
pStruct_(pStruct),
|
||||
baseName_(baseName),
|
||||
keepHistory_(keepHistory)
|
||||
{}
|
||||
|
||||
|
||||
@ -42,12 +66,13 @@ pFlow::uniquePtr<pFlow::integration>
|
||||
const word& baseName,
|
||||
pointStructure& pStruct,
|
||||
const word& method,
|
||||
const realx3Field_D& initialValField
|
||||
const realx3Field_D& initialValField,
|
||||
bool keepHistory
|
||||
)
|
||||
{
|
||||
if( wordvCtorSelector_.search(method) )
|
||||
{
|
||||
return wordvCtorSelector_[method] (baseName, pStruct, method, initialValField);
|
||||
return wordvCtorSelector_[method] (baseName, pStruct, method, initialValField, keepHistory);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ Licence:
|
||||
|
||||
#include "virtualConstructor.hpp"
|
||||
#include "pointFields.hpp"
|
||||
#include "Logical.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
@ -63,6 +64,15 @@ private:
|
||||
/// The base name for integration
|
||||
const word baseName_;
|
||||
|
||||
bool keepHistory_;
|
||||
|
||||
protected:
|
||||
|
||||
bool insertValues(
|
||||
const anyList& varList,
|
||||
const deviceViewType1D<realx3>& srcVals,
|
||||
realx3PointField_D& dstFeild);
|
||||
|
||||
public:
|
||||
|
||||
/// Type info
|
||||
@ -76,7 +86,8 @@ public:
|
||||
const word& baseName,
|
||||
pointStructure& pStruct,
|
||||
const word& method,
|
||||
const realx3Field_D& initialValField);
|
||||
const realx3Field_D& initialValField,
|
||||
bool keepHistory);
|
||||
|
||||
/// Copy constructor
|
||||
integration(const integration&) = default;
|
||||
@ -102,9 +113,10 @@ public:
|
||||
const word& baseName,
|
||||
pointStructure& pStruct,
|
||||
const word& method,
|
||||
const realx3Field_D& initialValField
|
||||
const realx3Field_D& initialValField,
|
||||
bool keepHistory
|
||||
),
|
||||
(baseName, pStruct, method, initialValField)
|
||||
(baseName, pStruct, method, initialValField, keepHistory)
|
||||
);
|
||||
|
||||
|
||||
@ -131,6 +143,13 @@ public:
|
||||
return owner_;
|
||||
}
|
||||
|
||||
bool keepHistory()const
|
||||
{
|
||||
return keepHistory_;
|
||||
}
|
||||
|
||||
virtual
|
||||
void updateBoundariesSlaveToMasterIfRequested() = 0;
|
||||
/// return integration method
|
||||
virtual
|
||||
word method()const = 0 ;
|
||||
@ -144,21 +163,10 @@ public:
|
||||
|
||||
/// Correction/main integration step
|
||||
virtual
|
||||
bool correct(real dt, realx3PointField_D& y, realx3PointField_D& dy) = 0;
|
||||
bool correct(real dt, realx3PointField_D& y, realx3PointField_D& dy, real damping = 1.0) = 0;
|
||||
|
||||
virtual
|
||||
bool correct(real dt, realx3Field_D& y, realx3PointField_D& dy) = 0;
|
||||
|
||||
/// Set the initial values for new indices
|
||||
virtual
|
||||
bool setInitialVals(
|
||||
const int32IndexContainer& newIndices,
|
||||
const realx3Vector& y) = 0;
|
||||
|
||||
/// Check if the method requires any set initial vals
|
||||
virtual
|
||||
bool needSetInitialVals()const = 0;
|
||||
|
||||
bool correctPStruct(real dt, pointStructure& pStruct, realx3PointField_D& vel) = 0;
|
||||
|
||||
/// Create the polymorphic object based on inputs
|
||||
static
|
||||
@ -166,7 +174,8 @@ public:
|
||||
const word& baseName,
|
||||
pointStructure& pStruct,
|
||||
const word& method,
|
||||
const realx3Field_D& initialValField);
|
||||
const realx3Field_D& initialValField,
|
||||
bool keepHistory);
|
||||
|
||||
}; // integration
|
||||
|
||||
|
Reference in New Issue
Block a user