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

AdamsBashforth2.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 __AdamsBashforth2_hpp__
#define __AdamsBashforth2_hpp__
#include "integration.hpp"
#include "pointFields.hpp"
namespace pFlow
{
class AdamsBashforth2
:
public integration
{
protected:
realx3PointField_D& dy1_;
using rpIntegration = Kokkos::RangePolicy<
DefaultExecutionSpace,
Kokkos::Schedule<Kokkos::Static>,
Kokkos::IndexType<int32>
>;
public:
// type info
TypeInfo("AdamsBashforth2");
AdamsBashforth2(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method);
virtual ~AdamsBashforth2()=default;
// - add a virtual constructor
add_vCtor(
integration,
AdamsBashforth2,
word);
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;
}
uniquePtr<integration> clone()const override
{
return makeUnique<AdamsBashforth2>(*this);
}
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::AdamsBashforth2::intRange(
real dt,
realx3Vector_D& y,
realx3Vector_D& dy,
activeFunctor activeP )
{
auto d_dy = dy.deviceVectorAll();
auto d_y = y.deviceVectorAll();
auto d_dy1= dy1_.deviceVectorAll();
auto activeRng = activeP.activeRange();
Kokkos::parallel_for(
"AdamsBashforth2::correct",
rpIntegration (activeRng.first, activeRng.second),
LAMBDA_HD(int32 i){
if( activeP(i))
{
d_y[i] += dt*(static_cast< real >(3.0 / 2.0) * d_dy[i] - static_cast< real >(1.0 / 2.0) * d_dy1[i]);
d_dy1[i] = d_dy[i];
}
});
Kokkos::fence();
return true;
}
} // pFlow
#endif //__integration_hpp__
pFlow::AdamsBashforth2::needSetInitialVals
bool needSetInitialVals() const override
Definition: AdamsBashforth2.hpp:75
pFlow::AdamsBashforth2::dy1_
realx3PointField_D & dy1_
Definition: AdamsBashforth2.hpp:38
pFlow::AdamsBashforth2::correct
bool correct(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsBashforth2.cpp:59
pFlow::AdamsBashforth2::clone
uniquePtr< integration > clone() const override
Definition: AdamsBashforth2.hpp:80
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::AdamsBashforth2::intRange
bool intRange(real dt, realx3Vector_D &y, realx3Vector_D &dy, activeFunctor activeP)
Definition: AdamsBashforth2.hpp:93
UNUSED
#define UNUSED(x)
Definition: pFlowMacros.hpp:35
pFlow::AdamsBashforth2::~AdamsBashforth2
virtual ~AdamsBashforth2()=default
pFlow::integration
Definition: integration.hpp:35
pFlow::integration::pStruct
const auto & pStruct() const
Definition: integration.hpp:72
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pointFields.hpp
pFlow::DefaultExecutionSpace
Kokkos::DefaultExecutionSpace DefaultExecutionSpace
Definition: KokkosTypes.hpp:47
pFlow::AdamsBashforth2::setInitialVals
bool setInitialVals(const int32IndexContainer &newIndices, const realx3Vector &y) override
Definition: AdamsBashforth2.cpp:77
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::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::pointField::activeRange
range activeRange() const
Definition: pointField.hpp:138
pFlow::VectorSingle
Definition: VectorSingle.hpp:45
pFlow::integration::owner
repository & owner()
Definition: integration.hpp:94
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::AdamsBashforth2
Definition: AdamsBashforth2.hpp:32
integration.hpp
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:54
pFlow::AdamsBashforth2::intAll
bool intAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Definition: AdamsBashforth2.cpp:84
pFlow::AdamsBashforth2::AdamsBashforth2
AdamsBashforth2(const word &baseName, repository &owner, const pointStructure &pStruct, const word &method)
Definition: AdamsBashforth2.cpp:26
pFlow::AdamsBashforth2::TypeInfo
TypeInfo("AdamsBashforth2")
pFlow::repository
Definition: repository.hpp:34
pFlow::VectorSingle::deviceVectorAll
INLINE_FUNCTION_H viewType & deviceVectorAll()
Definition: VectorSingle.hpp:295
pFlow::Vector< realx3 >
pFlow::range
kPair< int, int > range
Definition: KokkosTypes.hpp:54
pFlow::indexContainer< int32 >
pFlow::AdamsBashforth2::rpIntegration
Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< int32 > > rpIntegration
Definition: AdamsBashforth2.hpp:44
pFlow::AdamsBashforth2::add_vCtor
add_vCtor(integration, AdamsBashforth2, word)
pFlow::AdamsBashforth2::predict
bool predict(real UNUSED(dt), realx3Vector_D &UNUSED(y), realx3Vector_D &UNUSED(dy)) override
Definition: AdamsBashforth2.cpp:48