# PhasicFlow: src/Integration/AdamsBashforth5/AdamsBashforth5.hpp 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.

AdamsBashforth5.hpp
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.
-----------------------------------------------------------------------------*/
#ifndef __AdamsBashforth5_hpp__
#define __AdamsBashforth5_hpp__
#include "integration.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;
}
class AdamsBashforth5
:
public integration
{
protected:
pointField<VectorSingle,AB5History>& history_;
using rpIntegration = Kokkos::RangePolicy<
DefaultExecutionSpace,
Kokkos::Schedule<Kokkos::Static>,
Kokkos::IndexType<int32>
>;
public:
TypeInfo("AdamsBashforth5");
// - Constructors
AdamsBashforth5(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method);
uniquePtr<integration> clone()const override
{
return makeUnique<AdamsBashforth5>(*this);
}
virtual ~AdamsBashforth5()=default;
add_vCtor(
integration,
AdamsBashforth5,
word);
// - Methods
bool predict(
real UNUSED(dt),
realx3Vector_D & UNUSED(y),
realx3Vector_D& UNUSED(dy)) 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 false;
}
bool intAll(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
range activeRng);
template<typename activeFunctor>
bool intRange(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
activeFunctor activeP );
};
template<typename activeFunctor>
bool pFlow::AdamsBashforth5::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(
"AdamsBashforth5::correct",
rpIntegration (activeRng.first, activeRng.second),
LAMBDA_HD(int32 i){
if( activeP(i))
{
d_y[i] += 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_};
}
});
Kokkos::fence();
return true;
}
} // pFlow
#endif //
pFlow::iIstream::readBegin
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
Definition: iIstream.cpp:238
INLINE_FUNCTION
#define INLINE_FUNCTION
Definition: pFlowMacros.hpp:66
pFlow::AdamsBashforth5::add_vCtor
add_vCtor(integration, AdamsBashforth5, word)
Add this to the virtual constructor table.
pFlow::AdamsBashforth5::history_
pointField< VectorSingle, AB5History > & history_
Integration history.
Definition: AdamsBashforth5.hpp:86
pFlow::real
float real
Definition: builtinTypes.hpp:45
UNUSED
#define UNUSED(x)
Definition: pFlowMacros.hpp:35
pFlow::AB5History::dy4_
realx3 dy4_
Definition: AdamsBashforth5.hpp:38
pFlow::AdamsBashforth5::AdamsBashforth5
AdamsBashforth5(const word &baseName, repository &owner, const pointStructure &pStruct, const word &method)
Definition: AdamsBashforth5.cpp:26
pFlow::integration
Base class for integrating the first order ODE (IVP)
Definition: integration.hpp:51
pFlow::internalField< T, void >::deviceViewAll
const auto & deviceViewAll() const
Definition: internalField.hpp:92
pFlow::AdamsBashforth5::setInitialVals
bool setInitialVals(const int32IndexContainer &newIndices, const realx3Vector &y) override
Set the initial values for new indices.
Definition: AdamsBashforth5.cpp:79
pFlow::integration::pStruct
const auto & pStruct() const
Const ref to pointStructure.
Definition: integration.hpp:115
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::iIstream::readEnd
bool readEnd(const char *funcName)
End read of data chunk, ends with ')' return true or FatalIOError.
Definition: iIstream.cpp:258
pointFields.hpp
FUNCTION_NAME
#define FUNCTION_NAME
Definition: pFlowMacros.hpp:29
pFlow::DefaultExecutionSpace
Kokkos::DefaultExecutionSpace DefaultExecutionSpace
Default execution space, it can be device exe.
Definition: KokkosTypes.hpp:61
pFlow::AB5History::dy3_
realx3 dy3_
Definition: AdamsBashforth5.hpp:37
pFlow::token::SPACE
@ SPACE
Nul character.
Definition: token.hpp:86
pFlow::integration::baseName
const word & baseName() const
Base name.
Definition: integration.hpp:122
pFlow::AdamsBashforth5
Fifth order Adams-Bashforth integration method for solving ODE.
Definition: AdamsBashforth5.hpp:79
pFlow
Definition: demGeometry.hpp:27
pFlow::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.cpp:42
pFlow::AB5History
Definition: AdamsBashforth5.hpp:31
pFlow::pointField
Definition: pointField.hpp:33
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::AB5History::dy2_
realx3 dy2_
Definition: AdamsBashforth5.hpp:36
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::AdamsBashforth5::intAll
bool intAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Integrate on all points in the active range.
Definition: AdamsBashforth5.cpp:86
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::AB5History::dy1_
realx3 dy1_
Definition: AdamsBashforth5.hpp:35
pFlow::AdamsBashforth5::correct
bool correct(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsBashforth5.cpp:60
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::token::END_LIST
@ END_LIST
Begin list [isseparator].
Definition: token.hpp:92
pFlow::AdamsBashforth5::clone
uniquePtr< integration > clone() const override
Definition: AdamsBashforth5.hpp:108
pFlow::AdamsBashforth5::intRange
bool intRange(real dt, realx3Vector_D &y, realx3Vector_D &dy, activeFunctor activeP)
Integrate on active points in the active range.
Definition: AdamsBashforth5.hpp:162
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::VectorSingle
Definition: VectorSingle.hpp:44
pFlow::AdamsBashforth5::~AdamsBashforth5
virtual ~AdamsBashforth5()=default
pFlow::integration::owner
repository & owner()
Ref to the owner repository.
Definition: integration.hpp:129
pFlow::VectorSingle::deviceViewAll
INLINE_FUNCTION_H auto & deviceViewAll()
Device view range [0,capcity)
Definition: VectorSingle.cpp:249
pFlow::token::BEGIN_LIST
@ BEGIN_LIST
End entry [isseparator].
Definition: token.hpp:91
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
integration.hpp
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
pFlow::integration::method
virtual word method() const =0
return integration method
pFlow::repository
Definition: repository.hpp:34
pFlow::AdamsBashforth5::TypeInfo
TypeInfo("AdamsBashforth5")
Type info.
pFlow::triple< real >
pFlow::Vector< realx3 >
pFlow::AdamsBashforth5::rpIntegration
Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< int32 > > rpIntegration
Range policy for integration kernel.
Definition: AdamsBashforth5.hpp:93
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::AdamsBashforth5::predict
bool predict(real UNUSED(dt), realx3Vector_D &UNUSED(y), realx3Vector_D &UNUSED(dy)) override
Definition: AdamsBashforth5.cpp:49
pFlow::AdamsBashforth5::needSetInitialVals
bool needSetInitialVals() const override
Check if the method requires any set initial vals.
Definition: AdamsBashforth5.hpp:138
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39
pFlow::AB5History::TypeInfoNV
TypeInfoNV("AB5History")