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

AdamsMoulton3.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 __AdamsMoulton3_hpp__
#define __AdamsMoulton3_hpp__
#include "integration.hpp"
#include "pointFields.hpp"
namespace pFlow
{
class AdamsMoulton3
:
public integration
{
protected:
realx3PointField_D& y0_;
realx3PointField_D& dy0_;
realx3PointField_D& dy1_;
using rpIntegration = Kokkos::RangePolicy<
DefaultExecutionSpace,
Kokkos::Schedule<Kokkos::Static>,
Kokkos::IndexType<int32>
>;
public:
TypeInfo("AdamsMoulton3");
// - Constructors
AdamsMoulton3(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method);
uniquePtr<integration> clone()const override
{
return makeUnique<AdamsMoulton3>(*this);
}
virtual ~AdamsMoulton3()=default;
add_vCtor(
integration,
AdamsMoulton3,
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 AdamsMoulton3::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 activeRng = activeP.activeRange();
Kokkos::parallel_for(
"AdamsMoulton3::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 >(3.0 / 2.0) * d_dy[i]
- static_cast< real >(1.0 / 2.0) * d_dy1[i]
);
}
});
Kokkos::fence();
return true;
}
template<typename activeFunctor>
bool pFlow::AdamsMoulton3::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 activeRng = activeP.activeRange();
Kokkos::parallel_for(
"AdamsMoulton3::correct",
rpIntegration (activeRng.first, activeRng.second),
LAMBDA_HD(int32 i){
if( activeP(i))
{
auto corrct_y = d_y0[i] + dt*(
static_cast< real >(5.0/12.0)*d_dy[i]
+ static_cast< real >(8.0/12.0)*d_dy0[i]
- static_cast< real >(1.0/12.0)*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 //
pFlow::AdamsMoulton3::TypeInfo
TypeInfo("AdamsMoulton3")
Type info.
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::AdamsMoulton3::add_vCtor
add_vCtor(integration, AdamsMoulton3, word)
Add this to the virtual constructor table.
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::integration::pStruct
const auto & pStruct() const
Const ref to pointStructure.
Definition: integration.hpp:115
pFlow::AdamsMoulton3::AdamsMoulton3
AdamsMoulton3(const word &baseName, repository &owner, const pointStructure &pStruct, const word &method)
Construct from components.
Definition: AdamsMoulton3.cpp:26
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pointFields.hpp
pFlow::AdamsMoulton3::intAll
bool intAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Integrate on all points in the active range.
Definition: AdamsMoulton3.cpp:146
pFlow::DefaultExecutionSpace
Kokkos::DefaultExecutionSpace DefaultExecutionSpace
Default execution space, it can be device exe.
Definition: KokkosTypes.hpp:61
pFlow::AdamsMoulton3::rpIntegration
Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< int32 > > rpIntegration
Range policy for integration kernel.
Definition: AdamsMoulton3.hpp:56
pFlow::integration::baseName
const word & baseName() const
Base name.
Definition: integration.hpp:122
pFlow
Definition: demGeometry.hpp:27
pFlow::AdamsMoulton3::predictRange
bool predictRange(real dt, realx3Vector_D &y, realx3Vector_D &dy, activeFunctor activeP)
Prediction step on active points in the active range.
Definition: AdamsMoulton3.hpp:141
pFlow::pointField
Definition: pointField.hpp:33
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::AdamsMoulton3::setInitialVals
bool setInitialVals(const int32IndexContainer &newIndices, const realx3Vector &y) override
Set the initial values for new indices.
Definition: AdamsMoulton3.cpp:111
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::AdamsMoulton3::dy0_
realx3PointField_D & dy0_
dy at time t
Definition: AdamsMoulton3.hpp:46
pFlow::VectorSingle
Definition: VectorSingle.hpp:44
pFlow::AdamsMoulton3::clone
uniquePtr< integration > clone() const override
Definition: AdamsMoulton3.hpp:71
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::AdamsMoulton3::intRange
bool intRange(real dt, realx3Vector_D &y, realx3Vector_D &dy, activeFunctor activeP)
Integrate on active points in the active range.
Definition: AdamsMoulton3.hpp:178
pFlow::AdamsMoulton3::predictAll
bool predictAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Prediction step on all points in the active range.
Definition: AdamsMoulton3.cpp:120
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
integration.hpp
pFlow::AdamsMoulton3::dy1_
realx3PointField_D & dy1_
dy at time t-dt
Definition: AdamsMoulton3.hpp:49
pFlow::AdamsMoulton3::predict
bool predict(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsMoulton3.cpp:73
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
pFlow::AdamsMoulton3::y0_
realx3PointField_D & y0_
y at time t
Definition: AdamsMoulton3.hpp:43
pFlow::AdamsMoulton3::correct
bool correct(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsMoulton3.cpp:93
pFlow::AdamsMoulton3::~AdamsMoulton3
virtual ~AdamsMoulton3()=default
Destructor.
pFlow::integration::method
virtual word method() const =0
return integration method
pFlow::repository
Definition: repository.hpp:34
pFlow::AdamsMoulton3
Third order Adams-Moulton integration method for solving ODE.
Definition: AdamsMoulton3.hpp:36
pFlow::Vector< realx3 >
pFlow::AdamsMoulton3::needSetInitialVals
bool needSetInitialVals() const override
Check if the method requires any set initial vals.
Definition: AdamsMoulton3.hpp:102
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39