# PhasicFlow: src/Integration/AdamsBashforth3/AdamsBashforth3.cpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

AdamsBashforth3.cpp
Go to the documentation of this file.
/*------------------------------- 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 "AdamsBashforth3.hpp"
//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
)
:
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})))
{
}
bool pFlow::AdamsBashforth3::predict
(
real UNUSED(dt),
realx3Vector_D& UNUSED(y),
realx3Vector_D& UNUSED(dy)
)
{
return true;
}
bool pFlow::AdamsBashforth3::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::AdamsBashforth3::setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y)
{
return true;
}
bool pFlow::AdamsBashforth3::intAll(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
range activeRng)
{
auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceViewAll();
auto d_history = history_.deviceViewAll();
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();
return true;
}
pFlow::AdamsBashforth3::setInitialVals
bool setInitialVals(const int32IndexContainer &newIndices, const realx3Vector &y) override
Set the initial values for new indices.
Definition: AdamsBashforth3.cpp:79
pFlow::AdamsBashforth3::rpIntegration
Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< int32 > > rpIntegration
Range policy for integration kernel.
Definition: AdamsBashforth3.hpp:87
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::AB3History
Definition: AdamsBashforth3.hpp:31
pFlow::AdamsBashforth3::predict
bool predict(real UNUSED(dt), realx3Vector_D &UNUSED(y), realx3Vector_D &UNUSED(dy)) override
Definition: AdamsBashforth3.cpp:49
UNUSED
#define UNUSED(x)
Definition: pFlowMacros.hpp:35
pFlow::integration
Base class for integrating the first order ODE (IVP)
Definition: integration.hpp:51
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::zero3
const realx3 zero3(0.0)
Definition: types.hpp:137
AdamsBashforth3.hpp
pFlow::AdamsBashforth3::correct
bool correct(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsBashforth3.cpp:60
pFlow::AdamsBashforth3::AdamsBashforth3
AdamsBashforth3(const word &baseName, repository &owner, const pointStructure &pStruct, const word &method)
Construct from components.
Definition: AdamsBashforth3.cpp:26
pFlow::baseName
word baseName(const word &w, char sep='.')
Find the base in a group separated by "." and return it.
Definition: bTypesFunctions.cpp:185
pFlow::pointField
Definition: pointField.hpp:33
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::VectorSingle
Definition: VectorSingle.hpp:44
pFlow::objectFile
Definition: objectFile.hpp:30
pFlow::AdamsBashforth3::intAll
bool intAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Integrate on all points in the active range.
Definition: AdamsBashforth3.cpp:86
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::VectorSingle::deviceViewAll
INLINE_FUNCTION_H auto & deviceViewAll()
Device view range [0,capcity)
Definition: VectorSingle.cpp:249
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
pFlow::groupNames
word groupNames(const word &bw, const word &tw, char sep='.')
Group words and output bw.tw.
Definition: bTypesFunctions.cpp:179
pFlow::repository
Definition: repository.hpp:34
pFlow::Vector< realx3 >
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39