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

AdamsMoulton5.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 __AdamsMoulton5_hpp__
#define __AdamsMoulton5_hpp__
#include "integration.hpp"
#include "pointFields.hpp"
namespace pFlow
{
class AdamsMoulton5
:
public integration
{
protected:
realx3PointField_D& y0_;
realx3PointField_D& dy0_;
realx3PointField_D& dy1_;
realx3PointField_D& dy2_;
realx3PointField_D& dy3_;
using rpIntegration = Kokkos::RangePolicy<
DefaultExecutionSpace,
Kokkos::Schedule<Kokkos::Static>,
Kokkos::IndexType<int32>
>;
public:
TypeInfo("AdamsMoulton5");
// - Constructors
AdamsMoulton5(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method);
uniquePtr<integration> clone()const override
{
return makeUnique<AdamsMoulton5>(*this);
}
virtual ~AdamsMoulton5()=default;
// - add a virtual constructor
add_vCtor(
integration,
AdamsMoulton5,
word);
// - Methods
bool predict(
real dt,
realx3Vector_D& y,
realx3Vector_D& 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 true;
}
bool predictAll(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
range activeRng);
template<typename activeFunctor>
bool predictRange(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
activeFunctor activeP);
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 AdamsMoulton5::predictRange(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
activeFunctor activeP )
{
auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceViewAll();
auto d_y0 = y0_.deviceViewAll();
auto d_dy0 = dy0_.deviceViewAll();
auto d_dy1 = dy1_.deviceViewAll();
auto d_dy2 = dy2_.deviceViewAll();
auto d_dy3 = dy3_.deviceViewAll();
auto activeRng = activeP.activeRange();
Kokkos::parallel_for(
"AdamsMoulton5::predictRange",
rpIntegration (activeRng.first, activeRng.second),
LAMBDA_HD(int32 i){
if(activeP(i))
{
d_dy0[i] = d_dy[i];
d_y[i] = d_y0[i] + 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]);
}
});
Kokkos::fence();
return true;
}
template<typename activeFunctor>
bool pFlow::AdamsMoulton5::intRange(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
activeFunctor activeP )
{
auto d_dy = dy.deviceViewAll();
auto d_y = y.deviceViewAll();
auto d_dy0 = dy0_.deviceViewAll();
auto d_y0 = y0_.deviceViewAll();
auto d_dy1 = dy1_.deviceViewAll();
auto d_dy2 = dy2_.deviceViewAll();
auto d_dy3 = dy3_.deviceViewAll();
auto activeRng = activeP.activeRange();
Kokkos::parallel_for(
"AdamsMoulton5::correct",
rpIntegration (activeRng.first, activeRng.second),
LAMBDA_HD(int32 i){
if( activeP(i))
{
auto corrct_y = d_y0[i] + dt*(
static_cast< real >(251.0/720.0)*d_dy[i]
+ static_cast< real >(646.0/720.0)*d_dy0[i]
- static_cast< real >(264.0/720.0)*d_dy1[i]
+ static_cast< real >(106.0/720.0)*d_dy2[i]
- static_cast< real >( 19.0/720.0)*d_dy3[i]);
d_dy3[i]= d_dy2[i];
d_dy2[i]= d_dy1[i];
d_dy1[i]= d_dy0[i];
d_y0[i] = corrct_y;
d_y[i] = corrct_y;
}
});
Kokkos::fence();
return true;
}
} // pFlow
#endif //__integration_hpp__
pFlow::AdamsMoulton5::setInitialVals
bool setInitialVals(const int32IndexContainer &newIndices, const realx3Vector &y) override
Set the initial values for new indices.
Definition: AdamsMoulton5.cpp:132
pFlow::AdamsMoulton5::rpIntegration
Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< int32 > > rpIntegration
Range policy for integration kernel.
Definition: AdamsMoulton5.hpp:62
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::AdamsMoulton5::predictRange
bool predictRange(real dt, realx3Vector_D &y, realx3Vector_D &dy, activeFunctor activeP)
Prediction step on active points in the active range.
Definition: AdamsMoulton5.hpp:147
pFlow::integration
Base class for integrating the first order ODE (IVP)
Definition: integration.hpp:51
pFlow::internalField::deviceViewAll
const auto & deviceViewAll() const
Definition: internalField.hpp:92
pFlow::AdamsMoulton5::intAll
bool intAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Integrate on all points in the active range.
Definition: AdamsMoulton5.cpp:174
pFlow::integration::pStruct
const auto & pStruct() const
Const ref to pointStructure.
Definition: integration.hpp:115
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pointFields.hpp
pFlow::AdamsMoulton5::add_vCtor
add_vCtor(integration, AdamsMoulton5, word)
pFlow::AdamsMoulton5
Fifth order Adams-Moulton integration method for solving ODE.
Definition: AdamsMoulton5.hpp:36
pFlow::AdamsMoulton5::predictAll
bool predictAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Prediction step on all points in the active range.
Definition: AdamsMoulton5.cpp:141
pFlow::DefaultExecutionSpace
Kokkos::DefaultExecutionSpace DefaultExecutionSpace
Default execution space, it can be device exe.
Definition: KokkosTypes.hpp:61
pFlow::integration::baseName
const word & baseName() const
Base name.
Definition: integration.hpp:122
pFlow
Definition: demGeometry.hpp:27
pFlow::pointField
Definition: pointField.hpp:33
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::AdamsMoulton5::dy0_
realx3PointField_D & dy0_
dy at time t
Definition: AdamsMoulton5.hpp:46
pFlow::AdamsMoulton5::dy1_
realx3PointField_D & dy1_
dy at time t-dt
Definition: AdamsMoulton5.hpp:49
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::AdamsMoulton5::clone
uniquePtr< integration > clone() const override
Definition: AdamsMoulton5.hpp:77
pFlow::AdamsMoulton5::y0_
realx3PointField_D & y0_
y at time t
Definition: AdamsMoulton5.hpp:43
pFlow::AdamsMoulton5::correct
bool correct(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsMoulton5.cpp:114
pFlow::VectorSingle
Definition: VectorSingle.hpp:44
pFlow::AdamsMoulton5::AdamsMoulton5
AdamsMoulton5(const word &baseName, repository &owner, const pointStructure &pStruct, const word &method)
Construct from components.
Definition: AdamsMoulton5.cpp:25
pFlow::AdamsMoulton5::needSetInitialVals
bool needSetInitialVals() const override
Check if the method requires any set initial vals.
Definition: AdamsMoulton5.hpp:108
pFlow::integration::owner
repository & owner()
Ref to the owner repository.
Definition: integration.hpp:129
pFlow::AdamsMoulton5::predict
bool predict(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsMoulton5.cpp:94
pFlow::VectorSingle::deviceViewAll
INLINE_FUNCTION_H auto & deviceViewAll()
Device view range [0,capcity)
Definition: VectorSingle.cpp:249
pFlow::AdamsMoulton5::dy2_
realx3PointField_D & dy2_
dy at time t-2*dt
Definition: AdamsMoulton5.hpp:52
pFlow::AdamsMoulton5::dy3_
realx3PointField_D & dy3_
dy at time t-3*dt
Definition: AdamsMoulton5.hpp:55
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
integration.hpp
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
pFlow::AdamsMoulton5::intRange
bool intRange(real dt, realx3Vector_D &y, realx3Vector_D &dy, activeFunctor activeP)
Integrate on active points in the active range.
Definition: AdamsMoulton5.hpp:185
pFlow::integration::method
virtual word method() const =0
return integration method
pFlow::AdamsMoulton5::~AdamsMoulton5
virtual ~AdamsMoulton5()=default
Destructor.
pFlow::repository
Definition: repository.hpp:34
pFlow::Vector< realx3 >
pFlow::AdamsMoulton5::TypeInfo
TypeInfo("AdamsMoulton5")
Type info.
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39