AdamsMoulton3.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 "AdamsMoulton3.hpp"
22 
23 //const real AB2_coef[] = { 3.0 / 2.0, 1.0 / 2.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  y0_(
36  objectFile(
37  groupNames(baseName,"y0"),
38  "",
39  objectFile::READ_IF_PRESENT,
40  objectFile::WRITE_ALWAYS),
41  pStruct,
42  zero3,
43  false
44  )
45  ),
46  dy0_(
48  objectFile(
49  groupNames(baseName,"dy0"),
50  "",
51  objectFile::READ_IF_PRESENT,
52  objectFile::WRITE_ALWAYS),
53  pStruct,
54  zero3
55  )
56  ),
57  dy1_(
59  objectFile(
60  groupNames(baseName,"dy1"),
61  "",
62  objectFile::READ_IF_PRESENT,
63  objectFile::WRITE_ALWAYS),
64  pStruct,
65  zero3
66  )
67  )
68 {
69 
70 }
71 
73 (
74  real dt,
75  realx3Vector_D& y,
76  realx3Vector_D& dy
77 )
78 {
79 
80  if(this->pStruct().allActive())
81  {
82  return predictAll(dt, y, dy, this->pStruct().activeRange());
83  }
84  else
85  {
86  return predictRange(dt, y, dy, this->pStruct().activePointsMaskD());
87  }
88 
89  return true;
90 }
91 
93 (
94  real dt,
95  realx3Vector_D& y,
96  realx3Vector_D& dy
97 )
98 {
99  if(this->pStruct().allActive())
100  {
101  return intAll(dt, y, dy, this->pStruct().activeRange());
102  }
103  else
104  {
105  return intRange(dt, y, dy, this->pStruct().activePointsMaskD());
106  }
107 
108  return true;
109 }
110 
112  const int32IndexContainer& newIndices,
113  const realx3Vector& y)
114 {
115  y0_.insertSetElement(newIndices, y);
116 
117  return true;
118 }
119 
121  real dt,
122  realx3Vector_D& y,
123  realx3Vector_D& dy,
124  range activeRng)
125 {
126 
127  auto d_dy = dy.deviceVectorAll();
128  auto d_y = y.deviceVectorAll();
129  auto d_y0 = y0_.deviceVectorAll();
130  auto d_dy0 = dy0_.deviceVectorAll();
131  auto d_dy1= dy1_.deviceVectorAll();
132 
133  Kokkos::parallel_for(
134  "AdamsMoulton3::predict",
135  rpIntegration (activeRng.first, activeRng.second),
136  LAMBDA_HD(int32 i){
137  d_dy0[i] = d_dy[i];
138  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]);
139 
140  });
141  Kokkos::fence();
142 
143  return true;
144 }
145 
147  real dt,
148  realx3Vector_D& y,
149  realx3Vector_D& dy,
150  range activeRng)
151 {
152 
153  auto d_dy = dy.deviceVectorAll();
154  auto d_y = y.deviceVectorAll();
155 
156  auto d_dy0 = dy0_.deviceVectorAll();
157  auto d_y0 = y0_.deviceVectorAll();
158  auto d_dy1 = dy1_.deviceVectorAll();
159 
160  Kokkos::parallel_for(
161  "AdamsMoulton3::correct",
162  rpIntegration (activeRng.first, activeRng.second),
163  LAMBDA_HD(int32 i){
164  auto corrct_y = d_y0[i] + dt*(
165  static_cast<real>(5.0/12.0)*d_dy[i]
166  + static_cast<real>(8.0/12.0)*d_dy0[i]
167  - static_cast<real>(1.0/12.0)*d_dy1[i]);
168  d_y[i] = corrct_y;
169  d_y0[i] = corrct_y;
170  d_dy1[i]= d_dy0[i];
171  });
172  Kokkos::fence();
173 
174  return true;
175 }
pFlow::real
float real
Definition: builtinTypes.hpp:46
AdamsMoulton3.hpp
pFlow::integration
Definition: integration.hpp:35
pFlow::AdamsMoulton3::AdamsMoulton3
AdamsMoulton3(const word &baseName, repository &owner, const pointStructure &pStruct, const word &method)
Definition: AdamsMoulton3.cpp:26
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::AdamsMoulton3::intAll
bool intAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Definition: AdamsMoulton3.cpp:146
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
pFlow::AdamsMoulton3::rpIntegration
Kokkos::RangePolicy< DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< int32 > > rpIntegration
Definition: AdamsMoulton3.hpp:48
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::AdamsMoulton3::setInitialVals
bool setInitialVals(const int32IndexContainer &newIndices, const realx3Vector &y) override
Definition: AdamsMoulton3.cpp:111
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::VectorSingle
Definition: VectorSingle.hpp:45
pFlow::objectFile
Definition: objectFile.hpp:33
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::AdamsMoulton3::predictAll
bool predictAll(real dt, realx3Vector_D &y, realx3Vector_D &dy, range activeRng)
Definition: AdamsMoulton3.cpp:120
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:54
pFlow::groupNames
word groupNames(const word &bw, const word &tw, char sep='.')
Definition: bTypesFunctions.cpp:151
pFlow::AdamsMoulton3::y0_
realx3PointField_D & y0_
Definition: AdamsMoulton3.hpp:38
pFlow::AdamsMoulton3::correct
bool correct(real dt, realx3Vector_D &y, realx3Vector_D &dy) override
Definition: AdamsMoulton3.cpp:93
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 >