AdamsMoulton5.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 "AdamsMoulton5.hpp"
22 
23 
25 (
26  const word& baseName,
27  repository& owner,
28  const pointStructure& pStruct,
29  const word& method
30 )
31 :
32  integration(baseName, owner, pStruct, method),
33  y0_(
35  objectFile(
36  groupNames(baseName,"y0"),
37  "",
38  objectFile::READ_IF_PRESENT,
39  objectFile::WRITE_ALWAYS),
40  pStruct,
41  zero3,
42  false
43  )
44  ),
45  dy0_(
47  objectFile(
48  groupNames(baseName,"dy0"),
49  "",
50  objectFile::READ_IF_PRESENT,
51  objectFile::WRITE_ALWAYS),
52  pStruct,
53  zero3
54  )
55  ),
56  dy1_(
58  objectFile(
59  groupNames(baseName,"dy1"),
60  "",
61  objectFile::READ_IF_PRESENT,
62  objectFile::WRITE_ALWAYS),
63  pStruct,
64  zero3
65  )
66  ),
67  dy2_(
69  objectFile(
70  groupNames(baseName,"dy2"),
71  "",
72  objectFile::READ_IF_PRESENT,
73  objectFile::WRITE_ALWAYS),
74  pStruct,
75  zero3
76  )
77  ),
78  dy3_(
80  objectFile(
81  groupNames(baseName,"dy3"),
82  "",
83  objectFile::READ_IF_PRESENT,
84  objectFile::WRITE_ALWAYS),
85  pStruct,
86  zero3
87  )
88  )
89 {
90 
91 }
92 
94 (
95  real dt,
96  realx3Vector_D& y,
97  realx3Vector_D& dy
98 )
99 {
100 
101  if(this->pStruct().allActive())
102  {
103  return predictAll(dt, y, dy, this->pStruct().activeRange());
104  }
105  else
106  {
107  return predictRange(dt, y, dy, this->pStruct().activePointsMaskD());
108  }
109 
110  return true;
111 }
112 
114 (
115  real dt,
116  realx3Vector_D& y,
117  realx3Vector_D& dy
118 )
119 {
120  if(this->pStruct().allActive())
121  {
122  return intAll(dt, y, dy, this->pStruct().activeRange());
123  }
124  else
125  {
126  return intRange(dt, y, dy, this->pStruct().activePointsMaskD());
127  }
128 
129  return true;
130 }
131 
133  const int32IndexContainer& newIndices,
134  const realx3Vector& y)
135 {
136  y0_.insertSetElement(newIndices, y);
137 
138  return true;
139 }
140 
142  real dt,
143  realx3Vector_D& y,
144  realx3Vector_D& dy,
145  range activeRng)
146 {
147 
148  auto d_dy = dy.deviceVectorAll();
149  auto d_y = y.deviceVectorAll();
150 
151  auto d_y0 = y0_.deviceVectorAll();
152  auto d_dy0 = dy0_.deviceVectorAll();
153  auto d_dy1 = dy1_.deviceVectorAll();
154  auto d_dy2 = dy2_.deviceVectorAll();
155  auto d_dy3 = dy3_.deviceVectorAll();
156 
157  Kokkos::parallel_for(
158  "AdamsMoulton5::predict",
159  rpIntegration (activeRng.first, activeRng.second),
160  LAMBDA_HD(int32 i){
161  d_dy0[i] = d_dy[i];
162  d_y[i] = d_y0[i] + dt*(
163  static_cast<real>(55.0/24.0) * d_dy[i]
164  - static_cast<real>(59.0/24.0) * d_dy1[i]
165  + static_cast<real>(37.0/24.0) * d_dy2[i]
166  - static_cast<real>( 9.0/24.0) * d_dy3[i]);
167  });
168  Kokkos::fence();
169 
170  return true;
171 }
172 
173 
175  real dt,
176  realx3Vector_D& y,
177  realx3Vector_D& dy,
178  range activeRng)
179 {
180 
181  auto d_dy = dy.deviceVectorAll();
182  auto d_y = y.deviceVectorAll();
183 
184  auto d_dy0 = dy0_.deviceVectorAll();
185  auto d_y0 = y0_.deviceVectorAll();
186  auto d_dy1 = dy1_.deviceVectorAll();
187  auto d_dy2 = dy2_.deviceVectorAll();
188  auto d_dy3 = dy3_.deviceVectorAll();
189 
190  Kokkos::parallel_for(
191  "AdamsMoulton5::correct",
192  rpIntegration (activeRng.first, activeRng.second),
193  LAMBDA_HD(int32 i){
194  auto corrct_y = d_y0[i] + dt*(
195  static_cast<real>(251.0/720.0)*d_dy[i]
196  + static_cast<real>(646.0/720.0)*d_dy0[i]
197  - static_cast<real>(264.0/720.0)*d_dy1[i]
198  + static_cast<real>(106.0/720.0)*d_dy2[i]
199  - static_cast<real>( 19.0/720.0)*d_dy3[i]);
200 
201  d_dy3[i]= d_dy2[i];
202  d_dy2[i]= d_dy1[i];
203  d_dy1[i]= d_dy0[i];
204  d_y0[i] = corrct_y;
205  d_y[i] = corrct_y;
206  });
207  Kokkos::fence();
208 
209  return true;
210 }
211 
212 
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::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::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::zero3
const realx3 zero3(0.0)
Definition: types.hpp:97
pFlow::AdamsMoulton5::predictAll
bool predictAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Definition: AdamsMoulton5.cpp:141
pFlow::repository::emplaceObject
T & emplaceObject(const objectFile &objf, Args &&... args)
Definition: repositoryTemplates.cpp:38
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::AdamsMoulton5::y0_
realx3PointField_D & y0_
Definition: AdamsMoulton5.hpp:38
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::objectFile
Definition: objectFile.hpp:33
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::AdamsMoulton5::predict
bool predict(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsMoulton5.cpp:94
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
AdamsMoulton5.hpp
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 >