ASL  0.1.6
Advanced Simulation Library
flow2.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>
32 #include <acl/aclGenerators.h>
34 #include <num/aslLBGK.h>
35 #include <num/aslLBGKBC.h>
36 #include <utilities/aslTimer.h>
37 #include <acl/aclUtilities.h>
38 
39 
40 
41 typedef float FlT;
42 //typedef double FlT;
44 
45 using asl::AVec;
46 using asl::makeAVec;
47 
49 {
50  double hCyl (10.);
51  double rCyl (1.5);
52  double a(10.);
53  double b(6.);
54  vector<AVec<>> rect({.5*makeAVec( .866*a,-b,-a*.5),.5*makeAVec(-.866*a,-b, a*.5),
55  .5*makeAVec(-.866*a, b, a*.5),.5*makeAVec( .866*a, b,-a*.5)});
56  vector<AVec<>> r1(rect.size());
57  vector<AVec<>> r2(rect.size());
58  auto r1C(makeAVec(x,y+rCyl*.5+b*.5,hCyl));
59  auto r2C(makeAVec(x,y-rCyl*.5-b*.5,hCyl));
60  for(unsigned int i(0); i<rect.size();++i)
61  {
62  r1[i]=r1C + rect[i];
63  r2[i]=r2C + rect[i];
64  }
65 
67  res = (res &
68  generateDFPlane(makeAVec(.5,0.,.866), r1C + makeAVec(rCyl,0.,0.)) &
69  generateDFPlane(makeAVec(-.5,0.,-.866), r1C - makeAVec(rCyl,0.,0.))) |
70  generateDFCylinder(rCyl, makeAVec(0.,0.,hCyl), makeAVec(x,y,hCyl*.5));
71  return res;
72 }
73 
75 {
76  vector<double> xValues;
77  vector<double> yValues;
78 
79  for(unsigned int i(0); i < 8; ++i)
80  for(unsigned int j(0); j < 10; ++j)
81  {
82  xValues.push_back(25.+ 20.*i);
83  yValues.push_back(25.+ 15.*j);
84  }
85 
86  auto res(generateMirror(xValues[0], yValues[0]));
87  for(unsigned int i(1); i < xValues.size(); ++i)
88  res = res | generateMirror(xValues[i], yValues[i]);
89 
90  return res;
91 }
92 
93 
94 int main(int argc, char* argv[])
95 {
96  // Optionally add appParamsManager to be able to manipulate at least
97  // hardware parameters(platform/device) through command line/parameters file
98  asl::ApplicationParametersManager appParamsManager("flow2",
99  "1.0");
100  appParamsManager.load(argc, argv);
101 
102  Param dx(1.);
103  Param dt(1.);
104  Param nu(.0125);
105 
106  Param nuNum(nu.v()*dt.v()/dx.v()/dx.v());
107  AVec<int> size(asl::makeAVec(200,200,25));
108 
109  AVec<> gSize(dx.v()*AVec<>(size));
110 
111 
112  std::cout << "Data initialization... ";
113 
114  asl::Block block(size,dx.v());
115 
116  auto mirrorsMapMem(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
117  asl::initData(mirrorsMapMem, generateMirrors());
118 
119  std::cout << "Finished" << endl;
120 
121  std::cout << "Numerics initialization... ";
122 
123  asl::SPLBGK lbgk(new asl::LBGK(block,
124  acl::generateVEConstant(FlT(nuNum.v())),
125  &asl::d3q15()));
126 
127  lbgk->init();
128  asl::SPLBGKUtilities lbgkUtil(new asl::LBGKUtilities(lbgk));
129  lbgkUtil->initF(acl::generateVEConstant(.0,.0,.0));
130 // lbgkUtil->initF(acl::generateVEConstant(.1), acl::generateVEConstant(.0,.0,.0));
131 
132  auto bcNoSlip(generateBCNoSlip(lbgk,{asl::Y0, asl::YE, asl::Z0}));
133  auto bcNoSlipM(generateBCNoSlip(lbgk, mirrorsMapMem));
134  auto bcNoSlipV(generateBCNoSlipVel(lbgk, mirrorsMapMem));
135  auto bcP(asl::generateBCConstantPressure(lbgk, 1., {asl::X0, asl::XE}));
136  auto bcTop(asl::generateBCConstantVelocity(lbgk, asl::makeAVec(0.1,0.,0.), {asl::ZE}));
137 
138  bcNoSlip->init();
139  bcNoSlipM->init();
140  bcNoSlipV->init();
141  bcP->init();
142  bcTop->init();
143 
144  std::cout << "Finished" << endl;
145  std::cout << "Computing...";
146  asl::Timer timer;
147 
148  asl::WriterVTKXML writer("flow2");
149  writer.addScalars("map", *mirrorsMapMem);
150  writer.addScalars("rho", *lbgk->getRho());
151  writer.addVector("v", *lbgk->getVelocity());
152 
153 
154 
155  bcP->execute();
156  bcTop->execute();
157  bcNoSlip->execute();
158  bcNoSlipM->execute();
159 
160  bcNoSlipV->execute();
161  writer.write();
162 
163  timer.start();
164  for (unsigned int i(0); i < 1000 ; ++i)
165  {
166  lbgk->execute();
167  bcP->execute();
168  bcTop->execute();
169  bcNoSlip->execute();
170  bcNoSlipM->execute();
171  if (!(i%100))
172  {
173  cout << i << endl;
174  bcNoSlipV->execute();
175  writer.write();
176  }
177  }
178  timer.stop();
179 
180  std::cout << "Finished" << endl;
181 
182  cout << "time=" << timer.getTime() << "; clockTime="
183  << timer.getClockTime() << "; load="
184  << timer.getProcessorLoad() * 100 << "%" << endl;
185 
186  std::cout << "Output...";
187  std::cout << "Finished" << endl;
188  std::cout << "Ok" << endl;
189 
190  return 0;
191 }
int main(int argc, char *argv[])
Definition: flow2.cc:94
AVec< T > makeAVec(T a1)
Numerical method for fluid flow.
Definition: aslLBGK.h:77
float FlT
Definition: flow2.cc:41
asl::SPDistanceFunction generateMirror(double x, double y)
Definition: flow2.cc:48
const T & v() const
Definition: aslUValue.h:43
void addVector(std::string name, AbstractData &data)
AVec< T > makeAVec(T a1)
SPDistanceFunction generateDFConvexPolygonPrism(std::vector< AVec< double >> points)
generates infinite prism with convex polygon at its base
SPDistanceFunction generateDFPlane(const AVec< double > &n, const AVec< double > &p0)
const double getProcessorLoad() const
Definition: aslTimer.h:48
asl::UValue< double > Param
Definition: flow2.cc:43
asl::SPDistanceFunction generateMirrors()
Definition: flow2.cc:74
SPBCond generateBCConstantVelocity(SPLBGK nm, AVec<> v, const std::vector< SlicesNames > &sl)
const VectorTemplate & d3q15()
Vector template.
acl::VectorOfElements dx(const TemplateVE &a)
differential operator
const double getClockTime() const
Definition: aslTimer.h:47
void initData(SPAbstractData d, double a)
const double getTime() const
Definition: aslTimer.h:46
void addScalars(std::string name, AbstractData &data)
SPBCond generateBCConstantPressure(SPLBGK nm, double p, const std::vector< SlicesNames > &sl)
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.
SPDistanceFunction generateDFCylinder(double r, const AVec< double > &l, const AVec< double > &c)
generates cylinder
void load(int argc, char *argv[])
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
SPBCond generateBCNoSlip(SPLBGK nm, const std::vector< SlicesNames > &sl)