ASL  0.1.6
Advanced Simulation Library
flowRotatingCylinders.cc
Go to the documentation of this file.
1 /*
2  * Advanced Simulation Library <http://asl.org.il>
3  *
4  * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5  *
6  *
7  * This file is part of Advanced Simulation Library (ASL).
8  *
9  * ASL is free software: you can redistribute it and/or modify it
10  * under the terms of the GNU Affero General Public License as
11  * published by the Free Software Foundation, version 3 of the License.
12  *
13  * ASL is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Affero General Public License for more details.
17  *
18  * You should have received a copy of the GNU Affero General Public License
19  * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 
29 #include <aslDataInc.h>
30 #include <math/aslTemplates.h>
31 #include <aslGeomInc.h>
33 #include <acl/aclGenerators.h>
35 #include <num/aslLBGK.h>
36 #include <num/aslLBGKBC.h>
37 #include <utilities/aslTimer.h>
39 
40 
41 typedef float FlT;
42 //typedef double FlT;
44 
45 using asl::AVec;
46 using asl::makeAVec;
47 
48 
49 int main(int argc, char* argv[])
50 {
51  // Optionally add appParamsManager to be able to manipulate at least
52  // hardware parameters(platform/device) through command line/parameters file
53  asl::ApplicationParametersManager appParamsManager("flowRotatingCylinders",
54  "1.0");
55  appParamsManager.load(argc, argv);
56 
57  Param dx(1.);
58  Param dt(1.);
59  Param nu(.01);
60  Param w(2e-3);
61 
62  Param nuNum(nu.v()*dt.v()/dx.v()/dx.v());
63  AVec<int> size(asl::makeAVec(100,100,150));
64 
65  AVec<> gSize(dx.v()*AVec<>(size));
66 
67 
68  std::cout << "Data initialization... ";
69 
70  asl::Block block(size,dx.v());
71 
72  auto exCylMap(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
73  asl::initData(exCylMap,
75  makeAVec(0.,0.,1.),
76  .5*gSize),
77  dx.v()));
78  auto inCylMap(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
79  asl::initData(inCylMap,
81  makeAVec(0.,0.,1.),
82  .5*gSize),
83  dx.v()));
84 
85  auto computationalDomainMap(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
86  asl::initData(computationalDomainMap,
88  makeAVec(0.,0.,1.),
89  .5*gSize) |
90  generateDFCylinderInf(.24*gSize[0],
91  makeAVec(0.,0.,1.),
92  .5*gSize) |
93  asl::generateDFInBlock(block, 0),
94  dx.v()));
95 
96 
97  std::cout << "Finished" << endl;
98 
99  std::cout << "Numerics initialization... ";
100 
101  asl::SPLBGK lbgk(new asl::LBGK(block,
102  acl::generateVEConstant(FlT(nuNum.v())),
103  &asl::d3q15()));
104 
105  lbgk->init();
106  asl::SPLBGKUtilities lbgkUtil(new asl::LBGKUtilities(lbgk));
107  lbgkUtil->initF(acl::generateVEConstant(.0,.0,.0));
108 
109  std::vector<asl::SPNumMethod> bc;
110  std::vector<asl::SPNumMethod> bcV;
111 
112  auto vfEx(asl::generatePFRotationField(makeAVec(0.,0., w.v()), .5*gSize));
113  auto vfIn(asl::generatePFRotationField(makeAVec(0.,0.,-2.*w.v()), .5*gSize));
114 
115  bc.push_back(generateBCVelocity(lbgk, vfEx, exCylMap,computationalDomainMap));
116  bcV.push_back(generateBCNoSlipVel(lbgk, exCylMap));
117  bc.push_back(generateBCVelocity(lbgk, vfIn, inCylMap,computationalDomainMap));
118  bcV.push_back(generateBCNoSlipVel(lbgk, inCylMap));
119  bc.push_back(generateBCNoSlip(lbgk,{asl::Z0, asl::ZE}));
120 
121  initAll(bc);
122  initAll(bcV);
123 
124  std::cout << "Finished" << endl;
125  std::cout << "Computing...";
126  asl::Timer timer;
127 
128  asl::WriterVTKXML writer("flowRotCylRes");
129 // writer.addScalars("mapEx", *exCylMap);
130 // writer.addScalars("mapIn", *inCylMap);
131  writer.addScalars("map", *computationalDomainMap);
132  writer.addScalars("rho", *lbgk->getRho());
133  writer.addVector("v", *lbgk->getVelocity());
134 
135  executeAll(bc);
136 
137  executeAll(bcV);
138  writer.write();
139 
140  timer.start();
141  for (unsigned int i(0); i < 10001 ; ++i)
142  {
143  lbgk->execute();
144  executeAll(bc);
145  if (!(i%1000))
146  {
147  cout << i << endl;
148  executeAll(bcV);
149  writer.write();
150  }
151  }
152  timer.stop();
153 
154  std::cout << "Finished" << endl;
155 
156  cout << "time=" << timer.getTime() << "; clockTime="
157  << timer.getClockTime() << "; load="
158  << timer.getProcessorLoad() * 100 << "%" << endl;
159 
160  std::cout << "Output...";
161  std::cout << "Finished" << endl;
162  std::cout << "Ok" << endl;
163 
164  return 0;
165 }
AVec< T > makeAVec(T a1)
Numerical method for fluid flow.
Definition: aslLBGK.h:77
SPDistanceFunction normalize(SPDistanceFunction a, double dx)
const T & v() const
Definition: aslUValue.h:43
void addVector(std::string name, AbstractData &data)
void initAll(std::vector< T *> &v)
Definition: aslNumMethod.h:67
AVec< T > makeAVec(T a1)
SPDistanceFunction generateDFCylinderInf(double r, const AVec< double > &l, const AVec< double > &c)
generates infinite cylinder
asl::UValue< double > Param
const double getProcessorLoad() const
Definition: aslTimer.h:48
const VectorTemplate & d3q15()
Vector template.
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
const double getClockTime() const
Definition: aslTimer.h:47
void executeAll(std::vector< T *> &v)
Definition: aslNumMethod.h:55
int main(int argc, char *argv[])
void initData(SPAbstractData d, double a)
const double getTime() const
Definition: aslTimer.h:46
void addScalars(std::string name, AbstractData &data)
float FlT
void stop()
Definition: aslTimer.h:45
void start()
Definition: aslTimer.h:43
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
SPPositionFunction generatePFRotationField(const AVec< double > &axis, const AVec< double > &c)
void load(int argc, char *argv[])
SPDistanceFunction generateDFInBlock(const Block &b, unsigned int nG)
generates map corresponding to external (ghost) part of the block
SPNumMethod generateBCNoSlipVel(SPLBGK nmU, SPAbstractDataWithGhostNodes map)
for velocity field
contains different kernels for preprocessing and posprocessing of data used by LBGK ...
Definition: aslLBGK.h:137
SPNumMethod generateBCVelocity(SPLBGK nm, SPPositionFunction v, SPAbstractDataWithGhostNodes map)
SPBCond generateBCNoSlip(SPLBGK nm, const std::vector< SlicesNames > &sl)