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 "AdamsBashforth2.hpp"
|
2024-01-21 21:26:23 +00:00
|
|
|
#include "pointStructure.hpp"
|
|
|
|
#include "Time.hpp"
|
|
|
|
#include "vocabs.hpp"
|
2022-09-04 21:26:29 +00:00
|
|
|
|
2024-01-21 21:26:23 +00:00
|
|
|
namespace pFlow
|
|
|
|
{
|
2022-09-04 21:26:29 +00:00
|
|
|
|
2024-01-21 21:26:23 +00:00
|
|
|
/// Range policy for integration kernel (alias)
|
|
|
|
using rpIntegration = Kokkos::RangePolicy<
|
|
|
|
DefaultExecutionSpace,
|
|
|
|
Kokkos::Schedule<Kokkos::Static>,
|
|
|
|
Kokkos::IndexType<uint32>
|
|
|
|
>;
|
|
|
|
|
|
|
|
bool intAllActive(
|
|
|
|
real dt,
|
2024-01-29 15:57:19 +00:00
|
|
|
realx3Field_D& y,
|
2024-01-21 21:26:23 +00:00
|
|
|
realx3PointField_D& dy,
|
|
|
|
realx3PointField_D& dy1)
|
|
|
|
{
|
|
|
|
|
2024-01-29 15:57:19 +00:00
|
|
|
auto d_dy = dy.deviceView();
|
|
|
|
auto d_y = y.deviceView();
|
|
|
|
auto d_dy1= dy1.deviceView();
|
2024-01-21 21:26:23 +00:00
|
|
|
auto activeRng = dy1.activeRange();
|
|
|
|
|
|
|
|
Kokkos::parallel_for(
|
|
|
|
"AdamsBashforth2::correct",
|
|
|
|
rpIntegration (activeRng.start(), activeRng.end()),
|
2024-01-29 15:57:19 +00:00
|
|
|
LAMBDA_HD(uint32 i){
|
2024-01-21 21:26:23 +00:00
|
|
|
d_y[i] += 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();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool intScattered
|
2022-09-04 21:26:29 +00:00
|
|
|
(
|
2024-01-21 21:26:23 +00:00
|
|
|
real dt,
|
2024-01-29 15:57:19 +00:00
|
|
|
realx3Field_D& y,
|
2024-01-21 21:26:23 +00:00
|
|
|
realx3PointField_D& dy,
|
|
|
|
realx3PointField_D& dy1
|
2022-09-04 21:26:29 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
|
2024-01-29 15:57:19 +00:00
|
|
|
auto d_dy = dy.deviceView();
|
|
|
|
auto d_y = y.deviceView();
|
|
|
|
auto d_dy1 = dy1.deviceView();
|
2024-01-21 21:26:23 +00:00
|
|
|
auto activeRng = dy1.activeRange();
|
|
|
|
const auto& activeP = dy1.activePointsMaskDevice();
|
|
|
|
|
|
|
|
Kokkos::parallel_for(
|
|
|
|
"AdamsBashforth2::correct",
|
|
|
|
rpIntegration (activeRng.start(), activeRng.end()),
|
2024-01-29 15:57:19 +00:00
|
|
|
LAMBDA_HD(uint32 i){
|
2024-01-21 21:26:23 +00:00
|
|
|
if( activeP(i))
|
|
|
|
{
|
|
|
|
d_y[i] += 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();
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
2022-09-04 21:26:29 +00:00
|
|
|
}
|
|
|
|
|
2024-01-21 21:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pFlow::AdamsBashforth2::AdamsBashforth2
|
|
|
|
(
|
|
|
|
const word& baseName,
|
|
|
|
pointStructure& pStruct,
|
|
|
|
const word& method,
|
|
|
|
const realx3Field_D& initialValField
|
|
|
|
)
|
|
|
|
:
|
|
|
|
integration(baseName, pStruct, method, initialValField),
|
|
|
|
realx3PointField_D
|
|
|
|
(
|
|
|
|
objectFile
|
|
|
|
(
|
|
|
|
groupNames(baseName,"dy1"),
|
|
|
|
pStruct.time().integrationFolder(),
|
|
|
|
objectFile::READ_IF_PRESENT,
|
|
|
|
objectFile::WRITE_ALWAYS
|
|
|
|
),
|
|
|
|
pStruct,
|
|
|
|
zero3
|
|
|
|
)
|
|
|
|
{}
|
|
|
|
|
2022-09-04 21:26:29 +00:00
|
|
|
bool pFlow::AdamsBashforth2::predict
|
|
|
|
(
|
|
|
|
real UNUSED(dt),
|
2024-01-21 21:26:23 +00:00
|
|
|
realx3PointField_D& UNUSED(y),
|
|
|
|
realx3PointField_D& UNUSED(dy)
|
2022-09-04 21:26:29 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-01-29 15:57:19 +00:00
|
|
|
bool pFlow::AdamsBashforth2::predict
|
|
|
|
(
|
|
|
|
real dt,
|
|
|
|
realx3Field_D &y,
|
|
|
|
realx3PointField_D &dy
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-04 21:26:29 +00:00
|
|
|
bool pFlow::AdamsBashforth2::correct
|
|
|
|
(
|
|
|
|
real dt,
|
2024-01-21 21:26:23 +00:00
|
|
|
realx3PointField_D& y,
|
|
|
|
realx3PointField_D& dy
|
2022-09-04 21:26:29 +00:00
|
|
|
)
|
2024-01-29 15:57:19 +00:00
|
|
|
{
|
|
|
|
return correct(dt, y.field(), dy);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool pFlow::AdamsBashforth2::correct(real dt, realx3Field_D &y, realx3PointField_D &dy)
|
2022-09-04 21:26:29 +00:00
|
|
|
{
|
2024-01-21 21:26:23 +00:00
|
|
|
auto& dy1l = dy1();
|
|
|
|
|
|
|
|
if(dy1l.isAllActive())
|
2022-09-04 21:26:29 +00:00
|
|
|
{
|
2024-01-21 21:26:23 +00:00
|
|
|
return intAllActive(dt, y, dy, dy1l);
|
2022-09-04 21:26:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-21 21:26:23 +00:00
|
|
|
return intScattered(dt, y, dy, dy1l);
|
2022-09-04 21:26:29 +00:00
|
|
|
}
|
2024-01-29 15:57:19 +00:00
|
|
|
return false;
|
2022-09-04 21:26:29 +00:00
|
|
|
}
|
|
|
|
|
2022-10-25 16:00:57 +00:00
|
|
|
bool pFlow::AdamsBashforth2::setInitialVals(
|
|
|
|
const int32IndexContainer& newIndices,
|
|
|
|
const realx3Vector& y)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|