# PhasicFlow: src/Integration/AdamsMoulton5/AdamsMoulton5.hpp Source File

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:
// type info
TypeInfo("AdamsMoulton5");
AdamsMoulton5(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method);
virtual ~AdamsMoulton5()=default;
// - add a virtual constructor
add_vCtor(
integration,
AdamsMoulton5,
word);
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;
}
uniquePtr<integration> clone()const override
{
return makeUnique<AdamsMoulton5>(*this);
}
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.deviceVectorAll();
auto d_y = y.deviceVectorAll();
auto d_y0 = y0_.deviceVectorAll();
auto d_dy0 = dy0_.deviceVectorAll();
auto d_dy1 = dy1_.deviceVectorAll();
auto d_dy2 = dy2_.deviceVectorAll();
auto d_dy3 = dy3_.deviceVectorAll();
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.deviceVectorAll();
auto d_y = y.deviceVectorAll();
auto d_dy0 = dy0_.deviceVectorAll();
auto d_y0 = y0_.deviceVectorAll();
auto d_dy1 = dy1_.deviceVectorAll();
auto d_dy2 = dy2_.deviceVectorAll();
auto d_dy3 = dy3_.deviceVectorAll();
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
Definition: AdamsMoulton5.cpp:132
pFlow::AdamsMoulton5::rpIntegration
Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< int32 > > rpIntegration
Definition: AdamsMoulton5.hpp:52
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::AdamsMoulton5::predictRange
bool predictRange(real dt, realx3Vector_D &y, realx3Vector_D &dy, activeFunctor activeP)
Definition: AdamsMoulton5.hpp:107
pFlow::integration
Definition: integration.hpp:35
pFlow::AdamsMoulton5::intAll
bool intAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Definition: AdamsMoulton5.cpp:174
pFlow::integration::pStruct
const auto & pStruct() const
Definition: integration.hpp:72
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pointFields.hpp
pFlow::AdamsMoulton5::add_vCtor
add_vCtor(integration, AdamsMoulton5, word)
pFlow::AdamsMoulton5
Definition: AdamsMoulton5.hpp:32
pFlow::AdamsMoulton5::predictAll
bool predictAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Definition: AdamsMoulton5.cpp:141
pFlow::DefaultExecutionSpace
Kokkos::DefaultExecutionSpace DefaultExecutionSpace
Definition: KokkosTypes.hpp:47
pFlow::integration::baseName
const word & baseName() const
Definition: integration.hpp:89
pFlow
Definition: demComponent.hpp:28
pFlow::pointField
Definition: pointField.hpp:35
pFlow::pointStructure
Definition: pointStructure.hpp:44
pFlow::AdamsMoulton5::dy0_
realx3PointField_D & dy0_
Definition: AdamsMoulton5.hpp:40
pFlow::AdamsMoulton5::dy1_
realx3PointField_D & dy1_
Definition: AdamsMoulton5.hpp:42
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::AdamsMoulton5::clone
uniquePtr< integration > clone() const override
Definition: AdamsMoulton5.hpp:88
pFlow::AdamsMoulton5::y0_
realx3PointField_D & y0_
Definition: AdamsMoulton5.hpp:38
pFlow::pointField::activeRange
range activeRange() const
Definition: pointField.hpp:138
pFlow::AdamsMoulton5::correct
bool correct(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsMoulton5.cpp:114
pFlow::VectorSingle
Definition: VectorSingle.hpp:45
pFlow::AdamsMoulton5::AdamsMoulton5
AdamsMoulton5(const word &baseName, repository &owner, const pointStructure &pStruct, const word &method)
Definition: AdamsMoulton5.cpp:25
pFlow::AdamsMoulton5::needSetInitialVals
bool needSetInitialVals() const override
Definition: AdamsMoulton5.hpp:83
pFlow::integration::owner
repository & owner()
Definition: integration.hpp:94
pFlow::AdamsMoulton5::predict
bool predict(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsMoulton5.cpp:94
pFlow::AdamsMoulton5::dy2_
realx3PointField_D & dy2_
Definition: AdamsMoulton5.hpp:44
pFlow::AdamsMoulton5::dy3_
realx3PointField_D & dy3_
Definition: AdamsMoulton5.hpp:46
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
integration.hpp
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:54
pFlow::AdamsMoulton5::intRange
bool intRange(real dt, realx3Vector_D &y, realx3Vector_D &dy, activeFunctor activeP)
Definition: AdamsMoulton5.hpp:145
pFlow::AdamsMoulton5::~AdamsMoulton5
virtual ~AdamsMoulton5()=default
pFlow::repository
Definition: repository.hpp:34
pFlow::VectorSingle::deviceVectorAll
INLINE_FUNCTION_H viewType & deviceVectorAll()
Definition: VectorSingle.hpp:295
pFlow::Vector< realx3 >
pFlow::AdamsMoulton5::TypeInfo
TypeInfo("AdamsMoulton5")
pFlow::range
kPair< int, int > range
Definition: KokkosTypes.hpp:54
pFlow::indexContainer< int32 >