AdamsBashforth3.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #include "AdamsBashforth3.hpp"
22 
23 //const real AB3_coef[] = { 23.0 / 12.0, 16.0 / 12.0, 5.0 / 12.0 };
24 
26 (
27  const word& baseName,
28  repository& owner,
29  const pointStructure& pStruct,
30  const word& method
31 )
32 :
33  integration(baseName, owner, pStruct, method),
34  /*dy1_(
35  owner.emplaceObject<realx3PointField_D>(
36  objectFile(
37  groupNames(baseName,"dy1"),
38  "",
39  objectFile::READ_IF_PRESENT,
40  objectFile::WRITE_ALWAYS),
41  pStruct,
42  zero3)),
43  dy2_(
44  owner.emplaceObject<realx3PointField_D>(
45  objectFile(
46  groupNames(baseName,"dy2"),
47  "",
48  objectFile::READ_IF_PRESENT,
49  objectFile::WRITE_ALWAYS),
50  pStruct,
51  zero3))*/
52  history_(
54  objectFile(
55  groupNames(baseName,"AB3History"),
56  "",
57  objectFile::READ_IF_PRESENT,
58  objectFile::WRITE_ALWAYS),
59  pStruct,
61 
62 {
63 
64 }
65 
67 (
68  real UNUSED(dt),
71 )
72 {
73 
74  return true;
75 }
76 
78 (
79  real dt,
80  realx3Vector_D& y,
81  realx3Vector_D& dy
82 )
83 {
84 
85  if(this->pStruct().allActive())
86  {
87  return intAll(dt, y, dy, this->pStruct().activeRange());
88  }
89  else
90  {
91  return intRange(dt, y, dy, this->pStruct().activePointsMaskD());
92  }
93 
94  return true;
95 }
96 
98  const int32IndexContainer& newIndices,
99  const realx3Vector& y)
100 {
101  return true;
102 }
103 
105  real dt,
106  realx3Vector_D& y,
107  realx3Vector_D& dy,
108  range activeRng)
109 {
110  auto d_dy = dy.deviceVectorAll();
111  auto d_y = y.deviceVectorAll();
112  auto d_history = history_.deviceVectorAll();
113 
114  Kokkos::parallel_for(
115  "AdamsBashforth3::correct",
116  rpIntegration (activeRng.first, activeRng.second),
117  LAMBDA_HD(int32 i){
118  auto ldy = d_dy[i];
119  d_y[i] += dt*( static_cast<real>(23.0 / 12.0) * ldy
120  - static_cast<real>(16.0 / 12.0) * d_history[i].dy1_
121  + static_cast<real>(5.0 / 12.0) * d_history[i].dy2_);
122  d_history[i] = {ldy ,d_history[i].dy1_};
123  });
124  Kokkos::fence();
125 
126  return true;
127 }
pFlow::AdamsBashforth3::setInitialVals
bool setInitialVals(const int32IndexContainer &newIndices, const realx3Vector &y) override
Definition: AdamsBashforth3.cpp:97
pFlow::AdamsBashforth3::rpIntegration
Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< int32 > > rpIntegration
Definition: AdamsBashforth3.hpp:87
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::AB3History
Definition: AdamsBashforth3.hpp:31
pFlow::AdamsBashforth3::predict
bool predict(real UNUSED(dt), realx3Vector_D &UNUSED(y), realx3Vector_D &UNUSED(dy)) override
Definition: AdamsBashforth3.cpp:67
UNUSED
#define UNUSED(x)
Definition: pFlowMacros.hpp:35
pFlow::integration
Definition: integration.hpp:35
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::zero3
const realx3 zero3(0.0)
Definition: types.hpp:97
pFlow::repository::emplaceObject
T & emplaceObject(const objectFile &objf, Args &&... args)
Definition: repositoryTemplates.cpp:38
AdamsBashforth3.hpp
pFlow::AdamsBashforth3::correct
bool correct(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsBashforth3.cpp:78
pFlow::AdamsBashforth3::AdamsBashforth3
AdamsBashforth3(const word &baseName, repository &owner, const pointStructure &pStruct, const word &method)
Definition: AdamsBashforth3.cpp:26
pFlow::baseName
word baseName(const word &w, char sep='.')
Definition: bTypesFunctions.cpp:156
pFlow::pointField
Definition: pointField.hpp:35
pFlow::pointStructure
Definition: pointStructure.hpp:44
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::VectorSingle
Definition: VectorSingle.hpp:45
pFlow::objectFile
Definition: objectFile.hpp:33
pFlow::AdamsBashforth3::intAll
bool intAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Definition: AdamsBashforth3.cpp:104
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:54
pFlow::groupNames
word groupNames(const word &bw, const word &tw, char sep='.')
Definition: bTypesFunctions.cpp:151
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 >